summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2015-10-04 02:20:29 +0200
committerBenjamin Otte <otte@redhat.com>2015-10-13 02:56:47 +0200
commitf1837aaf08cac2b3d0635452a00f318131fddc55 (patch)
tree71a0bb457c4819c25ce8d261d92bb9feed3f8b80
parentcfb0de7a421fb93e6b415f666494824722a26739 (diff)
downloadgdk-pixbuf-f1837aaf08cac2b3d0635452a00f318131fddc55.tar.gz
test-common: If image data differs, output first coords that fail
-rw-r--r--tests/pixbuf-slow-load.c72
-rw-r--r--tests/test-common.c31
-rw-r--r--tests/test-images/tga/gtk-logo-32bpp-bottom-left.tgabin9260 -> 9260 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-32bpp-bottom-right.tgabin9260 -> 9260 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-32bpp-top-left.tgabin9260 -> 9260 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-32bpp-top-right.tgabin9260 -> 9260 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-cmap-8bpp-bottom-left.tgabin3196 -> 3116 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-cmap-8bpp-bottom-right.tgabin3196 -> 3116 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-cmap-8bpp-top-left.tgabin3196 -> 3116 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-cmap-8bpp-top-right.tgabin3196 -> 3116 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-cmap-rle-8bpp-bottom-left.tgabin1797 -> 1767 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-cmap-rle-8bpp-bottom-right.tgabin1797 -> 1767 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-cmap-rle-8bpp-top-left.tgabin1797 -> 1767 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-cmap-rle-8bpp-top-right.tgabin1797 -> 1767 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-gray-8bpp-bottom-left.tgabin2348 -> 6956 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-gray-8bpp-bottom-right.tgabin2348 -> 6956 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-gray-8bpp-top-left.tgabin2348 -> 6956 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-gray-8bpp-top-right.tgabin2348 -> 6956 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-gray-rle-8bpp-bottom-left.tgabin999 -> 2287 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-gray-rle-8bpp-bottom-right.tgabin999 -> 2287 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-gray-rle-8bpp-top-left.tgabin999 -> 2287 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-gray-rle-8bpp-top-right.tgabin999 -> 2287 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-rle-32bpp-bottom-left.tgabin4078 -> 4078 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-rle-32bpp-bottom-right.tgabin4078 -> 4078 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-rle-32bpp-top-left.tgabin4078 -> 4078 bytes
-rw-r--r--tests/test-images/tga/gtk-logo-rle-32bpp-top-right.tgabin4078 -> 4078 bytes
26 files changed, 80 insertions, 23 deletions
diff --git a/tests/pixbuf-slow-load.c b/tests/pixbuf-slow-load.c
index 308e50315..47e252315 100644
--- a/tests/pixbuf-slow-load.c
+++ b/tests/pixbuf-slow-load.c
@@ -33,7 +33,26 @@ loader_size_prepared (GdkPixbufLoader *loader,
{
g_assert (*pixbuf == NULL);
- *pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, w, h);
+ *pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, w, h);
+ g_assert (*pixbuf != NULL);
+}
+
+static void
+loader_area_prepared (GdkPixbufLoader *loader,
+ int w,
+ int h,
+ GdkPixbuf **pixbuf)
+{
+ g_assert (*pixbuf != NULL);
+
+ if (gdk_pixbuf_get_has_alpha (gdk_pixbuf_loader_get_pixbuf (loader)))
+ {
+ GdkPixbuf *alpha = gdk_pixbuf_add_alpha (*pixbuf, FALSE, 0, 0, 0);
+
+ g_object_unref (*pixbuf);
+ *pixbuf = alpha;
+ }
+
g_assert (*pixbuf != NULL);
}
@@ -52,56 +71,71 @@ loader_area_updated (GdkPixbufLoader *loader,
x, y);
}
+static char *
+make_ref_filename (const char *filename)
+{
+ return g_strconcat (filename, ".ref.png", NULL);
+}
+
+static gboolean
+is_ref_filename (const char *filename)
+{
+ return g_str_has_suffix (filename, ".ref.png");
+}
+
static void
-test_slow_load (gconstpointer file)
+test_reftest_success (gconstpointer file)
{
GdkPixbufLoader *loader;
GdkPixbuf *reference, *loaded = NULL;
GError *error = NULL;
const char *filename;
+ char *ref_filename;
guchar *contents;
gsize i, contents_length;
+ gboolean success;
filename = file;
- reference = gdk_pixbuf_new_from_file (filename, &error);
+ if (is_ref_filename (filename))
+ return;
+
+ ref_filename = make_ref_filename (filename);
+ reference = gdk_pixbuf_new_from_file (ref_filename, &error);
g_assert_no_error (error);
g_assert (reference != NULL);
- if (!gdk_pixbuf_get_has_alpha (reference))
- {
- GdkPixbuf *tmp = gdk_pixbuf_add_alpha (reference, FALSE, 0, 0, 0);
- g_object_unref (reference);
- reference = tmp;
- }
- loader = gdk_pixbuf_loader_new_with_mime_type ("image/x-tga", &error);
- g_assert_no_error (error);
+ loader = gdk_pixbuf_loader_new ();
g_assert (loader != NULL);
g_signal_connect (loader, "size-prepared", G_CALLBACK (loader_size_prepared), &loaded);
+ g_signal_connect (loader, "area-prepared", G_CALLBACK (loader_area_prepared), &loaded);
g_signal_connect (loader, "area-updated", G_CALLBACK (loader_area_updated), &loaded);
- if (!g_file_get_contents (filename, (gchar **) &contents, &contents_length, &error))
- g_assert_not_reached ();
+ success = g_file_get_contents (filename, (gchar **) &contents, &contents_length, &error);
g_assert_no_error (error);
+ g_assert (success);
for (i = 0; i < contents_length; i++)
{
- if (!gdk_pixbuf_loader_write (loader, &contents[i], 1, &error))
- g_assert_not_reached();
+ success = gdk_pixbuf_loader_write (loader, &contents[i], 1, &error);
g_assert_no_error (error);
+ g_assert (success);
}
- if (!gdk_pixbuf_loader_close (loader, &error))
- g_assert_not_reached ();
+ success = gdk_pixbuf_loader_close (loader, &error);
g_assert_no_error (error);
+ g_assert (success);
+
g_assert (loaded != NULL);
- g_assert (pixdata_equal (reference, loaded, &error));
+ success = pixdata_equal (reference, loaded, &error);
g_assert_no_error (error);
+ g_assert (success);
g_free (contents);
g_object_unref (loaded);
g_object_unref (loader);
g_object_unref (reference);
+ g_free (ref_filename);
}
int
@@ -112,7 +146,7 @@ main (int argc, char **argv)
g_test_init (&argc, &argv, NULL);
tga_test_images = g_build_filename (g_test_get_dir (G_TEST_DIST), "test-images/tga", NULL);
- add_test_for_all_images ("/pixbuf/slow-load", tga_test_images, test_slow_load);
+ add_test_for_all_images ("/pixbuf/reftest/success", tga_test_images, test_reftest_success);
g_free (tga_test_images);
return g_test_run ();
diff --git a/tests/test-common.c b/tests/test-common.c
index 01a0c3877..1bca8da19 100644
--- a/tests/test-common.c
+++ b/tests/test-common.c
@@ -105,11 +105,34 @@ pixdata_equal (GdkPixbuf *p1, GdkPixbuf *p2, GError **error)
g_set_error_literal (error, GDK_PIXBUF_ERROR, 0, "Rowstrides differ");
return FALSE;
}
+
if (memcmp (gdk_pixbuf_get_pixels (p1), gdk_pixbuf_get_pixels (p2),
- gdk_pixbuf_get_byte_length (p1)) != 0) {
- g_set_error_literal (error, GDK_PIXBUF_ERROR, 0, "Data differ");
- return FALSE;
- }
+ gdk_pixbuf_get_byte_length (p1)) != 0)
+ {
+ guint x, y, width, height, n_channels, rowstride;
+ const guchar *pixels1, *pixels2;
+
+ rowstride = gdk_pixbuf_get_rowstride (p1);
+ n_channels = gdk_pixbuf_get_n_channels (p1);
+ width = gdk_pixbuf_get_width (p1);
+ height = gdk_pixbuf_get_height (p1);
+ pixels1 = gdk_pixbuf_get_pixels (p1);
+ pixels2 = gdk_pixbuf_get_pixels (p2);
+
+ for (y = 0; y < height; y++)
+ {
+ for (x = 0; x < width; x++)
+ {
+ if (memcmp (&pixels1[x * n_channels], &pixels2[x * n_channels], n_channels) != 0)
+ {
+ g_set_error (error, GDK_PIXBUF_ERROR, 0, "Data differ at %ux%u", x, y);
+ return FALSE;
+ }
+ }
+ pixels1 += rowstride;
+ pixels2 += rowstride;
+ }
+ }
return TRUE;
}
diff --git a/tests/test-images/tga/gtk-logo-32bpp-bottom-left.tga b/tests/test-images/tga/gtk-logo-32bpp-bottom-left.tga
index 79986c644..46b1db128 100644
--- a/tests/test-images/tga/gtk-logo-32bpp-bottom-left.tga
+++ b/tests/test-images/tga/gtk-logo-32bpp-bottom-left.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-32bpp-bottom-right.tga b/tests/test-images/tga/gtk-logo-32bpp-bottom-right.tga
index fefe92e62..b2b916ecc 100644
--- a/tests/test-images/tga/gtk-logo-32bpp-bottom-right.tga
+++ b/tests/test-images/tga/gtk-logo-32bpp-bottom-right.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-32bpp-top-left.tga b/tests/test-images/tga/gtk-logo-32bpp-top-left.tga
index 3ba468305..212b447b9 100644
--- a/tests/test-images/tga/gtk-logo-32bpp-top-left.tga
+++ b/tests/test-images/tga/gtk-logo-32bpp-top-left.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-32bpp-top-right.tga b/tests/test-images/tga/gtk-logo-32bpp-top-right.tga
index afbe0e905..e76fcd483 100644
--- a/tests/test-images/tga/gtk-logo-32bpp-top-right.tga
+++ b/tests/test-images/tga/gtk-logo-32bpp-top-right.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-cmap-8bpp-bottom-left.tga b/tests/test-images/tga/gtk-logo-cmap-8bpp-bottom-left.tga
index 0de138fa4..8a364c727 100644
--- a/tests/test-images/tga/gtk-logo-cmap-8bpp-bottom-left.tga
+++ b/tests/test-images/tga/gtk-logo-cmap-8bpp-bottom-left.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-cmap-8bpp-bottom-right.tga b/tests/test-images/tga/gtk-logo-cmap-8bpp-bottom-right.tga
index cbbda1905..a530d46c1 100644
--- a/tests/test-images/tga/gtk-logo-cmap-8bpp-bottom-right.tga
+++ b/tests/test-images/tga/gtk-logo-cmap-8bpp-bottom-right.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-cmap-8bpp-top-left.tga b/tests/test-images/tga/gtk-logo-cmap-8bpp-top-left.tga
index 04e3a50b8..4b69b5b42 100644
--- a/tests/test-images/tga/gtk-logo-cmap-8bpp-top-left.tga
+++ b/tests/test-images/tga/gtk-logo-cmap-8bpp-top-left.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-cmap-8bpp-top-right.tga b/tests/test-images/tga/gtk-logo-cmap-8bpp-top-right.tga
index 5bdda53af..baaabf4e0 100644
--- a/tests/test-images/tga/gtk-logo-cmap-8bpp-top-right.tga
+++ b/tests/test-images/tga/gtk-logo-cmap-8bpp-top-right.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-bottom-left.tga b/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-bottom-left.tga
index e5df6d5a6..6d0770ee1 100644
--- a/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-bottom-left.tga
+++ b/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-bottom-left.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-bottom-right.tga b/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-bottom-right.tga
index de3e4178d..a2ed97320 100644
--- a/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-bottom-right.tga
+++ b/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-bottom-right.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-top-left.tga b/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-top-left.tga
index aa75ab39e..1204059c6 100644
--- a/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-top-left.tga
+++ b/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-top-left.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-top-right.tga b/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-top-right.tga
index fbde5d656..d0f41a504 100644
--- a/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-top-right.tga
+++ b/tests/test-images/tga/gtk-logo-cmap-rle-8bpp-top-right.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-gray-8bpp-bottom-left.tga b/tests/test-images/tga/gtk-logo-gray-8bpp-bottom-left.tga
index 428aa9377..956940e5a 100644
--- a/tests/test-images/tga/gtk-logo-gray-8bpp-bottom-left.tga
+++ b/tests/test-images/tga/gtk-logo-gray-8bpp-bottom-left.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-gray-8bpp-bottom-right.tga b/tests/test-images/tga/gtk-logo-gray-8bpp-bottom-right.tga
index 58c925067..32582203e 100644
--- a/tests/test-images/tga/gtk-logo-gray-8bpp-bottom-right.tga
+++ b/tests/test-images/tga/gtk-logo-gray-8bpp-bottom-right.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-gray-8bpp-top-left.tga b/tests/test-images/tga/gtk-logo-gray-8bpp-top-left.tga
index 80c1a0ec6..a35e8b878 100644
--- a/tests/test-images/tga/gtk-logo-gray-8bpp-top-left.tga
+++ b/tests/test-images/tga/gtk-logo-gray-8bpp-top-left.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-gray-8bpp-top-right.tga b/tests/test-images/tga/gtk-logo-gray-8bpp-top-right.tga
index e846052f0..93f9c4585 100644
--- a/tests/test-images/tga/gtk-logo-gray-8bpp-top-right.tga
+++ b/tests/test-images/tga/gtk-logo-gray-8bpp-top-right.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-gray-rle-8bpp-bottom-left.tga b/tests/test-images/tga/gtk-logo-gray-rle-8bpp-bottom-left.tga
index 3a1fe6d0d..1bafb18f8 100644
--- a/tests/test-images/tga/gtk-logo-gray-rle-8bpp-bottom-left.tga
+++ b/tests/test-images/tga/gtk-logo-gray-rle-8bpp-bottom-left.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-gray-rle-8bpp-bottom-right.tga b/tests/test-images/tga/gtk-logo-gray-rle-8bpp-bottom-right.tga
index 0d8ec83c2..8a1fa6de8 100644
--- a/tests/test-images/tga/gtk-logo-gray-rle-8bpp-bottom-right.tga
+++ b/tests/test-images/tga/gtk-logo-gray-rle-8bpp-bottom-right.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-gray-rle-8bpp-top-left.tga b/tests/test-images/tga/gtk-logo-gray-rle-8bpp-top-left.tga
index 5370ede36..0cc8d1d27 100644
--- a/tests/test-images/tga/gtk-logo-gray-rle-8bpp-top-left.tga
+++ b/tests/test-images/tga/gtk-logo-gray-rle-8bpp-top-left.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-gray-rle-8bpp-top-right.tga b/tests/test-images/tga/gtk-logo-gray-rle-8bpp-top-right.tga
index 354f6f582..a78d6a157 100644
--- a/tests/test-images/tga/gtk-logo-gray-rle-8bpp-top-right.tga
+++ b/tests/test-images/tga/gtk-logo-gray-rle-8bpp-top-right.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-rle-32bpp-bottom-left.tga b/tests/test-images/tga/gtk-logo-rle-32bpp-bottom-left.tga
index 9f5e8fed9..59851c167 100644
--- a/tests/test-images/tga/gtk-logo-rle-32bpp-bottom-left.tga
+++ b/tests/test-images/tga/gtk-logo-rle-32bpp-bottom-left.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-rle-32bpp-bottom-right.tga b/tests/test-images/tga/gtk-logo-rle-32bpp-bottom-right.tga
index 6b42d4da5..73b27053d 100644
--- a/tests/test-images/tga/gtk-logo-rle-32bpp-bottom-right.tga
+++ b/tests/test-images/tga/gtk-logo-rle-32bpp-bottom-right.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-rle-32bpp-top-left.tga b/tests/test-images/tga/gtk-logo-rle-32bpp-top-left.tga
index bc8421e29..ba9d47338 100644
--- a/tests/test-images/tga/gtk-logo-rle-32bpp-top-left.tga
+++ b/tests/test-images/tga/gtk-logo-rle-32bpp-top-left.tga
Binary files differ
diff --git a/tests/test-images/tga/gtk-logo-rle-32bpp-top-right.tga b/tests/test-images/tga/gtk-logo-rle-32bpp-top-right.tga
index baec40d6d..415df40b8 100644
--- a/tests/test-images/tga/gtk-logo-rle-32bpp-top-right.tga
+++ b/tests/test-images/tga/gtk-logo-rle-32bpp-top-right.tga
Binary files differ