mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-08 09:08:16 +02:00
test-suite: add image_diff_is_failure() function
This cleans the code and fixes a boolean logic error where this check was done manually.
This commit is contained in:
parent
2a91d42508
commit
2ce1afa322
6 changed files with 19 additions and 12 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue