summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2014-10-24 15:19:49 +0200
committerBastien Nocera <hadess@hadess.net>2014-10-24 15:30:50 +0200
commit3997cbb736ec67dd1b5a4205ab7aea3d5aecae1f (patch)
tree79a0463f63c2da2cab91f64d61c136876e332747 /tests
parent59e3b147287679fe214f39822f3918dba61c9e8f (diff)
downloadgdk-pixbuf-3997cbb736ec67dd1b5a4205ab7aea3d5aecae1f.tar.gz
ico: Fix support for 256x256 icons
In both loading and saving them. The ico format uses "0" as the width or height to mean 256: https://en.wikipedia.org/wiki/ICO_%28file_format%29#Icon_resource_structure Also add a test for that. https://bugzilla.gnome.org/show_bug.cgi?id=674724
Diffstat (limited to 'tests')
-rw-r--r--tests/pixbuf-save.c33
-rw-r--r--tests/test-common.c2
2 files changed, 34 insertions, 1 deletions
diff --git a/tests/pixbuf-save.c b/tests/pixbuf-save.c
index 72a7aea4b..61ef07baf 100644
--- a/tests/pixbuf-save.c
+++ b/tests/pixbuf-save.c
@@ -98,6 +98,38 @@ test_save_roundtrip (void)
}
static void
+test_save_ico (void)
+{
+ GError *error = NULL;
+ GdkPixbuf *ref, *ref2;
+ GdkPixbuf *pixbuf;
+
+ if (!format_supported ("ico") || !format_supported ("png"))
+ {
+ g_test_skip ("format not supported");
+ return;
+ }
+
+ ref = gdk_pixbuf_new_from_file (g_test_get_filename (G_TEST_DIST, "test-image.png", NULL), &error);
+ g_assert_no_error (error);
+
+ ref2 = gdk_pixbuf_scale_simple (ref, 256, 256, GDK_INTERP_NEAREST);
+ g_object_unref (ref);
+ ref = ref2;
+
+ gdk_pixbuf_save (ref, "pixbuf-save-roundtrip", "ico", &error, NULL);
+ g_assert_no_error (error);
+
+ pixbuf = gdk_pixbuf_new_from_file ("pixbuf-save-roundtrip", &error);
+ g_assert_no_error (error);
+
+ g_assert (pixbuf_equal (pixbuf, ref));
+
+ g_object_unref (pixbuf);
+ g_object_unref (ref);
+}
+
+static void
test_save_options (void)
{
GdkPixbuf *ref;
@@ -142,6 +174,7 @@ main (int argc, char **argv)
g_test_add_func ("/pixbuf/save/roundtrip", test_save_roundtrip);
g_test_add_func ("/pixbuf/save/options", test_save_options);
+ g_test_add_func ("/pixbuf/save/ico", test_save_ico);
return g_test_run ();
}
diff --git a/tests/test-common.c b/tests/test-common.c
index c7673e395..a7107a114 100644
--- a/tests/test-common.c
+++ b/tests/test-common.c
@@ -33,7 +33,7 @@ format_supported (const gchar *filename)
GSList *formats, *l;
gboolean retval;
const gchar *names[] = { "png", "jpeg", "bmp", "gif", "ras",
- "tga", "xpm", "xbm" };
+ "tga", "xpm", "xbm", "ico" };
gint i;
for (i = 0; i < G_N_ELEMENTS (names); i++)