From d2c5e3f2b39504390536553b33ed3dd232346273 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 27 Jul 2020 19:58:08 -0400 Subject: [PATCH] a11y: Add switch tests Tests the fix in the previous commit. --- testsuite/a11y/meson.build | 1 + testsuite/a11y/switch.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 testsuite/a11y/switch.c diff --git a/testsuite/a11y/meson.build b/testsuite/a11y/meson.build index 7a18db587a..f16be43cd7 100644 --- a/testsuite/a11y/meson.build +++ b/testsuite/a11y/meson.build @@ -16,6 +16,7 @@ tests = [ { 'name': 'dialog' }, { 'name': 'progressbar' }, { 'name': 'separator' }, + { 'name': 'switch' }, { 'name': 'window' }, ] diff --git a/testsuite/a11y/switch.c b/testsuite/a11y/switch.c new file mode 100644 index 0000000000..215c8da1af --- /dev/null +++ b/testsuite/a11y/switch.c @@ -0,0 +1,38 @@ +#include + +static void +switch_role (void) +{ + GtkWidget *widget = gtk_switch_new (); + g_object_ref_sink (widget); + + gtk_test_accessible_assert_role (widget, GTK_ACCESSIBLE_ROLE_SWITCH); + + g_object_unref (widget); +} + +static void +switch_state (void) +{ + GtkWidget *widget = gtk_switch_new (); + g_object_ref_sink (widget); + + gtk_test_accessible_assert_state (widget, GTK_ACCESSIBLE_STATE_CHECKED, FALSE); + + gtk_switch_set_active (GTK_SWITCH (widget), TRUE); + + gtk_test_accessible_assert_state (widget, GTK_ACCESSIBLE_STATE_CHECKED, TRUE); + + g_object_unref (widget); +} + +int +main (int argc, char *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + + g_test_add_func ("/a11y/switch/role", switch_role); + g_test_add_func ("/a11y/switch/state", switch_state); + + return g_test_run (); +}