]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
D-Bus: Do not use GLib.Application in tests
authorJürg Billeter <j@bitron.ch>
Wed, 15 Sep 2010 20:52:37 +0000 (22:52 +0200)
committerJürg Billeter <j@bitron.ch>
Wed, 15 Sep 2010 21:05:23 +0000 (23:05 +0200)
GApplication will not be available in GLib 2.26.

tests/dbus/arrays.test
tests/dbus/async.test
tests/dbus/basic-types.test
tests/dbus/bug602003.test
tests/dbus/signals.test
tests/dbus/structs.test

index 64551c02638c546229cfd8c0ee7e2393e3332cde..fd52c323fa4eb77adef81698eddf6269d026ee21 100644 (file)
@@ -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 ();
 }
index 11c0eeeb6c3fe63a0ca3f298a050398b1d6099e3..0ce9e854640048d86fdf985699dab68a8e1e90e6 100644 (file)
@@ -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 ();
 }
index d76805353c19b8f8b67b231acb03c47fbf2c2580..18f0d177dcefa12605d2a9e6c7b3125926737b43 100644 (file)
@@ -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 ();
 }
index e715cc12a0c0ddeb98fb9bdc05fa1e0c2c4faa3a..ceb2327e5de9e33e600ed1f0a3923804447f75ed 100644 (file)
@@ -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 ();
 }
index 10df0d35312ff1311872a5c2850d45240682cbcd..e46320b75270a9af40128c585e17cb154176b332 100644 (file)
@@ -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 ();
 }
index 8f721eb41e1179d2f6c82b5a8f861964acbea28b..73311ca6b896b4971431a41f24bc15fbf545aad6 100644 (file)
@@ -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 ();
 }