[vala] D-Bus: Do not use GLib.Application in tests



commit f6bb6a53f3f788082033019282f43c6afa308346
Author: Jürg Billeter <j bitron ch>
Date:   Wed Sep 15 22:52:37 2010 +0200

    D-Bus: Do not use GLib.Application in tests
    
    GApplication will not be available in GLib 2.26.

 tests/dbus/arrays.test      |   11 +++++++----
 tests/dbus/async.test       |   11 +++++++----
 tests/dbus/basic-types.test |   11 +++++++----
 tests/dbus/bug602003.test   |   11 +++++++----
 tests/dbus/signals.test     |   11 +++++++----
 tests/dbus/structs.test     |   11 +++++++----
 6 files changed, 42 insertions(+), 24 deletions(-)
---
diff --git a/tests/dbus/arrays.test b/tests/dbus/arrays.test
index 64551c0..fd52c32 100644
--- a/tests/dbus/arrays.test
+++ b/tests/dbus/arrays.test
@@ -49,12 +49,12 @@ class Test : Object {
 	}
 }
 
-Application app;
+MainLoop main_loop;
 
 void client_exit (Pid pid, int status) {
 	// client finished, terminate server
 	assert (status == 0);
-	app.quit ();
+	main_loop.quit ();
 }
 
 void main () {
@@ -62,12 +62,15 @@ void main () {
 	conn.register_object ("/org/example/test", new Test ());
 
 	// try to register service in session bus
-	app = new Application ("org.example.Test");
+	var request_result = conn.call_sync ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName",
+	                                      new Variant ("(su)", "org.example.Test", 0x4), null, 0, -1);
+	assert ((uint) request_result.get_child_value (0) == 1);
 
 	// server ready, spawn client
 	Pid client_pid;
 	Process.spawn_async (null, { "test", "/dbus/arrays/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
 	ChildWatch.add (client_pid, client_exit);
 
-	app.run ();
+	main_loop = new MainLoop ();
+	main_loop.run ();
 }
diff --git a/tests/dbus/async.test b/tests/dbus/async.test
index 11c0eee..0ce9e85 100644
--- a/tests/dbus/async.test
+++ b/tests/dbus/async.test
@@ -56,12 +56,12 @@ class Test : Object {
 	}
 }
 
-Application app;
+MainLoop main_loop;
 
 void client_exit (Pid pid, int status) {
 	// client finished, terminate server
 	assert (status == 0);
-	app.quit ();
+	main_loop.quit ();
 }
 
 void main () {
@@ -69,12 +69,15 @@ void main () {
 	conn.register_object ("/org/example/test", new Test ());
 
 	// try to register service in session bus
-	app = new Application ("org.example.Test");
+	var request_result = conn.call_sync ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName",
+	                                      new Variant ("(su)", "org.example.Test", 0x4), null, 0, -1);
+	assert ((uint) request_result.get_child_value (0) == 1);
 
 	// server ready, spawn client
 	Pid client_pid;
 	Process.spawn_async (null, { "test", "/dbus/async/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
 	ChildWatch.add (client_pid, client_exit);
 
-	app.run ();
+	main_loop = new MainLoop ();
+	main_loop.run ();
 }
diff --git a/tests/dbus/basic-types.test b/tests/dbus/basic-types.test
index d768053..18f0d17 100644
--- a/tests/dbus/basic-types.test
+++ b/tests/dbus/basic-types.test
@@ -49,12 +49,12 @@ class Test : Object {
 	}
 }
 
-Application app;
+MainLoop main_loop;
 
 void client_exit (Pid pid, int status) {
 	// client finished, terminate server
 	assert (status == 0);
-	app.quit ();
+	main_loop.quit ();
 }
 
 void main () {
@@ -62,12 +62,15 @@ void main () {
 	conn.register_object ("/org/example/test", new Test ());
 
 	// try to register service in session bus
-	app = new Application ("org.example.Test");
+	var request_result = conn.call_sync ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName",
+	                                      new Variant ("(su)", "org.example.Test", 0x4), null, 0, -1);
+	assert ((uint) request_result.get_child_value (0) == 1);
 
 	// server ready, spawn client
 	Pid client_pid;
 	Process.spawn_async (null, { "test", "/dbus/basic-types/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
 	ChildWatch.add (client_pid, client_exit);
 
-	app.run ();
+	main_loop = new MainLoop ();
+	main_loop.run ();
 }
diff --git a/tests/dbus/bug602003.test b/tests/dbus/bug602003.test
index e715cc1..ceb2327 100644
--- a/tests/dbus/bug602003.test
+++ b/tests/dbus/bug602003.test
@@ -27,12 +27,12 @@ class Test : Object {
 	}
 }
 
-Application app;
+MainLoop main_loop;
 
 void client_exit (Pid pid, int status) {
 	// client finished, terminate server
 	assert (status == 0);
-	app.quit ();
+	main_loop.quit ();
 }
 
 void main () {
@@ -40,12 +40,15 @@ void main () {
 	conn.register_object ("/org/example/test", new Test ());
 
 	// try to register service in session bus
-	app = new Application ("org.example.Test");
+	var request_result = conn.call_sync ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName",
+	                                      new Variant ("(su)", "org.example.Test", 0x4), null, 0, -1);
+	assert ((uint) request_result.get_child_value (0) == 1);
 
 	// server ready, spawn client
 	Pid client_pid;
 	Process.spawn_async (null, { "test", "/dbus/bug602003/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
 	ChildWatch.add (client_pid, client_exit);
 
-	app.run ();
+	main_loop = new MainLoop ();
+	main_loop.run ();
 }
diff --git a/tests/dbus/signals.test b/tests/dbus/signals.test
index 10df0d3..e46320b 100644
--- a/tests/dbus/signals.test
+++ b/tests/dbus/signals.test
@@ -38,12 +38,12 @@ class Test : Object {
 	}
 }
 
-Application app;
+MainLoop main_loop;
 
 void client_exit (Pid pid, int status) {
 	// client finished, terminate server
 	assert (status == 0);
-	app.quit ();
+	main_loop.quit ();
 }
 
 void main () {
@@ -51,12 +51,15 @@ void main () {
 	conn.register_object ("/org/example/test", new Test ());
 
 	// try to register service in session bus
-	app = new Application ("org.example.Test");
+	var request_result = conn.call_sync ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName",
+	                                      new Variant ("(su)", "org.example.Test", 0x4), null, 0, -1);
+	assert ((uint) request_result.get_child_value (0) == 1);
 
 	// server ready, spawn client
 	Pid client_pid;
 	Process.spawn_async (null, { "test", "/dbus/signals/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
 	ChildWatch.add (client_pid, client_exit);
 
-	app.run ();
+	main_loop = new MainLoop ();
+	main_loop.run ();
 }
diff --git a/tests/dbus/structs.test b/tests/dbus/structs.test
index 8f721eb..73311ca 100644
--- a/tests/dbus/structs.test
+++ b/tests/dbus/structs.test
@@ -62,12 +62,12 @@ class Test : Object {
 	}
 }
 
-Application app;
+MainLoop main_loop;
 
 void client_exit (Pid pid, int status) {
 	// client finished, terminate server
 	assert (status == 0);
-	app.quit ();
+	main_loop.quit ();
 }
 
 void main () {
@@ -75,12 +75,15 @@ void main () {
 	conn.register_object ("/org/example/test", new Test ());
 
 	// try to register service in session bus
-	app = new Application ("org.example.Test");
+	var request_result = conn.call_sync ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName",
+	                                      new Variant ("(su)", "org.example.Test", 0x4), null, 0, -1);
+	assert ((uint) request_result.get_child_value (0) == 1);
 
 	// server ready, spawn client
 	Pid client_pid;
 	Process.spawn_async (null, { "test", "/dbus/structs/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
 	ChildWatch.add (client_pid, client_exit);
 
-	app.run ();
+	main_loop = new MainLoop ();
+	main_loop.run ();
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]