From 9190e95df944d308bfabe0553a07b983d5798dcc Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 27 Jul 2020 20:28:19 -0400 Subject: [PATCH] a11y: Add scrollbar tests Tests the fix in the previous commit. --- testsuite/a11y/meson.build | 1 + testsuite/a11y/scrollbar.c | 63 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 testsuite/a11y/scrollbar.c diff --git a/testsuite/a11y/meson.build b/testsuite/a11y/meson.build index f16be43cd7..e3250c3709 100644 --- a/testsuite/a11y/meson.build +++ b/testsuite/a11y/meson.build @@ -15,6 +15,7 @@ tests = [ { 'name': 'checkbutton' }, { 'name': 'dialog' }, { 'name': 'progressbar' }, + { 'name': 'scrollbar' }, { 'name': 'separator' }, { 'name': 'switch' }, { 'name': 'window' }, diff --git a/testsuite/a11y/scrollbar.c b/testsuite/a11y/scrollbar.c new file mode 100644 index 0000000000..3f1b86594f --- /dev/null +++ b/testsuite/a11y/scrollbar.c @@ -0,0 +1,63 @@ +#include + +static void +scrollbar_role (void) +{ + GtkWidget *widget = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, NULL); + g_object_ref_sink (widget); + + gtk_test_accessible_assert_role (widget, GTK_ACCESSIBLE_ROLE_SCROLLBAR); + + g_object_unref (widget); +} + +static void +scrollbar_state (void) +{ + GtkWidget *widget = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, NULL); + g_object_ref_sink (widget); + + gtk_test_accessible_assert_state (widget, GTK_ACCESSIBLE_STATE_DISABLED, FALSE); + + gtk_widget_set_sensitive (widget, FALSE); + + gtk_test_accessible_assert_state (widget, GTK_ACCESSIBLE_STATE_DISABLED, TRUE); + + g_object_unref (widget); +} + +static void +scrollbar_properties (void) +{ + GtkAdjustment *adj = gtk_adjustment_new (0.0, 0.0, 100.0, 1.0, 10.0, 10.0); + GtkWidget *widget = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, adj); + g_object_ref_sink (widget); + + gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_ORIENTATION, GTK_ORIENTATION_HORIZONTAL); + + gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, 100.); + gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, 0.); + gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, 0.); + + gtk_orientable_set_orientation (GTK_ORIENTABLE (widget), GTK_ORIENTATION_VERTICAL); + gtk_adjustment_set_value (adj, 50.0); + + gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_ORIENTATION, GTK_ORIENTATION_VERTICAL); + gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, 100.); + gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, 0.); + gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, 50.0); + + g_object_unref (widget); +} + +int +main (int argc, char *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + + g_test_add_func ("/a11y/scrollbar/role", scrollbar_role); + g_test_add_func ("/a11y/scrollbar/state", scrollbar_state); + g_test_add_func ("/a11y/scrollbar/properties", scrollbar_properties); + + return g_test_run (); +}