summaryrefslogtreecommitdiff
path: root/test/xlib-surface.c
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2006-08-31 04:01:10 -0700
committerCarl Worth <cworth@cworth.org>2006-08-31 04:01:10 -0700
commitd1834cca192fe6f8e429be0461fab6914e04024d (patch)
treebae8be8e3f1604d25682131660937c44a19a7e9b /test/xlib-surface.c
parentd52a1f762d33f3ada919b581e0d62f8ba1c2314c (diff)
downloadcairo-d1834cca192fe6f8e429be0461fab6914e04024d.tar.gz
test: Ignore single-bit errors for SVG backend.
The interface of the various buffer/image_diff functions is improved to provide the maximum pixel difference in addition to the number of pixels that differ. This value can then be used to compare against a per-backend tolerance. Currently I've set the SVG backend's tolerance to 1 to handle some issues we're currently seeing of single-bit differences on different systems, (but we're not exactly sure why yet). Also I improved the image_diff routines to properly report a status value on failure rather than the bogus value of -1 for pixels_changed.
Diffstat (limited to 'test/xlib-surface.c')
-rw-r--r--test/xlib-surface.c75
1 files changed, 42 insertions, 33 deletions
diff --git a/test/xlib-surface.c b/test/xlib-surface.c
index e20b6ebfc..ccde14c1f 100644
--- a/test/xlib-surface.c
+++ b/test/xlib-surface.c
@@ -74,7 +74,7 @@ erase_pattern (cairo_surface_t *surface)
cairo_destroy (cr);
}
-static cairo_bool_t
+static cairo_test_status_t
do_test (Display *dpy,
unsigned char *reference_data,
unsigned char *test_data,
@@ -87,12 +87,12 @@ do_test (Display *dpy,
cairo_surface_t *surface;
cairo_surface_t *test_surface;
cairo_t *test_cr;
- cairo_bool_t result;
+ buffer_diff_result_t result;
Drawable drawable;
int screen = DefaultScreen (dpy);
if (use_pixmap && offscreen)
- return 1;
+ return CAIRO_TEST_SUCCESS;
if (use_pixmap) {
drawable = XCreatePixmap (dpy, DefaultRootWindow (dpy),
@@ -129,7 +129,7 @@ do_test (Display *dpy,
if (cairo_xlib_surface_get_width (surface) != SIZE ||
cairo_xlib_surface_get_height (surface) != SIZE)
- return 0;
+ return CAIRO_TEST_FAILURE;
}
draw_pattern (surface);
@@ -160,23 +160,25 @@ do_test (Display *dpy,
if (offscreen) {
size_t offset = 4 * (SIZE * OFFSCREEN_OFFSET + OFFSCREEN_OFFSET);
- result = !buffer_diff_noalpha (reference_data + offset,
- test_data + offset,
- diff_data + offset,
- SIZE - OFFSCREEN_OFFSET,
- SIZE - OFFSCREEN_OFFSET,
- 4 * SIZE,
- 4 * SIZE,
- 4 * SIZE);
+ buffer_diff_noalpha (reference_data + offset,
+ test_data + offset,
+ diff_data + offset,
+ SIZE - OFFSCREEN_OFFSET,
+ SIZE - OFFSCREEN_OFFSET,
+ 4 * SIZE,
+ 4 * SIZE,
+ 4 * SIZE,
+ &result);
} else {
- result = !buffer_diff_noalpha (reference_data,
- test_data,
- diff_data,
- SIZE,
- SIZE,
- 4 * SIZE,
- 4 * SIZE,
- 4 * SIZE);
+ buffer_diff_noalpha (reference_data,
+ test_data,
+ diff_data,
+ SIZE,
+ SIZE,
+ 4 * SIZE,
+ 4 * SIZE,
+ 4 * SIZE,
+ &result);
}
fprintf (log_file, "xlib-surface: %s, %s, %s%s: %s\n",
@@ -186,9 +188,12 @@ do_test (Display *dpy,
use_pixmap ?
" " :
(offscreen ? ", offscreen" : ", onscreen"),
- result ? "PASS" : "FAIL");
+ result.pixels_changed ? "FAIL" : "PASS");
- return result;
+ if (result.pixels_changed)
+ return CAIRO_TEST_FAILURE;
+ else
+ return CAIRO_TEST_SUCCESS;
}
static cairo_bool_t
@@ -218,7 +223,7 @@ main (void)
cairo_bool_t use_pixmap;
cairo_bool_t set_size;
cairo_bool_t offscreen;
- result = 0;
+ cairo_test_status_t status, result = CAIRO_TEST_SUCCESS;
cairo_test_init ("xlib-surface");
log_file = fopen ("xlib-surface.log", "w");
@@ -254,21 +259,25 @@ main (void)
for (set_size = 0; set_size <= 1; set_size++)
for (use_pixmap = 0; use_pixmap <= 1; use_pixmap++)
- for (offscreen = 0; offscreen <= 1; offscreen++)
- if (!do_test (dpy,
- reference_data, test_data, diff_data,
- 1, use_pixmap, set_size, offscreen))
- result = 1;
+ for (offscreen = 0; offscreen <= 1; offscreen++) {
+ status = do_test (dpy,
+ reference_data, test_data, diff_data,
+ 1, use_pixmap, set_size, offscreen);
+ if (status)
+ result = status;
+ }
_cairo_xlib_test_disable_render ();
for (set_size = 0; set_size <= 1; set_size++)
for (use_pixmap = 0; use_pixmap <= 1; use_pixmap++)
- for (offscreen = 0; offscreen <= 1; offscreen++)
- if (!do_test (dpy,
- reference_data, test_data, diff_data,
- 0, use_pixmap, set_size, offscreen))
- result = 1;
+ for (offscreen = 0; offscreen <= 1; offscreen++) {
+ status = do_test (dpy,
+ reference_data, test_data, diff_data,
+ 0, use_pixmap, set_size, offscreen);
+ if (status)
+ result = status;
+ }
free (reference_data);
free (test_data);