File: t3.c

package info (click to toggle)
webp-pixbuf-loader 0.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,144 kB
  • sloc: ansic: 1,194; sh: 17; makefile: 7
file content (48 lines) | stat: -rw-r--r-- 1,866 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glib.h>

gint
main (gint argc, gchar **argv)
{
  GdkPixbufAnimation *anim
      = gdk_pixbuf_animation_new_from_file (g_getenv ("TEST_FILE"), NULL);
  g_assert (anim != NULL);
  g_assert (! gdk_pixbuf_animation_is_static_image (anim)); // Make sure it is an animation

  G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  GTimeVal time = { 0 };
  G_GNUC_END_IGNORE_DEPRECATIONS

  GdkPixbufAnimationIter *iter = gdk_pixbuf_animation_get_iter (anim, &time);
  g_assert (iter != NULL);

  /* Frame 1 */
  time.tv_usec = 1000;
  g_assert (gdk_pixbuf_animation_iter_advance (iter, &time) == FALSE); // Step 1ms
  g_assert (gdk_pixbuf_animation_iter_get_pixbuf (iter) != NULL);
  g_assert_cmpint (gdk_pixbuf_animation_iter_get_delay_time (iter), ==, 1000);

  time.tv_sec += 1;
  g_assert (gdk_pixbuf_animation_iter_advance (iter, &time) == TRUE); // Step 1s and 1ms
  g_assert (gdk_pixbuf_animation_iter_get_pixbuf (iter) != NULL);
  g_assert_cmpint (gdk_pixbuf_animation_iter_get_delay_time (iter), ==, 300);

  time.tv_usec += 300000;
  g_assert (gdk_pixbuf_animation_iter_advance (iter, &time) == TRUE); // Step 300ms
  g_assert (gdk_pixbuf_animation_iter_get_pixbuf (iter) != NULL);
  g_assert_cmpint (gdk_pixbuf_animation_iter_get_delay_time (iter), ==, 300);

  time.tv_usec += 300000;
  g_assert (gdk_pixbuf_animation_iter_advance (iter, &time) == TRUE); // Step 300ms
  g_assert (gdk_pixbuf_animation_iter_get_pixbuf (iter) != NULL);
  g_assert_cmpint (gdk_pixbuf_animation_iter_get_delay_time (iter), ==, 300);

  time.tv_usec += 300000;
  g_assert (gdk_pixbuf_animation_iter_advance (iter, &time) == TRUE); // Step 300ms
  g_assert (gdk_pixbuf_animation_iter_get_pixbuf (iter) != NULL);
  g_assert_cmpint (gdk_pixbuf_animation_iter_get_delay_time (iter), ==, 1000);

  g_object_unref (iter);
  g_object_unref (anim);
  return 0;
}