From: Jürg Billeter Date: Wed, 15 Sep 2010 20:52:37 +0000 (+0200) Subject: D-Bus: Do not use GLib.Application in tests X-Git-Tag: 0.10.0~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51a730d22b7ac0d6ef423d4a9d3accf0fea4ea6e;p=thirdparty%2Fvala.git D-Bus: Do not use GLib.Application in tests GApplication will not be available in GLib 2.26. --- diff --git a/tests/dbus/arrays.test b/tests/dbus/arrays.test index 64551c026..fd52c323f 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 11c0eeeb6..0ce9e8546 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 d76805353..18f0d177d 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 e715cc12a..ceb2327e5 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 10df0d353..e46320b75 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 8f721eb41..73311ca6b 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 (); }