[sapwood] extract the pixmap creation code
- From: Sven Herzberg <herzi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sapwood] extract the pixmap creation code
- Date: Fri, 6 Aug 2010 12:05:53 +0000 (UTC)
commit 27479dec2b2eef13a61ad90d122eced8b8931c97
Author: Sven Herzberg <herzi gnome-de org>
Date: Thu Aug 5 14:13:56 2010 +0200
extract the pixmap creation code
* tests/test-framework.c,
* tests/test-framework.h,
* tests/test-sapwood.c: extract the pixmap creation code
tests/test-framework.c | 22 ++++++++++++++++++++++
tests/test-framework.h | 8 ++++++++
tests/test-sapwood.c | 28 ++--------------------------
3 files changed, 32 insertions(+), 26 deletions(-)
---
diff --git a/tests/test-framework.c b/tests/test-framework.c
index 6f66903..1197a43 100644
--- a/tests/test-framework.c
+++ b/tests/test-framework.c
@@ -20,5 +20,27 @@
#include "test-framework.h"
+GdkPixmap*
+create_pixmap (int width,
+ int height)
+{
+ GdkColormap* colormap;
+ GdkDrawable* drawable;
+ cairo_t * cr;
+
+ colormap = gdk_screen_get_system_colormap (gdk_screen_get_default ());
+ g_assert (colormap);
+
+ drawable = gdk_pixmap_new (NULL, 200, 200, gdk_colormap_get_visual (colormap)->depth);
+ g_test_queue_unref (drawable);
+ gdk_drawable_set_colormap (drawable, colormap);
+
+ cr = gdk_cairo_create (drawable);
+ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+ cairo_paint (cr);
+ cairo_destroy (cr);
+
+ return drawable;
+}
/* vim:set et sw=2 cino=t0,f0,(0,{s,>2s,n-1s,^-1s,e2s: */
diff --git a/tests/test-framework.h b/tests/test-framework.h
index 35556c6..1a75f57 100644
--- a/tests/test-framework.h
+++ b/tests/test-framework.h
@@ -21,6 +21,13 @@
#ifndef TEST_FRAMEWORK_H
#define TEST_FRAMEWORK_H
+#include <gdk/gdk.h>
+
+G_BEGIN_DECLS
+
+GdkDrawable* create_pixmap (int width,
+ int height);
+
#define assert_cmp_pixbuf(a,op,b) \
G_STMT_START { \
if (a && b) \
@@ -80,6 +87,7 @@
} \
} G_STMT_END
+G_END_DECLS
#endif /* !TEST_FRAMEWORK_H */
diff --git a/tests/test-sapwood.c b/tests/test-sapwood.c
index e4d49b7..6bfda1f 100644
--- a/tests/test-sapwood.c
+++ b/tests/test-sapwood.c
@@ -33,11 +33,9 @@ test_larger (void)
{
SapwoodPixmap* pixmap;
SapwoodRect rects[9];
- GdkColormap * colormap;
GdkDrawable * drawable = NULL;
GdkPixbuf * result;
GdkPixbuf * expected;
- cairo_t * cr;
GError * error = NULL;
char abspath[PATH_MAX + 1];
int code;
@@ -69,17 +67,7 @@ test_larger (void)
rects[i].dest.height = row == 1 ? 200 - 2 * 16 : 16;
}
- colormap = gdk_screen_get_system_colormap (gdk_screen_get_default ());
- g_assert (colormap);
-
- drawable = gdk_pixmap_new (NULL, 200, 200, gdk_colormap_get_visual (colormap)->depth);
- g_test_queue_unref (drawable);
- gdk_drawable_set_colormap (drawable, colormap);
-
- cr = gdk_cairo_create (drawable);
- cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
- cairo_paint (cr);
- cairo_destroy (cr);
+ drawable = create_pixmap (200, 200);
gdk_error_trap_push ();
@@ -123,12 +111,10 @@ test_larger_masked (void)
{
SapwoodPixmap* pixmap;
SapwoodRect rects[9];
- GdkColormap * colormap;
GdkDrawable * drawable = NULL;
GdkPixbuf * result;
GdkPixbuf * expected;
GdkBitmap * mask;
- cairo_t * cr;
GError * error = NULL;
char abspath[PATH_MAX + 1];
int code;
@@ -160,21 +146,11 @@ test_larger_masked (void)
rects[i].dest.height = row == 1 ? 200 - 2 * 16 : 16;
}
- colormap = gdk_screen_get_system_colormap (gdk_screen_get_default ());
- g_assert (colormap);
-
- drawable = gdk_pixmap_new (NULL, 200, 200, gdk_colormap_get_visual (colormap)->depth);
- g_test_queue_unref (drawable);
- gdk_drawable_set_colormap (drawable, colormap);
+ drawable = create_pixmap (200, 200);
mask = gdk_pixmap_new (NULL, 200, 200, 1);
g_test_queue_unref (mask);
- cr = gdk_cairo_create (drawable);
- cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
- cairo_paint (cr);
- cairo_destroy (cr);
-
gdk_error_trap_push ();
sapwood_pixmap_render_rects (pixmap,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]