diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-10-20 01:07:13 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-10-20 01:07:13 -0400 |
commit | b9e9898212fd8f8f0c4d16baee5a2f77fd288f49 (patch) | |
tree | 1f4afb77c93b53d39d6f6b0c65b5ee2fb7ef37d5 /testsuite | |
parent | 7c47b6907b6b7ca8787a952c367d098315710a4b (diff) | |
download | gtk+-b9e9898212fd8f8f0c4d16baee5a2f77fd288f49.tar.gz |
a11y: Add tests for GtkListBox
Test that roles, states and properties are as expected.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/a11y/listbox.c | 66 | ||||
-rw-r--r-- | testsuite/a11y/meson.build | 1 |
2 files changed, 67 insertions, 0 deletions
diff --git a/testsuite/a11y/listbox.c b/testsuite/a11y/listbox.c new file mode 100644 index 0000000000..0204a6b1f2 --- /dev/null +++ b/testsuite/a11y/listbox.c @@ -0,0 +1,66 @@ +#include <gtk/gtk.h> + +static void +listbox_role (void) +{ + GtkWidget *widget = gtk_list_box_new (); + + g_object_ref_sink (widget); + + gtk_list_box_append (GTK_LIST_BOX (widget), gtk_label_new ("a")); + + gtk_test_accessible_assert_role (GTK_ACCESSIBLE (widget), GTK_ACCESSIBLE_ROLE_LIST); + gtk_test_accessible_assert_role (GTK_ACCESSIBLE (gtk_widget_get_first_child (widget)), GTK_ACCESSIBLE_ROLE_LIST_ITEM); + + g_object_unref (widget); +} + +static void +listbox_state (void) +{ + GtkWidget *window = gtk_window_new (); + GtkWidget *widget = gtk_list_box_new (); + + gtk_window_set_child (GTK_WINDOW (window), widget); + + gtk_list_box_append (GTK_LIST_BOX (widget), gtk_label_new ("a")); + + gtk_test_accessible_assert_state (GTK_ACCESSIBLE (gtk_widget_get_first_child (widget)), GTK_ACCESSIBLE_STATE_SELECTED, FALSE); + + gtk_list_box_select_row (GTK_LIST_BOX (widget), + GTK_LIST_BOX_ROW (gtk_widget_get_first_child (widget))); + + gtk_test_accessible_assert_state (GTK_ACCESSIBLE (gtk_widget_get_first_child (widget)), GTK_ACCESSIBLE_STATE_SELECTED, TRUE); + + gtk_window_destroy (GTK_WINDOW (window)); +} + +static void +listbox_properties (void) +{ + GtkWidget *widget = gtk_list_box_new (); + + g_object_ref_sink (widget); + + gtk_list_box_append (GTK_LIST_BOX (widget), gtk_label_new ("a")); + + gtk_test_accessible_assert_property (GTK_ACCESSIBLE (widget), GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE, FALSE); + + gtk_list_box_set_selection_mode (GTK_LIST_BOX (widget), GTK_SELECTION_MULTIPLE); + + gtk_test_accessible_assert_property (GTK_ACCESSIBLE (widget), GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE, TRUE); + + g_object_unref (widget); +} + +int +main (int argc, char *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + + g_test_add_func ("/a11y/listbox/role", listbox_role); + g_test_add_func ("/a11y/listbox/state", listbox_state); + g_test_add_func ("/a11y/listbox/properties", listbox_properties); + + return g_test_run (); +} diff --git a/testsuite/a11y/meson.build b/testsuite/a11y/meson.build index fa708ae3c6..bb3bd97a8a 100644 --- a/testsuite/a11y/meson.build +++ b/testsuite/a11y/meson.build @@ -18,6 +18,7 @@ tests = [ { 'name': 'expander' }, { 'name': 'image' }, { 'name': 'label' }, + { 'name': 'listbox' }, { 'name': 'levelbar' }, { 'name': 'passwordentry' }, { 'name': 'progressbar' }, |