1#include <gtk/gtk.h>
2
3static void
4test_set_source_big_pixbuf (void)
5{
6 cairo_surface_t *surface;
7 GdkPixbuf *pixbuf;
8 cairo_t *cr;
9
10#define WAY_TOO_BIG 65540
11
12 /* Check that too big really is to big.
13 * If this check fails, somebody improved Cairo and this test is useless.
14 */
15 surface = cairo_image_surface_create (format: CAIRO_FORMAT_ARGB32, WAY_TOO_BIG, height: 1);
16 g_assert_cmpint (cairo_surface_status (surface), !=, CAIRO_STATUS_SUCCESS);
17 cairo_surface_destroy (surface);
18
19 surface = cairo_image_surface_create (format: CAIRO_FORMAT_ARGB32, width: 10, height: 10);
20 cr = cairo_create (target: surface);
21 pixbuf = gdk_pixbuf_new (colorspace: GDK_COLORSPACE_RGB, FALSE, bits_per_sample: 8, WAY_TOO_BIG, height: 1);
22
23 gdk_cairo_set_source_pixbuf (cr, pixbuf, pixbuf_x: 0, pixbuf_y: 0);
24 g_assert_cmpint (cairo_status (cr), !=, CAIRO_STATUS_SUCCESS);
25
26 g_object_unref (object: pixbuf);
27 cairo_destroy (cr);
28 cairo_surface_destroy (surface);
29}
30
31int
32main (int argc, char *argv[])
33{
34 (g_test_init) (argc: &argc, argv: &argv, NULL);
35 gtk_init ();
36
37 g_test_add_func (testpath: "/drawing/set-source-big-pixbuf", test_func: test_set_source_big_pixbuf);
38
39 return g_test_run ();
40}
41

source code of gtk/testsuite/gdk/cairo.c