From ee8080cc0bda9141e323c01b12e812b1ab748e18 Mon Sep 17 00:00:00 2001 From: Paolo Borelli Date: Sat, 24 Nov 2012 19:12:13 +0100 Subject: [PATCH] Add GApplication local_command_line test Assert that startup and shutdown are not called if we return TRUE from local_command_line --- gio/tests/gapplication.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/gio/tests/gapplication.c b/gio/tests/gapplication.c index 044bb37..6e247a8 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 (); } -- 2.7.4