diff --git a/test/Makefile.am b/test/Makefile.am index b840d4d15..3b1f6b958 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -245,8 +245,6 @@ glyph-cache-pressure-ps-argb32-ref.png \ glyph-cache-pressure-svg-ref.png \ gradient-alpha-ref.png \ gradient-alpha-rgb24-ref.png \ -in-fill-empty-trapezoid-ref.png \ -in-fill-empty-trapezoid-rgb24-ref.png \ infinite-join-ref.png \ infinite-join-ps-argb32-ref.png \ leaky-dash-ref.png \ diff --git a/test/in-fill-empty-trapezoid-ref.png b/test/in-fill-empty-trapezoid-ref.png deleted file mode 100644 index 60ae61784..000000000 Binary files a/test/in-fill-empty-trapezoid-ref.png and /dev/null differ diff --git a/test/in-fill-empty-trapezoid-rgb24-ref.png b/test/in-fill-empty-trapezoid-rgb24-ref.png deleted file mode 100644 index ef08ebb59..000000000 Binary files a/test/in-fill-empty-trapezoid-rgb24-ref.png and /dev/null differ diff --git a/test/in-fill-empty-trapezoid.c b/test/in-fill-empty-trapezoid.c index 4986aec71..58d347ac7 100644 --- a/test/in-fill-empty-trapezoid.c +++ b/test/in-fill-empty-trapezoid.c @@ -35,22 +35,22 @@ #include "cairo-test.h" -static cairo_test_draw_function_t draw; - -cairo_test_t test = { - "in-fill-empty-trapezoid", - "Tests that the tessellator doesn't produce obviously empty trapezoids", - 10, 10, - draw -}; - -static cairo_test_status_t -draw (cairo_t *cr_orig, int width, int height) +int +main (void) { int x,y; + int width = 10; + int height = 10; cairo_surface_t *surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); cairo_t *cr = cairo_create (surf); - cairo_set_source_rgb (cr_orig, 1, 0, 0); + int false_positive_count = 0; + cairo_status_t status; + char const * description = + "Test that the tessellator isn't producing obviously empty trapezoids"; + + cairo_test_init ("in-fill-empty-trapezoid"); + cairo_test_log ("%s\n", description); + printf ("%s\n", description); /* Empty horizontal trapezoid. */ cairo_move_to (cr, 0, height/3); @@ -67,24 +67,32 @@ draw (cairo_t *cr_orig, int width, int height) cairo_line_to (cr, width, 0); cairo_close_path (cr); - /* Point sample the tessellated path. The x and y starting offsets - * are chosen to hit the nasty bits while still being able to do a - * relatively sparse sampling. */ + status = cairo_status (cr); + + /* Point sample the tessellated path. */ for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { if (cairo_in_fill (cr, x, y)) { - cairo_rectangle(cr_orig, x, y, 1, 1); - cairo_fill (cr_orig); + false_positive_count++; } } } cairo_destroy (cr); cairo_surface_destroy (surf); + + /* Check that everything went well. */ + if (CAIRO_STATUS_SUCCESS != status) { + cairo_test_log ("Failed to create a test surface and path: %s\n", + cairo_status_to_string (status)); + return CAIRO_TEST_FAILURE; + } + + if (0 != false_positive_count) { + cairo_test_log ("Point sampling found %d false positives " + "from cairo_in_fill()\n", + false_positive_count); + return CAIRO_TEST_FAILURE; + } + return CAIRO_TEST_SUCCESS; } - -int -main (void) -{ - return cairo_test (&test); -}