mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 05:50:10 +00:00
testsuite: Add some more a11y tests
Test that overriding roles works, both via g_object_new, and via ui files.
This commit is contained in:
parent
7669198d2c
commit
c2735f98b4
@ -25,6 +25,7 @@ entry_properties (void)
|
||||
|
||||
gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER, "Hello");
|
||||
gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_READ_ONLY, TRUE);
|
||||
gtk_test_accessible_assert_property (widget, GTK_ACCESSIBLE_PROPERTY_HAS_POPUP, TRUE);
|
||||
|
||||
g_object_unref (widget);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ tests = [
|
||||
{ 'name': 'stack' },
|
||||
{ 'name': 'switch' },
|
||||
{ 'name': 'textview' },
|
||||
{ 'name': 'togglebutton' },
|
||||
{ 'name': 'window' },
|
||||
]
|
||||
|
||||
|
91
testsuite/a11y/togglebutton.c
Normal file
91
testsuite/a11y/togglebutton.c
Normal file
@ -0,0 +1,91 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
toggle_button_role (void)
|
||||
{
|
||||
GtkWidget *button = gtk_toggle_button_new ();
|
||||
g_object_ref_sink (button);
|
||||
|
||||
gtk_test_accessible_assert_role (button, GTK_ACCESSIBLE_ROLE_TOGGLE_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
|
||||
toggle_button_label (void)
|
||||
{
|
||||
GtkWidget *button = gtk_toggle_button_new_with_label ("Hello");
|
||||
g_object_ref_sink (button);
|
||||
|
||||
gtk_test_accessible_assert_relation (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, gtk_widget_get_first_child (button), NULL);
|
||||
|
||||
g_object_unref (button);
|
||||
}
|
||||
|
||||
/* Check that we set up a labelled_by relationship between a button
|
||||
* and its label.
|
||||
*/
|
||||
static void
|
||||
toggle_button_relation (void)
|
||||
{
|
||||
GtkWidget *button = gtk_toggle_button_new_with_mnemonic ("_Hello");
|
||||
|
||||
g_object_ref_sink (button);
|
||||
|
||||
gtk_test_accessible_assert_relation (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_RELATION_LABELLED_BY, gtk_widget_get_first_child (button), NULL);
|
||||
|
||||
g_object_unref (button);
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_button_generic (void)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GtkWidget *button;
|
||||
GError *error = NULL;
|
||||
|
||||
button = g_object_new (GTK_TYPE_TOGGLE_BUTTON,
|
||||
"accessible-role", GTK_ACCESSIBLE_ROLE_GENERIC,
|
||||
NULL);
|
||||
|
||||
g_object_ref_sink (button);
|
||||
|
||||
gtk_test_accessible_assert_role (button, GTK_ACCESSIBLE_ROLE_GENERIC);
|
||||
|
||||
g_object_unref (button);
|
||||
|
||||
builder = gtk_builder_new ();
|
||||
|
||||
gtk_builder_add_from_string (builder,
|
||||
"<interface>"
|
||||
" <object class='GtkToggleButton' id='togglebutton'>"
|
||||
" <property name='accessible-role'>generic</property>"
|
||||
" </object>"
|
||||
"</interface>",
|
||||
-1, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
button = GTK_WIDGET (gtk_builder_get_object (builder, "togglebutton"));
|
||||
|
||||
gtk_test_accessible_assert_role (button, GTK_ACCESSIBLE_ROLE_GENERIC);
|
||||
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/a11y/togglebutton/role", toggle_button_role);
|
||||
g_test_add_func ("/a11y/togglebutton/label", toggle_button_label);
|
||||
g_test_add_func ("/a11y/togglebutton/relation", toggle_button_relation);
|
||||
g_test_add_func ("/a11y/togglebutton/generic", toggle_button_generic);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
Loading…
Reference in New Issue
Block a user