Tests: It is useless to unset "DBUS_SESSION_BUS_ADDRESS" manually
[platform/upstream/glib.git] / gio / tests / gapplication.c
index 8769693..c9610c0 100644 (file)
@@ -65,7 +65,7 @@ spawn (const gchar *expected_stdout,
 
   va_start (ap, first_arg);
   array = g_ptr_array_new ();
-  g_ptr_array_add (array, g_strdup ("./basic-application"));
+  g_ptr_array_add (array, g_test_build_filename (G_TEST_BUILT, "basic-application", NULL));
   for (arg = first_arg; arg; arg = va_arg (ap, const gchar *))
     g_ptr_array_add (array, g_strdup (arg));
   g_ptr_array_add (array, NULL);
@@ -320,7 +320,8 @@ nodbus_activate (GApplication *app)
 static void
 test_nodbus (void)
 {
-  gchar *argv[] = { "./unimportant", NULL };
+  char *binpath = g_test_build_filename (G_TEST_BUILT, "unimportant", NULL);
+  gchar *argv[] = { binpath, NULL };
   GApplication *app;
 
   app = g_application_new ("org.gtk.Unimportant", G_APPLICATION_FLAGS_NONE);
@@ -329,6 +330,7 @@ test_nodbus (void)
   g_object_unref (app);
 
   g_assert (nodbus_activated);
+  g_free (binpath);
 }
 
 static gboolean noappid_activated;
@@ -348,7 +350,8 @@ noappid_activate (GApplication *app)
 static void
 test_noappid (void)
 {
-  gchar *argv[] = { "./unimportant", NULL };
+  char *binpath = g_test_build_filename (G_TEST_BUILT, "unimportant", NULL);
+  gchar *argv[] = { binpath, NULL };
   GApplication *app;
 
   app = g_application_new (NULL, G_APPLICATION_FLAGS_NONE);
@@ -357,6 +360,7 @@ test_noappid (void)
   g_object_unref (app);
 
   g_assert (noappid_activated);
+  g_free (binpath);
 }
 
 
@@ -385,7 +389,8 @@ static void
 test_quit (void)
 {
   GDBusConnection *c;
-  gchar *argv[] = { "./unimportant", NULL };
+  char *binpath = g_test_build_filename (G_TEST_BUILT, "unimportant", NULL);
+  gchar *argv[] = { binpath, NULL };
   GApplication *app;
 
   session_bus_up ();
@@ -401,6 +406,7 @@ test_quit (void)
   g_assert (quit_activated);
 
   session_bus_down ();
+  g_free (binpath);
 }
 
 static void
@@ -439,16 +445,16 @@ on_activate (GApplication *app)
 static void
 test_actions (void)
 {
-  gchar *argv[] = { "./unimportant", NULL };
+  char *binpath = g_test_build_filename (G_TEST_BUILT, "unimportant", NULL);
+  gchar *argv[] = { binpath, NULL };
   GApplication *app;
 
-  g_unsetenv ("DBUS_SESSION_BUS_ADDRESS");
-
   app = g_application_new ("org.gtk.Unimportant",
                            G_APPLICATION_FLAGS_NONE);
   g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
   g_application_run (app, 1, argv);
   g_object_unref (app);
+  g_free (binpath);
 }
 
 typedef GApplication TestLocCmdApp;
@@ -493,17 +499,17 @@ test_loc_cmd_app_class_init (TestLocCmdAppClass *klass)
 static void
 test_local_command_line (void)
 {
-  gchar *argv[] = { "./unimportant", "-invalid", NULL };
+  char *binpath = g_test_build_filename (G_TEST_BUILT, "unimportant", NULL);
+  gchar *argv[] = { binpath, "-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);
+  g_free (binpath);
 }
 
 int