forked from AuroraMiddleware/gtk
a11y tests: Use the new AtkValue interface
The old interface is deprecated, and we just implemented the new one, so lets test it.
This commit is contained in:
parent
47094a2a8a
commit
4fc256de8a
@ -427,40 +427,34 @@ dump_atk_value (AtkValue *atk_value,
|
||||
guint depth,
|
||||
GString *string)
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
GValue svalue = G_VALUE_INIT;
|
||||
AtkRange *range;
|
||||
gdouble value;
|
||||
gchar *text;
|
||||
|
||||
value = 0.0;
|
||||
text = NULL;
|
||||
|
||||
atk_value_get_value_and_text (atk_value, &value, &text);
|
||||
range = atk_value_get_range (atk_value);
|
||||
|
||||
g_string_append_printf (string, "%*s<AtkValue>\n", depth, "");
|
||||
|
||||
g_value_init (&value, G_TYPE_DOUBLE);
|
||||
g_value_init (&svalue, G_TYPE_STRING);
|
||||
if (range)
|
||||
{
|
||||
g_string_append_printf (string, "%*sminimum value: %f\n", depth, "", atk_range_get_lower_limit (range));
|
||||
|
||||
atk_value_get_minimum_value (atk_value, &value);
|
||||
if (g_value_transform (&value, &svalue))
|
||||
g_string_append_printf (string, "%*sminimum value: %s\n", depth, "", g_value_get_string (&svalue));
|
||||
g_string_append_printf (string, "%*smaximum value: %f\n", depth, "", atk_range_get_upper_limit (range));
|
||||
|
||||
atk_range_free (range);
|
||||
}
|
||||
|
||||
if (text)
|
||||
{
|
||||
g_string_append_printf (string, "%*scurrent value: %f %s\n", depth, "", value, text);
|
||||
g_free (text);
|
||||
}
|
||||
else
|
||||
g_string_append_printf (string, "%*sminimum value: <%s>\n", depth, "", G_VALUE_TYPE_NAME (&value));
|
||||
|
||||
g_value_reset (&value);
|
||||
g_value_reset (&svalue);
|
||||
|
||||
atk_value_get_maximum_value (atk_value, &value);
|
||||
if (g_value_transform (&value, &svalue))
|
||||
g_string_append_printf (string, "%*smaximum value: %s\n", depth, "", g_value_get_string (&svalue));
|
||||
else
|
||||
g_string_append_printf (string, "%*smaximum value: <%s>\n", depth, "", G_VALUE_TYPE_NAME (&value));
|
||||
|
||||
g_value_reset (&value);
|
||||
g_value_reset (&svalue);
|
||||
|
||||
atk_value_get_current_value (atk_value, &value);
|
||||
if (g_value_transform (&value, &svalue))
|
||||
g_string_append_printf (string, "%*scurrent value: %s\n", depth, "", g_value_get_string (&svalue));
|
||||
else
|
||||
g_string_append_printf (string, "%*scurrent value: %s\n", depth, "", G_VALUE_TYPE_NAME (&value));
|
||||
|
||||
g_value_reset (&value);
|
||||
g_value_reset (&svalue);
|
||||
g_string_append_printf (string, "%*scurrent value: %f\n", depth, "", value);
|
||||
|
||||
/* Don't dump minimum increment; it changes too much in response to
|
||||
* theme changes.
|
||||
|
@ -63,7 +63,8 @@ test_basic (GtkWidget *widget)
|
||||
AtkObject *atk_object;
|
||||
AtkValue *atk_value;
|
||||
gdouble value = 50;
|
||||
GValue ret;
|
||||
gdouble ret;
|
||||
gchar *text;
|
||||
|
||||
atk_object = gtk_widget_get_accessible (widget);
|
||||
atk_value = ATK_VALUE (atk_object);
|
||||
@ -74,9 +75,10 @@ test_basic (GtkWidget *widget)
|
||||
g_assert_cmpint (notify_data.count, ==, 1);
|
||||
g_assert_cmpstr (notify_data.last_name, ==, "accessible-value");
|
||||
|
||||
memset (&ret, 0, sizeof (ret));
|
||||
atk_value_get_current_value (atk_value, &ret);
|
||||
g_assert_cmpfloat (g_value_get_double (&ret), ==, value);
|
||||
text = NULL;
|
||||
atk_value_get_value_and_text (atk_value, &ret, &text);
|
||||
g_assert_cmpfloat (ret, ==, value);
|
||||
g_free (text);
|
||||
|
||||
g_free (notify_data.last_name);
|
||||
g_signal_handlers_disconnect_by_func (atk_object, G_CALLBACK (notify_cb), ¬ify_data);
|
||||
|
Loading…
Reference in New Issue
Block a user