summaryrefslogtreecommitdiff
path: root/gio
diff options
context:
space:
mode:
authorPaolo Borelli <pborelli@gnome.org>2012-11-24 19:12:13 +0100
committerPaolo Borelli <pborelli@gnome.org>2012-11-24 19:21:54 +0100
commitee8080cc0bda9141e323c01b12e812b1ab748e18 (patch)
tree8ed33fdb4fc345801f7d9e31f713f0d75378614d /gio
parent543bbd8752cf6370897c711afed3caa0663a4850 (diff)
downloadglib-ee8080cc0bda9141e323c01b12e812b1ab748e18.tar.gz
Add GApplication local_command_line test
Assert that startup and shutdown are not called if we return TRUE from local_command_line
Diffstat (limited to 'gio')
-rw-r--r--gio/tests/gapplication.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/gio/tests/gapplication.c b/gio/tests/gapplication.c
index 044bb3714..6e247a859 100644
--- a/gio/tests/gapplication.c
+++ b/gio/tests/gapplication.c
@@ -448,6 +448,61 @@ test_actions (void)
g_object_unref (app);
}
+typedef GApplication TestLocCmdApp;
+typedef GApplicationClass TestLocCmdAppClass;
+
+static GType test_loc_cmd_app_get_type (void);
+G_DEFINE_TYPE (TestLocCmdApp, test_loc_cmd_app, G_TYPE_APPLICATION)
+
+static void
+test_loc_cmd_app_init (TestLocCmdApp *app)
+{
+}
+
+static void
+test_loc_cmd_app_startup (GApplication *app)
+{
+ g_assert_not_reached ();
+}
+
+static void
+test_loc_cmd_app_shutdown (GApplication *app)
+{
+ g_assert_not_reached ();
+}
+
+static gboolean
+test_loc_cmd_app_local_command_line (GApplication *application,
+ gchar ***arguments,
+ gint *exit_status)
+{
+ return TRUE;
+}
+
+static void
+test_loc_cmd_app_class_init (TestLocCmdAppClass *klass)
+{
+ G_APPLICATION_CLASS (klass)->startup = test_loc_cmd_app_startup;
+ G_APPLICATION_CLASS (klass)->shutdown = test_loc_cmd_app_shutdown;
+ G_APPLICATION_CLASS (klass)->local_command_line = test_loc_cmd_app_local_command_line;
+}
+
+static void
+test_local_command_line (void)
+{
+ gchar *argv[] = { "./unimportant", "-invalid", NULL };
+ GApplication *app;
+
+ g_unsetenv ("DBUS_SESSION_BUS_ADDRESS");
+
+ app = g_object_new (test_loc_cmd_app_get_type (),
+ "application-id", "org.gtk.Unimportant",
+ "flags", G_APPLICATION_FLAGS_NONE,
+ NULL);
+ g_application_run (app, 1, argv);
+ g_object_unref (app);
+}
+
int
main (int argc, char **argv)
{
@@ -463,6 +518,7 @@ main (int argc, char **argv)
g_test_add_func ("/gapplication/app-id", appid);
g_test_add_func ("/gapplication/quit", test_quit);
g_test_add_func ("/gapplication/actions", test_actions);
+ g_test_add_func ("/gapplication/local-command-line", test_local_command_line);
return g_test_run ();
}