diff options
author | Benjamin Otte <otte@redhat.com> | 2010-04-14 22:43:29 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-04-14 22:45:18 +0200 |
commit | 5fed41ee2bb3097c1446c1cf2038c912d5932692 (patch) | |
tree | d52742f16a9f7da7d1c7b2ce668bef5f44342ead /test | |
parent | 6826f020014fff566678a1ff92014211e2a21d4c (diff) |
test: Add test checking that all setters properly check surface->status
In particular, make sure that the setters when called on a const nil
surface don't try to set surface->status.
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.sources | 1 | ||||
-rw-r--r-- | test/error-setters.c | 109 |
2 files changed, 110 insertions, 0 deletions
diff --git a/test/Makefile.sources b/test/Makefile.sources index 65e81865..34143db9 100644 --- a/test/Makefile.sources +++ b/test/Makefile.sources @@ -73,6 +73,7 @@ test_sources = \ device-offset-fractional.c \ device-offset-positive.c \ device-offset-scale.c \ + error-setters.c \ extend-pad.c \ extend-pad-border.c \ extend-pad-similar.c \ diff --git a/test/error-setters.c b/test/error-setters.c new file mode 100644 index 00000000..e6b715ab --- /dev/null +++ b/test/error-setters.c @@ -0,0 +1,109 @@ +/* + * Copyright © 2010 Red Hat Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of + * Red Hat, Inc. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Red Hat, Inc. makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Benjamin Otte <otte@redhat.com> + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <limits.h> + +#include "cairo-test.h" + +#if CAIRO_HAS_GL_SURFACE +#include <cairo-gl.h> +#endif +#if CAIRO_HAS_OS2_SURFACE +#include <cairo-os2.h> +#endif +#if CAIRO_HAS_PDF_SURFACE +#include <cairo-pdf.h> +#endif +#if CAIRO_HAS_PS_SURFACE +#include <cairo-ps.h> +#endif +#if CAIRO_HAS_XCB_SURFACE +#include <cairo-xcb.h> +#endif +#if CAIRO_HAS_XLIB_SURFACE +#include <cairo-xlib.h> +#endif + +static cairo_test_status_t +preamble (cairo_test_context_t *ctx) +{ + cairo_surface_t *surface; + + /* get the error surface */ + surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, INT_MAX, INT_MAX); + +#if CAIRO_HAS_GL_SURFACE + cairo_gl_surface_set_size (surface, 0, 0); + cairo_gl_surface_swapbuffers (surface); +#endif + +#if CAIRO_HAS_OS2_SURFACE + cairo_os2_surface_set_hwnd (surface, 0); + cairo_os2_surface_set_size (surface, 0, 0); + cairo_os2_surface_set_manual_window_refresh (surface, FALSE); +#endif + +#if CAIRO_HAS_PDF_SURFACE + cairo_pdf_surface_restrict_to_version (surface, CAIRO_PDF_VERSION_1_4); + cairo_pdf_surface_set_size (surface, 0, 0); +#endif + +#if CAIRO_HAS_PS_SURFACE + cairo_ps_surface_set_eps (surface, FALSE); + cairo_ps_surface_set_size (surface, 0, 0); + cairo_ps_surface_restrict_to_level (surface, CAIRO_PS_LEVEL_2); + cairo_ps_surface_dsc_comment (surface, NULL); + cairo_ps_surface_dsc_begin_setup (surface); + cairo_ps_surface_dsc_begin_page_setup (surface); +#endif + +#if CAIRO_HAS_XCB_SURFACE + cairo_xcb_surface_set_size (surface, 0, 0); +#endif + +#if CAIRO_HAS_XLIB_SURFACE + cairo_xlib_surface_set_size (surface, 0, 0); + cairo_xlib_surface_set_drawable (surface, 0, 0, 0); +#endif + + cairo_surface_set_mime_data (surface, NULL, NULL, 0, NULL, 0); + cairo_surface_set_device_offset (surface, 0, 0); + cairo_surface_set_fallback_resolution (surface, 0, 0); + + cairo_surface_destroy (surface); + + return CAIRO_TEST_SUCCESS; +} + +CAIRO_TEST (error_setters, + "Check setters properly error out on read-only error surfaces", + NULL, /* keywords */ + NULL, /* requirements */ + 0, 0, + preamble, NULL) |