Handle AtkValue implementations that return integer values

We do this by transforming the returned GValue to a string.
As a side-effect, the formatting for doubles changes, so
adjust expected output to match.
This commit is contained in:
Matthias Clasen 2011-06-21 18:01:26 -04:00
parent 8fdcb60c87
commit dbf204b5b9
2 changed files with 40 additions and 9 deletions

View File

@ -396,17 +396,48 @@ dump_atk_value (AtkValue *atk_value,
GString *string)
{
GValue value = { 0, };
GValue svalue = { 0, };
g_string_append_printf (string, "%*s<AtkValue>\n", depth, "");
g_value_init (&value, G_TYPE_DOUBLE);
g_value_init (&svalue, G_TYPE_STRING);
atk_value_get_minimum_value (atk_value, &value);
g_string_append_printf (string, "%*sminimum value: %g\n", depth, "", g_value_get_double (&value));
if (g_value_transform (&value, &svalue))
g_string_append_printf (string, "%*sminimum value: %s\n", depth, "", g_value_get_string (&svalue));
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);
g_string_append_printf (string, "%*smaximum value: %g\n", depth, "", g_value_get_double (&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);
g_string_append_printf (string, "%*scurrent value: %g\n", depth, "", g_value_get_double (&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);
atk_value_get_minimum_increment (atk_value, &value);
g_string_append_printf (string, "%*sminimum increment: %g\n", depth, "", g_value_get_double (&value));
if (g_value_transform (&value, &svalue))
g_string_append_printf (string, "%*sminimum increment: %s\n", depth, "", g_value_get_string (&svalue));
else
g_string_append_printf (string, "%*sminimum increment: %s\n", depth, "", G_VALUE_TYPE_NAME (&value));
g_value_reset (&value);
g_value_reset (&svalue);
}
static void

View File

@ -16,7 +16,7 @@ window1
layer: widget
alpha: 1
<AtkText>
text: 45.5
text: ?45.5
character count: 5
caret offset: 0
default attributes: left-margin: 0
@ -49,7 +49,7 @@ window1
<AtkAction>
action 0 name: activate
<AtkValue>
minimum value: 0.5
maximum value: 99.5
current value: 45.5
minimum increment: 0.5
minimum value: 0.500000
maximum value: 99.500000
current value: 45.500000
minimum increment: 0.500000