| 1 |
#include <gdk/gdk.h> |
| 2 |
|
| 3 |
static void |
| 4 |
test_list_seats (void) |
| 5 |
{ |
| 6 |
GdkDisplay *display; |
| 7 |
GdkSeat *seat0, *seat; |
| 8 |
GList *list, *l; |
| 9 |
gboolean found_default; |
| 10 |
|
| 11 |
display = gdk_display_get_default (); |
| 12 |
seat0 = gdk_display_get_default_seat (display); |
| 13 |
|
| 14 |
g_assert_true (GDK_IS_SEAT (seat0)); |
| 15 |
|
| 16 |
found_default = FALSE; |
| 17 |
list = gdk_display_list_seats (display); |
| 18 |
for (l = list; l; l = l->next) |
| 19 |
{ |
| 20 |
seat = l->data; |
| 21 |
|
| 22 |
g_assert_true (GDK_IS_SEAT (seat)); |
| 23 |
g_assert (gdk_seat_get_display (seat) == display); |
| 24 |
|
| 25 |
if (seat == seat0) |
| 26 |
found_default = TRUE; |
| 27 |
} |
| 28 |
g_list_free (list); |
| 29 |
|
| 30 |
g_assert_true (found_default); |
| 31 |
} |
| 32 |
|
| 33 |
static void |
| 34 |
test_default_seat (void) |
| 35 |
{ |
| 36 |
GdkDisplay *display; |
| 37 |
GdkSeat *seat0; |
| 38 |
GdkSeatCapabilities caps; |
| 39 |
GdkDevice *pointer0, *keyboard0, *device; |
| 40 |
GList *slaves, *l; |
| 41 |
|
| 42 |
display = gdk_display_get_default (); |
| 43 |
seat0 = gdk_display_get_default_seat (display); |
| 44 |
|
| 45 |
g_assert_true (GDK_IS_SEAT (seat0)); |
| 46 |
|
| 47 |
caps = gdk_seat_get_capabilities (seat0); |
| 48 |
|
| 49 |
g_assert (caps != GDK_SEAT_CAPABILITY_NONE); |
| 50 |
|
| 51 |
pointer0 = gdk_seat_get_pointer (seat0); |
| 52 |
slaves = gdk_seat_get_slaves (seat0, GDK_SEAT_CAPABILITY_POINTER); |
| 53 |
|
| 54 |
if ((caps & GDK_SEAT_CAPABILITY_POINTER) != 0) |
| 55 |
{ |
| 56 |
g_assert_nonnull (pointer0); |
| 57 |
g_assert (gdk_device_get_device_type (pointer0) == GDK_DEVICE_TYPE_MASTER); |
| 58 |
g_assert (gdk_device_get_display (pointer0) == display); |
| 59 |
g_assert (gdk_device_get_seat (pointer0) == seat0); |
| 60 |
|
| 61 |
g_assert_nonnull (slaves); |
| 62 |
for (l = slaves; l; l = l->next) |
| 63 |
{ |
| 64 |
device = l->data; |
| 65 |
g_assert (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_SLAVE); |
| 66 |
g_assert (gdk_device_get_display (device) == display); |
| 67 |
g_assert (gdk_device_get_seat (device) == seat0); |
| 68 |
} |
| 69 |
g_list_free (slaves); |
| 70 |
} |
| 71 |
else |
| 72 |
{ |
| 73 |
g_assert_null (pointer0); |
| 74 |
g_assert_null (slaves); |
| 75 |
} |
| 76 |
|
| 77 |
keyboard0 = gdk_seat_get_keyboard (seat0); |
| 78 |
slaves = gdk_seat_get_slaves (seat0, GDK_SEAT_CAPABILITY_KEYBOARD); |
| 79 |
|
| 80 |
if ((caps & GDK_SEAT_CAPABILITY_KEYBOARD) != 0) |
| 81 |
{ |
| 82 |
g_assert_nonnull (keyboard0); |
| 83 |
g_assert (gdk_device_get_device_type (keyboard0) == GDK_DEVICE_TYPE_MASTER); |
| 84 |
g_assert (gdk_device_get_display (keyboard0) == display); |
| 85 |
g_assert (gdk_device_get_seat (keyboard0) == seat0); |
| 86 |
g_assert (gdk_device_get_source (keyboard0) == GDK_SOURCE_KEYBOARD); |
| 87 |
|
| 88 |
g_assert_nonnull (slaves); |
| 89 |
for (l = slaves; l; l = l->next) |
| 90 |
{ |
| 91 |
device = l->data; |
| 92 |
g_assert (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_SLAVE); |
| 93 |
g_assert (gdk_device_get_display (device) == display); |
| 94 |
g_assert (gdk_device_get_seat (device) == seat0); |
| 95 |
g_assert (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD); |
| 96 |
} |
| 97 |
g_list_free (slaves); |
| 98 |
} |
| 99 |
else |
| 100 |
{ |
| 101 |
g_assert_null (keyboard0); |
| 102 |
g_assert_null (slaves); |
| 103 |
} |
| 104 |
|
| 105 |
} |
| 106 |
|
| 107 |
int |
| 108 |
main (int argc, char *argv[]) |
| 109 |
{ |
| 110 |
g_test_init (&argc, &argv, NULL); |
| 111 |
|
| 112 |
gdk_init (NULL, NULL); |
| 113 |
|
| 114 |
g_test_bug_base ("http://bugzilla.gnome.org/"); |
| 115 |
|
| 116 |
g_test_add_func ("/seat/list", test_list_seats); |
| 117 |
g_test_add_func ("/seat/default", test_default_seat); |
| 118 |
|
| 119 |
return g_test_run (); |
| 120 |
} |