From 829464a3c7b3054ba4d73a9b217a6db466dabc88 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Sat, 18 Jan 2014 14:29:16 -0500 Subject: [PATCH] test default GSimpleAction activation Test the default handling of the "activate" signal on GSimpleAction. https://bugzilla.gnome.org/show_bug.cgi?id=722503 --- gio/tests/actions.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/gio/tests/actions.c b/gio/tests/actions.c index b33ff8485..35de47f4e 100644 --- a/gio/tests/actions.c +++ b/gio/tests/actions.c @@ -301,6 +301,34 @@ test_stateful (void) g_object_unref (action); } +static void +test_default_activate (void) +{ + GSimpleAction *action; + GVariant *state; + + /* Test changing state via activation with parameter */ + action = g_simple_action_new_stateful ("foo", G_VARIANT_TYPE_STRING, g_variant_new_string ("hihi")); + g_action_activate (G_ACTION (action), g_variant_new_string ("bye")); + state = g_action_get_state (G_ACTION (action)); + g_assert_cmpstr (g_variant_get_string (state, NULL), ==, "bye"); + g_variant_unref (state); + g_object_unref (action); + + /* Test toggling a boolean action via activation with no parameter */ + action = g_simple_action_new_stateful ("foo", NULL, g_variant_new_boolean (FALSE)); + g_action_activate (G_ACTION (action), NULL); + state = g_action_get_state (G_ACTION (action)); + g_assert (g_variant_get_boolean (state)); + g_variant_unref (state); + /* and back again */ + g_action_activate (G_ACTION (action), NULL); + state = g_action_get_state (G_ACTION (action)); + g_assert (!g_variant_get_boolean (state)); + g_variant_unref (state); + g_object_unref (action); +} + static gboolean foo_activated = FALSE; static gboolean bar_activated = FALSE; @@ -1133,6 +1161,7 @@ main (int argc, char **argv) g_test_add_func ("/actions/name", test_name); g_test_add_func ("/actions/simplegroup", test_simple_group); g_test_add_func ("/actions/stateful", test_stateful); + g_test_add_func ("/actions/default-activate", test_default_activate); g_test_add_func ("/actions/entries", test_entries); g_test_add_func ("/actions/parse-detailed", test_parse_detailed); g_test_add_func ("/actions/dbus/export", test_dbus_export);