error-setters.c 3.3 KB

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