[gdk-pixbuf] tests: Add more pixdata tests
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf] tests: Add more pixdata tests
- Date: Fri, 16 Dec 2016 15:39:00 +0000 (UTC)
commit a8291060fb5b22504be63faeabaf27722e70c785
Author: Bastien Nocera <hadess hadess net>
Date: Fri Dec 16 16:05:03 2016 +0100
tests: Add more pixdata tests
Those ones should succeed, and we test both uncompressed and
RLE-compressed data.
https://bugzilla.gnome.org/show_bug.cgi?id=775693
tests/Makefile.am | 1 +
tests/pixbuf-pixdata.c | 42 ++++++++++++++++++++++++++++++++++++++++++
tests/test-image-rle.pixdata | Bin 0 -> 8406 bytes
3 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 34d12f0..ca91ed1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -62,6 +62,7 @@ dist_installed_test_data = \
large.jpg \
bug775218.jpg \
test-image.pixdata \
+ test-image-rle.pixdata \
bug775693.pixdata \
$(wildcard $(srcdir)/test-images/fail/*) \
$(wildcard $(srcdir)/test-images/randomly-modified/*) \
diff --git a/tests/pixbuf-pixdata.c b/tests/pixbuf-pixdata.c
index 8746440..558e581 100644
--- a/tests/pixbuf-pixdata.c
+++ b/tests/pixbuf-pixdata.c
@@ -53,6 +53,47 @@ test_pixdata_deserialize (gconstpointer data)
g_clear_object (&pixbuf);
}
+
+static void
+test_pixdata_success (void)
+{
+ const gchar *path;
+ GdkPixbuf *pixbuf;
+ GdkPixdata pixdata1, pixdata2;
+ GError *error = NULL;
+ GdkPixbuf *ref;
+ gchar *contents;
+ gsize size;
+
+ path = g_test_get_filename (G_TEST_DIST, "test-image.png", NULL);
+ ref = gdk_pixbuf_new_from_file (path, &error);
+ g_assert_no_error (error);
+
+ g_file_get_contents (g_test_get_filename (G_TEST_DIST, "test-image.pixdata", NULL), &contents, &size,
&error);
+ g_assert_no_error (error);
+ gdk_pixdata_deserialize (&pixdata1, size, (const guint8 *) contents, &error);
+ g_assert_no_error (error);
+ pixbuf = gdk_pixbuf_from_pixdata (&pixdata1, FALSE, &error);
+ g_assert_no_error (error);
+
+ pixdata_equal (ref, pixbuf, &error);
+ g_assert_no_error (error);
+ g_free (contents);
+ g_object_unref (pixbuf);
+
+ g_file_get_contents (g_test_get_filename (G_TEST_DIST, "test-image-rle.pixdata", NULL), &contents, &size,
&error);
+ g_assert_no_error (error);
+ gdk_pixdata_deserialize (&pixdata2, size, (const guint8 *) contents, &error);
+ g_assert_no_error (error);
+ pixbuf = gdk_pixbuf_from_pixdata (&pixdata2, FALSE, &error);
+ g_assert_no_error (error);
+
+ pixdata_equal (ref, pixbuf, &error);
+ g_assert_no_error (error);
+ g_free (contents);
+ g_object_unref (pixbuf);
+ g_object_unref (ref);
+}
G_GNUC_END_IGNORE_DEPRECATIONS
static void
@@ -79,6 +120,7 @@ main (int argc, char **argv)
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/pixbuf/pixdata", test_pixdata);
+ g_test_add_func ("/pixbuf/pixdata/success", test_pixdata_success);
g_test_add_data_func ("/pixbuf/pixdata/bug775693", "bug775693.pixdata", test_pixdata_deserialize);
return g_test_run ();
diff --git a/tests/test-image-rle.pixdata b/tests/test-image-rle.pixdata
new file mode 100644
index 0000000..fd93780
Binary files /dev/null and b/tests/test-image-rle.pixdata differ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]