diff options
author | Bastien Nocera <hadess@hadess.net> | 2015-09-26 19:47:08 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2015-10-05 14:05:02 +0200 |
commit | 744e21326898233d32572905eb227c2a7fc29da5 (patch) | |
tree | 847bb4ee7698721b28efd0184adc6a421eb07252 | |
parent | 04c02024fcfbbe99901020ed7074bf177cf90d7d (diff) | |
download | gdk-pixbuf-744e21326898233d32572905eb227c2a7fc29da5.tar.gz |
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
-rw-r--r-- | tests/1_partyanimsm2.gif | bin | 0 -> 268106 bytes | |||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | 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 Binary files differnew file mode 100644 index 000000000..785f0f1bd --- /dev/null +++ b/tests/1_partyanimsm2.gif diff --git a/tests/Makefile.am b/tests/Makefile.am index 1f09711f1..bdd68f31c 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 6c188f4e1..21bffbb1d 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 (); } |