1 | #include <gtk/gtk.h> |
2 | |
3 | /* Some of the accessible attributes are general enough |
4 | * that GTK maintains them for every widget. These tests |
5 | * are checking them. |
6 | */ |
7 | |
8 | static void |
9 | test_hidden (void) |
10 | { |
11 | GtkWidget *widget; |
12 | |
13 | widget = gtk_button_new (); |
14 | g_object_ref_sink (widget); |
15 | |
16 | gtk_test_accessible_assert_state (widget, GTK_ACCESSIBLE_STATE_HIDDEN, FALSE); |
17 | |
18 | gtk_widget_hide (widget); |
19 | |
20 | gtk_test_accessible_assert_state (widget, GTK_ACCESSIBLE_STATE_HIDDEN, TRUE); |
21 | |
22 | g_object_unref (object: widget); |
23 | } |
24 | |
25 | static void |
26 | test_disabled (void) |
27 | { |
28 | GtkWidget *widget; |
29 | |
30 | widget = gtk_expander_new (label: "" ); |
31 | g_object_ref_sink (widget); |
32 | |
33 | gtk_test_accessible_assert_state (widget, GTK_ACCESSIBLE_STATE_DISABLED, FALSE); |
34 | |
35 | gtk_widget_set_sensitive (widget, FALSE); |
36 | |
37 | gtk_test_accessible_assert_state (widget, GTK_ACCESSIBLE_STATE_DISABLED, TRUE); |
38 | |
39 | g_object_unref (object: widget); |
40 | } |
41 | |
42 | static void |
43 | test_orientation (void) |
44 | { |
45 | GtkWidget *widget; |
46 | |
47 | widget = gtk_scale_new (orientation: GTK_ORIENTATION_HORIZONTAL, NULL); |
48 | g_object_ref_sink (widget); |
49 | |
50 | gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_ORIENTATION, GTK_ORIENTATION_HORIZONTAL); |
51 | |
52 | gtk_orientable_set_orientation (GTK_ORIENTABLE (widget), orientation: GTK_ORIENTATION_VERTICAL); |
53 | |
54 | gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_ORIENTATION, GTK_ORIENTATION_VERTICAL); |
55 | |
56 | g_object_unref (object: widget); |
57 | } |
58 | |
59 | static void |
60 | test_labelled_by (void) |
61 | { |
62 | GtkWidget *widget; |
63 | GtkWidget *label; |
64 | |
65 | widget = gtk_switch_new (); |
66 | g_object_ref_sink (widget); |
67 | |
68 | gtk_test_accessible_assert_relation (widget, GTK_ACCESSIBLE_RELATION_LABELLED_BY, NULL); |
69 | |
70 | label = gtk_label_new (str: "Switch" ); |
71 | g_object_ref_sink (label); |
72 | gtk_widget_add_mnemonic_label (widget, label); |
73 | |
74 | gtk_test_accessible_assert_relation (widget, GTK_ACCESSIBLE_RELATION_LABELLED_BY, label, NULL); |
75 | |
76 | g_object_unref (object: widget); |
77 | g_object_unref (object: label); |
78 | } |
79 | |
80 | int |
81 | main (int argc, char *argv[]) |
82 | { |
83 | gtk_test_init (argcp: &argc, argvp: &argv, NULL); |
84 | |
85 | g_test_add_func (testpath: "/a11y/general/hidden" , test_func: test_hidden); |
86 | g_test_add_func (testpath: "/a11y/general/disabled" , test_func: test_disabled); |
87 | g_test_add_func (testpath: "/a11y/general/orientation" , test_func: test_orientation); |
88 | g_test_add_func (testpath: "/a11y/general/labelled-by" , test_func: test_labelled_by); |
89 | |
90 | return g_test_run (); |
91 | } |
92 | |