[vala/0.52] tests: Extend "dynamic" signal test to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.52] tests: Extend "dynamic" signal test to increase coverage
- Date: Sun, 14 Nov 2021 12:15:22 +0000 (UTC)
commit 6de87a845920e71a3ae1fa31a2c44f9dccddf39b
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon Nov 1 14:02:04 2021 +0100
tests: Extend "dynamic" signal test to increase coverage
tests/objects/dynamic.vala | 61 ++++++++++++++++++++++++++++++++++------------
1 file changed, 46 insertions(+), 15 deletions(-)
---
diff --git a/tests/objects/dynamic.vala b/tests/objects/dynamic.vala
index aa429432a..ff9c9dddb 100644
--- a/tests/objects/dynamic.vala
+++ b/tests/objects/dynamic.vala
@@ -3,6 +3,18 @@ class Foo : Object {
public string prop { get; set; }
}
+class Bar : Object {
+ public bool success = false;
+
+ public void sig_cb () {
+ success = true;
+ }
+
+ public void sig_after_cb () {
+ assert (success);
+ }
+}
+
bool success = false;
void sig_cb () {
@@ -14,22 +26,41 @@ void sig_after_cb () {
}
void main () {
- var real = new Foo ();
- dynamic Object foo = real;
+ {
+ var real = new Foo ();
+ dynamic Object foo = real;
- foo.prop = "foo";
- string s = foo.prop;
- assert (s == "foo");
+ foo.prop = "foo";
+ string s = foo.prop;
+ assert (s == "foo");
- success = false;
- var id1 = foo.sig.connect_after (sig_after_cb);
- var id2 = foo.sig.connect (sig_cb);
- real.sig ();
- assert (success);
+ success = false;
+ var id1 = foo.sig.connect_after (sig_after_cb);
+ var id2 = foo.sig.connect (sig_cb);
+ real.sig ();
+ assert (success);
+
+ success = false;
+ SignalHandler.disconnect (foo, id1);
+ SignalHandler.disconnect (foo, id2);
+ real.sig ();
+ assert (!success);
+ }
+ {
+ var real = new Foo ();
+ dynamic Object foo = real;
+
+ var bar = new Bar ();
+ bar.success = false;
+ var id1 = foo.sig.connect_after (bar.sig_after_cb);
+ var id2 = foo.sig.connect (bar.sig_cb);
+ real.sig ();
+ assert (bar.success);
- success = false;
- SignalHandler.disconnect (foo, id1);
- SignalHandler.disconnect (foo, id2);
- real.sig ();
- assert (!success);
+ bar.success = false;
+ SignalHandler.disconnect (foo, id1);
+ SignalHandler.disconnect (foo, id2);
+ real.sig ();
+ assert (!bar.success);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]