1 | #include <gtk/gtk.h> |
2 | #include <cairo-gobject.h> |
3 | |
4 | static void |
5 | test_cursor_named (void) |
6 | { |
7 | GdkCursor *cursor; |
8 | |
9 | cursor = gdk_cursor_new_from_name (name: "default" , NULL); |
10 | |
11 | g_assert_cmpstr (gdk_cursor_get_name (cursor), ==, "default" ); |
12 | g_assert_null (gdk_cursor_get_fallback (cursor)); |
13 | g_assert_cmpint (gdk_cursor_get_hotspot_x (cursor), ==, 0); |
14 | g_assert_cmpint (gdk_cursor_get_hotspot_y (cursor), ==, 0); |
15 | g_assert_null (gdk_cursor_get_texture (cursor)); |
16 | |
17 | g_object_unref (object: cursor); |
18 | } |
19 | |
20 | static void |
21 | test_cursor_texture (void) |
22 | { |
23 | GdkPixbuf *pixbuf; |
24 | GdkTexture *texture; |
25 | GdkCursor *cursor; |
26 | |
27 | pixbuf = gdk_pixbuf_new (colorspace: GDK_COLORSPACE_RGB, TRUE, bits_per_sample: 8, width: 32, height: 32); |
28 | texture = gdk_texture_new_for_pixbuf (pixbuf); |
29 | cursor = gdk_cursor_new_from_texture (texture, hotspot_x: 1, hotspot_y: 2, NULL); |
30 | |
31 | g_assert_null (gdk_cursor_get_name (cursor)); |
32 | g_assert_null (gdk_cursor_get_fallback (cursor)); |
33 | g_assert_cmpint (gdk_cursor_get_hotspot_x (cursor), ==, 1); |
34 | g_assert_cmpint (gdk_cursor_get_hotspot_y (cursor), ==, 2); |
35 | g_assert_true (gdk_cursor_get_texture (cursor) == texture); |
36 | |
37 | g_object_unref (object: cursor); |
38 | g_object_unref (object: texture); |
39 | g_object_unref (object: pixbuf); |
40 | } |
41 | |
42 | static void |
43 | test_cursor_fallback (void) |
44 | { |
45 | GdkCursor *fallback; |
46 | GdkCursor *cursor; |
47 | |
48 | fallback = gdk_cursor_new_from_name (name: "default" , NULL); |
49 | cursor = gdk_cursor_new_from_name (name: "text" , fallback); |
50 | |
51 | g_assert_true (gdk_cursor_get_fallback (cursor) == fallback); |
52 | |
53 | g_object_unref (object: cursor); |
54 | g_object_unref (object: fallback); |
55 | } |
56 | |
57 | int |
58 | main (int argc, char *argv[]) |
59 | { |
60 | (g_test_init) (argc: &argc, argv: &argv, NULL); |
61 | |
62 | gtk_init (); |
63 | |
64 | g_test_add_func (testpath: "/cursor/named" , test_func: test_cursor_named); |
65 | g_test_add_func (testpath: "/cursor/texture" , test_func: test_cursor_texture); |
66 | g_test_add_func (testpath: "/cursor/fallback" , test_func: test_cursor_fallback); |
67 | |
68 | return g_test_run (); |
69 | } |
70 | |