diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-03-12 18:58:20 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-03-12 19:04:56 -0400 |
commit | 1011a0d68a985ec1cdc0d10a30a1c3619d133be0 (patch) | |
tree | b87a70deb110e3a9545f5b3a561a0f5a6431072c | |
parent | a94734bb83761af9c45cc6d2ad3ce1ca0ba17908 (diff) | |
download | gdk-pixbuf-1011a0d68a985ec1cdc0d10a30a1c3619d133be0.tar.gz |
Add a simple test for gdk_pixbuf_composite
-rw-r--r-- | tests/Makefile.am | 7 | ||||
-rw-r--r-- | tests/pixbuf-composite.c | 45 |
2 files changed, 52 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index fc00d4e6e..cf5eb6d6c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -36,6 +36,7 @@ test_programs = \ pixbuf-short-gif-write \ pixbuf-save \ pixbuf-readonly-to-mutable \ + pixbuf-composite \ $(NULL) dist_installed_test_data = \ @@ -108,6 +109,12 @@ pixbuf_readonly_to_mutable_SOURCES = \ test-common.h \ $(NULL) +pixbuf_composite_SOURCES = \ + pixbuf-composite.c \ + test-common.c \ + test-common.h \ + $(NULL) + pixbuf_resource_SOURCES = \ pixbuf-resource.c \ test-common.c \ diff --git a/tests/pixbuf-composite.c b/tests/pixbuf-composite.c new file mode 100644 index 000000000..ecc3f8130 --- /dev/null +++ b/tests/pixbuf-composite.c @@ -0,0 +1,45 @@ +#include <gdk-pixbuf.h> +#include "test-common.h" + +static void +test_composite (void) +{ + GdkPixbuf *red, *green, *out, *ref, *sub; + + red = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 24, 24); + gdk_pixbuf_fill (red, 0xff000000); + + green = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 12, 12); + gdk_pixbuf_fill (green, 0x00ff0000); + + out = gdk_pixbuf_copy (red); + + gdk_pixbuf_composite (green, out, + 0, 0, 12, 12, + 0, 0, 1.0, 1.0, + GDK_INTERP_NEAREST, + 255); + + ref = gdk_pixbuf_copy (red); + sub = gdk_pixbuf_new_subpixbuf (ref, 0, 0, 12, 12); + + gdk_pixbuf_fill (sub, 0x00ff0000); + + g_assert (pixdata_equal (out, ref, NULL)); + + g_object_unref (red); + g_object_unref (green); + g_object_unref (out); + g_object_unref (ref); + g_object_unref (sub); +} + +int +main (int argc, char *argv[]) +{ + g_test_init (&argc, &argv, NULL); + + g_test_add_func ("/pixbuf/composite", test_composite); + + return g_test_run (); +} |