319
319
void check_header (const char * expected_label, const char * expected_icon, const char * expected_a11y)
322
const gchar * label = NULL;
323
const gchar * icon = NULL;
324
const gchar * a11y = NULL;
327
variant = g_action_group_get_action_state (G_ACTION_GROUP(action_group), "_header");
328
g_variant_get (variant, "(&s&s&sb)", &label, &icon, &a11y, &visible);
321
GVariant * state = g_action_group_get_action_state (G_ACTION_GROUP(action_group), "_header");
322
ASSERT_TRUE (state != NULL);
323
ASSERT_TRUE (g_variant_is_of_type (state, G_VARIANT_TYPE ("a{sv}")));
330
325
if (expected_label != NULL)
331
ASSERT_STREQ (expected_label, label);
327
GVariant * v = g_variant_lookup_value (state, "label", G_VARIANT_TYPE_STRING);
328
if (!v) // if no label in the state, expected_label must be an empty string
329
ASSERT_FALSE (*expected_label);
331
ASSERT_STREQ (expected_label, g_variant_get_string (v, NULL));
334
if (expected_a11y != NULL)
336
GVariant * v = g_variant_lookup_value (state, "accessible-desc", G_VARIANT_TYPE_STRING);
337
ASSERT_TRUE (v != NULL);
338
ASSERT_STREQ (expected_a11y, g_variant_get_string (v, NULL));
333
342
if (expected_icon != NULL)
334
ASSERT_STREQ (expected_icon, icon);
336
if (expected_a11y != NULL)
337
ASSERT_STREQ (expected_a11y, a11y);
344
GVariant * v = g_variant_lookup_value (state, "icon", NULL);
345
GIcon * expected = g_themed_icon_new (expected_icon);
346
GIcon * actual = g_icon_deserialize (v);
347
ASSERT_TRUE (g_icon_equal (expected, actual));
348
g_object_unref (actual);
349
g_object_unref (expected);
339
353
// the session menu is always visible...
354
gboolean visible = false;
355
g_variant_lookup (state, "visible", "b", &visible);
340
356
ASSERT_TRUE (visible);
342
g_variant_unref (variant);
358
g_variant_unref (state);
345
361
void check_label (const char * expected_label, GMenuModel * model, int pos)