summaryrefslogtreecommitdiff
path: root/test/dash-zero-length.c
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2006-06-29 06:12:48 +0200
committerCarl Worth <cworth@cworth.org>2006-06-29 06:12:48 +0200
commit734e10709f5c62c0b64e51a03df8e109e7eebe0d (patch)
tree63f3c06ba13c1d3a5672a0e13c1c59e96adea238 /test/dash-zero-length.c
parent8aa306caac99ebe074a6cde8b424b1780cafefee (diff)
downloadcairo-734e10709f5c62c0b64e51a03df8e109e7eebe0d.tar.gz
Add several more stress tests to test/dash-zero-length
Diffstat (limited to 'test/dash-zero-length.c')
-rw-r--r--test/dash-zero-length.c85
1 files changed, 56 insertions, 29 deletions
diff --git a/test/dash-zero-length.c b/test/dash-zero-length.c
index a5d0047de..2014c07e6 100644
--- a/test/dash-zero-length.c
+++ b/test/dash-zero-length.c
@@ -26,7 +26,7 @@
#include "cairo-test.h"
#define IMAGE_WIDTH 19
-#define IMAGE_HEIGHT 25
+#define IMAGE_HEIGHT 61
/* A test of the two extremes of dashing: a solid line
* and an invisible one. Also test that capping works
@@ -39,44 +39,71 @@ cairo_test_t test = {
IMAGE_WIDTH, IMAGE_HEIGHT
};
+static void
+draw_dash (cairo_t *cr, double *dash, int num_dashes)
+{
+ cairo_set_dash (cr, dash, num_dashes, 0.0);
+ cairo_move_to (cr, 1, 2);
+ cairo_line_to (cr, 18, 2);
+ cairo_stroke (cr);
+ cairo_translate (cr, 0, 3);
+}
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
- double solid_line[] = { 4, 0 };
- double invisible_line[] = { 0, 4 };
- double dotted_line[] = { 0, 6 };
- double rounded_line[] = { 2, 6 };
+ static double solid_line[] = { 4, 0 };
+ static double invisible_line[] = { 0, 4 };
+ static double dotted_line[] = { 0, 6 };
+ static double zero_1_of_3[] = { 0, 2, 3 };
+ static double zero_2_of_3[] = { 1, 0, 3 };
+ static double zero_3_of_3[] = { 1, 2, 0 };
+ static double zero_1_of_4[] = { 0, 2, 3, 4 };
+ static double zero_2_of_4[] = { 1, 0, 3, 4 };
+ static double zero_3_of_4[] = { 1, 2, 0, 4 };
+ static double zero_4_of_4[] = { 1, 2, 3, 0 };
+ static double zero_1_2_of_4[] = { 0, 0, 3, 4 };
+ static double zero_1_3_of_4[] = { 0, 2, 0, 4 };
+/* Clearly it would be nice to draw this one as well, but it seems to trigger a bug in ghostscript. */
+#if BUG_FIXED_IN_GHOSTSCRIPT
+ static double zero_1_4_of_4[] = { 0, 2, 3, 0 };
+#endif
+ static double zero_2_3_of_4[] = { 1, 0, 0, 4 };
+ static double zero_2_4_of_4[] = { 1, 0, 3, 0 };
+ static double zero_3_4_of_4[] = { 1, 2, 0, 0 };
+ static double zero_1_2_3_of_4[] = { 0, 0, 0, 4 };
+ static double zero_1_2_4_of_4[] = { 0, 0, 3, 0 };
+ static double zero_1_3_4_of_4[] = { 0, 2, 0, 0 };
+ static double zero_2_3_4_of_4[] = { 1, 0, 0, 0 };
cairo_set_source_rgb (cr, 1, 0, 0);
cairo_set_line_width (cr, 2);
- /* draw a solid line */
- cairo_set_dash (cr, solid_line, 2, 0);
- cairo_move_to (cr, 1, 2);
- cairo_line_to (cr, 18, 2);
- cairo_stroke (cr);
-
- /* draw an invisible line */
- cairo_set_dash (cr, invisible_line, 2, 0);
- cairo_move_to (cr, 1, 8);
- cairo_line_to (cr, 18, 8);
- cairo_stroke (cr);
+ draw_dash (cr, solid_line, 2);
+ draw_dash (cr, invisible_line, 2);
- /* draw a dotted line */
- cairo_set_line_width (cr, 5);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
- cairo_set_dash (cr, dotted_line, 2, 0);
- cairo_move_to (cr, 5, 13);
- cairo_line_to (cr, 18, 13);
- cairo_stroke (cr);
+ draw_dash (cr, dotted_line, 2);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
- /* draw a rounded line */
- cairo_set_line_width (cr, 5);
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
- cairo_set_dash (cr, rounded_line, 2, 2);
- cairo_move_to (cr, 5, 20);
- cairo_line_to (cr, 18, 20);
- cairo_stroke (cr);
+ draw_dash (cr, zero_1_of_3, 3);
+ draw_dash (cr, zero_2_of_3, 3);
+ draw_dash (cr, zero_3_of_3, 3);
+ draw_dash (cr, zero_1_of_4, 4);
+ draw_dash (cr, zero_2_of_4, 4);
+ draw_dash (cr, zero_3_of_4, 4);
+ draw_dash (cr, zero_4_of_4, 4);
+ draw_dash (cr, zero_1_2_of_4, 4);
+ draw_dash (cr, zero_1_3_of_4, 4);
+#if BUG_FIXED_IN_GHOSTSCRIPT
+ draw_dash (cr, zero_1_4_of_4, 4);
+#endif
+ draw_dash (cr, zero_2_3_of_4, 4);
+ draw_dash (cr, zero_2_4_of_4, 4);
+ draw_dash (cr, zero_3_4_of_4, 4);
+ draw_dash (cr, zero_1_2_3_of_4, 4);
+ draw_dash (cr, zero_1_2_4_of_4, 4);
+ draw_dash (cr, zero_1_3_4_of_4, 4);
+ draw_dash (cr, zero_2_3_4_of_4, 4);
return CAIRO_TEST_SUCCESS;
}