diff --git a/test/buffer-diff.c b/test/buffer-diff.c index 8fc3f891e..087ac459b 100644 --- a/test/buffer-diff.c +++ b/test/buffer-diff.c @@ -252,3 +252,11 @@ image_diff (const cairo_test_context_t *ctx, return CAIRO_STATUS_SUCCESS; } + +cairo_bool_t +image_diff_is_failure (const buffer_diff_result_t *result, + unsigned int tolerance) +{ + return result->pixels_changed && + result->max_diff > tolerance; +} diff --git a/test/buffer-diff.h b/test/buffer-diff.h index c09bc6464..2cbb8959c 100644 --- a/test/buffer-diff.h +++ b/test/buffer-diff.h @@ -66,4 +66,8 @@ image_diff (const cairo_test_context_t *ctx, cairo_surface_t *surface_diff, buffer_diff_result_t *result); +cairo_bool_t +image_diff_is_failure (const buffer_diff_result_t *result, + unsigned int tolerance); + #endif diff --git a/test/cairo-test-trace.c b/test/cairo-test-trace.c index ed81eb294..77ee84bc9 100644 --- a/test/cairo-test-trace.c +++ b/test/cairo-test-trace.c @@ -723,8 +723,7 @@ matches_reference (struct slave *slave) return FALSE; } - if (slave->result.pixels_changed && - slave->result.max_diff > slave->target->error_tolerance) { + if (image_diff_is_failure (&slave->result, slave->target->error_tolerance)) { slave->difference = diff; return FALSE; } else { diff --git a/test/cairo-test.c b/test/cairo-test.c index e2bc687b2..286df09ad 100644 --- a/test/cairo-test.c +++ b/test/cairo-test.c @@ -1319,8 +1319,7 @@ REPEAT: &result); _xunlink (ctx, diff_png_path); if (diff_status || - (result.pixels_changed && - result.max_diff > target->error_tolerance)) + image_diff_is_failure (&result, target->error_tolerance)) { /* that failed, so check against the specific backend */ ref_image = cairo_test_get_reference_image (ctx, ref_png_path, @@ -1345,8 +1344,7 @@ REPEAT: cairo_status_to_string (diff_status)); ret = CAIRO_TEST_FAILURE; } - else if (result.pixels_changed && - result.max_diff > target->error_tolerance) + else if (image_diff_is_failure (&result, target->error_tolerance)) { ret = CAIRO_TEST_FAILURE; @@ -1403,8 +1401,7 @@ REPEAT: diff_image, &result); if (diff_status == CAIRO_STATUS_SUCCESS && - (result.pixels_changed == 0 || - result.max_diff > target->error_tolerance)) + !image_diff_is_failure (&result, target->error_tolerance)) { ret = CAIRO_TEST_XFAILURE; } diff --git a/test/fallback-resolution.c b/test/fallback-resolution.c index 1ffacb1b2..5b18a7efb 100644 --- a/test/fallback-resolution.c +++ b/test/fallback-resolution.c @@ -234,8 +234,7 @@ check_result (cairo_test_context_t *ctx, cairo_test_log (ctx, "Error: Failed to compare images: %s\n", cairo_status_to_string (status)); ret = FALSE; - } else if (result.pixels_changed && - result.max_diff > target->error_tolerance) + } else if (image_diff_is_failure (&result, target->error_tolerance)) { ret = FALSE; diff --git a/test/xlib-surface.c b/test/xlib-surface.c index a7ff02085..be44b148b 100644 --- a/test/xlib-surface.c +++ b/test/xlib-surface.c @@ -250,9 +250,9 @@ do_test (const cairo_test_context_t *ctx, use_pixmap ? " " : (offscreen ? ", offscreen" : ", onscreen"), - result.pixels_changed ? "FAIL" : "PASS"); + image_diff_is_failure (&result, 0) ? "FAIL" : "PASS"); - if (result.pixels_changed) + if (image_diff_is_failure (&result, 0)) return CAIRO_TEST_FAILURE; else return CAIRO_TEST_SUCCESS;