From efbc8e0066f82ee530b4770e4484d6372e5e7cc1 Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Thu, 16 Oct 2014 17:05:13 +0200 Subject: Never manually connect to the destroyed signal of any object. The web channel always connects to that signal automatically for internal book-keeping purposes. Thus we do not have to connect to the signal for wrapped objects. This simplifies the tests and reduces the IPC traffic for wrapped objects. Change-Id: Iaf8d9ce0b87874917cdcdf9013e21a53ee36b53a Reviewed-by: Simon Hausmann --- tests/auto/qml/tst_webchannel.qml | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/tst_webchannel.qml b/tests/auto/qml/tst_webchannel.qml index 3e76d12..f304197 100644 --- a/tests/auto/qml/tst_webchannel.qml +++ b/tests/auto/qml/tst_webchannel.qml @@ -244,11 +244,6 @@ TestCase { compare(myFactory.lastObj.objectName, "testObj"); compare(channel.objects[testObjId].objectName, "testObj"); - // deleteLater signal connection - msg = client.awaitMessage(); - compare(msg.type, JSClient.QWebChannelMessageTypes.connectToSignal); - compare(msg.object, testObjId); - // mySignal connection msg = client.awaitMessage(); compare(msg.type, JSClient.QWebChannelMessageTypes.connectToSignal); @@ -287,26 +282,23 @@ TestCase { // objects even if no callback function is set function test_wrapper_wrapEveryQObject() { + var testObj; var channel = client.createChannel(function(channel) { - channel.objects.myFactory.create("testObj"); + channel.objects.myFactory.create("testObj", function(obj) { + testObj = obj; + }); }); client.awaitInit(); // ignore first message (call to myFactory.create()) client.awaitMessage(); - - // second message connects to destroyed signal and contains the new objects ID - var msg = client.awaitMessage(); - verify(msg.object); - - var testObjId = msg.object; - compare(msg.type, JSClient.QWebChannelMessageTypes.connectToSignal); - compare(typeof channel.objects[testObjId], "object"); - client.awaitIdle(); - channel.objects[testObjId].deleteLater(); - msg = client.awaitMessage(); + verify(testObj); + var testObjId = testObj.__id__; + + testObj.deleteLater(); + var msg = client.awaitMessage(); compare(msg.type, JSClient.QWebChannelMessageTypes.invokeMethod); compare(msg.object, testObjId); @@ -329,14 +321,10 @@ TestCase { }); client.awaitInit(); - // first message (call to myFactory.create()) + // call to myFactory.create() var msg = client.awaitMessage(); compare(msg.type, JSClient.QWebChannelMessageTypes.invokeMethod); - // second message connects to destroyed signal - msg = client.awaitMessage(); - compare(msg.type, JSClient.QWebChannelMessageTypes.connectToSignal); - client.awaitIdle(); testObj.myProperty = 42; -- cgit v1.2.1