Imported Upstream version 2.53.3
[platform/upstream/glib.git] / gio / tests / gdbus-proxy.c
index 202bee3..fff1f48 100644 (file)
@@ -5,7 +5,7 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -13,9 +13,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  *
  * Author: David Zeuthen <davidz@redhat.com>
  */
@@ -26,8 +24,6 @@
 
 #include "gdbus-tests.h"
 
-static const gchar *binpath;
-
 /* all tests rely on a shared mainloop */
 static GMainLoop *loop = NULL;
 
@@ -764,7 +760,6 @@ test_proxy (void)
   GDBusProxy *proxy;
   GDBusConnection *connection;
   GError *error;
-  gchar *path;
 
   error = NULL;
   connection = g_bus_get_sync (G_BUS_TYPE_SESSION,
@@ -783,9 +778,7 @@ test_proxy (void)
   g_assert_no_error (error);
 
   /* this is safe; testserver will exit once the bus goes away */
-  path = g_build_filename (binpath, "gdbus-testserver", NULL);
-  g_assert (g_spawn_command_line_async (path, NULL));
-  g_free (path);
+  g_assert (g_spawn_command_line_async (g_test_get_filename (G_TEST_BUILT, "gdbus-testserver", NULL), NULL));
 
   _g_assert_property_notify (proxy, "g-name-owner");
 
@@ -836,8 +829,6 @@ fail_test (gpointer user_data)
 static void
 test_async (void)
 {
-  gchar *path;
-
   g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
                             G_DBUS_PROXY_FLAGS_NONE,
                             NULL,                      /* GDBusInterfaceInfo */
@@ -849,9 +840,7 @@ test_async (void)
                             NULL);
 
   /* this is safe; testserver will exit once the bus goes away */
-  path = g_build_filename (binpath, "gdbus-testserver", NULL);
-  g_assert (g_spawn_command_line_async (path, NULL));
-  g_free (path);
+  g_assert (g_spawn_command_line_async (g_test_get_filename (G_TEST_BUILT, "gdbus-testserver", NULL), NULL));
 
   g_timeout_add (10000, fail_test, NULL);
   g_main_loop_run (loop);
@@ -921,11 +910,6 @@ main (int   argc,
   gint ret;
   GDBusNodeInfo *introspection_data = NULL;
 
-  if (g_getenv ("G_TEST_DATA"))
-    binpath = g_getenv ("G_TEST_DATA");
-  else
-    binpath = BUILDDIR;
-
   g_test_init (&argc, &argv, NULL);
 
   introspection_data = g_dbus_node_info_new_for_xml (frob_dbus_interface_xml, NULL);
@@ -935,17 +919,14 @@ main (int   argc,
   /* all the tests rely on a shared main loop */
   loop = g_main_loop_new (NULL, FALSE);
 
-  session_bus_up ();
-
   g_test_add_func ("/gdbus/proxy", test_proxy);
   g_test_add_func ("/gdbus/proxy/no-properties", test_no_properties);
   g_test_add_func ("/gdbus/proxy/wellknown-noauto", test_wellknown_noauto);
   g_test_add_func ("/gdbus/proxy/async", test_async);
 
-  ret = g_test_run();
+  ret = session_bus_run();
 
   g_dbus_node_info_unref (introspection_data);
 
-  session_bus_down ();
   return ret;
 }