2 * Copyright © 2005 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Keith Packard not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Keith Packard makes no
11 * representations about the suitability of this software for any purpose. It
12 * is provided "as is" without express or implied warranty.
14 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
23 #include "cairo-test.h"
28 invalid_rel_move_to (cairo_surface_t
*target
)
31 cairo_status_t status
;
33 cr
= cairo_create (target
);
34 cairo_rel_move_to (cr
, SIZE
, SIZE
/2);
35 status
= cairo_status (cr
);
42 invalid_rel_line_to (cairo_surface_t
*target
)
45 cairo_status_t status
;
47 cr
= cairo_create (target
);
48 cairo_rel_line_to (cr
, -SIZE
, SIZE
/2);
49 status
= cairo_status (cr
);
56 invalid_rel_curve_to (cairo_surface_t
*target
)
59 cairo_status_t status
;
61 cr
= cairo_create (target
);
62 cairo_rel_curve_to (cr
,
66 status
= cairo_status (cr
);
72 static cairo_test_status_t
73 draw (cairo_t
*cr
, int width
, int height
)
75 const cairo_test_context_t
*ctx
= cairo_test_get_context (cr
);
76 cairo_status_t status
;
77 cairo_test_status_t result
;
79 /* first test that a relative move without a current point fails... */
80 status
= invalid_rel_move_to (cairo_get_target (cr
));
81 if (status
!= CAIRO_STATUS_NO_CURRENT_POINT
) {
82 result
= cairo_test_status_from_status (ctx
, status
);
83 if (result
== CAIRO_TEST_NO_MEMORY
)
86 cairo_test_log (ctx
, "Error: invalid cairo_rel_move_to() did not raise NO_CURRENT_POINT\n");
90 status
= invalid_rel_line_to (cairo_get_target (cr
));
91 if (status
!= CAIRO_STATUS_NO_CURRENT_POINT
) {
92 result
= cairo_test_status_from_status (ctx
, status
);
93 if (result
== CAIRO_TEST_NO_MEMORY
)
96 cairo_test_log (ctx
, "Error: invalid cairo_rel_line_to() did not raise NO_CURRENT_POINT\n");
100 status
= invalid_rel_curve_to (cairo_get_target (cr
));
101 if (status
!= CAIRO_STATUS_NO_CURRENT_POINT
) {
102 result
= cairo_test_status_from_status (ctx
, status
);
103 if (result
== CAIRO_TEST_NO_MEMORY
)
106 cairo_test_log (ctx
, "Error: invalid cairo_rel_curve_to() did not raise NO_CURRENT_POINT\n");
110 cairo_set_source_rgb (cr
, 1, 1, 1);
111 cairo_move_to (cr
, 0, 0);
112 cairo_rel_move_to (cr
, SIZE
, SIZE
/2);
113 cairo_rel_line_to (cr
, -SIZE
, SIZE
/2);
114 cairo_rel_curve_to (cr
,
121 return CAIRO_TEST_SUCCESS
;
124 CAIRO_TEST (rel_path
,
125 "Tests calls to various relative path functions",
126 "path", /* keywords */
127 NULL
, /* requirements */