summaryrefslogtreecommitdiff
path: root/test/in-fill-empty-trapezoid.c
diff options
context:
space:
mode:
authorM Joonas Pihlaja <jpihlaja@cc.helsinki.fi>2006-12-07 02:30:41 +0200
committerM Joonas Pihlaja <jpihlaja@cc.helsinki.fi>2006-12-07 02:31:10 +0200
commit6301f92d2af2fd7928352965bcab42bab9deb59d (patch)
treef2ede6bf1e98f26bb9ef0d8423a9fc60add044fc /test/in-fill-empty-trapezoid.c
parentc13a1a2ed0ce8ba2b43e4e70c66cdc5b98e80eb4 (diff)
downloadcairo-6301f92d2af2fd7928352965bcab42bab9deb59d.tar.gz
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
Diffstat (limited to 'test/in-fill-empty-trapezoid.c')
-rw-r--r--test/in-fill-empty-trapezoid.c54
1 files changed, 31 insertions, 23 deletions
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;
}