From a79f70e2dfa1fa3d3a418310c7b8c8bb89c2d3c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lutz=20Sch=C3=B6nemann?= Date: Mon, 11 Aug 2014 14:05:13 +0200 Subject: 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 --- tests/auto/qml/tst_webchannel.qml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'tests') 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({})); -- cgit v1.2.1