[glib] test default GSimpleAction activation
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] test default GSimpleAction activation
- Date: Tue, 21 Jan 2014 20:15:51 +0000 (UTC)
commit 829464a3c7b3054ba4d73a9b217a6db466dabc88
Author: Ryan Lortie <desrt desrt ca>
Date: Sat Jan 18 14:29:16 2014 -0500
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 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/actions.c b/gio/tests/actions.c
index b33ff84..35de47f 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]