summaryrefslogtreecommitdiff
path: root/test/leaky-dashed-rectangle.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-04-29 15:19:40 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2008-04-29 15:19:40 +0100
commit8742429c7958bb7f87595b1c018b4da7856b2f92 (patch)
tree479d27c91d9b9991ad25b25efa51d1d918a7643f /test/leaky-dashed-rectangle.c
parentafa4ff8df598b60ab75a95ceac9bc0dafedd3b22 (diff)
downloadcairo-8742429c7958bb7f87595b1c018b4da7856b2f92.tar.gz
[test] Add test case for a leaky dashed rectangle.
Franz Schmid reported on the mailing list, http://lists.cairographics.org/archives/cairo/2008-April/013912.html, an issue with drawing a dashed rubber band in Scribus. The problem appears when segments of the dashed rectangle are outside the image, with the errant dash connecting the ends of the visible segments.
Diffstat (limited to 'test/leaky-dashed-rectangle.c')
-rw-r--r--test/leaky-dashed-rectangle.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/test/leaky-dashed-rectangle.c b/test/leaky-dashed-rectangle.c
new file mode 100644
index 000000000..0d9e2460b
--- /dev/null
+++ b/test/leaky-dashed-rectangle.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright © 2008 Chris Wilson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Chris Wilson not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Chris Wilson makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Chris Wilson <chris@chris-wilson.co.uk>
+ * Franz Schmid <Franz.Schmid@altmuehlnet.de>
+ */
+
+/* Test case for bug reported by Franz Schmid <Franz.Schmid@altmuehlnet.de>
+ * http://lists.cairographics.org/archives/cairo/2008-April/013912.html
+ */
+
+#include "cairo-test.h"
+
+#define WIDTH 60
+#define HEIGHT 60
+
+static cairo_test_draw_function_t draw;
+
+cairo_test_t test = {
+ "leaky-dashed-rectangle",
+ "Exercises bug in which a dashed stroke leaks in from outside the surface",
+ WIDTH, HEIGHT,
+ draw
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ const double dash[2] = {4, 2};
+
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_paint (cr);
+
+ cairo_set_source_rgb (cr, 0., 0., 0);
+
+ cairo_translate (cr, 0.5, .5);
+ cairo_set_line_width (cr, 1); /* This is vital to reproduce the bug. */
+
+ /* First check simple rectangles */
+ cairo_set_source_rgb (cr, 0., 0., 0);
+ cairo_rectangle (cr, -WIDTH/4, -HEIGHT/4, WIDTH, HEIGHT);
+ cairo_stroke (cr);
+ cairo_rectangle (cr, WIDTH+WIDTH/4, -HEIGHT/4, -WIDTH, HEIGHT);
+ cairo_stroke (cr);
+ cairo_rectangle (cr, -WIDTH/4, HEIGHT+HEIGHT/4, WIDTH, -HEIGHT);
+ cairo_stroke (cr);
+ cairo_rectangle (cr, WIDTH+WIDTH/4, HEIGHT+HEIGHT/4, -WIDTH, -HEIGHT);
+ cairo_stroke (cr);
+
+ cairo_set_dash (cr, dash, 2, 0);
+
+ /* And now dashed. */
+ cairo_set_source_rgb (cr, 1., 0., 0);
+ cairo_rectangle (cr, -WIDTH/4, -HEIGHT/4, WIDTH, HEIGHT);
+ cairo_stroke (cr);
+ cairo_set_source_rgb (cr, 0., 1., 0);
+ cairo_rectangle (cr, WIDTH+WIDTH/4, -HEIGHT/4, -WIDTH, HEIGHT);
+ cairo_stroke (cr);
+ cairo_set_source_rgb (cr, 0., 0., 1);
+ cairo_rectangle (cr, -WIDTH/4, HEIGHT+HEIGHT/4, WIDTH, -HEIGHT);
+ cairo_stroke (cr);
+ cairo_set_source_rgb (cr, 1., 1., 0);
+ cairo_rectangle (cr, WIDTH+WIDTH/4, HEIGHT+HEIGHT/4, -WIDTH, -HEIGHT);
+ cairo_stroke (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test);
+}