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
#include "config.h"
27

            
28
#include <limits.h>
29

            
30
#include "cairo-test.h"
31

            
32
#if CAIRO_HAS_PDF_SURFACE
33
#include <cairo-pdf.h>
34
#endif
35
#if CAIRO_HAS_PS_SURFACE
36
#include <cairo-ps.h>
37
#endif
38
#if CAIRO_HAS_XCB_SURFACE
39
#include <cairo-xcb.h>
40
#endif
41
#if CAIRO_HAS_XLIB_SURFACE
42
#include <cairo-xlib.h>
43
#endif
44

            
45
static cairo_test_status_t
46
1
preamble (cairo_test_context_t *ctx)
47
{
48
    cairo_surface_t *surface;
49

            
50
    /* get the error surface */
51
1
    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, INT_MAX, INT_MAX);
52

            
53
#if CAIRO_HAS_PDF_SURFACE
54
1
    cairo_pdf_surface_restrict_to_version (surface, CAIRO_PDF_VERSION_1_4);
55
1
    cairo_pdf_surface_set_size (surface, 0, 0);
56
#endif
57

            
58
#if CAIRO_HAS_PS_SURFACE
59
1
    cairo_ps_surface_set_eps (surface, FALSE);
60
1
    cairo_ps_surface_set_size (surface, 0, 0);
61
1
    cairo_ps_surface_restrict_to_level (surface, CAIRO_PS_LEVEL_2);
62
1
    cairo_ps_surface_dsc_comment (surface, NULL);
63
1
    cairo_ps_surface_dsc_begin_setup (surface);
64
1
    cairo_ps_surface_dsc_begin_page_setup (surface);
65
#endif
66

            
67
#if CAIRO_HAS_XCB_SURFACE
68
1
    cairo_xcb_surface_set_size (surface, 0, 0);
69
#endif
70

            
71
#if CAIRO_HAS_XLIB_SURFACE
72
1
    cairo_xlib_surface_set_size (surface, 0, 0);
73
1
    cairo_xlib_surface_set_drawable (surface, 0, 0, 0);
74
#endif
75

            
76
1
    cairo_surface_set_mime_data (surface, NULL, NULL, 0, NULL, 0);
77
1
    cairo_surface_set_device_offset (surface, 0, 0);
78
1
    cairo_surface_set_fallback_resolution (surface, 0, 0);
79

            
80
1
    cairo_surface_destroy (surface);
81

            
82
1
    return CAIRO_TEST_SUCCESS;
83
}
84

            
85
1
CAIRO_TEST (error_setters,
86
	    "Check setters properly error out on read-only error surfaces",
87
	    NULL, /* keywords */
88
	    NULL, /* requirements */
89
	    0, 0,
90
	    preamble, NULL)