summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2014-10-16 13:37:22 +0200
committerMilian Wolff <milian.wolff@kdab.com>2014-12-02 14:16:55 +0100
commit81dac6e848da8e8a071a2069862590889a287067 (patch)
treeb8bbca884fd5e04755f6feaa7310e2d02c5fac34 /tests
parent86d77a900852691267f556fbde98406a12ee4310 (diff)
downloadqtwebchannel-81dac6e848da8e8a071a2069862590889a287067.tar.gz
Make objects inside properties accessible.
Similar to the support for factory-methods, we must wrap objects in properties to make them accessible to clients. This patch adds the required code for that. Besides support for simple properties that reference an object, this patch also adds support for list properties that contain objects. The client-side unwrap of properties is delayed until all objects are initialized, as a property might reference another registered object. Change-Id: I9fb90a8eab4c66d2f4231fdb482e0d97d128df3e Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/tst_webchannel.qml17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/auto/qml/tst_webchannel.qml b/tests/auto/qml/tst_webchannel.qml
index f304197..e7fcedc 100644
--- a/tests/auto/qml/tst_webchannel.qml
+++ b/tests/auto/qml/tst_webchannel.qml
@@ -66,6 +66,8 @@ TestCase {
property var bar: 1
WebChannel.id: "myOtherObj"
}
+ QtObject{ id: bar; objectName: "bar" }
+ QtObject{ id: baz; objectName: "baz" }
QtObject {
id: myFactory
property var lastObj
@@ -74,9 +76,13 @@ TestCase {
lastObj = component.createObject(myFactory, {objectName: id});
return lastObj;
}
+ property var objectInProperty: QtObject {
+ objectName: "foo"
+ }
+ property var otherObject: myObj
+ property var objects: [ bar, baz ];
WebChannel.id: "myFactory"
}
-
Component {
id: component
QtObject {
@@ -264,6 +270,15 @@ TestCase {
myFactory.lastObj.mySignal("foobar", 42);
+ // property should be wrapped
+ compare(channel.objects.myFactory.objectInProperty.objectName, "foo");
+ // list property as well
+ compare(channel.objects.myFactory.objects.length, 2);
+ compare(channel.objects.myFactory.objects[0].objectName, "bar");
+ compare(channel.objects.myFactory.objects[1].objectName, "baz");
+ // also works with properties that reference other registered objects
+ compare(channel.objects.myFactory.otherObject, channel.objects.myObj);
+
// deleteLater call
msg = client.awaitMessage();
compare(msg.type, JSClient.QWebChannelMessageTypes.invokeMethod);