a11y: Add scrollbar tests

Tests the fix in the previous commit.
This commit is contained in:
Matthias Clasen 2020-07-27 20:28:19 -04:00
parent e10aedccc6
commit 9190e95df9
2 changed files with 64 additions and 0 deletions

View File

@ -15,6 +15,7 @@ tests = [
{ 'name': 'checkbutton' },
{ 'name': 'dialog' },
{ 'name': 'progressbar' },
{ 'name': 'scrollbar' },
{ 'name': 'separator' },
{ 'name': 'switch' },
{ 'name': 'window' },

View File

@ -0,0 +1,63 @@
#include <gtk/gtk.h>
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 ();
}