[gdk-pixbuf] tests: Add test case for thumbnailing failure



commit 744e21326898233d32572905eb227c2a7fc29da5
Author: Bastien Nocera <hadess hadess net>
Date:   Sat Sep 26 19:47:08 2015 +0200

    tests: Add test case for thumbnailing failure
    
    Add a test case that replicates gnome-desktop's thumbnailing. The
    important thing here is to only load until we have a first frame, and
    close the GIF loader.
    
    Test file by Rebecca Mock from:
    http://www.wired.com/2013/09/the-rise-of-subtle-tasteful-and-commissioned-animated-gif-illustrations/
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755672

 tests/1_partyanimsm2.gif       |  Bin 0 -> 268106 bytes
 tests/Makefile.am              |    1 +
 tests/pixbuf-short-gif-write.c |   39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/tests/1_partyanimsm2.gif b/tests/1_partyanimsm2.gif
new file mode 100644
index 0000000..785f0f1
Binary files /dev/null and b/tests/1_partyanimsm2.gif differ
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1f09711..bdd68f3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -48,6 +48,7 @@ test_programs =                       \
 dist_installed_test_data =             \
        test-image.png                  \
        test-animation.gif              \
+       1_partyanimsm2.gif              \
        test-animation.ani              \
        icc-profile.jpeg                \
        icc-profile.png                 \
diff --git a/tests/pixbuf-short-gif-write.c b/tests/pixbuf-short-gif-write.c
index 6c188f4..21bffbb 100644
--- a/tests/pixbuf-short-gif-write.c
+++ b/tests/pixbuf-short-gif-write.c
@@ -51,11 +51,50 @@ test_short_gif_write (void)
     g_object_unref (loader);
 }
 
+static void
+test_load_first_frame (void)
+{
+    GIOChannel* channel;
+    gboolean has_frame = FALSE;
+    GError *error = NULL;
+    GdkPixbuf *pixbuf;
+
+    channel = g_io_channel_new_file (g_test_get_filename (G_TEST_DIST, "1_partyanimsm2.gif", NULL), "r", 
NULL);
+    g_assert (channel != NULL);
+    g_io_channel_set_encoding (channel, NULL, NULL);
+
+    GdkPixbufLoader *loader = gdk_pixbuf_loader_new_with_type ("gif", NULL);
+    g_assert (loader != NULL);
+
+    while (!has_frame) {
+        loader_write_from_channel (loader, channel, 4096);
+        GdkPixbufAnimation *animation = gdk_pixbuf_loader_get_animation (loader);
+        if (animation) {
+            GdkPixbufAnimationIter *iter = gdk_pixbuf_animation_get_iter (animation, NULL);
+            if (!gdk_pixbuf_animation_iter_on_currently_loading_frame (iter))
+                has_frame = TRUE;
+            g_object_unref (iter);
+        }
+    }
+
+    g_io_channel_unref (channel);
+
+    gdk_pixbuf_loader_close (loader, &error);
+    g_assert_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INCOMPLETE_ANIMATION);
+    g_clear_error (&error);
+    pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
+    g_assert (pixbuf);
+    g_assert_cmpint (gdk_pixbuf_get_width (pixbuf), ==, 660);
+    g_assert_cmpint (gdk_pixbuf_get_height (pixbuf), ==, 666);
+    g_object_unref (loader);
+}
+
 int main (int argc, char *argv[])
 {
   g_test_init (&argc, &argv, NULL);
 
   g_test_add_func ("/animation/short_gif_write", test_short_gif_write);
+  g_test_add_func ("/animation/load_first_frame", test_load_first_frame);
 
   return g_test_run ();
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]