1 | #include <gtk/gtk.h> |
2 | |
3 | static void |
4 | stack_role (void) |
5 | { |
6 | GtkWidget *stack = gtk_stack_new (); |
7 | GtkWidget *child1 = gtk_label_new (str: "a" ); |
8 | GtkWidget *child2 = gtk_label_new (str: "b" ); |
9 | GtkWidget *switcher = gtk_stack_switcher_new (); |
10 | GtkWidget *child; |
11 | GtkStackPage *page; |
12 | |
13 | g_object_ref_sink (stack); |
14 | g_object_ref_sink (switcher); |
15 | |
16 | gtk_stack_add_named (GTK_STACK (stack), child: child1, name: "a" ); |
17 | gtk_stack_add_named (GTK_STACK (stack), child: child2, name: "b" ); |
18 | |
19 | gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack)); |
20 | |
21 | gtk_test_accessible_assert_role (GTK_ACCESSIBLE (stack), GTK_ACCESSIBLE_ROLE_GROUP); |
22 | gtk_test_accessible_assert_role (GTK_ACCESSIBLE (switcher), GTK_ACCESSIBLE_ROLE_TAB_LIST); |
23 | |
24 | child = gtk_widget_get_first_child (widget: switcher); |
25 | page = gtk_stack_get_page (GTK_STACK (stack), child: child1); |
26 | gtk_test_accessible_assert_role (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_ROLE_TAB); |
27 | gtk_test_accessible_assert_role (GTK_ACCESSIBLE (page), GTK_ACCESSIBLE_ROLE_TAB_PANEL); |
28 | |
29 | child = gtk_widget_get_last_child (widget: switcher); |
30 | page = gtk_stack_get_page (GTK_STACK (stack), child: child2); |
31 | gtk_test_accessible_assert_role (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_ROLE_TAB); |
32 | gtk_test_accessible_assert_role (GTK_ACCESSIBLE (page), GTK_ACCESSIBLE_ROLE_TAB_PANEL); |
33 | |
34 | g_object_unref (object: stack); |
35 | g_object_unref (object: switcher); |
36 | } |
37 | |
38 | static void |
39 | stack_state (void) |
40 | { |
41 | GtkWidget *stack = gtk_stack_new (); |
42 | GtkWidget *child1 = gtk_label_new (str: "a" ); |
43 | GtkWidget *child2 = gtk_label_new (str: "b" ); |
44 | GtkWidget *switcher = gtk_stack_switcher_new (); |
45 | GtkWidget *child; |
46 | |
47 | g_object_ref_sink (stack); |
48 | g_object_ref_sink (switcher); |
49 | |
50 | gtk_stack_add_named (GTK_STACK (stack), child: child1, name: "a" ); |
51 | gtk_stack_add_named (GTK_STACK (stack), child: child2, name: "b" ); |
52 | |
53 | gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack)); |
54 | |
55 | child = gtk_widget_get_first_child (widget: switcher); |
56 | gtk_test_accessible_assert_state (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_STATE_SELECTED, TRUE); |
57 | |
58 | child = gtk_widget_get_last_child (widget: switcher); |
59 | gtk_test_accessible_assert_state (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_STATE_SELECTED, FALSE); |
60 | |
61 | g_object_unref (object: stack); |
62 | g_object_unref (object: switcher); |
63 | } |
64 | |
65 | static void |
66 | stack_relations (void) |
67 | { |
68 | GtkWidget *stack = gtk_stack_new (); |
69 | GtkWidget *child1 = gtk_label_new (str: "a" ); |
70 | GtkWidget *child2 = gtk_label_new (str: "b" ); |
71 | GtkWidget *switcher = gtk_stack_switcher_new (); |
72 | GtkWidget *child; |
73 | GtkStackPage *page; |
74 | |
75 | g_object_ref_sink (stack); |
76 | g_object_ref_sink (switcher); |
77 | |
78 | gtk_stack_add_named (GTK_STACK (stack), child: child1, name: "a" ); |
79 | gtk_stack_add_named (GTK_STACK (stack), child: child2, name: "b" ); |
80 | |
81 | gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack)); |
82 | |
83 | child = gtk_widget_get_first_child (widget: switcher); |
84 | page = gtk_stack_get_page (GTK_STACK (stack), child: child1); |
85 | gtk_test_accessible_assert_relation (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_RELATION_CONTROLS, page, NULL); |
86 | |
87 | child = gtk_widget_get_last_child (widget: switcher); |
88 | page = gtk_stack_get_page (GTK_STACK (stack), child: child2); |
89 | gtk_test_accessible_assert_relation (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_RELATION_CONTROLS, page, NULL); |
90 | |
91 | g_object_unref (object: stack); |
92 | g_object_unref (object: switcher); |
93 | } |
94 | |
95 | int |
96 | main (int argc, char *argv[]) |
97 | { |
98 | gtk_test_init (argcp: &argc, argvp: &argv, NULL); |
99 | |
100 | g_test_add_func (testpath: "/a11y/stack/role" , test_func: stack_role); |
101 | g_test_add_func (testpath: "/a11y/stack/state" , test_func: stack_state); |
102 | g_test_add_func (testpath: "/a11y/stack/relations" , test_func: stack_relations); |
103 | |
104 | return g_test_run (); |
105 | } |
106 | |
107 | |