[sapwood] add a test for the cropped rendering



commit 12883483a65e79ba154d10c61f13e1918fed8844
Author: Sven Herzberg <herzi gnome-de org>
Date:   Fri Aug 6 13:24:12 2010 +0200

    add a test for the cropped rendering
    
    * tests/test-theme-pixbuf.c: test the cropped rendering
    * tests/theme-pixbuf-render-cropped.png: add a reference image for the
      new test

 tests/test-theme-pixbuf.c             |   43 +++++++++++++++++++++++++++++++++
 tests/theme-pixbuf-render-cropped.png |  Bin 0 -> 301 bytes
 2 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-theme-pixbuf.c b/tests/test-theme-pixbuf.c
index 8786e14..6c2ee37 100644
--- a/tests/test-theme-pixbuf.c
+++ b/tests/test-theme-pixbuf.c
@@ -71,10 +71,53 @@ test_render_clipped (void)
   assert_cmp_pixbuf (result, ==, expected);
 }
 
+static void
+test_render_cropped (void)
+{
+  GdkRectangle  clip_rect = {0, 0, 50, 50};
+  GdkDrawable * drawable;
+  ThemePixbuf * pixbuf;
+  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);
+
+  theme_pixbuf_render (pixbuf,
+                       GTK_TYPE_BUTTON,
+                       drawable,
+                       NULL, /* cropping is only used when mask == NULL */
+                       &clip_rect,
+                       COMPONENT_ALL,
+                       FALSE, /* FIXME: test with TRUE as well */
+                       0, 0,
+                       50, 50);
+
+  result = gdk_pixbuf_get_from_drawable (NULL, drawable,
+                                         gdk_drawable_get_colormap (drawable),
+                                         0, 0, 0, 0, 50, 50);
+  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-cropped.png", &error);
+  g_assert_no_error (error);
+  g_test_queue_unref (expected);
+
+  assert_cmp_pixbuf (result, ==, expected);
+}
+
 void
 test_theme_pixbuf (void)
 {
   g_test_add_func ("/sapwood/theme-pixbuf/render-clipped", test_render_clipped);
+  g_test_add_func ("/sapwood/theme-pixbuf/render-cropped", test_render_cropped);
 }
 
 /* vim:set et sw=2 cino=t0,f0,(0,{s,>2s,n-1s,^-1s,e2s: */
diff --git a/tests/theme-pixbuf-render-cropped.png b/tests/theme-pixbuf-render-cropped.png
new file mode 100644
index 0000000..bc70e08
Binary files /dev/null and b/tests/theme-pixbuf-render-cropped.png differ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]