[gtk/matthiasc/for-master: 2/4] a11y: Add tests for GtkStack and GtkStackSwitcher
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 2/4] a11y: Add tests for GtkStack and GtkStackSwitcher
- Date: Tue, 20 Oct 2020 05:15:36 +0000 (UTC)
commit 7c47b6907b6b7ca8787a952c367d098315710a4b
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Oct 20 00:46:07 2020 -0400
a11y: Add tests for GtkStack and GtkStackSwitcher
Test that the roles, states and relations are
as expected.
testsuite/a11y/meson.build | 1 +
testsuite/a11y/stack.c | 111 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 112 insertions(+)
---
diff --git a/testsuite/a11y/meson.build b/testsuite/a11y/meson.build
index bed847ec91..fa708ae3c6 100644
--- a/testsuite/a11y/meson.build
+++ b/testsuite/a11y/meson.build
@@ -25,6 +25,7 @@ tests = [
{ 'name': 'searchentry' },
{ 'name': 'separator' },
{ 'name': 'spinbutton' },
+ { 'name': 'stack' },
{ 'name': 'switch' },
{ 'name': 'textview' },
{ 'name': 'window' },
diff --git a/testsuite/a11y/stack.c b/testsuite/a11y/stack.c
new file mode 100644
index 0000000000..3f092c9f55
--- /dev/null
+++ b/testsuite/a11y/stack.c
@@ -0,0 +1,111 @@
+#include <gtk/gtk.h>
+
+static void
+stack_role (void)
+{
+ GtkWidget *stack = gtk_stack_new ();
+ GtkWidget *child1 = gtk_label_new ("a");
+ GtkWidget *child2 = gtk_label_new ("b");
+ GtkWidget *switcher = gtk_stack_switcher_new ();
+ GtkWidget *child;
+ GtkStackPage *page;
+
+ g_object_ref_sink (stack);
+ g_object_ref_sink (switcher);
+
+ gtk_stack_add_named (GTK_STACK (stack), child1, "a");
+ gtk_stack_add_named (GTK_STACK (stack), child2, "b");
+
+ gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack));
+
+ gtk_test_accessible_assert_role (GTK_ACCESSIBLE (stack), GTK_ACCESSIBLE_ROLE_WIDGET);
+ gtk_test_accessible_assert_role (GTK_ACCESSIBLE (switcher), GTK_ACCESSIBLE_ROLE_TAB_LIST);
+
+ child = gtk_widget_get_first_child (switcher);
+ page = gtk_stack_get_page (GTK_STACK (stack), child1);
+ gtk_test_accessible_assert_role (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_ROLE_TAB);
+ gtk_test_accessible_assert_role (GTK_ACCESSIBLE (page), GTK_ACCESSIBLE_ROLE_TAB_PANEL);
+
+ child = gtk_widget_get_last_child (switcher);
+ page = gtk_stack_get_page (GTK_STACK (stack), child2);
+ gtk_test_accessible_assert_role (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_ROLE_TAB);
+ gtk_test_accessible_assert_role (GTK_ACCESSIBLE (page), GTK_ACCESSIBLE_ROLE_TAB_PANEL);
+
+ g_object_unref (stack);
+ g_object_unref (switcher);
+}
+
+static void
+stack_state (void)
+{
+ GtkWidget *stack = gtk_stack_new ();
+ GtkWidget *child1 = gtk_label_new ("a");
+ GtkWidget *child2 = gtk_label_new ("b");
+ GtkWidget *switcher = gtk_stack_switcher_new ();
+ GtkWidget *child;
+
+ g_object_ref_sink (stack);
+ g_object_ref_sink (switcher);
+
+ gtk_stack_add_named (GTK_STACK (stack), child1, "a");
+ gtk_stack_add_named (GTK_STACK (stack), child2, "b");
+
+ gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack));
+
+ child = gtk_widget_get_first_child (switcher);
+ gtk_test_accessible_assert_state (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_STATE_SELECTED, TRUE);
+
+ child = gtk_widget_get_last_child (switcher);
+ gtk_test_accessible_assert_state (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_STATE_SELECTED, FALSE);
+
+ g_object_unref (stack);
+ g_object_unref (switcher);
+}
+
+static void
+stack_relations (void)
+{
+ GtkWidget *stack = gtk_stack_new ();
+ GtkWidget *child1 = gtk_label_new ("a");
+ GtkWidget *child2 = gtk_label_new ("b");
+ GtkWidget *switcher = gtk_stack_switcher_new ();
+ GtkWidget *child;
+ GtkStackPage *page;
+ GList *list;
+
+ g_object_ref_sink (stack);
+ g_object_ref_sink (switcher);
+
+ gtk_stack_add_named (GTK_STACK (stack), child1, "a");
+ gtk_stack_add_named (GTK_STACK (stack), child2, "b");
+
+ gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack));
+
+ child = gtk_widget_get_first_child (switcher);
+ page = gtk_stack_get_page (GTK_STACK (stack), child1);
+ list = g_list_append (NULL, page);
+ gtk_test_accessible_assert_relation (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_RELATION_CONTROLS, list);
+ g_list_free (list);
+
+ child = gtk_widget_get_last_child (switcher);
+ page = gtk_stack_get_page (GTK_STACK (stack), child2);
+ list = g_list_append (NULL, page);
+ gtk_test_accessible_assert_relation (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_RELATION_CONTROLS, list);
+ g_list_free (list);
+
+ g_object_unref (stack);
+ g_object_unref (switcher);
+}
+
+int
+main (int argc, char *argv[])
+{
+ gtk_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/a11y/stack/role", stack_role);
+ g_test_add_func ("/a11y/stack/state", stack_state);
+ g_test_add_func ("/a11y/stack/relations", stack_relations);
+
+ return g_test_run ();
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]