[vala] D-Bus: Port tests to GDBus
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] D-Bus: Port tests to GDBus
- Date: Sun, 20 Jun 2010 10:02:13 +0000 (UTC)
commit 512cf92394aa2bbbc5c3c9b9ac8de20c552ffdb2
Author: Jürg Billeter <j bitron ch>
Date: Sat Jun 19 22:35:02 2010 +0200
D-Bus: Port tests to GDBus
tests/dbus/arrays.test | 29 +++++++++++------------------
tests/dbus/async.test | 29 +++++++++++------------------
tests/dbus/basic-types.test | 31 ++++++++++++-------------------
tests/dbus/bug596862.vala | 2 +-
tests/dbus/bug602003.test | 31 ++++++++++++-------------------
tests/dbus/signals.test | 27 ++++++++++-----------------
tests/dbus/structs.test | 27 ++++++++++-----------------
tests/testrunner.sh | 9 +++------
8 files changed, 70 insertions(+), 115 deletions(-)
---
diff --git a/tests/dbus/arrays.test b/tests/dbus/arrays.test
index f119fda..64551c0 100644
--- a/tests/dbus/arrays.test
+++ b/tests/dbus/arrays.test
@@ -1,4 +1,5 @@
-Packages: dbus-glib-1
+Packages: gio-2.0
+D-Bus
Program: client
@@ -6,15 +7,13 @@ Program: client
interface Test : Object {
public abstract string[] test_property { owned get; set; }
- public abstract int[] test_int (int[] i, out int[] j) throws DBus.Error;
- public abstract string[] test_string (string[] s, out string[] t) throws DBus.Error;
+ public abstract int[] test_int (int[] i, out int[] j) throws IOError;
+ public abstract string[] test_string (string[] s, out string[] t) throws IOError;
}
void main () {
- var conn = DBus.Bus.get (DBus.BusType.SESSION);
-
// client
- var test = (Test) conn.get_object ("org.example.Test", "/org/example/test");
+ Test test = Bus.get_proxy_sync (BusType.SESSION, "org.example.Test", "/org/example/test");
int[] j, k;
k = test.test_int ({ 42 }, out j);
@@ -50,31 +49,25 @@ class Test : Object {
}
}
-MainLoop main_loop;
+Application app;
void client_exit (Pid pid, int status) {
// client finished, terminate server
assert (status == 0);
- main_loop.quit ();
+ app.quit ();
}
void main () {
- var conn = DBus.Bus.get (DBus.BusType.SESSION);
- dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
+ var conn = Bus.get_sync (BusType.SESSION);
+ conn.register_object ("/org/example/test", new Test ());
// try to register service in session bus
- uint request_name_result = bus.request_name ("org.example.Test", (uint) 0);
- assert (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER);
-
- // start server
- var server = new Test ();
- conn.register_object ("/org/example/test", server);
+ app = new Application ("org.example.Test");
// 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);
- main_loop = new MainLoop (null, false);
- main_loop.run ();
+ app.run ();
}
diff --git a/tests/dbus/async.test b/tests/dbus/async.test
index f23aaf9..11c0eee 100644
--- a/tests/dbus/async.test
+++ b/tests/dbus/async.test
@@ -1,11 +1,12 @@
-Packages: gio-2.0 dbus-glib-1
+Packages: gio-2.0
+D-Bus
Program: client
[DBus (name = "org.example.Test")]
interface Test : Object {
- public abstract async int test_int (int i, out int j) throws DBus.Error;
- public abstract async string test_string (string s, out string t) throws DBus.Error;
+ public abstract async int test_int (int i, out int j) throws IOError;
+ public abstract async string test_string (string s, out string t) throws IOError;
}
MainLoop main_loop;
@@ -25,10 +26,8 @@ async void run (Test test) {
}
void main () {
- var conn = DBus.Bus.get (DBus.BusType.SESSION);
-
// client
- var test = (Test) conn.get_object ("org.example.Test", "/org/example/test");
+ Test test = Bus.get_proxy_sync (BusType.SESSION, "org.example.Test", "/org/example/test");
run.begin (test);
@@ -57,31 +56,25 @@ class Test : Object {
}
}
-MainLoop main_loop;
+Application app;
void client_exit (Pid pid, int status) {
// client finished, terminate server
assert (status == 0);
- main_loop.quit ();
+ app.quit ();
}
void main () {
- var conn = DBus.Bus.get (DBus.BusType.SESSION);
- dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
+ var conn = Bus.get_sync (BusType.SESSION);
+ conn.register_object ("/org/example/test", new Test ());
// try to register service in session bus
- uint request_name_result = bus.request_name ("org.example.Test", (uint) 0);
- assert (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER);
-
- // start server
- var server = new Test ();
- conn.register_object ("/org/example/test", server);
+ app = new Application ("org.example.Test");
// 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);
- main_loop = new MainLoop (null, false);
- main_loop.run ();
+ app.run ();
}
diff --git a/tests/dbus/basic-types.test b/tests/dbus/basic-types.test
index 7dc6a92..d768053 100644
--- a/tests/dbus/basic-types.test
+++ b/tests/dbus/basic-types.test
@@ -1,4 +1,5 @@
-Packages: dbus-glib-1
+Packages: gio-2.0
+D-Bus
Program: client
@@ -6,15 +7,13 @@ Program: client
interface Test : Object {
public abstract string test_property { owned get; set; }
- public abstract int test_int (int i, out int j) throws DBus.Error;
- public abstract string test_string (string s, out string t) throws DBus.Error;
+ public abstract int test_int (int i, out int j) throws IOError;
+ public abstract string test_string (string s, out string t) throws IOError;
}
void main () {
- var conn = DBus.Bus.get (DBus.BusType.SESSION);
-
- // client
- var test = (Test) conn.get_object ("org.example.Test", "/org/example/test");
+ // client
+ Test test = Bus.get_proxy_sync (BusType.SESSION, "org.example.Test", "/org/example/test");
int j, k;
k = test.test_int (42, out j);
@@ -50,31 +49,25 @@ class Test : Object {
}
}
-MainLoop main_loop;
+Application app;
void client_exit (Pid pid, int status) {
// client finished, terminate server
assert (status == 0);
- main_loop.quit ();
+ app.quit ();
}
void main () {
- var conn = DBus.Bus.get (DBus.BusType.SESSION);
- dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
+ var conn = Bus.get_sync (BusType.SESSION);
+ conn.register_object ("/org/example/test", new Test ());
// try to register service in session bus
- uint request_name_result = bus.request_name ("org.example.Test", (uint) 0);
- assert (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER);
-
- // start server
- var server = new Test ();
- conn.register_object ("/org/example/test", server);
+ app = new Application ("org.example.Test");
// 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);
- main_loop = new MainLoop (null, false);
- main_loop.run ();
+ app.run ();
}
diff --git a/tests/dbus/bug596862.vala b/tests/dbus/bug596862.vala
index fd9ec5e..69487a0 100644
--- a/tests/dbus/bug596862.vala
+++ b/tests/dbus/bug596862.vala
@@ -1,6 +1,6 @@
[DBus (name = "org.example.Test")]
public class Foo : Object {
- public void do_foo (Value value) {
+ public void do_foo (Variant value) {
}
}
diff --git a/tests/dbus/bug602003.test b/tests/dbus/bug602003.test
index cf3127f..e715cc1 100644
--- a/tests/dbus/bug602003.test
+++ b/tests/dbus/bug602003.test
@@ -1,19 +1,18 @@
-Packages: dbus-glib-1
+Packages: gio-2.0
+D-Bus
Program: client
[DBus (name = "org.example.Test")]
interface Test : Object {
- public abstract Value test_string () throws DBus.Error;
+ public abstract Variant test_string () throws IOError;
}
void main () {
- var conn = DBus.Bus.get (DBus.BusType.SESSION);
-
// client
- var test = (Test) conn.get_object ("org.example.Test", "/org/example/test");
+ Test test = Bus.get_proxy_sync (BusType.SESSION, "org.example.Test", "/org/example/test");
- Value v = test.test_string ();
+ Variant v = test.test_string ();
string[] s = (string[]) v;
assert (s.length == 1 && s[0] == "hello");
}
@@ -22,37 +21,31 @@ Program: server
[DBus (name = "org.example.Test")]
class Test : Object {
- public Value test_string () {
+ public Variant test_string () {
string[] s = { "hello" };
return s;
}
}
-MainLoop main_loop;
+Application app;
void client_exit (Pid pid, int status) {
// client finished, terminate server
assert (status == 0);
- main_loop.quit ();
+ app.quit ();
}
void main () {
- var conn = DBus.Bus.get (DBus.BusType.SESSION);
- dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
+ var conn = Bus.get_sync (BusType.SESSION);
+ conn.register_object ("/org/example/test", new Test ());
// try to register service in session bus
- uint request_name_result = bus.request_name ("org.example.Test", (uint) 0);
- assert (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER);
-
- // start server
- var server = new Test ();
- conn.register_object ("/org/example/test", server);
+ app = new Application ("org.example.Test");
// 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);
- main_loop = new MainLoop (null, false);
- main_loop.run ();
+ app.run ();
}
diff --git a/tests/dbus/signals.test b/tests/dbus/signals.test
index 12f35e0..10df0d3 100644
--- a/tests/dbus/signals.test
+++ b/tests/dbus/signals.test
@@ -1,4 +1,5 @@
-Packages: dbus-glib-1
+Packages: gio-2.0
+D-Bus
Program: client
@@ -6,16 +7,14 @@ Program: client
interface Test : Object {
public signal void foo (int i);
- public abstract void do_foo (int i) throws DBus.Error;
+ public abstract void do_foo (int i) throws IOError;
}
MainLoop main_loop;
void main () {
- var conn = DBus.Bus.get (DBus.BusType.SESSION);
-
// client
- var test = (Test) conn.get_object ("org.example.Test", "/org/example/test");
+ Test test = Bus.get_proxy_sync (BusType.SESSION, "org.example.Test", "/org/example/test");
test.foo.connect ((i) => {
assert (i == 42);
@@ -39,31 +38,25 @@ class Test : Object {
}
}
-MainLoop main_loop;
+Application app;
void client_exit (Pid pid, int status) {
// client finished, terminate server
assert (status == 0);
- main_loop.quit ();
+ app.quit ();
}
void main () {
- var conn = DBus.Bus.get (DBus.BusType.SESSION);
- dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
+ var conn = Bus.get_sync (BusType.SESSION);
+ conn.register_object ("/org/example/test", new Test ());
// try to register service in session bus
- uint request_name_result = bus.request_name ("org.example.Test", (uint) 0);
- assert (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER);
-
- // start server
- var server = new Test ();
- conn.register_object ("/org/example/test", server);
+ app = new Application ("org.example.Test");
// 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);
- main_loop = new MainLoop (null, false);
- main_loop.run ();
+ app.run ();
}
diff --git a/tests/dbus/structs.test b/tests/dbus/structs.test
index 744aad4..8f721eb 100644
--- a/tests/dbus/structs.test
+++ b/tests/dbus/structs.test
@@ -1,4 +1,5 @@
-Packages: dbus-glib-1
+Packages: gio-2.0
+D-Bus
Program: client
@@ -16,14 +17,12 @@ struct FooStruct {
interface Test : Object {
public abstract FooStruct test_property { owned get; set; }
- public abstract FooStruct test_struct (FooStruct f, out FooStruct g) throws DBus.Error;
+ public abstract FooStruct test_struct (FooStruct f, out FooStruct g) throws IOError;
}
void main () {
- var conn = DBus.Bus.get (DBus.BusType.SESSION);
-
// client
- var test = (Test) conn.get_object ("org.example.Test", "/org/example/test");
+ Test test = Bus.get_proxy_sync (BusType.SESSION, "org.example.Test", "/org/example/test");
FooStruct f, g, h;
f = FooStruct (42, "hello");
@@ -63,31 +62,25 @@ class Test : Object {
}
}
-MainLoop main_loop;
+Application app;
void client_exit (Pid pid, int status) {
// client finished, terminate server
assert (status == 0);
- main_loop.quit ();
+ app.quit ();
}
void main () {
- var conn = DBus.Bus.get (DBus.BusType.SESSION);
- dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
+ var conn = Bus.get_sync (BusType.SESSION);
+ conn.register_object ("/org/example/test", new Test ());
// try to register service in session bus
- uint request_name_result = bus.request_name ("org.example.Test", (uint) 0);
- assert (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER);
-
- // start server
- var server = new Test ();
- conn.register_object ("/org/example/test", server);
+ app = new Application ("org.example.Test");
// 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);
- main_loop = new MainLoop (null, false);
- main_loop.run ();
+ app.run ();
}
diff --git a/tests/testrunner.sh b/tests/testrunner.sh
index 5eb436b..175caca 100755
--- a/tests/testrunner.sh
+++ b/tests/testrunner.sh
@@ -35,12 +35,9 @@ function testheader() {
if [ "$1" = "Packages:" ]; then
shift
PACKAGES="$PACKAGES $@"
- for pkg in "$@"; do
- if [ "$pkg" = "dbus-glib-1" ]; then
- echo 'eval `dbus-launch --sh-syntax`' >> prepare
- echo 'trap "kill $DBUS_SESSION_BUS_PID" INT TERM EXIT' >> prepare
- fi
- done
+ elif [ "$1" = "D-Bus" ]; then
+ echo 'eval `dbus-launch --sh-syntax`' >> prepare
+ echo 'trap "kill $DBUS_SESSION_BUS_PID" INT TERM EXIT' >> prepare
fi
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]