ff65ad4f2de8eca87de78e8da7c43ab750dbb7ee
[framework/graphics/cairo.git] / test / error-setters.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 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30 #include <limits.h>
31
32 #include "cairo-test.h"
33
34 #if CAIRO_HAS_GL_SURFACE
35 #include <cairo-gl.h>
36 #endif
37 #if CAIRO_HAS_OS2_SURFACE
38 #include <cairo-os2.h>
39 #endif
40 #if CAIRO_HAS_PDF_SURFACE
41 #include <cairo-pdf.h>
42 #endif
43 #if CAIRO_HAS_PS_SURFACE
44 #include <cairo-ps.h>
45 #endif
46 #if CAIRO_HAS_XCB_SURFACE
47 #include <cairo-xcb.h>
48 #endif
49 #if CAIRO_HAS_XLIB_SURFACE
50 #include <cairo-xlib.h>
51 #endif
52
53 static cairo_test_status_t
54 preamble (cairo_test_context_t *ctx)
55 {
56     cairo_surface_t *surface;
57
58     /* get the error surface */
59     surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, INT_MAX, INT_MAX);
60
61 #if CAIRO_HAS_GL_SURFACE
62     cairo_gl_surface_set_size (surface, 0, 0);
63     cairo_gl_surface_swapbuffers (surface);
64 #endif
65
66 #if CAIRO_HAS_OS2_SURFACE
67     cairo_os2_surface_set_hwnd (surface, 0);
68     cairo_os2_surface_set_size (surface, 0, 0, 0);
69     cairo_os2_surface_set_manual_window_refresh (surface, FALSE);
70 #endif
71
72 #if CAIRO_HAS_PDF_SURFACE
73     cairo_pdf_surface_restrict_to_version (surface, CAIRO_PDF_VERSION_1_4);
74     cairo_pdf_surface_set_size (surface, 0, 0);
75 #endif
76
77 #if CAIRO_HAS_PS_SURFACE
78     cairo_ps_surface_set_eps (surface, FALSE);
79     cairo_ps_surface_set_size (surface, 0, 0);
80     cairo_ps_surface_restrict_to_level (surface, CAIRO_PS_LEVEL_2);
81     cairo_ps_surface_dsc_comment (surface, NULL);
82     cairo_ps_surface_dsc_begin_setup (surface);
83     cairo_ps_surface_dsc_begin_page_setup (surface);
84 #endif
85
86 #if CAIRO_HAS_XCB_SURFACE
87     cairo_xcb_surface_set_size (surface, 0, 0);
88 #endif
89
90 #if CAIRO_HAS_XLIB_SURFACE
91     cairo_xlib_surface_set_size (surface, 0, 0);
92     cairo_xlib_surface_set_drawable (surface, 0, 0, 0);
93 #endif
94
95     cairo_surface_set_mime_data (surface, NULL, NULL, 0, NULL, 0);
96     cairo_surface_set_device_offset (surface, 0, 0);
97     cairo_surface_set_fallback_resolution (surface, 0, 0);
98
99     cairo_surface_destroy (surface);
100
101     return CAIRO_TEST_SUCCESS;
102 }
103
104 CAIRO_TEST (error_setters,
105             "Check setters properly error out on read-only error surfaces",
106             NULL, /* keywords */
107             NULL, /* requirements */
108             0, 0,
109             preamble, NULL)