From: Ryan Lortie Date: Wed, 29 Jun 2011 15:10:38 +0000 (+0100) Subject: actions: merge testcases change_state and entries X-Git-Tag: 2.29.10~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e6a25caa82410038e635c30deefbe3d0812aa9d3;p=platform%2Fupstream%2Fglib.git actions: merge testcases change_state and entries Since we have support for change_state in GActionEntry now. --- diff --git a/gio/tests/actions.c b/gio/tests/actions.c index 757ecc9..44da440 100644 --- a/gio/tests/actions.c +++ b/gio/tests/actions.c @@ -278,14 +278,30 @@ activate_bar (GSimpleAction *simple, } static void +change_volume_state (GSimpleAction *action, + GVariant *value, + gpointer user_data) +{ + gint requested; + + requested = g_variant_get_int32 (value); + + /* Volume only goes from 0 to 10 */ + if (0 <= requested && requested <= 10) + g_simple_action_set_state (action, value); +} + +static void test_entries (void) { const GActionEntry entries[] = { - { "foo", activate_foo }, - { "bar", activate_bar, "s" }, - { "toggle", NULL, NULL, "false" } + { "foo", activate_foo }, + { "bar", activate_bar, "s" }, + { "toggle", NULL, NULL, "false" }, + { "volume", NULL, NULL, "0", change_volume_state } }; GSimpleActionGroup *actions; + GVariant *state; actions = g_simple_action_group_new (); g_simple_action_group_add_entries (actions, entries, @@ -325,51 +341,25 @@ test_entries (void) } g_test_trap_assert_failed (); - g_object_unref (actions); -} - - -/* /actions/change-state */ -static void -change_volume_state (GSimpleAction *action, - GVariant *value, - gpointer user_data) -{ - gint requested; - - requested = g_variant_get_int32 (value); - - /* Volume only goes from 0 to 10 */ - if (0 <= requested && requested <= 10) - g_simple_action_set_state (action, value); -} - -static void -test_change_state (void) -{ - GSimpleAction *action; - GVariant *state; - - action = g_simple_action_new_stateful ("volume", NULL, - g_variant_new_int32 (0)); - g_signal_connect (action, "change-state", - G_CALLBACK (change_volume_state), NULL); - - state = g_action_get_state (G_ACTION (action)); + state = g_action_group_get_action_state (G_ACTION_GROUP (actions), "volume"); g_assert_cmpint (g_variant_get_int32 (state), ==, 0); g_variant_unref (state); /* should change */ - g_action_change_state (G_ACTION (action), g_variant_new_int32 (7)); - state = g_action_get_state (G_ACTION (action)); + g_action_group_change_action_state (G_ACTION_GROUP (actions), "volume", + g_variant_new_int32 (7)); + state = g_action_group_get_action_state (G_ACTION_GROUP (actions), "volume"); g_assert_cmpint (g_variant_get_int32 (state), ==, 7); g_variant_unref (state); /* should not change */ - g_action_change_state (G_ACTION (action), g_variant_new_int32 (11)); - state = g_action_get_state (G_ACTION (action)); + g_action_group_change_action_state (G_ACTION_GROUP (actions), "volume", + g_variant_new_int32 (11)); + state = g_action_group_get_action_state (G_ACTION_GROUP (actions), "volume"); g_assert_cmpint (g_variant_get_int32 (state), ==, 7); g_variant_unref (state); + + g_object_unref (actions); } int @@ -382,7 +372,6 @@ main (int argc, char **argv) g_test_add_func ("/actions/simplegroup", test_simple_group); g_test_add_func ("/actions/stateful", test_stateful); g_test_add_func ("/actions/entries", test_entries); - g_test_add_func ("/actions/change-state", test_change_state); return g_test_run (); }