[sapwood] implement the clipping test for ThemePixbuf
- From: Sven Herzberg <herzi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sapwood] implement the clipping test for ThemePixbuf
- Date: Fri, 6 Aug 2010 12:06:18 +0000 (UTC)
commit 4a0c55f304e21b18df943165e7b5d6ea6a2e94a9
Author: Sven Herzberg <herzi gnome-de org>
Date: Thu Aug 5 14:03:41 2010 +0200
implement the clipping test for ThemePixbuf
* tests/test-framework.h,
* tests/test-sapwood.c: move the include for uintptr_t into the header
with the macro using it
* tests/test-theme-pixbuf.c: implement the first ThemePixbuf test
* tests/theme-pixbuf-render-clipped.png: the expected test result
tests/test-framework.h | 1 +
tests/test-sapwood.c | 1 -
tests/test-theme-pixbuf.c | 44 +++++++++++++++++++++++++++++++++
tests/theme-pixbuf-render-clipped.png | Bin 0 -> 357 bytes
4 files changed, 45 insertions(+), 1 deletions(-)
---
diff --git a/tests/test-framework.h b/tests/test-framework.h
index 1a75f57..faee694 100644
--- a/tests/test-framework.h
+++ b/tests/test-framework.h
@@ -21,6 +21,7 @@
#ifndef TEST_FRAMEWORK_H
#define TEST_FRAMEWORK_H
+#include <stdint.h> /* uintptr_t */
#include <gdk/gdk.h>
G_BEGIN_DECLS
diff --git a/tests/test-sapwood.c b/tests/test-sapwood.c
index db1621f..b2fc719 100644
--- a/tests/test-sapwood.c
+++ b/tests/test-sapwood.c
@@ -21,7 +21,6 @@
*/
#include <errno.h> /* errno */
-#include <stdint.h> /* uintptr_t */
#include <stdlib.h> /* realpath() */
#include <sapwood-pixmap.h>
#include <gdk/gdkx.h> /* GDK_DISPLAY_XDISPLAY() */
diff --git a/tests/test-theme-pixbuf.c b/tests/test-theme-pixbuf.c
index 32759d2..8786e14 100644
--- a/tests/test-theme-pixbuf.c
+++ b/tests/test-theme-pixbuf.c
@@ -22,9 +22,53 @@
#include "test-sapwood.h"
+#include "test-framework.h"
+#include "theme-pixbuf.h"
+
static void
test_render_clipped (void)
{
+ GdkRectangle clip_rect = {100, 100, 100, 100};
+ GdkDrawable * drawable;
+ ThemePixbuf * pixbuf;
+ GdkBitmap * mask;
+ GdkPixbuf * expected;
+ GdkPixbuf * result;
+ GError * error = NULL;
+
+ pixbuf = theme_pixbuf_new ();
+ theme_pixbuf_set_filename (pixbuf,
+ TOP_SRCDIR G_DIR_SEPARATOR_S
+ "tests" G_DIR_SEPARATOR_S
+ "test-source-alpha75.png");
+ theme_pixbuf_set_border (pixbuf, 16, 16, 16, 16);
+ g_test_queue_destroy ((GFreeFunc) theme_pixbuf_unref, pixbuf);
+
+ drawable = create_pixmap (200, 200);
+
+ mask = gdk_pixmap_new (NULL, 200, 200, 1);
+ g_test_queue_unref (mask);
+
+ theme_pixbuf_render (pixbuf,
+ GTK_TYPE_BUTTON,
+ drawable,
+ mask,
+ &clip_rect,
+ COMPONENT_ALL,
+ FALSE, /* FIXME: test with TRUE as well */
+ 0, 0,
+ 200, 200);
+
+ result = gdk_pixbuf_get_from_drawable (NULL, drawable,
+ gdk_drawable_get_colormap (drawable),
+ 100, 100, 0, 0, 100, 100);
+ g_test_queue_unref (result);
+
+ expected = gdk_pixbuf_new_from_file (TOP_SRCDIR G_DIR_SEPARATOR_S "tests" G_DIR_SEPARATOR_S "theme-pixbuf-render-clipped.png", &error);
+ g_assert_no_error (error);
+ g_test_queue_unref (expected);
+
+ assert_cmp_pixbuf (result, ==, expected);
}
void
diff --git a/tests/theme-pixbuf-render-clipped.png b/tests/theme-pixbuf-render-clipped.png
new file mode 100644
index 0000000..2066422
Binary files /dev/null and b/tests/theme-pixbuf-render-clipped.png differ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]