c4a754dee5f3e207f86fc32c59e1c7ed7562fbf2
[platform/core/graphics/cairo.git] / test / api-special-cases.c
1 /*
2  * Copyright © 2010 Red Hat Inc.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software
5  * and its documentation for any purpose is hereby granted without
6  * fee, provided that the above copyright notice appear in all copies
7  * and that both that copyright notice and this permission notice
8  * appear in supporting documentation, and that the name of
9  * Red Hat, Inc. not be used in advertising or publicity pertaining to
10  * distribution of the software without specific, written prior
11  * permission. Red Hat, Inc. makes no representations about the
12  * suitability of this software for any purpose.  It is provided "as
13  * is" without express or implied warranty.
14  *
15  * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
16  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
18  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
21  * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  *
23  * Author: Benjamin Otte <otte@redhat.com>
24  */
25
26 /*
27  * WHAT THIS TEST DOES
28  *
29  * This test tests that for all public APIs Cairo behaves correct, consistent
30  * and most of all doesn't crash. It does this by calling all APIs that take
31  * surfaces or contexts and calling them on specially prepared arguments that
32  * should fail when called on this function.
33  *
34  * ADDING NEW FUNCTIONS
35  *
36  * You need (for adding the function cairo_surface_foo):
37  * 1) A surface_test_func_t named test_cairo_surface_foo that gets passed the
38  *    prepared surface and has the job of calling the function and checking
39  *    the return value (if one exists) for correctness. The top of this file
40  *    contains all these shim functions.
41  * 2) Knowledge if the function behaves like a setter or like a getter. A 
42  *    setter should set an error status on the surface, a getter does not
43  *    modify the function.
44  * 3) Knowledge if the function only works for a specific surface type and for
45  *    which one.
46  * 4) An entry in the tests array using the TEST() macro. It takes as arguments:
47  *    - The function name
48  *    - TRUE if the function modifies the surface, FALSE otherwise
49  *    - the surface type for which the function is valid or -1 if it is valid
50  *      for all surface types.
51  *
52  * FIXING FAILURES
53  *
54  * The test will dump failures notices into the api-special-cases.log file (when 
55  * it doesn't crash). These should be pretty self-explanatory. Usually it is 
56  * enough to just add a new check to the function it complained about.
57  */
58
59 #ifdef HAVE_CONFIG_H
60 #include "config.h"
61 #endif
62
63 #include <assert.h>
64 #include <limits.h>
65
66 #include "cairo-test.h"
67
68 #if CAIRO_HAS_GL_SURFACE
69 #include <cairo-gl.h>
70 #endif
71 #if CAIRO_HAS_OS2_SURFACE
72 #include <cairo-os2.h>
73 #endif
74 #if CAIRO_HAS_PDF_SURFACE
75 #include <cairo-pdf.h>
76 #endif
77 #if CAIRO_HAS_PS_SURFACE
78 #include <cairo-ps.h>
79 #endif
80 #if CAIRO_HAS_QUARTZ_SURFACE
81 #define Cursor QuartzCursor
82 #include <cairo-quartz.h>
83 #undef Cursor
84 #endif
85 #if CAIRO_HAS_SVG_SURFACE
86 #include <cairo-svg.h>
87 #endif
88 #if CAIRO_HAS_TEE_SURFACE
89 #include <cairo-tee.h>
90 #endif
91 #if CAIRO_HAS_XCB_SURFACE
92 #include <cairo-xcb.h>
93 #endif
94 #if CAIRO_HAS_XLIB_SURFACE
95 #define Cursor XCursor
96 #include <cairo-xlib.h>
97 #undef Cursor
98 #endif
99
100 #define surface_has_type(surface,type) (cairo_surface_get_type (surface) == (type))
101
102 typedef cairo_test_status_t (* surface_test_func_t) (cairo_surface_t *surface);
103 typedef cairo_test_status_t (* context_test_func_t) (cairo_t *cr);
104
105 static cairo_test_status_t
106 test_cairo_reference (cairo_t *cr)
107 {
108     cairo_destroy (cairo_reference (cr));
109
110     return CAIRO_TEST_SUCCESS;
111 }
112
113 static cairo_test_status_t
114 test_cairo_get_reference_count (cairo_t *cr)
115 {
116     unsigned int refcount = cairo_get_reference_count (cr);
117     if (refcount > 0)
118         return CAIRO_TEST_SUCCESS;
119     /* inert error context have a refcount of 0 */
120     return cairo_status (cr) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
121 }
122
123 static cairo_test_status_t
124 test_cairo_set_user_data (cairo_t *cr)
125 {
126     static cairo_user_data_key_t key;
127     cairo_status_t status;
128
129     status = cairo_set_user_data (cr, &key, &key, NULL);
130     if (status == CAIRO_STATUS_NO_MEMORY)
131         return CAIRO_TEST_NO_MEMORY;
132     else if (status)
133         return CAIRO_TEST_SUCCESS;
134
135     if (cairo_get_user_data (cr, &key) != &key)
136         return CAIRO_TEST_ERROR;
137
138     return CAIRO_TEST_SUCCESS;
139 }
140
141 static cairo_test_status_t
142 test_cairo_save (cairo_t *cr)
143 {
144     cairo_save (cr);
145     cairo_restore (cr);
146
147     return CAIRO_TEST_SUCCESS;
148 }
149
150 static cairo_test_status_t
151 test_cairo_push_group (cairo_t *cr)
152 {
153     cairo_pattern_t *pattern;
154     cairo_status_t status;
155
156     cairo_push_group (cr);
157     pattern = cairo_pop_group (cr);
158     status = cairo_pattern_status (pattern);
159     cairo_pattern_destroy (pattern);
160
161     return status == CAIRO_STATUS_SUCCESS || status == cairo_status (cr) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
162 }
163
164 static cairo_test_status_t
165 test_cairo_push_group_with_content (cairo_t *cr)
166 {
167     cairo_push_group_with_content (cr, CAIRO_CONTENT_COLOR_ALPHA);
168     cairo_pop_group_to_source (cr);
169
170     return CAIRO_TEST_SUCCESS;
171 }
172
173 static cairo_test_status_t
174 test_cairo_set_operator (cairo_t *cr)
175 {
176     cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
177
178     return CAIRO_TEST_SUCCESS;
179 }
180
181 static cairo_test_status_t
182 test_cairo_set_source (cairo_t *cr)
183 {
184     cairo_pattern_t *source = cairo_pattern_create_rgb (0, 0, 0);
185     cairo_set_source (cr, source);
186     cairo_pattern_destroy (source);
187
188     return CAIRO_TEST_SUCCESS;
189 }
190
191 static cairo_test_status_t
192 test_cairo_set_source_rgb (cairo_t *cr)
193 {
194     cairo_set_source_rgb (cr, 0, 0, 0);
195
196     return CAIRO_TEST_SUCCESS;
197 }
198
199 static cairo_test_status_t
200 test_cairo_set_source_rgba (cairo_t *cr)
201 {
202     cairo_set_source_rgba (cr, 0, 0, 0, 1);
203
204     return CAIRO_TEST_SUCCESS;
205 }
206
207 static cairo_test_status_t
208 test_cairo_set_source_surface (cairo_t *cr)
209 {
210     cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
211     cairo_set_source_surface (cr, surface, 0, 0);
212     cairo_surface_destroy (surface);
213
214     return CAIRO_TEST_SUCCESS;
215 }
216
217 static cairo_test_status_t
218 test_cairo_set_tolerance (cairo_t *cr)
219 {
220     cairo_set_tolerance (cr, 42);
221
222     return CAIRO_TEST_SUCCESS;
223 }
224
225 static cairo_test_status_t
226 test_cairo_set_antialias (cairo_t *cr)
227 {
228     cairo_set_antialias (cr, CAIRO_ANTIALIAS_BEST);
229
230     return CAIRO_TEST_SUCCESS;
231 }
232
233 static cairo_test_status_t
234 test_cairo_set_fill_rule (cairo_t *cr)
235 {
236     cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
237
238     return CAIRO_TEST_SUCCESS;
239 }
240
241 static cairo_test_status_t
242 test_cairo_set_line_width (cairo_t *cr)
243 {
244     cairo_set_line_width (cr, 42);
245
246     return CAIRO_TEST_SUCCESS;
247 }
248
249 static cairo_test_status_t
250 test_cairo_set_line_cap (cairo_t *cr)
251 {
252     cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
253
254     return CAIRO_TEST_SUCCESS;
255 }
256
257 static cairo_test_status_t
258 test_cairo_set_line_join (cairo_t *cr)
259 {
260     cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL);
261
262     return CAIRO_TEST_SUCCESS;
263 }
264
265 static cairo_test_status_t
266 test_cairo_set_dash (cairo_t *cr)
267 {
268     cairo_set_dash (cr, NULL, 0, 0);
269
270     return CAIRO_TEST_SUCCESS;
271 }
272
273 static cairo_test_status_t
274 test_cairo_set_miter_limit (cairo_t *cr)
275 {
276     cairo_set_miter_limit (cr, 2);
277
278     return CAIRO_TEST_SUCCESS;
279 }
280
281 static cairo_test_status_t
282 test_cairo_translate (cairo_t *cr)
283 {
284     cairo_translate (cr, 2, 2);
285
286     return CAIRO_TEST_SUCCESS;
287 }
288
289 static cairo_test_status_t
290 test_cairo_scale (cairo_t *cr)
291 {
292     cairo_scale (cr, 2, 2);
293
294     return CAIRO_TEST_SUCCESS;
295 }
296
297 static cairo_test_status_t
298 test_cairo_rotate (cairo_t *cr)
299 {
300     cairo_rotate (cr, 2);
301
302     return CAIRO_TEST_SUCCESS;
303 }
304
305 static cairo_test_status_t
306 test_cairo_transform (cairo_t *cr)
307 {
308     cairo_matrix_t matrix;
309
310     cairo_matrix_init_translate (&matrix, 1, 1);
311     cairo_transform (cr, &matrix);
312
313     return CAIRO_TEST_SUCCESS;
314 }
315
316 static cairo_test_status_t
317 test_cairo_set_matrix (cairo_t *cr)
318 {
319     cairo_matrix_t matrix;
320
321     cairo_matrix_init_translate (&matrix, 1, 1);
322     cairo_set_matrix (cr, &matrix);
323
324     return CAIRO_TEST_SUCCESS;
325 }
326
327 static cairo_test_status_t
328 test_cairo_identity_matrix (cairo_t *cr)
329 {
330     cairo_identity_matrix (cr);
331
332     return CAIRO_TEST_SUCCESS;
333 }
334
335 static cairo_test_status_t
336 test_cairo_user_to_device (cairo_t *cr)
337 {
338     double x = 42, y = 42;
339
340     cairo_user_to_device (cr, &x, &y);
341
342     return CAIRO_TEST_SUCCESS;
343 }
344
345 static cairo_test_status_t
346 test_cairo_user_to_device_distance (cairo_t *cr)
347 {
348     double x = 42, y = 42;
349
350     cairo_user_to_device_distance (cr, &x, &y);
351
352     return CAIRO_TEST_SUCCESS;
353 }
354
355 static cairo_test_status_t
356 test_cairo_device_to_user (cairo_t *cr)
357 {
358     double x = 42, y = 42;
359
360     cairo_device_to_user (cr, &x, &y);
361
362     return CAIRO_TEST_SUCCESS;
363 }
364
365 static cairo_test_status_t
366 test_cairo_device_to_user_distance (cairo_t *cr)
367 {
368     double x = 42, y = 42;
369
370     cairo_device_to_user_distance (cr, &x, &y);
371
372     return CAIRO_TEST_SUCCESS;
373 }
374
375 static cairo_test_status_t
376 test_cairo_new_path (cairo_t *cr)
377 {
378     cairo_new_path (cr);
379
380     return CAIRO_TEST_SUCCESS;
381 }
382
383 static cairo_test_status_t
384 test_cairo_move_to (cairo_t *cr)
385 {
386     cairo_move_to (cr, 2, 2);
387
388     return CAIRO_TEST_SUCCESS;
389 }
390
391 static cairo_test_status_t
392 test_cairo_new_sub_path (cairo_t *cr)
393 {
394     cairo_new_sub_path (cr);
395
396     return CAIRO_TEST_SUCCESS;
397 }
398
399 static cairo_test_status_t
400 test_cairo_line_to (cairo_t *cr)
401 {
402     cairo_line_to (cr, 2, 2);
403
404     return CAIRO_TEST_SUCCESS;
405 }
406
407 static cairo_test_status_t
408 test_cairo_curve_to (cairo_t *cr)
409 {
410     cairo_curve_to (cr, 2, 2, 3, 3, 4, 4);
411
412     return CAIRO_TEST_SUCCESS;
413 }
414
415 static cairo_test_status_t
416 test_cairo_arc (cairo_t *cr)
417 {
418     cairo_arc (cr, 2, 2, 3, 0, 2 * M_PI);
419
420     return CAIRO_TEST_SUCCESS;
421 }
422
423 static cairo_test_status_t
424 test_cairo_arc_negative (cairo_t *cr)
425 {
426     cairo_arc_negative (cr, 2, 2, 3, 0, 2 * M_PI);
427
428     return CAIRO_TEST_SUCCESS;
429 }
430
431 static cairo_test_status_t
432 test_cairo_rel_move_to (cairo_t *cr)
433 {
434     cairo_rel_move_to (cr, 2, 2);
435
436     return CAIRO_TEST_SUCCESS;
437 }
438
439 static cairo_test_status_t
440 test_cairo_rel_line_to (cairo_t *cr)
441 {
442     cairo_rel_line_to (cr, 2, 2);
443
444     return CAIRO_TEST_SUCCESS;
445 }
446
447 static cairo_test_status_t
448 test_cairo_rel_curve_to (cairo_t *cr)
449 {
450     cairo_rel_curve_to (cr, 2, 2, 3, 3, 4, 4);
451
452     return CAIRO_TEST_SUCCESS;
453 }
454
455 static cairo_test_status_t
456 test_cairo_rectangle (cairo_t *cr)
457 {
458     cairo_rectangle (cr, 2, 2, 3, 3);
459
460     return CAIRO_TEST_SUCCESS;
461 }
462
463 static cairo_test_status_t
464 test_cairo_close_path (cairo_t *cr)
465 {
466     cairo_close_path (cr);
467
468     return CAIRO_TEST_SUCCESS;
469 }
470
471 static cairo_test_status_t
472 test_cairo_path_extents (cairo_t *cr)
473 {
474     double x1, y1, x2, y2;
475     cairo_path_extents (cr, &x1, &y1, &x2, &y2);
476
477     return CAIRO_TEST_SUCCESS;
478 }
479
480 static cairo_test_status_t
481 test_cairo_paint (cairo_t *cr)
482 {
483     cairo_paint (cr);
484
485     return CAIRO_TEST_SUCCESS;
486 }
487
488 static cairo_test_status_t
489 test_cairo_paint_with_alpha (cairo_t *cr)
490 {
491     cairo_paint_with_alpha (cr, 0.5);
492
493     return CAIRO_TEST_SUCCESS;
494 }
495
496 static cairo_test_status_t
497 test_cairo_mask (cairo_t *cr)
498 {
499     cairo_pattern_t *pattern;
500
501     pattern = cairo_pattern_create_rgb (0.5, 0.5, 0.5);
502     cairo_mask (cr, pattern);
503
504     cairo_pattern_destroy (pattern);
505     return CAIRO_TEST_SUCCESS;
506 }
507
508 static cairo_test_status_t
509 test_cairo_mask_surface (cairo_t *cr)
510 {
511     cairo_surface_t *surface;
512
513     surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
514     cairo_mask_surface (cr, surface, 0, 0);
515
516     cairo_surface_destroy (surface);
517     return CAIRO_TEST_SUCCESS;
518 }
519
520 static cairo_test_status_t
521 test_cairo_stroke (cairo_t *cr)
522 {
523     cairo_stroke (cr);
524
525     return CAIRO_TEST_SUCCESS;
526 }
527
528 static cairo_test_status_t
529 test_cairo_stroke_preserve (cairo_t *cr)
530 {
531     cairo_stroke_preserve (cr);
532
533     return CAIRO_TEST_SUCCESS;
534 }
535
536 static cairo_test_status_t
537 test_cairo_fill (cairo_t *cr)
538 {
539     cairo_fill (cr);
540
541     return CAIRO_TEST_SUCCESS;
542 }
543
544 static cairo_test_status_t
545 test_cairo_fill_preserve (cairo_t *cr)
546 {
547     cairo_fill_preserve (cr);
548
549     return CAIRO_TEST_SUCCESS;
550 }
551
552 static cairo_test_status_t
553 test_cairo_copy_page (cairo_t *cr)
554 {
555     cairo_copy_page (cr);
556
557     return CAIRO_TEST_SUCCESS;
558 }
559
560 static cairo_test_status_t
561 test_cairo_show_page (cairo_t *cr)
562 {
563     cairo_show_page (cr);
564
565     return CAIRO_TEST_SUCCESS;
566 }
567
568 static cairo_test_status_t
569 test_cairo_in_stroke (cairo_t *cr)
570 {
571     cairo_in_stroke (cr, 1, 1);
572
573     return CAIRO_TEST_SUCCESS;
574 }
575
576 static cairo_test_status_t
577 test_cairo_in_fill (cairo_t *cr)
578 {
579     cairo_in_fill (cr, 1, 1);
580
581     return CAIRO_TEST_SUCCESS;
582 }
583
584 static cairo_test_status_t
585 test_cairo_in_clip (cairo_t *cr)
586 {
587     cairo_in_clip (cr, 1, 1);
588
589     return CAIRO_TEST_SUCCESS;
590 }
591
592 static cairo_test_status_t
593 test_cairo_stroke_extents (cairo_t *cr)
594 {
595     double x1, y1, x2, y2;
596     cairo_stroke_extents (cr, &x1, &y1, &x2, &y2);
597
598     return CAIRO_TEST_SUCCESS;
599 }
600
601 static cairo_test_status_t
602 test_cairo_fill_extents (cairo_t *cr)
603 {
604     double x1, y1, x2, y2;
605     cairo_fill_extents (cr, &x1, &y1, &x2, &y2);
606
607     return CAIRO_TEST_SUCCESS;
608 }
609
610 static cairo_test_status_t
611 test_cairo_reset_clip (cairo_t *cr)
612 {
613     cairo_reset_clip (cr);
614
615     return CAIRO_TEST_SUCCESS;
616 }
617
618 static cairo_test_status_t
619 test_cairo_clip (cairo_t *cr)
620 {
621     cairo_clip (cr);
622
623     return CAIRO_TEST_SUCCESS;
624 }
625
626 static cairo_test_status_t
627 test_cairo_clip_preserve (cairo_t *cr)
628 {
629     cairo_clip_preserve (cr);
630
631     return CAIRO_TEST_SUCCESS;
632 }
633
634 static cairo_test_status_t
635 test_cairo_clip_extents (cairo_t *cr)
636 {
637     double x1, y1, x2, y2;
638     cairo_clip_extents (cr, &x1, &y1, &x2, &y2);
639
640     return CAIRO_TEST_SUCCESS;
641 }
642
643 static cairo_test_status_t
644 test_cairo_copy_clip_rectangle_list (cairo_t *cr)
645 {
646     cairo_rectangle_list_destroy (cairo_copy_clip_rectangle_list (cr));
647
648     return CAIRO_TEST_SUCCESS;
649 }
650
651 static cairo_test_status_t
652 test_cairo_select_font_face (cairo_t *cr)
653 {
654     cairo_select_font_face (cr, "Arial", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
655
656     return CAIRO_TEST_SUCCESS;
657 }
658
659 static cairo_test_status_t
660 test_cairo_set_font_size (cairo_t *cr)
661 {
662     cairo_set_font_size (cr, 42);
663
664     return CAIRO_TEST_SUCCESS;
665 }
666
667 static cairo_test_status_t
668 test_cairo_set_font_matrix (cairo_t *cr)
669 {
670     cairo_matrix_t matrix;
671
672     cairo_matrix_init_translate (&matrix, 1, 1);
673     cairo_set_font_matrix (cr, &matrix);
674
675     return CAIRO_TEST_SUCCESS;
676 }
677
678 static cairo_test_status_t
679 test_cairo_get_font_matrix (cairo_t *cr)
680 {
681     cairo_matrix_t matrix;
682
683     cairo_get_font_matrix (cr, &matrix);
684
685     return CAIRO_TEST_SUCCESS;
686 }
687
688 static cairo_test_status_t
689 test_cairo_set_font_options (cairo_t *cr)
690 {
691     cairo_font_options_t *opt = cairo_font_options_create ();
692     cairo_set_font_options (cr, opt);
693     cairo_font_options_destroy (opt);
694
695     return CAIRO_TEST_SUCCESS;
696 }
697
698 static cairo_test_status_t
699 test_cairo_get_font_options (cairo_t *cr)
700 {
701     cairo_font_options_t *opt = cairo_font_options_create ();
702     cairo_get_font_options (cr, opt);
703     cairo_font_options_destroy (opt);
704
705     return CAIRO_TEST_SUCCESS;
706 }
707
708 static cairo_test_status_t
709 test_cairo_set_font_face (cairo_t *cr)
710 {
711     cairo_set_font_face (cr, cairo_get_font_face (cr));
712
713     return CAIRO_TEST_SUCCESS;
714 }
715
716 static cairo_test_status_t
717 test_cairo_set_scaled_font (cairo_t *cr)
718 {
719     cairo_set_scaled_font (cr, cairo_get_scaled_font (cr));
720
721     return CAIRO_TEST_SUCCESS;
722 }
723
724 static cairo_test_status_t
725 test_cairo_show_text (cairo_t *cr)
726 {
727     cairo_show_text (cr, "Cairo");
728
729     return CAIRO_TEST_SUCCESS;
730 }
731
732 static cairo_test_status_t
733 test_cairo_show_glyphs (cairo_t *cr)
734 {
735     cairo_glyph_t glyph;
736
737     glyph.index = 65;
738     glyph.x = 0;
739     glyph.y = 0;
740
741     cairo_show_glyphs (cr, &glyph, 1);
742
743     return CAIRO_TEST_SUCCESS;
744 }
745
746 static cairo_test_status_t
747 test_cairo_show_text_glyphs (cairo_t *cr)
748 {
749     cairo_glyph_t glyph;
750     cairo_text_cluster_t cluster;
751
752     glyph.index = 65;
753     glyph.x = 0;
754     glyph.y = 0;
755
756     cluster.num_bytes = 1;
757     cluster.num_glyphs = 1;
758
759     cairo_show_text_glyphs (cr, "a", -1, &glyph, 1, &cluster, 1, 0);
760
761     return CAIRO_TEST_SUCCESS;
762 }
763
764 static cairo_test_status_t
765 test_cairo_text_path (cairo_t *cr)
766 {
767     cairo_text_path (cr, "Cairo");
768
769     return CAIRO_TEST_SUCCESS;
770 }
771
772 static cairo_test_status_t
773 test_cairo_glyph_path (cairo_t *cr)
774 {
775     cairo_glyph_t glyph;
776
777     glyph.index = 65;
778     glyph.x = 0;
779     glyph.y = 0;
780
781     cairo_glyph_path (cr, &glyph, 1);
782
783     return CAIRO_TEST_SUCCESS;
784 }
785
786 static cairo_test_status_t
787 test_cairo_text_extents (cairo_t *cr)
788 {
789     cairo_text_extents_t extents;
790
791     cairo_text_extents (cr, "Cairo", &extents);
792
793     return CAIRO_TEST_SUCCESS;
794 }
795
796 static cairo_test_status_t
797 test_cairo_glyph_extents (cairo_t *cr)
798 {
799     cairo_glyph_t glyph;
800     cairo_text_extents_t extents;
801
802     glyph.index = 65;
803     glyph.x = 0;
804     glyph.y = 0;
805
806     cairo_glyph_extents (cr, &glyph, 1, &extents);
807
808     return CAIRO_TEST_SUCCESS;
809 }
810
811 static cairo_test_status_t
812 test_cairo_font_extents (cairo_t *cr)
813 {
814     cairo_font_extents_t extents;
815
816     cairo_font_extents (cr, &extents);
817
818     return CAIRO_TEST_SUCCESS;
819 }
820
821 static cairo_test_status_t
822 test_cairo_get_operator (cairo_t *cr)
823 {
824     cairo_get_operator (cr);
825
826     return CAIRO_TEST_SUCCESS;
827 }
828
829 static cairo_test_status_t
830 test_cairo_get_source (cairo_t *cr)
831 {
832     cairo_get_source (cr);
833
834     return CAIRO_TEST_SUCCESS;
835 }
836
837 static cairo_test_status_t
838 test_cairo_get_tolerance (cairo_t *cr)
839 {
840     cairo_get_tolerance (cr);
841
842     return CAIRO_TEST_SUCCESS;
843 }
844
845 static cairo_test_status_t
846 test_cairo_get_antialias (cairo_t *cr)
847 {
848     cairo_get_antialias (cr);
849
850     return CAIRO_TEST_SUCCESS;
851 }
852
853 static cairo_test_status_t
854 test_cairo_has_current_point (cairo_t *cr)
855 {
856     cairo_has_current_point (cr);
857
858     return CAIRO_TEST_SUCCESS;
859 }
860
861 static cairo_test_status_t
862 test_cairo_get_current_point (cairo_t *cr)
863 {
864     double x, y;
865
866     cairo_get_current_point (cr, &x, &y);
867
868     return CAIRO_TEST_SUCCESS;
869 }
870
871 static cairo_test_status_t
872 test_cairo_get_fill_rule (cairo_t *cr)
873 {
874     cairo_get_fill_rule (cr);
875
876     return CAIRO_TEST_SUCCESS;
877 }
878
879 static cairo_test_status_t
880 test_cairo_get_line_width (cairo_t *cr)
881 {
882     cairo_get_line_width (cr);
883
884     return CAIRO_TEST_SUCCESS;
885 }
886
887 static cairo_test_status_t
888 test_cairo_get_line_cap (cairo_t *cr)
889 {
890     cairo_get_line_cap (cr);
891
892     return CAIRO_TEST_SUCCESS;
893 }
894
895 static cairo_test_status_t
896 test_cairo_get_line_join (cairo_t *cr)
897 {
898     cairo_get_line_join (cr);
899
900     return CAIRO_TEST_SUCCESS;
901 }
902
903 static cairo_test_status_t
904 test_cairo_get_miter_limit (cairo_t *cr)
905 {
906     cairo_get_miter_limit (cr);
907
908     return CAIRO_TEST_SUCCESS;
909 }
910
911 static cairo_test_status_t
912 test_cairo_get_dash_count (cairo_t *cr)
913 {
914     cairo_get_dash_count (cr);
915
916     return CAIRO_TEST_SUCCESS;
917 }
918
919 static cairo_test_status_t
920 test_cairo_get_dash (cairo_t *cr)
921 {
922     double dashes[42];
923     double offset;
924
925     cairo_get_dash (cr, &dashes[0], &offset);
926
927     return CAIRO_TEST_SUCCESS;
928 }
929
930 static cairo_test_status_t
931 test_cairo_get_matrix (cairo_t *cr)
932 {
933     cairo_matrix_t matrix;
934
935     cairo_get_matrix (cr, &matrix);
936
937     return CAIRO_TEST_SUCCESS;
938 }
939
940 static cairo_test_status_t
941 test_cairo_get_target (cairo_t *cr)
942 {
943     cairo_get_target (cr);
944
945     return CAIRO_TEST_SUCCESS;
946 }
947
948 static cairo_test_status_t
949 test_cairo_get_group_target (cairo_t *cr)
950 {
951     cairo_get_group_target (cr);
952
953     return CAIRO_TEST_SUCCESS;
954 }
955
956 static cairo_test_status_t
957 test_cairo_copy_path (cairo_t *cr)
958 {
959     cairo_path_destroy (cairo_copy_path (cr));
960
961     return CAIRO_TEST_SUCCESS;
962 }
963
964 static cairo_test_status_t
965 test_cairo_copy_path_flat (cairo_t *cr)
966 {
967     cairo_path_destroy (cairo_copy_path_flat (cr));
968
969     return CAIRO_TEST_SUCCESS;
970 }
971
972 static cairo_test_status_t
973 test_cairo_append_path (cairo_t *cr)
974 {
975     cairo_path_data_t data[3];
976     cairo_path_t path;
977
978     path.status = CAIRO_STATUS_SUCCESS;
979     path.data = &data[0];
980     path.num_data = ARRAY_LENGTH(data);
981
982     data[0].header.type = CAIRO_PATH_MOVE_TO;
983     data[0].header.length = 2;
984     data[1].point.x = 1;
985     data[1].point.y = 2;
986     data[2].header.type = CAIRO_PATH_CLOSE_PATH;
987     data[2].header.length = 1;
988
989     cairo_append_path (cr, &path);
990
991     return CAIRO_TEST_SUCCESS;
992 }
993
994 static cairo_test_status_t
995 test_cairo_surface_create_similar (cairo_surface_t *surface)
996 {
997     cairo_surface_t *similar;
998     
999     similar = cairo_surface_create_similar (surface, CAIRO_CONTENT_ALPHA, 100, 100);
1000     
1001     cairo_surface_destroy (similar);
1002     return CAIRO_TEST_SUCCESS;
1003 }
1004
1005 static cairo_test_status_t
1006 test_cairo_surface_create_for_rectangle (cairo_surface_t *surface)
1007 {
1008     cairo_surface_t *similar;
1009     
1010     similar = cairo_surface_create_for_rectangle (surface, 1, 1, 8, 8);
1011     
1012     cairo_surface_destroy (similar);
1013     return CAIRO_TEST_SUCCESS;
1014 }
1015
1016 static cairo_test_status_t
1017 test_cairo_surface_reference (cairo_surface_t *surface)
1018 {
1019     cairo_surface_destroy (cairo_surface_reference (surface));
1020     return CAIRO_TEST_SUCCESS;
1021 }
1022
1023 static cairo_test_status_t
1024 test_cairo_surface_finish (cairo_surface_t *surface)
1025 {
1026     cairo_surface_finish (surface);
1027     return CAIRO_TEST_SUCCESS;
1028 }
1029
1030 static cairo_test_status_t
1031 test_cairo_surface_get_device (cairo_surface_t *surface)
1032 {
1033     /* cairo_device_t *device = */cairo_surface_get_device (surface);
1034     return CAIRO_TEST_SUCCESS;
1035 }
1036
1037 static cairo_test_status_t
1038 test_cairo_surface_get_reference_count (cairo_surface_t *surface)
1039 {
1040     unsigned int refcount = cairo_surface_get_reference_count (surface);
1041     if (refcount > 0)
1042         return CAIRO_TEST_SUCCESS;
1043     /* inert error surfaces have a refcount of 0 */
1044     return cairo_surface_status (surface) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1045 }
1046
1047 static cairo_test_status_t
1048 test_cairo_surface_status (cairo_surface_t *surface)
1049 {
1050     cairo_status_t status = cairo_surface_status (surface);
1051     return status < CAIRO_STATUS_LAST_STATUS ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1052 }
1053
1054 static cairo_test_status_t
1055 test_cairo_surface_get_type (cairo_surface_t *surface)
1056 {
1057     /* cairo_surface_type_t type = */cairo_surface_get_type (surface);
1058     return CAIRO_TEST_SUCCESS;
1059 }
1060
1061 static cairo_test_status_t
1062 test_cairo_surface_get_content (cairo_surface_t *surface)
1063 {
1064     cairo_content_t content = cairo_surface_get_content (surface);
1065
1066     switch (content) {
1067     case CAIRO_CONTENT_COLOR:
1068     case CAIRO_CONTENT_ALPHA:
1069     case CAIRO_CONTENT_COLOR_ALPHA:
1070         return CAIRO_TEST_SUCCESS;
1071     default:
1072         return CAIRO_TEST_ERROR;
1073     }
1074 }
1075
1076 static cairo_test_status_t
1077 test_cairo_surface_set_user_data (cairo_surface_t *surface)
1078 {
1079     static cairo_user_data_key_t key;
1080     cairo_status_t status;
1081
1082     status = cairo_surface_set_user_data (surface, &key, &key, NULL);
1083     if (status == CAIRO_STATUS_NO_MEMORY)
1084         return CAIRO_TEST_NO_MEMORY;
1085     else if (status)
1086         return CAIRO_TEST_SUCCESS;
1087
1088     if (cairo_surface_get_user_data (surface, &key) != &key)
1089         return CAIRO_TEST_ERROR;
1090
1091     return CAIRO_TEST_SUCCESS;
1092 }
1093
1094 static cairo_test_status_t
1095 test_cairo_surface_set_mime_data (cairo_surface_t *surface)
1096 {
1097     const char *mimetype = "text/x-uri";
1098     const char *data = "http://www.cairographics.org";
1099     cairo_status_t status;
1100
1101     status = cairo_surface_set_mime_data (surface,
1102                                           mimetype,
1103                                           (const unsigned char *) data,
1104                                           strlen (data),
1105                                           NULL, NULL);
1106     return status ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1107 }
1108
1109 static cairo_test_status_t
1110 test_cairo_surface_get_mime_data (cairo_surface_t *surface)
1111 {
1112     const char *mimetype = "text/x-uri";
1113     const unsigned char *data;
1114     unsigned long length;
1115
1116     cairo_surface_get_mime_data (surface, mimetype, &data, &length);
1117     return data == NULL && length == 0 ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1118 }
1119
1120 static cairo_test_status_t
1121 test_cairo_surface_get_font_options (cairo_surface_t *surface)
1122 {
1123     cairo_font_options_t *options;
1124     cairo_status_t status;
1125
1126     options = cairo_font_options_create ();
1127     if (likely (!cairo_font_options_status (options)))
1128         cairo_surface_get_font_options (surface, options);
1129     status = cairo_font_options_status (options);
1130     cairo_font_options_destroy (options);
1131     return status ? CAIRO_TEST_ERROR : CAIRO_TEST_SUCCESS;
1132 }
1133
1134 static cairo_test_status_t
1135 test_cairo_surface_flush (cairo_surface_t *surface)
1136 {
1137     cairo_surface_flush (surface);
1138     return CAIRO_TEST_SUCCESS;
1139 }
1140
1141 static cairo_test_status_t
1142 test_cairo_surface_mark_dirty (cairo_surface_t *surface)
1143 {
1144     cairo_surface_mark_dirty (surface);
1145     return CAIRO_TEST_SUCCESS;
1146 }
1147
1148 static cairo_test_status_t
1149 test_cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface)
1150 {
1151     cairo_surface_mark_dirty_rectangle (surface, 1, 1, 8, 8);
1152     return CAIRO_TEST_SUCCESS;
1153 }
1154
1155 static cairo_test_status_t
1156 test_cairo_surface_set_device_offset (cairo_surface_t *surface)
1157 {
1158     cairo_surface_set_device_offset (surface, 5, 5);
1159     return CAIRO_TEST_SUCCESS;
1160 }
1161
1162 static cairo_test_status_t
1163 test_cairo_surface_get_device_offset (cairo_surface_t *surface)
1164 {
1165     double x, y;
1166
1167     cairo_surface_get_device_offset (surface, &x, &y);
1168     return CAIRO_TEST_SUCCESS;
1169 }
1170
1171 static cairo_test_status_t
1172 test_cairo_surface_set_fallback_resolution (cairo_surface_t *surface)
1173 {
1174     cairo_surface_set_fallback_resolution (surface, 42, 42);
1175     return CAIRO_TEST_SUCCESS;
1176 }
1177
1178 static cairo_test_status_t
1179 test_cairo_surface_get_fallback_resolution (cairo_surface_t *surface)
1180 {
1181     double x, y;
1182
1183     cairo_surface_get_fallback_resolution (surface, &x, &y);
1184     return CAIRO_TEST_SUCCESS;
1185 }
1186
1187 static cairo_test_status_t
1188 test_cairo_surface_copy_page (cairo_surface_t *surface)
1189 {
1190     cairo_surface_copy_page (surface);
1191     return CAIRO_TEST_SUCCESS;
1192 }
1193
1194 static cairo_test_status_t
1195 test_cairo_surface_show_page (cairo_surface_t *surface)
1196 {
1197     cairo_surface_show_page (surface);
1198     return CAIRO_TEST_SUCCESS;
1199 }
1200
1201 static cairo_test_status_t
1202 test_cairo_surface_has_show_text_glyphs (cairo_surface_t *surface)
1203 {
1204     cairo_surface_has_show_text_glyphs (surface);
1205     return CAIRO_TEST_SUCCESS;
1206 }
1207
1208 static cairo_test_status_t
1209 test_cairo_image_surface_get_data (cairo_surface_t *surface)
1210 {
1211     unsigned char *data = cairo_image_surface_get_data (surface);
1212     return data == NULL || surface_has_type (surface, CAIRO_SURFACE_TYPE_IMAGE) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1213 }
1214
1215 static cairo_test_status_t
1216 test_cairo_image_surface_get_format (cairo_surface_t *surface)
1217 {
1218     cairo_format_t format = cairo_image_surface_get_format (surface);
1219     return format == CAIRO_FORMAT_INVALID || surface_has_type (surface, CAIRO_SURFACE_TYPE_IMAGE) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1220 }
1221
1222 static cairo_test_status_t
1223 test_cairo_image_surface_get_width (cairo_surface_t *surface)
1224 {
1225     unsigned int width = cairo_image_surface_get_width (surface);
1226     return width == 0 || surface_has_type (surface, CAIRO_SURFACE_TYPE_IMAGE) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1227 }
1228
1229 static cairo_test_status_t
1230 test_cairo_image_surface_get_height (cairo_surface_t *surface)
1231 {
1232     unsigned int height = cairo_image_surface_get_height (surface);
1233     return height == 0 || surface_has_type (surface, CAIRO_SURFACE_TYPE_IMAGE) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1234 }
1235
1236 static cairo_test_status_t
1237 test_cairo_image_surface_get_stride (cairo_surface_t *surface)
1238 {
1239     unsigned int stride = cairo_image_surface_get_stride (surface);
1240     return stride == 0 || surface_has_type (surface, CAIRO_SURFACE_TYPE_IMAGE) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1241 }
1242
1243 #if CAIRO_HAS_PNG_FUNCTIONS
1244
1245 static cairo_test_status_t
1246 test_cairo_surface_write_to_png (cairo_surface_t *surface)
1247 {
1248     cairo_status_t status;
1249
1250     status = cairo_surface_write_to_png (surface, "/this/file/will/definitely/not/exist.png");
1251     
1252     return status ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1253 }
1254
1255 static cairo_status_t
1256 write_func_that_always_fails (void *closure, const unsigned char *data, unsigned int length)
1257 {
1258     return CAIRO_STATUS_WRITE_ERROR;
1259 }
1260
1261 static cairo_test_status_t
1262 test_cairo_surface_write_to_png_stream (cairo_surface_t *surface)
1263 {
1264     cairo_status_t status;
1265
1266     status = cairo_surface_write_to_png_stream (surface,
1267                                                 write_func_that_always_fails,
1268                                                 NULL);
1269     
1270     return status && status != CAIRO_STATUS_WRITE_ERROR ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1271 }
1272
1273 #endif /* CAIRO_HAS_PNG_FUNCTIONS */
1274
1275 static cairo_test_status_t
1276 test_cairo_recording_surface_ink_extents (cairo_surface_t *surface)
1277 {
1278     double x, y, w, h;
1279
1280     cairo_recording_surface_ink_extents (surface, &x, &y, &w, &h);
1281     return x == 0 && y == 0 && w == 0 && h == 0 ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1282 }
1283
1284 #if CAIRO_HAS_TEE_SURFACE
1285
1286 static cairo_test_status_t
1287 test_cairo_tee_surface_add (cairo_surface_t *surface)
1288 {
1289     cairo_surface_t *image = cairo_image_surface_create (CAIRO_FORMAT_A8, 10, 10);
1290
1291     cairo_tee_surface_add (surface, image);
1292     cairo_surface_destroy (image);
1293     return CAIRO_TEST_SUCCESS;
1294 }
1295
1296 static cairo_test_status_t
1297 test_cairo_tee_surface_remove (cairo_surface_t *surface)
1298 {
1299     cairo_surface_t *image = cairo_image_surface_create (CAIRO_FORMAT_A8, 10, 10);
1300
1301     cairo_tee_surface_remove (surface, image);
1302     cairo_surface_destroy (image);
1303     return CAIRO_TEST_SUCCESS;
1304 }
1305
1306 static cairo_test_status_t
1307 test_cairo_tee_surface_index (cairo_surface_t *surface)
1308 {
1309     cairo_surface_t *master;
1310     cairo_status_t status;
1311
1312     master = cairo_tee_surface_index (surface, 0);
1313     status = cairo_surface_status (master);
1314     cairo_surface_destroy (master);
1315     return status ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1316 }
1317
1318 #endif /* CAIRO_HAS_TEE_SURFACE */
1319
1320 #if CAIRO_HAS_GL_SURFACE
1321
1322 static cairo_test_status_t
1323 test_cairo_gl_surface_set_size (cairo_surface_t *surface)
1324 {
1325     cairo_gl_surface_set_size (surface, 5, 5);
1326     return CAIRO_TEST_SUCCESS;
1327 }
1328
1329 static cairo_test_status_t
1330 test_cairo_gl_surface_get_width (cairo_surface_t *surface)
1331 {
1332     unsigned int width = cairo_gl_surface_get_width (surface);
1333     return width == 0 || surface_has_type (surface, CAIRO_SURFACE_TYPE_GL) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1334 }
1335
1336 static cairo_test_status_t
1337 test_cairo_gl_surface_get_height (cairo_surface_t *surface)
1338 {
1339     unsigned int height = cairo_gl_surface_get_height (surface);
1340     return height == 0 || surface_has_type (surface, CAIRO_SURFACE_TYPE_GL) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1341 }
1342
1343 static cairo_test_status_t
1344 test_cairo_gl_surface_swapbuffers (cairo_surface_t *surface)
1345 {
1346     cairo_gl_surface_swapbuffers (surface);
1347     return CAIRO_TEST_SUCCESS;
1348 }
1349
1350 #endif /* CAIRO_HAS_GL_SURFACE */
1351
1352 #if CAIRO_HAS_PDF_SURFACE
1353
1354 static cairo_test_status_t
1355 test_cairo_pdf_surface_restrict_to_version (cairo_surface_t *surface)
1356 {
1357     cairo_pdf_surface_restrict_to_version (surface, CAIRO_PDF_VERSION_1_4);
1358     return CAIRO_TEST_SUCCESS;
1359 }
1360
1361 static cairo_test_status_t
1362 test_cairo_pdf_surface_set_size (cairo_surface_t *surface)
1363 {
1364     cairo_pdf_surface_set_size (surface, 5, 5);
1365     return CAIRO_TEST_SUCCESS;
1366 }
1367
1368 #endif /* CAIRO_HAS_PDF_SURFACE */
1369
1370 #if CAIRO_HAS_PS_SURFACE
1371
1372 static cairo_test_status_t
1373 test_cairo_ps_surface_restrict_to_level (cairo_surface_t *surface)
1374 {
1375     cairo_ps_surface_restrict_to_level (surface, CAIRO_PS_LEVEL_2);
1376     return CAIRO_TEST_SUCCESS;
1377 }
1378
1379 static cairo_test_status_t
1380 test_cairo_ps_surface_set_eps (cairo_surface_t *surface)
1381 {
1382     cairo_ps_surface_set_eps (surface, TRUE);
1383     return CAIRO_TEST_SUCCESS;
1384 }
1385
1386 static cairo_test_status_t
1387 test_cairo_ps_surface_get_eps (cairo_surface_t *surface)
1388 {
1389     cairo_bool_t eps = cairo_ps_surface_get_eps (surface);
1390     return eps ? CAIRO_TEST_ERROR : CAIRO_TEST_SUCCESS;
1391 }
1392
1393 static cairo_test_status_t
1394 test_cairo_ps_surface_set_size (cairo_surface_t *surface)
1395 {
1396     cairo_ps_surface_set_size (surface, 5, 5);
1397     return CAIRO_TEST_SUCCESS;
1398 }
1399
1400 static cairo_test_status_t
1401 test_cairo_ps_surface_dsc_comment (cairo_surface_t *surface)
1402 {
1403     cairo_ps_surface_dsc_comment (surface, "54, 74, 90, 2010");
1404     return CAIRO_TEST_SUCCESS;
1405 }
1406
1407 static cairo_test_status_t
1408 test_cairo_ps_surface_dsc_begin_setup (cairo_surface_t *surface)
1409 {
1410     cairo_ps_surface_dsc_begin_setup (surface);
1411     return CAIRO_TEST_SUCCESS;
1412 }
1413
1414 static cairo_test_status_t
1415 test_cairo_ps_surface_dsc_begin_page_setup (cairo_surface_t *surface)
1416 {
1417     cairo_ps_surface_dsc_begin_page_setup (surface);
1418     return CAIRO_TEST_SUCCESS;
1419 }
1420
1421 #endif /* CAIRO_HAS_PS_SURFACE */
1422
1423 #if CAIRO_HAS_QUARTZ_SURFACE
1424
1425 static cairo_test_status_t
1426 test_cairo_quartz_surface_get_cg_context (cairo_surface_t *surface)
1427 {
1428     CGContextRef context = cairo_quartz_surface_get_cg_context (surface);
1429     return context == NULL || surface_has_type (surface, CAIRO_SURFACE_TYPE_QUARTZ) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1430 }
1431
1432 #endif /* CAIRO_HAS_QUARTZ_SURFACE */
1433
1434 #if CAIRO_HAS_SVG_SURFACE
1435
1436 static cairo_test_status_t
1437 test_cairo_svg_surface_restrict_to_version (cairo_surface_t *surface)
1438 {
1439     cairo_svg_surface_restrict_to_version (surface, CAIRO_SVG_VERSION_1_1);
1440     return CAIRO_TEST_SUCCESS;
1441 }
1442
1443 #endif /* CAIRO_HAS_SVG_SURFACE */
1444
1445 #if CAIRO_HAS_XCB_SURFACE
1446
1447 static cairo_test_status_t
1448 test_cairo_xcb_surface_set_size (cairo_surface_t *surface)
1449 {
1450     cairo_xcb_surface_set_size (surface, 5, 5);
1451     return CAIRO_TEST_SUCCESS;
1452 }
1453
1454 static cairo_test_status_t
1455 test_cairo_xcb_surface_set_drawable (cairo_surface_t *surface)
1456 {
1457     cairo_xcb_surface_set_drawable (surface, 0, 5, 5);
1458     return CAIRO_TEST_SUCCESS;
1459 }
1460
1461 #endif
1462
1463 #if CAIRO_HAS_XLIB_SURFACE
1464
1465 static cairo_test_status_t
1466 test_cairo_xlib_surface_set_size (cairo_surface_t *surface)
1467 {
1468     cairo_xlib_surface_set_size (surface, 5, 5);
1469     return CAIRO_TEST_SUCCESS;
1470 }
1471
1472 static cairo_test_status_t
1473 test_cairo_xlib_surface_set_drawable (cairo_surface_t *surface)
1474 {
1475     cairo_xlib_surface_set_drawable (surface, 0, 5, 5);
1476     return CAIRO_TEST_SUCCESS;
1477 }
1478
1479 static cairo_test_status_t
1480 test_cairo_xlib_surface_get_display (cairo_surface_t *surface)
1481 {
1482     Display *display = cairo_xlib_surface_get_display (surface);
1483     return display == NULL || surface_has_type (surface, CAIRO_SURFACE_TYPE_XLIB) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1484 }
1485
1486 static cairo_test_status_t
1487 test_cairo_xlib_surface_get_screen (cairo_surface_t *surface)
1488 {
1489     Screen *screen = cairo_xlib_surface_get_screen (surface);
1490     return screen == NULL || surface_has_type (surface, CAIRO_SURFACE_TYPE_XLIB) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1491 }
1492
1493 static cairo_test_status_t
1494 test_cairo_xlib_surface_get_visual (cairo_surface_t *surface)
1495 {
1496     Visual *visual = cairo_xlib_surface_get_visual (surface);
1497     return visual == NULL || surface_has_type (surface, CAIRO_SURFACE_TYPE_XLIB) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1498 }
1499
1500 static cairo_test_status_t
1501 test_cairo_xlib_surface_get_drawable (cairo_surface_t *surface)
1502 {
1503     Drawable drawable = cairo_xlib_surface_get_drawable (surface);
1504     return drawable == 0 || surface_has_type (surface, CAIRO_SURFACE_TYPE_XLIB) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1505 }
1506
1507 static cairo_test_status_t
1508 test_cairo_xlib_surface_get_depth (cairo_surface_t *surface)
1509 {
1510     int depth = cairo_xlib_surface_get_depth (surface);
1511     return depth == 0 || surface_has_type (surface, CAIRO_SURFACE_TYPE_XLIB) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1512 }
1513
1514 static cairo_test_status_t
1515 test_cairo_xlib_surface_get_width (cairo_surface_t *surface)
1516 {
1517     int width = cairo_xlib_surface_get_width (surface);
1518     return width == 0 || surface_has_type (surface, CAIRO_SURFACE_TYPE_XLIB) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1519 }
1520
1521 static cairo_test_status_t
1522 test_cairo_xlib_surface_get_height (cairo_surface_t *surface)
1523 {
1524     int height = cairo_xlib_surface_get_height (surface);
1525     return height == 0 || surface_has_type (surface, CAIRO_SURFACE_TYPE_XLIB) ? CAIRO_TEST_SUCCESS : CAIRO_TEST_ERROR;
1526 }
1527
1528 #endif
1529
1530 #define TEST(name) { #name, test_ ## name }
1531
1532 struct {
1533     const char *name;
1534     context_test_func_t func;
1535 } context_tests[] = {
1536     TEST (cairo_reference),
1537     TEST (cairo_get_reference_count),
1538     TEST (cairo_set_user_data),
1539     TEST (cairo_save),
1540     TEST (cairo_push_group),
1541     TEST (cairo_push_group_with_content),
1542     TEST (cairo_set_operator),
1543     TEST (cairo_set_source),
1544     TEST (cairo_set_source_rgb),
1545     TEST (cairo_set_source_rgba),
1546     TEST (cairo_set_source_surface),
1547     TEST (cairo_set_tolerance),
1548     TEST (cairo_set_antialias),
1549     TEST (cairo_set_fill_rule),
1550     TEST (cairo_set_line_width),
1551     TEST (cairo_set_line_cap),
1552     TEST (cairo_set_line_join),
1553     TEST (cairo_set_dash),
1554     TEST (cairo_set_miter_limit),
1555     TEST (cairo_translate),
1556     TEST (cairo_scale),
1557     TEST (cairo_rotate),
1558     TEST (cairo_transform),
1559     TEST (cairo_set_matrix),
1560     TEST (cairo_identity_matrix),
1561     TEST (cairo_user_to_device),
1562     TEST (cairo_user_to_device_distance),
1563     TEST (cairo_device_to_user),
1564     TEST (cairo_device_to_user_distance),
1565     TEST (cairo_new_path),
1566     TEST (cairo_move_to),
1567     TEST (cairo_new_sub_path),
1568     TEST (cairo_line_to),
1569     TEST (cairo_curve_to),
1570     TEST (cairo_arc),
1571     TEST (cairo_arc_negative),
1572     TEST (cairo_rel_move_to),
1573     TEST (cairo_rel_line_to),
1574     TEST (cairo_rel_curve_to),
1575     TEST (cairo_rectangle),
1576     TEST (cairo_close_path),
1577     TEST (cairo_path_extents),
1578     TEST (cairo_paint),
1579     TEST (cairo_paint_with_alpha),
1580     TEST (cairo_mask),
1581     TEST (cairo_mask_surface),
1582     TEST (cairo_stroke),
1583     TEST (cairo_stroke_preserve),
1584     TEST (cairo_fill),
1585     TEST (cairo_fill_preserve),
1586     TEST (cairo_copy_page),
1587     TEST (cairo_show_page),
1588     TEST (cairo_in_stroke),
1589     TEST (cairo_in_fill),
1590     TEST (cairo_in_clip),
1591     TEST (cairo_stroke_extents),
1592     TEST (cairo_fill_extents),
1593     TEST (cairo_reset_clip),
1594     TEST (cairo_clip),
1595     TEST (cairo_clip_preserve),
1596     TEST (cairo_clip_extents),
1597     TEST (cairo_copy_clip_rectangle_list),
1598     TEST (cairo_select_font_face),
1599     TEST (cairo_set_font_size),
1600     TEST (cairo_set_font_matrix),
1601     TEST (cairo_get_font_matrix),
1602     TEST (cairo_set_font_options),
1603     TEST (cairo_get_font_options),
1604     TEST (cairo_set_font_face),
1605     TEST (cairo_set_scaled_font),
1606     TEST (cairo_show_text),
1607     TEST (cairo_show_glyphs),
1608     TEST (cairo_show_text_glyphs),
1609     TEST (cairo_text_path),
1610     TEST (cairo_glyph_path),
1611     TEST (cairo_text_extents),
1612     TEST (cairo_glyph_extents),
1613     TEST (cairo_font_extents),
1614     TEST (cairo_get_operator),
1615     TEST (cairo_get_source),
1616     TEST (cairo_get_tolerance),
1617     TEST (cairo_get_antialias),
1618     TEST (cairo_has_current_point),
1619     TEST (cairo_get_current_point),
1620     TEST (cairo_get_fill_rule),
1621     TEST (cairo_get_line_width),
1622     TEST (cairo_get_line_cap),
1623     TEST (cairo_get_line_join),
1624     TEST (cairo_get_miter_limit),
1625     TEST (cairo_get_dash_count),
1626     TEST (cairo_get_dash),
1627     TEST (cairo_get_matrix),
1628     TEST (cairo_get_target),
1629     TEST (cairo_get_group_target),
1630     TEST (cairo_copy_path),
1631     TEST (cairo_copy_path_flat),
1632     TEST (cairo_append_path),
1633 };
1634
1635 #undef TEST
1636
1637 #define TEST(name, surface_type, sets_status) { #name, test_ ## name, surface_type, sets_status }
1638
1639 struct {
1640     const char *name;
1641     surface_test_func_t func;
1642     int surface_type; /* cairo_surface_type_t or -1 */
1643     cairo_bool_t modifies_surface;
1644 } surface_tests[] = {
1645     TEST (cairo_surface_create_similar, -1, FALSE),
1646     TEST (cairo_surface_create_for_rectangle, -1, FALSE),
1647     TEST (cairo_surface_reference, -1, FALSE),
1648     TEST (cairo_surface_finish, -1, TRUE),
1649     TEST (cairo_surface_get_device, -1, FALSE),
1650     TEST (cairo_surface_get_reference_count, -1, FALSE),
1651     TEST (cairo_surface_status, -1, FALSE),
1652     TEST (cairo_surface_get_type, -1, FALSE),
1653     TEST (cairo_surface_get_content, -1, FALSE),
1654     TEST (cairo_surface_set_user_data, -1, FALSE),
1655     TEST (cairo_surface_set_mime_data, -1, TRUE),
1656     TEST (cairo_surface_get_mime_data, -1, FALSE),
1657     TEST (cairo_surface_get_font_options, -1, FALSE),
1658     TEST (cairo_surface_flush, -1, TRUE),
1659     TEST (cairo_surface_mark_dirty, -1, TRUE),
1660     TEST (cairo_surface_mark_dirty_rectangle, -1, TRUE),
1661     TEST (cairo_surface_set_device_offset, -1, TRUE),
1662     TEST (cairo_surface_get_device_offset, -1, FALSE),
1663     TEST (cairo_surface_set_fallback_resolution, -1, TRUE),
1664     TEST (cairo_surface_get_fallback_resolution, -1, FALSE),
1665     TEST (cairo_surface_copy_page, -1, TRUE),
1666     TEST (cairo_surface_show_page, -1, TRUE),
1667     TEST (cairo_surface_has_show_text_glyphs, -1, FALSE),
1668     TEST (cairo_image_surface_get_data, CAIRO_SURFACE_TYPE_IMAGE, FALSE),
1669     TEST (cairo_image_surface_get_format, CAIRO_SURFACE_TYPE_IMAGE, FALSE),
1670     TEST (cairo_image_surface_get_width, CAIRO_SURFACE_TYPE_IMAGE, FALSE),
1671     TEST (cairo_image_surface_get_height, CAIRO_SURFACE_TYPE_IMAGE, FALSE),
1672     TEST (cairo_image_surface_get_stride, CAIRO_SURFACE_TYPE_IMAGE, FALSE),
1673 #if CAIRO_HAS_PNG_FUNCTIONS
1674     TEST (cairo_surface_write_to_png, -1, FALSE),
1675     TEST (cairo_surface_write_to_png_stream, -1, FALSE),
1676 #endif
1677     TEST (cairo_recording_surface_ink_extents, CAIRO_SURFACE_TYPE_RECORDING, FALSE),
1678 #if CAIRO_HAS_TEE_SURFACE
1679     TEST (cairo_tee_surface_add, CAIRO_SURFACE_TYPE_TEE, TRUE),
1680     TEST (cairo_tee_surface_remove, CAIRO_SURFACE_TYPE_TEE, TRUE),
1681     TEST (cairo_tee_surface_index, CAIRO_SURFACE_TYPE_TEE, FALSE),
1682 #endif
1683 #if CAIRO_HAS_GL_SURFACE
1684     TEST (cairo_gl_surface_set_size, CAIRO_SURFACE_TYPE_GL, TRUE),
1685     TEST (cairo_gl_surface_get_width, CAIRO_SURFACE_TYPE_GL, FALSE),
1686     TEST (cairo_gl_surface_get_height, CAIRO_SURFACE_TYPE_GL, FALSE),
1687     TEST (cairo_gl_surface_swapbuffers, CAIRO_SURFACE_TYPE_GL, TRUE),
1688 #endif
1689 #if CAIRO_HAS_PDF_SURFACE
1690     TEST (cairo_pdf_surface_restrict_to_version, CAIRO_SURFACE_TYPE_PDF, TRUE),
1691     TEST (cairo_pdf_surface_set_size, CAIRO_SURFACE_TYPE_PDF, TRUE),
1692 #endif
1693 #if CAIRO_HAS_PS_SURFACE
1694     TEST (cairo_ps_surface_restrict_to_level, CAIRO_SURFACE_TYPE_PS, TRUE),
1695     TEST (cairo_ps_surface_set_eps, CAIRO_SURFACE_TYPE_PS, TRUE),
1696     TEST (cairo_ps_surface_get_eps, CAIRO_SURFACE_TYPE_PS, FALSE),
1697     TEST (cairo_ps_surface_set_size, CAIRO_SURFACE_TYPE_PS, TRUE),
1698     TEST (cairo_ps_surface_dsc_comment, CAIRO_SURFACE_TYPE_PS, TRUE),
1699     TEST (cairo_ps_surface_dsc_begin_setup, CAIRO_SURFACE_TYPE_PS, TRUE),
1700     TEST (cairo_ps_surface_dsc_begin_page_setup, CAIRO_SURFACE_TYPE_PS, TRUE),
1701 #endif
1702 #if CAIRO_HAS_QUARTZ_SURFACE
1703     TEST (cairo_quartz_surface_get_cg_context, CAIRO_SURFACE_TYPE_QUARTZ, FALSE),
1704 #endif
1705 #if CAIRO_HAS_SVG_SURFACE
1706     TEST (cairo_svg_surface_restrict_to_version, CAIRO_SURFACE_TYPE_SVG, TRUE),
1707 #endif
1708 #if CAIRO_HAS_XCB_SURFACE
1709     TEST (cairo_xcb_surface_set_size, CAIRO_SURFACE_TYPE_XCB, TRUE),
1710     TEST (cairo_xcb_surface_set_drawable, CAIRO_SURFACE_TYPE_XCB, TRUE),
1711 #endif
1712 #if CAIRO_HAS_XLIB_SURFACE
1713     TEST (cairo_xlib_surface_set_size, CAIRO_SURFACE_TYPE_XLIB, TRUE),
1714     TEST (cairo_xlib_surface_set_drawable, CAIRO_SURFACE_TYPE_XLIB, TRUE),
1715     TEST (cairo_xlib_surface_get_display, CAIRO_SURFACE_TYPE_XLIB, FALSE),
1716     TEST (cairo_xlib_surface_get_drawable, CAIRO_SURFACE_TYPE_XLIB, FALSE),
1717     TEST (cairo_xlib_surface_get_screen, CAIRO_SURFACE_TYPE_XLIB, FALSE),
1718     TEST (cairo_xlib_surface_get_visual, CAIRO_SURFACE_TYPE_XLIB, FALSE),
1719     TEST (cairo_xlib_surface_get_depth, CAIRO_SURFACE_TYPE_XLIB, FALSE),
1720     TEST (cairo_xlib_surface_get_width, CAIRO_SURFACE_TYPE_XLIB, FALSE),
1721     TEST (cairo_xlib_surface_get_height, CAIRO_SURFACE_TYPE_XLIB, FALSE),
1722 #endif
1723 };
1724
1725 static cairo_test_status_t
1726 preamble (cairo_test_context_t *ctx)
1727 {
1728     cairo_surface_t *surface;
1729     cairo_t *cr;
1730     cairo_test_status_t test_status;
1731     cairo_status_t status_before, status_after;
1732     unsigned int i;
1733
1734     /* Test an error surface */
1735     for (i = 0; i < ARRAY_LENGTH (surface_tests); i++) {
1736         surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, INT_MAX, INT_MAX);
1737         status_before = cairo_surface_status (surface);
1738         assert (status_before);
1739
1740         test_status = surface_tests[i].func (surface);
1741
1742         status_after = cairo_surface_status (surface);
1743         cairo_surface_destroy (surface);
1744
1745         if (test_status != CAIRO_TEST_SUCCESS) {
1746             cairo_test_log (ctx,
1747                             "Failed test %s with %d\n",
1748                             surface_tests[i].name, (int) test_status);
1749             return test_status;
1750         }
1751
1752         if (status_before != status_after) {
1753             cairo_test_log (ctx,
1754                             "Failed test %s: Modified surface status from %u (%s) to %u (%s)\n",
1755                             surface_tests[i].name,
1756                             status_before, cairo_status_to_string (status_before),
1757                             status_after, cairo_status_to_string (status_after));
1758             return CAIRO_TEST_ERROR;
1759         }
1760     }
1761
1762     /* Test an error context */
1763     for (i = 0; i < ARRAY_LENGTH (context_tests); i++) {
1764         cr = cairo_create (NULL);
1765         status_before = cairo_status (cr);
1766         assert (status_before);
1767
1768         test_status = context_tests[i].func (cr);
1769
1770         status_after = cairo_status (cr);
1771         cairo_destroy (cr);
1772
1773         if (test_status != CAIRO_TEST_SUCCESS) {
1774             cairo_test_log (ctx,
1775                             "Failed test %s with %d\n",
1776                             context_tests[i].name, (int) test_status);
1777             return test_status;
1778         }
1779
1780         if (status_before != status_after) {
1781             cairo_test_log (ctx,
1782                             "Failed test %s: Modified context status from %u (%s) to %u (%s)\n",
1783                             context_tests[i].name,
1784                             status_before, cairo_status_to_string (status_before),
1785                             status_after, cairo_status_to_string (status_after));
1786             return CAIRO_TEST_ERROR;
1787         }
1788     }
1789
1790     /* Test a context for an error surface */
1791     for (i = 0; i < ARRAY_LENGTH (context_tests); i++) {
1792         surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, INT_MAX, INT_MAX);
1793         cr = cairo_create (surface);
1794         cairo_surface_destroy (surface);
1795         status_before = cairo_status (cr);
1796         assert (status_before);
1797
1798         test_status = context_tests[i].func (cr);
1799
1800         status_after = cairo_status (cr);
1801         cairo_destroy (cr);
1802
1803         if (test_status != CAIRO_TEST_SUCCESS) {
1804             cairo_test_log (ctx,
1805                             "Failed test %s with %d\n",
1806                             context_tests[i].name, (int) test_status);
1807             return test_status;
1808         }
1809
1810         if (status_before != status_after) {
1811             cairo_test_log (ctx,
1812                             "Failed test %s: Modified context status from %u (%s) to %u (%s)\n",
1813                             context_tests[i].name,
1814                             status_before, cairo_status_to_string (status_before),
1815                             status_after, cairo_status_to_string (status_after));
1816             return CAIRO_TEST_ERROR;
1817         }
1818     }
1819
1820     return CAIRO_TEST_SUCCESS;
1821 }
1822
1823 static cairo_test_status_t
1824 test_context (const cairo_test_context_t *ctx, cairo_t *cr, const char *name, unsigned int i)
1825 {
1826     cairo_test_status_t test_status;
1827     cairo_status_t status_before, status_after;
1828
1829     /* Make sure that there is a current point */
1830     cairo_move_to (cr, 0, 0);
1831
1832     status_before = cairo_status (cr);
1833     test_status = context_tests[i].func (cr);
1834     status_after = cairo_status (cr);
1835
1836     if (test_status != CAIRO_TEST_SUCCESS) {
1837         cairo_test_log (ctx,
1838                         "Failed test %s on %s with %d\n",
1839                         context_tests[i].name, name, (int) test_status);
1840         return test_status;
1841     }
1842
1843     if (status_after != CAIRO_STATUS_SURFACE_FINISHED && status_before != status_after) {
1844         cairo_test_log (ctx,
1845                         "Failed test %s on %s: Modified context status from %u (%s) to %u (%s)\n",
1846                         context_tests[i].name, name,
1847                         status_before, cairo_status_to_string (status_before),
1848                         status_after, cairo_status_to_string (status_after));
1849         return CAIRO_TEST_ERROR;
1850     }
1851
1852     return CAIRO_TEST_SUCCESS;
1853 }
1854
1855 static cairo_test_status_t
1856 draw (cairo_t *cr, int width, int height)
1857 {
1858     const cairo_test_context_t *ctx = cairo_test_get_context (cr);
1859     cairo_surface_t *similar, *target;
1860     cairo_test_status_t test_status;
1861     cairo_status_t status;
1862     cairo_t *cr2;
1863     unsigned int i;
1864
1865     target = cairo_get_target (cr);
1866
1867     /* Test a finished similar surface */
1868     for (i = 0; i < ARRAY_LENGTH (surface_tests); i++) {
1869         similar = cairo_surface_create_similar (target,
1870                                                 cairo_surface_get_content (target),
1871                                                 10, 10);
1872         cairo_surface_finish (similar);
1873         test_status = surface_tests[i].func (similar);
1874         status = cairo_surface_status (similar);
1875         cairo_surface_destroy (similar);
1876
1877         if (test_status != CAIRO_TEST_SUCCESS) {
1878             cairo_test_log (ctx,
1879                             "Failed test %s with %d\n",
1880                             surface_tests[i].name, (int) test_status);
1881             return test_status;
1882         }
1883
1884         if (surface_tests[i].modifies_surface &&
1885             strcmp (surface_tests[i].name, "cairo_surface_finish") &&
1886             strcmp (surface_tests[i].name, "cairo_surface_flush") &&
1887             status != CAIRO_STATUS_SURFACE_FINISHED) {
1888             cairo_test_log (ctx,
1889                             "Failed test %s: Finished surface not set into error state\n",
1890                             surface_tests[i].name);
1891             return CAIRO_TEST_ERROR;
1892         }
1893     }
1894
1895     /* Test a context for a finished similar surface */
1896     for (i = 0; i < ARRAY_LENGTH (context_tests); i++) {
1897         similar = cairo_surface_create_similar (target,
1898                                                 cairo_surface_get_content (target),
1899                                                 10, 10);
1900         cairo_surface_finish (similar);
1901         cr2 = cairo_create (similar);
1902         test_status = test_context (ctx, cr2, "finished surface", i);
1903         cairo_surface_destroy (similar);
1904         cairo_destroy (cr2);
1905
1906         if (test_status != CAIRO_TEST_SUCCESS)
1907             return test_status;
1908     }
1909
1910     /* Test a context for a similar surface finished later */
1911     for (i = 0; i < ARRAY_LENGTH (context_tests); i++) {
1912         similar = cairo_surface_create_similar (target,
1913                                                 cairo_surface_get_content (target),
1914                                                 10, 10);
1915         cr2 = cairo_create (similar);
1916         cairo_surface_finish (similar);
1917         test_status = test_context (ctx, cr2, "finished surface after create", i);
1918         cairo_surface_destroy (similar);
1919         cairo_destroy (cr2);
1920
1921         if (test_status != CAIRO_TEST_SUCCESS)
1922             return test_status;
1923     }
1924
1925     /* Test a context for a similar surface finished later with a path */
1926     for (i = 0; i < ARRAY_LENGTH (context_tests); i++) {
1927         similar = cairo_surface_create_similar (target,
1928                                                 cairo_surface_get_content (target),
1929                                                 10, 10);
1930         cr2 = cairo_create (similar);
1931         cairo_rectangle (cr2, 2, 2, 4, 4);
1932         cairo_surface_finish (similar);
1933         test_status = test_context (ctx, cr2, "finished surface with path", i);
1934         cairo_surface_destroy (similar);
1935         cairo_destroy (cr2);
1936
1937         if (test_status != CAIRO_TEST_SUCCESS)
1938             return test_status;
1939     }
1940
1941     /* Test a normal surface for functions that have the wrong type */
1942     for (i = 0; i < ARRAY_LENGTH (surface_tests); i++) {
1943         cairo_status_t desired_status;
1944
1945         if (surface_tests[i].surface_type == -1)
1946             continue;
1947         similar = cairo_surface_create_similar (target,
1948                                                 cairo_surface_get_content (target),
1949                                                 10, 10);
1950         if (cairo_surface_get_type (similar) == (cairo_surface_type_t) surface_tests[i].surface_type) {
1951             cairo_surface_destroy (similar);
1952             continue;
1953         }
1954
1955         test_status = surface_tests[i].func (similar);
1956         status = cairo_surface_status (similar);
1957         cairo_surface_destroy (similar);
1958
1959         if (test_status != CAIRO_TEST_SUCCESS) {
1960             cairo_test_log (ctx,
1961                             "Failed test %s with %d\n",
1962                             surface_tests[i].name, (int) test_status);
1963             return test_status;
1964         }
1965
1966         desired_status = surface_tests[i].modifies_surface ? CAIRO_STATUS_SURFACE_TYPE_MISMATCH : CAIRO_STATUS_SUCCESS;
1967         if (status != desired_status) {
1968             cairo_test_log (ctx,
1969                             "Failed test %s: Surface status should be %u (%s), but is %u (%s)\n",
1970                             surface_tests[i].name,
1971                             desired_status, cairo_status_to_string (desired_status),
1972                             status, cairo_status_to_string (status));
1973             return CAIRO_TEST_ERROR;
1974         }
1975     }
1976
1977     /* 565-compatible gray background */
1978     cairo_set_source_rgb (cr, 0.51613, 0.55555, 0.51613);
1979     cairo_paint (cr);
1980
1981     return CAIRO_TEST_SUCCESS;
1982 }
1983
1984 CAIRO_TEST (api_special_cases,
1985             "Check surface functions properly handle wrong surface arguments",
1986             "api", /* keywords */
1987             NULL, /* requirements */
1988             10, 10,
1989             preamble, draw)