1
/*
2
 * Copyright © 2007 Red Hat, Inc.
3
 *
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use, copy,
8
 * modify, merge, publish, distribute, sublicense, and/or sell copies
9
 * of the Software, and to permit persons to whom the Software is
10
 * furnished to do so, subject to the following conditions:
11
 *
12
 * The above copyright notice and this permission notice shall be
13
 * included in all copies or substantial portions of the Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 * SOFTWARE.
23
 *
24
 * Author: Carl Worth <cworth@cworth.org>
25
 */
26

            
27
#include "cairo-test.h"
28

            
29
/* This is a test case for the following bug:
30
 *
31
 *	Crash in cairo_stroke_extents when line width is 0 and line cap is ROUND
32
 *	(_cairo_pen_find_active_cw_vertex_index)
33
 *	https://bugs.freedesktop.org/show_bug.cgi?id=10231
34
 */
35

            
36
static cairo_test_status_t
37
3
draw (cairo_t *cr, int width, int height)
38
{
39
    double x1, y1, x2, y2;
40

            
41
3
    cairo_move_to (cr, 0.0, 0.0);
42
3
    cairo_line_to (cr, 100.0, 100.0);
43
3
    cairo_set_line_width (cr, 0.0);
44

            
45
3
    cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
46
3
    cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
47
3
    cairo_stroke_extents (cr, &x1, &y1, &x2, &y2);
48
3
    cairo_in_stroke (cr, 50, 50);
49
3
    cairo_stroke_preserve (cr);
50

            
51
3
    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
52
3
    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
53
3
    cairo_stroke_extents (cr, &x1, &y1, &x2, &y2);
54
3
    cairo_in_stroke (cr, 50, 50);
55
3
    cairo_stroke_preserve (cr);
56

            
57
3
    cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
58
3
    cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL);
59
3
    cairo_stroke_extents (cr, &x1, &y1, &x2, &y2);
60
3
    cairo_in_stroke (cr, 50, 50);
61
3
    cairo_stroke (cr);
62

            
63
3
    return CAIRO_TEST_SUCCESS;
64
}
65

            
66
1
CAIRO_TEST (line_width_zero,
67
	    "Test all stroke operations and all cap,join styles with line width of zero",
68
	    "stroke", /* keywords */
69
	    NULL, /* requirements */
70
	    0, 0,
71
	    NULL, draw)