summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-08-24 14:26:24 -0400
committerMatthias Clasen <mclasen@redhat.com>2015-08-24 16:27:16 -0400
commite4eaa11b0ac28960ab0696085d49104166c9a5b2 (patch)
tree24283be29b1db5163274fb9e66c55234c1d9ff8e
parent7012b9a0b6263310fc7d57f0b06583c8404599af (diff)
downloadgdk-pixbuf-e4eaa11b0ac28960ab0696085d49104166c9a5b2.tar.gz
Add a test for scaling down a huge image
This currently segfaults in the png loader.
-rw-r--r--tests/large.pngbin0 -> 2507420 bytes
-rw-r--r--tests/pixbuf-scale.c30
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/large.png b/tests/large.png
new file mode 100644
index 000000000..310bd62cd
--- /dev/null
+++ b/tests/large.png
Binary files differ
diff --git a/tests/pixbuf-scale.c b/tests/pixbuf-scale.c
index eeddfe689..c6f55b522 100644
--- a/tests/pixbuf-scale.c
+++ b/tests/pixbuf-scale.c
@@ -65,6 +65,35 @@ test_scale (gconstpointer data)
g_object_unref (ref);
}
+static void
+test_scale_down (gconstpointer data)
+{
+ const gchar *filename = data;
+ const gchar *path;
+ GError *error = NULL;
+ GdkPixbuf *ref;
+ GdkPixbuf *pixbuf;
+ gint width, height;
+
+ if (!format_supported (filename))
+ {
+ g_test_skip ("format not supported");
+ return;
+ }
+
+ path = g_test_get_filename (G_TEST_DIST, filename, NULL);
+ ref = gdk_pixbuf_new_from_file (path, &error);
+ g_assert_no_error (error);
+
+ width = gdk_pixbuf_get_width (ref);
+ height = gdk_pixbuf_get_height (ref);
+
+ pixbuf = gdk_pixbuf_scale_simple (ref, width / 10, height / 10, GDK_INTERP_BILINEAR);
+ g_assert (pixbuf != NULL);
+
+ g_object_unref (ref);
+}
+
int
main (int argc, char **argv)
{
@@ -78,6 +107,7 @@ main (int argc, char **argv)
g_test_add_data_func ("/pixbuf/scale/tga", "test-images/valid_tga_test", test_scale);
g_test_add_data_func ("/pixbuf/scale/xpm", "test-images/valid_xpm_test", test_scale);
g_test_add_data_func ("/pixbuf/scale/xbm", "test-images/valid.xbm", test_scale);
+ g_test_add_data_func ("/pixbuf/scale/large", "large.png", test_scale_down);
return g_test_run ();
}