gtk/testsuite/a11y/scrollbar.c
Emmanuele Bassi c264254d4b a11y: Parse reference lists using varargs
Using GList is a bit lame, and makes the API more complicated to use
than necessary in the common case.

The only real use case for a GList is gtk_widget_add_mnemonic_label(),
and for that we can use the GValue-based API instead.

Fixes: #3343
2020-11-10 14:31:56 +00:00

90 lines
2.9 KiB
C

#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);
}
static void
scrollbar_relations (void)
{
GtkWidget *sw = gtk_scrolled_window_new ();
GtkWidget *hscrollbar;
GtkWidget *vscrollbar;
GtkWidget *child;
g_object_ref_sink (sw);
hscrollbar = gtk_scrolled_window_get_hscrollbar (GTK_SCROLLED_WINDOW (sw));
vscrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (sw));
gtk_test_accessible_assert_relation (hscrollbar, GTK_ACCESSIBLE_RELATION_CONTROLS, NULL);
gtk_test_accessible_assert_relation (vscrollbar, GTK_ACCESSIBLE_RELATION_CONTROLS, NULL);
child = gtk_text_view_new ();
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), child);
gtk_test_accessible_assert_relation (hscrollbar, GTK_ACCESSIBLE_RELATION_CONTROLS, child, NULL);
gtk_test_accessible_assert_relation (vscrollbar, GTK_ACCESSIBLE_RELATION_CONTROLS, child, NULL);
g_object_unref (sw);
}
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);
g_test_add_func ("/a11y/scrollbar/relations", scrollbar_relations);
return g_test_run ();
}