forked from AuroraMiddleware/gtk
Merge branch 'matthiasc/for-master' into 'master'
Some more a11y tests See merge request GNOME/gtk!2726
This commit is contained in:
commit
5504278b78
66
testsuite/a11y/flowbox.c
Normal file
66
testsuite/a11y/flowbox.c
Normal file
@ -0,0 +1,66 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
flowbox_role (void)
|
||||
{
|
||||
GtkWidget *widget = gtk_flow_box_new ();
|
||||
|
||||
g_object_ref_sink (widget);
|
||||
|
||||
gtk_flow_box_insert (GTK_FLOW_BOX (widget), gtk_label_new ("a"), 0);
|
||||
|
||||
gtk_test_accessible_assert_role (GTK_ACCESSIBLE (widget), GTK_ACCESSIBLE_ROLE_GRID);
|
||||
gtk_test_accessible_assert_role (GTK_ACCESSIBLE (gtk_widget_get_first_child (widget)), GTK_ACCESSIBLE_ROLE_GRID_CELL);
|
||||
|
||||
g_object_unref (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
flowbox_state (void)
|
||||
{
|
||||
GtkWidget *window = gtk_window_new ();
|
||||
GtkWidget *widget = gtk_flow_box_new ();
|
||||
|
||||
gtk_window_set_child (GTK_WINDOW (window), widget);
|
||||
|
||||
gtk_flow_box_insert (GTK_FLOW_BOX (widget), gtk_label_new ("a"), 0);
|
||||
|
||||
gtk_test_accessible_assert_state (GTK_ACCESSIBLE (gtk_widget_get_first_child (widget)), GTK_ACCESSIBLE_STATE_SELECTED, FALSE);
|
||||
|
||||
gtk_flow_box_select_child (GTK_FLOW_BOX (widget),
|
||||
GTK_FLOW_BOX_CHILD (gtk_widget_get_first_child (widget)));
|
||||
|
||||
gtk_test_accessible_assert_state (GTK_ACCESSIBLE (gtk_widget_get_first_child (widget)), GTK_ACCESSIBLE_STATE_SELECTED, TRUE);
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
}
|
||||
|
||||
static void
|
||||
flowbox_properties (void)
|
||||
{
|
||||
GtkWidget *widget = gtk_flow_box_new ();
|
||||
|
||||
g_object_ref_sink (widget);
|
||||
|
||||
gtk_flow_box_insert (GTK_FLOW_BOX (widget), gtk_label_new ("a"), 0);
|
||||
|
||||
gtk_test_accessible_assert_property (GTK_ACCESSIBLE (widget), GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE, FALSE);
|
||||
|
||||
gtk_flow_box_set_selection_mode (GTK_FLOW_BOX (widget), GTK_SELECTION_MULTIPLE);
|
||||
|
||||
gtk_test_accessible_assert_property (GTK_ACCESSIBLE (widget), GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE, TRUE);
|
||||
|
||||
g_object_unref (widget);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/a11y/flowbox/role", flowbox_role);
|
||||
g_test_add_func ("/a11y/flowbox/state", flowbox_state);
|
||||
g_test_add_func ("/a11y/flowbox/properties", flowbox_properties);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
@ -44,6 +44,22 @@ label_relations (void)
|
||||
g_object_unref (label2);
|
||||
}
|
||||
|
||||
static void
|
||||
label_properties (void)
|
||||
{
|
||||
GtkWidget *label = gtk_label_new ("a");
|
||||
|
||||
g_object_ref_sink (label);
|
||||
|
||||
gtk_test_accessible_assert_property (label, GTK_ACCESSIBLE_PROPERTY_LABEL, "a");
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (label), "b");
|
||||
|
||||
gtk_test_accessible_assert_property (label, GTK_ACCESSIBLE_PROPERTY_LABEL, "b");
|
||||
|
||||
g_object_unref (label);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@ -51,6 +67,7 @@ main (int argc, char *argv[])
|
||||
|
||||
g_test_add_func ("/a11y/label/role", label_role);
|
||||
g_test_add_func ("/a11y/label/relations", label_relations);
|
||||
g_test_add_func ("/a11y/label/properties", label_properties);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
66
testsuite/a11y/listbox.c
Normal file
66
testsuite/a11y/listbox.c
Normal file
@ -0,0 +1,66 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
listbox_role (void)
|
||||
{
|
||||
GtkWidget *widget = gtk_list_box_new ();
|
||||
|
||||
g_object_ref_sink (widget);
|
||||
|
||||
gtk_list_box_append (GTK_LIST_BOX (widget), gtk_label_new ("a"));
|
||||
|
||||
gtk_test_accessible_assert_role (GTK_ACCESSIBLE (widget), GTK_ACCESSIBLE_ROLE_LIST);
|
||||
gtk_test_accessible_assert_role (GTK_ACCESSIBLE (gtk_widget_get_first_child (widget)), GTK_ACCESSIBLE_ROLE_LIST_ITEM);
|
||||
|
||||
g_object_unref (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
listbox_state (void)
|
||||
{
|
||||
GtkWidget *window = gtk_window_new ();
|
||||
GtkWidget *widget = gtk_list_box_new ();
|
||||
|
||||
gtk_window_set_child (GTK_WINDOW (window), widget);
|
||||
|
||||
gtk_list_box_append (GTK_LIST_BOX (widget), gtk_label_new ("a"));
|
||||
|
||||
gtk_test_accessible_assert_state (GTK_ACCESSIBLE (gtk_widget_get_first_child (widget)), GTK_ACCESSIBLE_STATE_SELECTED, FALSE);
|
||||
|
||||
gtk_list_box_select_row (GTK_LIST_BOX (widget),
|
||||
GTK_LIST_BOX_ROW (gtk_widget_get_first_child (widget)));
|
||||
|
||||
gtk_test_accessible_assert_state (GTK_ACCESSIBLE (gtk_widget_get_first_child (widget)), GTK_ACCESSIBLE_STATE_SELECTED, TRUE);
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
}
|
||||
|
||||
static void
|
||||
listbox_properties (void)
|
||||
{
|
||||
GtkWidget *widget = gtk_list_box_new ();
|
||||
|
||||
g_object_ref_sink (widget);
|
||||
|
||||
gtk_list_box_append (GTK_LIST_BOX (widget), gtk_label_new ("a"));
|
||||
|
||||
gtk_test_accessible_assert_property (GTK_ACCESSIBLE (widget), GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE, FALSE);
|
||||
|
||||
gtk_list_box_set_selection_mode (GTK_LIST_BOX (widget), GTK_SELECTION_MULTIPLE);
|
||||
|
||||
gtk_test_accessible_assert_property (GTK_ACCESSIBLE (widget), GTK_ACCESSIBLE_PROPERTY_MULTI_SELECTABLE, TRUE);
|
||||
|
||||
g_object_unref (widget);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/a11y/listbox/role", listbox_role);
|
||||
g_test_add_func ("/a11y/listbox/state", listbox_state);
|
||||
g_test_add_func ("/a11y/listbox/properties", listbox_properties);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
@ -16,8 +16,10 @@ tests = [
|
||||
{ 'name': 'dialog' },
|
||||
{ 'name': 'entry' },
|
||||
{ 'name': 'expander' },
|
||||
{ 'name': 'flowbox' },
|
||||
{ 'name': 'image' },
|
||||
{ 'name': 'label' },
|
||||
{ 'name': 'listbox' },
|
||||
{ 'name': 'levelbar' },
|
||||
{ 'name': 'passwordentry' },
|
||||
{ 'name': 'progressbar' },
|
||||
@ -25,6 +27,7 @@ tests = [
|
||||
{ 'name': 'searchentry' },
|
||||
{ 'name': 'separator' },
|
||||
{ 'name': 'spinbutton' },
|
||||
{ 'name': 'stack' },
|
||||
{ 'name': 'switch' },
|
||||
{ 'name': 'textview' },
|
||||
{ 'name': 'window' },
|
||||
|
111
testsuite/a11y/stack.c
Normal file
111
testsuite/a11y/stack.c
Normal file
@ -0,0 +1,111 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
stack_role (void)
|
||||
{
|
||||
GtkWidget *stack = gtk_stack_new ();
|
||||
GtkWidget *child1 = gtk_label_new ("a");
|
||||
GtkWidget *child2 = gtk_label_new ("b");
|
||||
GtkWidget *switcher = gtk_stack_switcher_new ();
|
||||
GtkWidget *child;
|
||||
GtkStackPage *page;
|
||||
|
||||
g_object_ref_sink (stack);
|
||||
g_object_ref_sink (switcher);
|
||||
|
||||
gtk_stack_add_named (GTK_STACK (stack), child1, "a");
|
||||
gtk_stack_add_named (GTK_STACK (stack), child2, "b");
|
||||
|
||||
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack));
|
||||
|
||||
gtk_test_accessible_assert_role (GTK_ACCESSIBLE (stack), GTK_ACCESSIBLE_ROLE_WIDGET);
|
||||
gtk_test_accessible_assert_role (GTK_ACCESSIBLE (switcher), GTK_ACCESSIBLE_ROLE_TAB_LIST);
|
||||
|
||||
child = gtk_widget_get_first_child (switcher);
|
||||
page = gtk_stack_get_page (GTK_STACK (stack), child1);
|
||||
gtk_test_accessible_assert_role (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_ROLE_TAB);
|
||||
gtk_test_accessible_assert_role (GTK_ACCESSIBLE (page), GTK_ACCESSIBLE_ROLE_TAB_PANEL);
|
||||
|
||||
child = gtk_widget_get_last_child (switcher);
|
||||
page = gtk_stack_get_page (GTK_STACK (stack), child2);
|
||||
gtk_test_accessible_assert_role (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_ROLE_TAB);
|
||||
gtk_test_accessible_assert_role (GTK_ACCESSIBLE (page), GTK_ACCESSIBLE_ROLE_TAB_PANEL);
|
||||
|
||||
g_object_unref (stack);
|
||||
g_object_unref (switcher);
|
||||
}
|
||||
|
||||
static void
|
||||
stack_state (void)
|
||||
{
|
||||
GtkWidget *stack = gtk_stack_new ();
|
||||
GtkWidget *child1 = gtk_label_new ("a");
|
||||
GtkWidget *child2 = gtk_label_new ("b");
|
||||
GtkWidget *switcher = gtk_stack_switcher_new ();
|
||||
GtkWidget *child;
|
||||
|
||||
g_object_ref_sink (stack);
|
||||
g_object_ref_sink (switcher);
|
||||
|
||||
gtk_stack_add_named (GTK_STACK (stack), child1, "a");
|
||||
gtk_stack_add_named (GTK_STACK (stack), child2, "b");
|
||||
|
||||
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack));
|
||||
|
||||
child = gtk_widget_get_first_child (switcher);
|
||||
gtk_test_accessible_assert_state (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_STATE_SELECTED, TRUE);
|
||||
|
||||
child = gtk_widget_get_last_child (switcher);
|
||||
gtk_test_accessible_assert_state (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_STATE_SELECTED, FALSE);
|
||||
|
||||
g_object_unref (stack);
|
||||
g_object_unref (switcher);
|
||||
}
|
||||
|
||||
static void
|
||||
stack_relations (void)
|
||||
{
|
||||
GtkWidget *stack = gtk_stack_new ();
|
||||
GtkWidget *child1 = gtk_label_new ("a");
|
||||
GtkWidget *child2 = gtk_label_new ("b");
|
||||
GtkWidget *switcher = gtk_stack_switcher_new ();
|
||||
GtkWidget *child;
|
||||
GtkStackPage *page;
|
||||
GList *list;
|
||||
|
||||
g_object_ref_sink (stack);
|
||||
g_object_ref_sink (switcher);
|
||||
|
||||
gtk_stack_add_named (GTK_STACK (stack), child1, "a");
|
||||
gtk_stack_add_named (GTK_STACK (stack), child2, "b");
|
||||
|
||||
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack));
|
||||
|
||||
child = gtk_widget_get_first_child (switcher);
|
||||
page = gtk_stack_get_page (GTK_STACK (stack), child1);
|
||||
list = g_list_append (NULL, page);
|
||||
gtk_test_accessible_assert_relation (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_RELATION_CONTROLS, list);
|
||||
g_list_free (list);
|
||||
|
||||
child = gtk_widget_get_last_child (switcher);
|
||||
page = gtk_stack_get_page (GTK_STACK (stack), child2);
|
||||
list = g_list_append (NULL, page);
|
||||
gtk_test_accessible_assert_relation (GTK_ACCESSIBLE (child), GTK_ACCESSIBLE_RELATION_CONTROLS, list);
|
||||
g_list_free (list);
|
||||
|
||||
g_object_unref (stack);
|
||||
g_object_unref (switcher);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gtk_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/a11y/stack/role", stack_role);
|
||||
g_test_add_func ("/a11y/stack/state", stack_state);
|
||||
g_test_add_func ("/a11y/stack/relations", stack_relations);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user