diff options
author | Lutz Schönemann <lutz.schoenemann@basyskom.com> | 2014-08-11 14:05:13 +0200 |
---|---|---|
committer | Milian Wolff <milian.wolff@kdab.com> | 2014-08-26 13:19:29 +0200 |
commit | a79f70e2dfa1fa3d3a418310c7b8c8bb89c2d3c8 (patch) | |
tree | 06c4cc801089108c871e9f75d2a317b5e23ead1f /tests | |
parent | a6ebe42f2c997175c221f916bad7fdfd6fd3585d (diff) | |
download | qtwebchannel-a79f70e2dfa1fa3d3a418310c7b8c8bb89c2d3c8.tar.gz |
Fixing failing testcases
Some testcases do not consider all messages. These changes make
the test wait at specific points until these messages are sent.
Change-Id: Ie8f4b9492fefade0be91e7f829824db39d61ddee
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/tst_webchannel.qml | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/tests/auto/qml/tst_webchannel.qml b/tests/auto/qml/tst_webchannel.qml index 005696f..3e76d12 100644 --- a/tests/auto/qml/tst_webchannel.qml +++ b/tests/auto/qml/tst_webchannel.qml @@ -94,11 +94,27 @@ TestCase { registeredObjects: [myObj, myOtherObj, myFactory] } + function initChannel() { + client.serverTransport.receiveMessage(JSON.stringify({type: JSClient.QWebChannelMessageTypes.idle})); + webChannel.blockUpdates = true; + webChannel.blockUpdates = false; + } + function init() { myObj.myProperty = 1 + // immediately send pending updates + // to avoid property changed signals + // during run of test case + initChannel(); client.cleanup(); } + function cleanup() { + // make tests a bit more strict and predictable + // by assuming that a test consumes all messages + initChannel(); + compare(client.clientMessages.length, 0); + } function test_property() { @@ -122,12 +138,13 @@ TestCase { compare(initialValue, 1); compare(myObj.myProperty, 3); - client.awaitIdle(); + client.awaitIdle(); // init + client.awaitIdle(); // property update // change property, should be propagated to HTML client and a message be send there myObj.myProperty = 2; compare(myObj.myProperty, 2); - client.awaitIdle(); + client.awaitIdle(); // property update compare(changedValue, 2); } @@ -163,7 +180,7 @@ TestCase { compare(msg.type, JSClient.QWebChannelMessageTypes.connectToSignal); compare(msg.object, "myObj"); - client.awaitIdle(); + client.awaitIdle(); // initialization myObj.mySignal("test"); @@ -259,7 +276,7 @@ TestCase { compare(signalArgs, {"0": "foobar", "1": 42}); - client.awaitIdle(); + client.awaitIdle(); // destroyed signal compare(JSON.stringify(testObjBeforeDeletion), JSON.stringify({})); compare(JSON.stringify(testObjAfterDeletion), JSON.stringify({})); |