[gdk-pixbuf] Add a test for adding alpha to a large image
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf] Add a test for adding alpha to a large image
- Date: Tue, 25 Aug 2015 19:26:17 +0000 (UTC)
commit 27ee097ecba4d31f9adda1d66446694deb28f0de
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Aug 24 15:01:17 2015 -0400
Add a test for adding alpha to a large image
This is prone to segfaults when we are not careful.
tests/pixbuf-scale.c | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/tests/pixbuf-scale.c b/tests/pixbuf-scale.c
index c6f55b5..3ea3eb2 100644
--- a/tests/pixbuf-scale.c
+++ b/tests/pixbuf-scale.c
@@ -94,6 +94,36 @@ test_scale_down (gconstpointer data)
g_object_unref (ref);
}
+static void
+test_add_alpha (gconstpointer data)
+{
+ const gchar *filename = data;
+ const gchar *path;
+ GError *error = NULL;
+ GdkPixbuf *ref;
+ GdkPixbuf *pixbuf;
+
+ 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);
+
+ pixbuf = gdk_pixbuf_add_alpha (ref, FALSE, 0, 0, 0);
+ g_assert (pixbuf != NULL);
+ g_object_unref (pixbuf);
+
+ pixbuf = gdk_pixbuf_add_alpha (ref, TRUE, 0, 0, 255);
+ g_assert (pixbuf != NULL);
+ g_object_unref (pixbuf);
+
+ g_object_unref (ref);
+}
+
int
main (int argc, char **argv)
{
@@ -108,6 +138,7 @@ main (int argc, char **argv)
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);
+ g_test_add_data_func ("/pixbuf/add-alpha/large", "large.png", test_add_alpha);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]