From ac0fcc55a6f8201a9645d52fa3582e01665d4c39 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sun, 26 Jul 2020 20:30:35 +0100 Subject: [PATCH] a11y: Add a simple test case for GtkButton's accessible state --- testsuite/a11y/button.c | 37 +++++++++++++++++++++++++++++++++++++ testsuite/a11y/meson.build | 1 + 2 files changed, 38 insertions(+) create mode 100644 testsuite/a11y/button.c diff --git a/testsuite/a11y/button.c b/testsuite/a11y/button.c new file mode 100644 index 0000000000..9c5fdad777 --- /dev/null +++ b/testsuite/a11y/button.c @@ -0,0 +1,37 @@ +#include + +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); +} + +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); + + return g_test_run (); +} diff --git a/testsuite/a11y/meson.build b/testsuite/a11y/meson.build index ec50ba4273..9f0f45738b 100644 --- a/testsuite/a11y/meson.build +++ b/testsuite/a11y/meson.build @@ -10,6 +10,7 @@ testdatadir = join_paths(installed_test_datadir, 'gtk') # - 'link_args': (array): additional linker arguments # - 'suites': (array): additional test suites tests = [ + { 'name': 'button' }, ]