diff options
author | M Joonas Pihlaja <jpihlaja@cc.helsinki.fi> | 2006-12-07 02:30:41 +0200 |
---|---|---|
committer | M Joonas Pihlaja <jpihlaja@cc.helsinki.fi> | 2006-12-07 02:31:10 +0200 |
commit | 6301f92d2af2fd7928352965bcab42bab9deb59d (patch) | |
tree | f2ede6bf1e98f26bb9ef0d8423a9fc60add044fc | |
parent | c13a1a2ed0ce8ba2b43e4e70c66cdc5b98e80eb4 (diff) |
Rework the in-fill-empty-trapezoid test to not use the cairo_test() framework.
As suggested by Behdad Esfahbod, we can not use the cairo_test() framework
when it is getting in the way. The test itself doesn't depend on any
particular backend.
http://lists.freedesktop.org/archives/cairo/2006-December/008809.html
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/in-fill-empty-trapezoid-ref.png | bin | 108 -> 0 bytes | |||
-rw-r--r-- | test/in-fill-empty-trapezoid-rgb24-ref.png | bin | 107 -> 0 bytes | |||
-rw-r--r-- | test/in-fill-empty-trapezoid.c | 54 |
4 files changed, 31 insertions, 25 deletions
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 Binary files differdeleted file mode 100644 index 60ae61784..000000000 --- a/test/in-fill-empty-trapezoid-ref.png +++ /dev/null diff --git a/test/in-fill-empty-trapezoid-rgb24-ref.png b/test/in-fill-empty-trapezoid-rgb24-ref.png Binary files differdeleted file mode 100644 index ef08ebb59..000000000 --- a/test/in-fill-empty-trapezoid-rgb24-ref.png +++ /dev/null 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); - return CAIRO_TEST_SUCCESS; -} -int -main (void) -{ - return cairo_test (&test); + /* 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; } |