1#include <gtk/gtk.h>
2
3static void
4button_role (void)
5{
6 GtkWidget *button = gtk_button_new ();
7 g_object_ref_sink (button);
8
9 gtk_test_accessible_assert_role (button, GTK_ACCESSIBLE_ROLE_BUTTON);
10
11 /* Simple command buttons have a "pressed" state set to "undefined" */
12 gtk_test_accessible_assert_state (button, GTK_ACCESSIBLE_STATE_PRESSED, GTK_ACCESSIBLE_VALUE_UNDEFINED);
13
14 g_object_unref (object: button);
15}
16
17static void
18button_label (void)
19{
20 GtkWidget *button = gtk_button_new_with_label (label: "Hello");
21 g_object_ref_sink (button);
22
23 gtk_test_accessible_assert_property (button, GTK_ACCESSIBLE_PROPERTY_LABEL, "Hello");
24
25 g_object_unref (object: button);
26}
27
28/* Check that we set up a labelled_by relationship between a button
29 * and its label.
30 */
31static void
32button_relation (void)
33{
34 GtkWidget *button = gtk_button_new_with_mnemonic (label: "_Hello");
35
36 g_object_ref_sink (button);
37
38 gtk_test_accessible_assert_relation (GTK_ACCESSIBLE (button),
39 GTK_ACCESSIBLE_RELATION_LABELLED_BY, gtk_widget_get_first_child (button), NULL);
40
41 g_object_unref (object: button);
42}
43
44static void
45linkbutton_role (void)
46{
47 GtkWidget *button = gtk_link_button_new (uri: "Hello");
48 g_object_ref_sink (button);
49
50 gtk_test_accessible_assert_role (button, GTK_ACCESSIBLE_ROLE_LINK);
51
52 g_object_unref (object: button);
53}
54
55static void
56linkbutton_label (void)
57{
58 GtkWidget *button = gtk_link_button_new (uri: "Hello");
59 g_object_ref_sink (button);
60
61 gtk_test_accessible_assert_property (button, GTK_ACCESSIBLE_PROPERTY_LABEL, "Hello");
62
63 g_object_unref (object: button);
64}
65
66int
67main (int argc, char *argv[])
68{
69 gtk_test_init (argcp: &argc, argvp: &argv, NULL);
70
71 g_test_add_func (testpath: "/a11y/button/role", test_func: button_role);
72 g_test_add_func (testpath: "/a11y/button/label", test_func: button_label);
73 g_test_add_func (testpath: "/a11y/button/relation", test_func: button_relation);
74 g_test_add_func (testpath: "/a11y/linkbutton/role", test_func: linkbutton_role);
75 g_test_add_func (testpath: "/a11y/linkbutton/label", test_func: linkbutton_label);
76
77 return g_test_run ();
78}
79

source code of gtk/testsuite/a11y/button.c