]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Extend "DBus signals" test to increase coverage 61e69f43be39cbd57df4fc4ea4d63c92ac57ebb0 122/head
authorCorentin Noël <corentin@elementary.io>
Sun, 5 Apr 2020 12:25:29 +0000 (14:25 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 5 Apr 2020 14:20:19 +0000 (16:20 +0200)
This adds code coverage for generating multiple signals, tests for
arrays and ensures that the private signals are not leaking.

tests/dbus/signals.test

index 10544c52057cb370111c6a22aa02c0ded8243927..2ea689c676661b8a7a68606c526f837e3d81d6b4 100644 (file)
@@ -6,8 +6,11 @@ Program: client
 [DBus (name = "org.example.Test")]
 interface Test : Object {
        public signal void foo (int i);
+       public signal void bar (string[] baz);
+       internal signal void finish ();
 
-       public abstract void do_foo (int i) throws IOError;
+       public abstract void do_foo (int i) throws DBusError, IOError;
+       public abstract void do_bar (string[] baz) throws DBusError, IOError;
 }
 
 MainLoop main_loop;
@@ -18,10 +21,22 @@ void main () {
 
        test.foo.connect ((i) => {
                assert (i == 42);
+       });
+
+       test.bar.connect ((baz) => {
+               assert (baz.length == 3);
+               assert (baz[0] == "zero");
+               assert (baz[1] == "one");
+               assert (baz[2] == "two");
                main_loop.quit ();
        });
 
+       test.finish.connect (() => {
+               assert_not_reached ();
+       });
+
        test.do_foo (42);
+       test.do_bar ({"zero", "one", "two"});
 
        main_loop = new MainLoop ();
        main_loop.run ();
@@ -32,9 +47,16 @@ Program: server
 [DBus (name = "org.example.Test")]
 class Test : Object {
        public signal void foo (int i);
+       public signal void bar (string[] baz);
+       private signal void finish ();
 
-       public void do_foo (int i) {
+       public void do_foo (int i) throws DBusError, IOError {
                this.foo (i);
+               finish ();
+       }
+
+       public void do_bar (string[] baz) throws DBusError, IOError {
+               this.bar (baz);
        }
 }