summaryrefslogtreecommitdiff
path: root/tests/auto/qml/tst_webchannel.qml
diff options
context:
space:
mode:
authorLutz Schönemann <lutz.schoenemann@basyskom.com>2014-08-11 14:05:13 +0200
committerMilian Wolff <milian.wolff@kdab.com>2014-08-26 13:19:29 +0200
commita79f70e2dfa1fa3d3a418310c7b8c8bb89c2d3c8 (patch)
tree06c4cc801089108c871e9f75d2a317b5e23ead1f /tests/auto/qml/tst_webchannel.qml
parenta6ebe42f2c997175c221f916bad7fdfd6fd3585d (diff)
downloadqtwebchannel-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/auto/qml/tst_webchannel.qml')
-rw-r--r--tests/auto/qml/tst_webchannel.qml25
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({}));