Upload Tizen2.0 source
[framework/graphics/cairo.git] / test / line-width-tolerance.c
1 /* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
2 /*
3  * Copyright 2011 Red Hat Inc.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without
8  * restriction, including without limitation the rights to use, copy,
9  * modify, merge, publish, distribute, sublicense, and/or sell copies
10  * of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24  *
25  * Author: Benjamin Otte <otte@redhat.com>
26  */
27
28 /*
29  * Test case taken from the WebKit test suite, failure originally reported
30  * by Zan Dobersek <zandobersek@gmail.com> at
31  * https://bugs.webkit.org/show_bug.cgi?id=54471
32  */
33
34 #include "cairo-test.h"
35
36 #include <math.h>
37
38 #define RADIUS 50
39
40 static cairo_test_status_t
41 draw (cairo_t *cr, int width, int height)
42 {
43     /* fill with green so RGB and RGBA tests can share the ref image */
44     cairo_set_source_rgb (cr, 0, 1, 0);
45     cairo_paint (cr);
46
47     /* red to see eventual bugs immediately */
48     cairo_set_source_rgb (cr, 1, 0, 0);
49
50     /* stroke 3/4 of a circle where the last quarter would be this
51      * reference image. Keep just a 1 pixel border. Use a huge line
52      * width (twice the circle's radius to get it filled completely).
53      */
54     cairo_set_line_width (cr, 2 * RADIUS);
55     cairo_arc (cr, 1, RADIUS - 1, RADIUS, 0, - M_PI / 2.0);
56     cairo_stroke (cr);
57
58     return CAIRO_TEST_SUCCESS;
59 }
60
61 CAIRO_TEST (line_width_tolerance,
62             "Test interaction of line width and tolerance when stroking arcs",
63             "stroke", /* keywords */
64             NULL, /* requirements */
65             RADIUS, RADIUS,
66             NULL, draw)