diff options
author | Matthias Clasen <mclasen@redhat.com> | 2012-11-21 17:39:19 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2012-11-21 21:20:25 -0500 |
commit | 4ffa4724383cbb93c4c2fd0fb8d46027a54acde0 (patch) | |
tree | 4ee752971cb4d63b1e9f8b897b2b013543177fec | |
parent | bace1822d792cd8767156508834237d550888177 (diff) | |
download | glib-4ffa4724383cbb93c4c2fd0fb8d46027a54acde0.tar.gz |
Add a test for the GAppLaunchContext::launched signal
-rw-r--r-- | gio/tests/appinfo.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/gio/tests/appinfo.c b/gio/tests/appinfo.c index 91512527a..8c532127d 100644 --- a/gio/tests/appinfo.c +++ b/gio/tests/appinfo.c @@ -192,6 +192,55 @@ test_launch_context (void) g_object_unref (context); } +static gboolean launched_reached; + +static void +launched (GAppLaunchContext *context, + GAppInfo *info, + GVariant *platform_data, + gpointer user_data) +{ + gint pid; + + pid = 0; + g_assert (g_variant_lookup (platform_data, "pid", "i", &pid)); + g_assert (pid != 0); + + launched_reached = TRUE; +} + +static void +launch_failed (GAppLaunchContext *context, + const gchar *startup_notify_id) +{ + g_assert_not_reached (); +} + +static void +test_launch_context_signals (void) +{ + GAppLaunchContext *context; + GAppInfo *appinfo; + GError *error = NULL; + + context = g_app_launch_context_new (); + g_signal_connect (context, "launched", G_CALLBACK (launched), NULL); + g_signal_connect (context, "launch_failed", G_CALLBACK (launch_failed), NULL); + appinfo = g_app_info_create_from_commandline ("./appinfo-test --option", + "cmdline-app-test", + G_APP_INFO_CREATE_SUPPORTS_URIS, + NULL); + + error = NULL; + g_assert (g_app_info_launch (appinfo, NULL, context, &error)); + g_assert_no_error (error); + + g_assert (launched_reached); + + g_object_unref (appinfo); + g_object_unref (context); +} + static void test_tryexec (void) { @@ -387,6 +436,7 @@ main (int argc, char *argv[]) g_test_add_func ("/appinfo/show-in", test_show_in); g_test_add_func ("/appinfo/commandline", test_commandline); g_test_add_func ("/appinfo/launch-context", test_launch_context); + g_test_add_func ("/appinfo/launch-context-signals", test_launch_context_signals); g_test_add_func ("/appinfo/tryexec", test_tryexec); g_test_add_func ("/appinfo/associations", test_associations); g_test_add_func ("/appinfo/environment", test_environment); |