mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-28 01:57:14 +02:00
Add GApplication local_command_line test
Assert that startup and shutdown are not called if we return TRUE from local_command_line
This commit is contained in:
@@ -448,6 +448,61 @@ test_actions (void)
|
|||||||
g_object_unref (app);
|
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
|
int
|
||||||
main (int argc, char **argv)
|
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/app-id", appid);
|
||||||
g_test_add_func ("/gapplication/quit", test_quit);
|
g_test_add_func ("/gapplication/quit", test_quit);
|
||||||
g_test_add_func ("/gapplication/actions", test_actions);
|
g_test_add_func ("/gapplication/actions", test_actions);
|
||||||
|
g_test_add_func ("/gapplication/local-command-line", test_local_command_line);
|
||||||
|
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user