1 | /* GTK - The GIMP Toolkit |
2 | * Copyright (C) 2013 Benjamin Otte <otte@gnome.org> |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
16 | */ |
17 | |
18 | #include <gtk/gtk.h> |
19 | #include <locale.h> |
20 | |
21 | /* This test tests functions that are supposed to work without calling gtk_init() |
22 | * or gdk_init(). |
23 | */ |
24 | |
25 | static void |
26 | test_gdk_cairo_set_source_pixbuf (void) |
27 | { |
28 | cairo_surface_t *surface; |
29 | cairo_t *cr; |
30 | GdkPixbuf *pixbuf; |
31 | |
32 | pixbuf = gdk_pixbuf_new (colorspace: GDK_COLORSPACE_RGB, FALSE, bits_per_sample: 8, width: 5, height: 5); |
33 | surface = cairo_image_surface_create (format: CAIRO_FORMAT_ARGB32, width: 10, height: 10); |
34 | cr = cairo_create (target: surface); |
35 | |
36 | gdk_cairo_set_source_pixbuf (cr, pixbuf, pixbuf_x: 0, pixbuf_y: 0); |
37 | cairo_paint (cr); |
38 | |
39 | cairo_destroy (cr); |
40 | cairo_surface_destroy (surface); |
41 | g_object_unref (object: pixbuf); |
42 | } |
43 | |
44 | int |
45 | main (int argc, |
46 | char *argv[]) |
47 | { |
48 | /* Keep in sync with gtk_test_init() */ |
49 | (g_test_init) (argc: &argc, argv: &argv, NULL); |
50 | g_setenv (variable: "GTK_MODULES" , value: "" , TRUE); |
51 | setlocale (LC_ALL, locale: "C" ); |
52 | |
53 | |
54 | g_test_add_func (testpath: "/no_gtk_init/gdk_cairo_set_source_pixbuf" , test_func: test_gdk_cairo_set_source_pixbuf); |
55 | |
56 | |
57 | return g_test_run(); |
58 | } |
59 | |