From 2824dedd22a60f6598d06aaa6e6d6e2424cbfa01 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sun, 28 Jun 2020 13:00:17 +0200 Subject: Change test code for older vala compat --- xmpp-vala/tests/stanza.vala | 6 +- xmpp-vala/tests/testcase.vala | 168 +++++++++++++++++++++--------------------- 2 files changed, 88 insertions(+), 86 deletions(-) (limited to 'xmpp-vala/tests') diff --git a/xmpp-vala/tests/stanza.vala b/xmpp-vala/tests/stanza.vala index 17cd8317..b1fce46d 100644 --- a/xmpp-vala/tests/stanza.vala +++ b/xmpp-vala/tests/stanza.vala @@ -9,7 +9,7 @@ class StanzaTest : Gee.TestCase { add_async_test("ack_stream", (cb) => { test_ack_stream.begin(cb); }); } - private async void test_node_one(Gee.TestCase.FinishCallback cb) { + private async void test_node_one(Gee.TestFinishedCallback cb) { var node1 = new StanzaNode.build("test", "ns1_uri") .add_self_xmlns() .put_attribute("ns2", "ns2_uri", XMLNS_URI) @@ -26,7 +26,7 @@ class StanzaTest : Gee.TestCase { cb(); } - private async void test_typical_stream(Gee.TestCase.FinishCallback cb) { + private async void test_typical_stream(Gee.TestFinishedCallback cb) { var stream = """ { main_loop.quit (); return false; }); + } + + public bool finish_timeout () { + Test.fail (); + Test.message (@"Timeout of $(timeout)ms reached."); + main_loop.quit (); + return false; + } - private interface Adaptor : Object { - public abstract void set_up (void* fixture); - public abstract void run (void* fixture); - public abstract void tear_down (void* fixture); - } - - private class DefaultAdaptor : Object, Adaptor { - [CCode (notify = false)] - public string name { get; private set; } - private TestMethod test; - private TestCase test_case; - - public DefaultAdaptor (string name, - owned TestMethod test, - TestCase test_case) { - this.name = name; - this.test = (owned)test; - this.test_case = test_case; - } - - public void set_up (void* fixture) { - this.test_case.set_up (); - } - - public void run (void* fixture) { - this.test (); - } - - public void tear_down (void* fixture) { - this.test_case.tear_down (); - } - } - - private class AsyncAdaptor : Object, Adaptor { - [CCode (notify = false)] - public string name { get; private set; } - private AsyncTestMethod test; - private TestCase test_case; - private MainLoop main_loop; - private int timeout; - - public AsyncAdaptor (string name, - owned AsyncTestMethod test, - TestCase test_case, - int timeout) { - this.name = name; - this.test = (owned)test; - this.test_case = test_case; - this.timeout = timeout; - } - - public void set_up (void* fixture) { - this.test_case.set_up (); - main_loop = new MainLoop (); - } - - public void run (void* fixture) { - this.test (finish); - Timeout.add (timeout, finish_timeout); - main_loop.run (); - } - - public void finish () { - Idle.add (() => { main_loop.quit (); return false; }); - } - - public bool finish_timeout () { - Test.fail (); - Test.message (@"Timeout of $(timeout)ms reached."); - main_loop.quit (); - return false; - } - - public void tear_down (void* fixture) { - this.test_case.tear_down (); - } + public void tear_down (void* fixture) { + this.test_case.tear_down (); } } -- cgit v1.2.3-54-g00ecf