summaryrefslogtreecommitdiff
path: root/testsuite/a11y/button.c
blob: 803a2fecf84fcf51e0a6ef881be88a8f1af198d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <gtk/gtk.h>

static void
button_role (void)
{
  GtkWidget *button = gtk_button_new ();
  g_object_ref_sink (button);

  gtk_test_accessible_assert_role (button, GTK_ACCESSIBLE_ROLE_BUTTON);

  /* Simple command buttons have a "pressed" state set to "undefined" */
  gtk_test_accessible_assert_state (button, GTK_ACCESSIBLE_STATE_PRESSED, GTK_ACCESSIBLE_VALUE_UNDEFINED);

  g_object_unref (button);
}

static void
button_label (void)
{
  GtkWidget *button = gtk_button_new_with_label ("Hello");
  g_object_ref_sink (button);

  gtk_test_accessible_assert_property (button, GTK_ACCESSIBLE_PROPERTY_LABEL, "Hello");

  g_object_unref (button);
}

/* Check that we set up a labelled_by relationship between a button
 * and its label.
 */
static void
button_relation (void)
{
  GtkWidget *button = gtk_button_new_with_mnemonic ("_Hello");
  GList *list;

  g_object_ref_sink (button);

  list = g_list_append (NULL, gtk_widget_get_first_child (button));
  gtk_test_accessible_assert_relation (GTK_ACCESSIBLE (button), GTK_ACCESSIBLE_RELATION_LABELLED_BY, list);
  g_list_free (list);

  g_object_unref (button);
}

static void
linkbutton_role (void)
{
  GtkWidget *button = gtk_link_button_new ("Hello");
  g_object_ref_sink (button);

  gtk_test_accessible_assert_role (button, GTK_ACCESSIBLE_ROLE_LINK);

  g_object_unref (button);
}

static void
linkbutton_label (void)
{
  GtkWidget *button = gtk_link_button_new ("Hello");
  g_object_ref_sink (button);

  gtk_test_accessible_assert_property (button, GTK_ACCESSIBLE_PROPERTY_LABEL, "Hello");

  g_object_unref (button);
}

int
main (int argc, char *argv[])
{
  gtk_test_init (&argc, &argv, NULL);

  g_test_add_func ("/a11y/button/role", button_role);
  g_test_add_func ("/a11y/button/label", button_label);
  g_test_add_func ("/a11y/button/relation", button_relation);
  g_test_add_func ("/a11y/linkbutton/role", linkbutton_role);
  g_test_add_func ("/a11y/linkbutton/label", linkbutton_label);

  return g_test_run ();
}