mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
a11y: Add more tests
Test some of the attributes that GTK maintains for every widget.
This commit is contained in:
parent
13b9b9b7d8
commit
37d4932b31
94
testsuite/a11y/general.c
Normal file
94
testsuite/a11y/general.c
Normal file
@ -0,0 +1,94 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
/* Some of the accessible attributes are general enough
|
||||
* that GTK maintains them for every widget. These tests
|
||||
* are checking them.
|
||||
*/
|
||||
|
||||
static void
|
||||
test_hidden (void)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_button_new ();
|
||||
g_object_ref_sink (widget);
|
||||
|
||||
gtk_test_accessible_assert_state (widget, GTK_ACCESSIBLE_STATE_HIDDEN, FALSE);
|
||||
|
||||
gtk_widget_hide (widget);
|
||||
|
||||
gtk_test_accessible_assert_state (widget, GTK_ACCESSIBLE_STATE_HIDDEN, TRUE);
|
||||
|
||||
g_object_unref (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
test_disabled (void)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_expander_new ("");
|
||||
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
|
||||
test_orientation (void)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, NULL);
|
||||
g_object_ref_sink (widget);
|
||||
|
||||
gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_ORIENTATION, GTK_ORIENTATION_HORIZONTAL);
|
||||
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (widget), GTK_ORIENTATION_VERTICAL);
|
||||
|
||||
gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_ORIENTATION, GTK_ORIENTATION_VERTICAL);
|
||||
|
||||
g_object_unref (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
test_labelled_by (void)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkWidget *label;
|
||||
GList *list;
|
||||
|
||||
widget = gtk_switch_new ();
|
||||
g_object_ref_sink (widget);
|
||||
|
||||
gtk_test_accessible_assert_relation (widget, GTK_ACCESSIBLE_RELATION_LABELLED_BY, NULL);
|
||||
|
||||
label = gtk_label_new ("Switch");
|
||||
g_object_ref_sink (label);
|
||||
gtk_widget_add_mnemonic_label (widget, label);
|
||||
|
||||
list = g_list_append (NULL, label);
|
||||
gtk_test_accessible_assert_relation (widget, GTK_ACCESSIBLE_RELATION_LABELLED_BY, list);
|
||||
g_list_free (list);
|
||||
|
||||
g_object_unref (widget);
|
||||
g_object_unref (label);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/a11y/general/hidden", test_hidden);
|
||||
g_test_add_func ("/a11y/general/disabled", test_disabled);
|
||||
g_test_add_func ("/a11y/general/orientation", test_orientation);
|
||||
g_test_add_func ("/a11y/general/labelled-by", test_labelled_by);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
@ -17,6 +17,7 @@ tests = [
|
||||
{ 'name': 'entry' },
|
||||
{ 'name': 'expander' },
|
||||
{ 'name': 'flowbox' },
|
||||
{ 'name': 'general' },
|
||||
{ 'name': 'image' },
|
||||
{ 'name': 'label' },
|
||||
{ 'name': 'listbox' },
|
||||
|
Loading…
Reference in New Issue
Block a user