summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2016-06-21 11:30:03 +0200
committerMilian Wolff <milian.wolff@kdab.com>2016-06-28 11:13:14 +0000
commitd3c594c382761241742cd6713f249abeb538ffaa (patch)
tree2e5e510a7d6ade77d061f3fa4c248ea91a88f306 /tests/auto
parentf48e8c9711fbeb350ccf70f852ce3732844d4287 (diff)
downloadqtwebchannel-d3c594c382761241742cd6713f249abeb538ffaa.tar.gz
Properly unwrap QObject signal parameters on the JavaScript side.
This enables you to pass `QObject*` parameters via signals to the JavaScript side. The object will be serialized and then unwrapped as needed now. Task-number: QTBUG-54243 Change-Id: Ie8a6d14eb1351f14f1855d242ceb3b3f8262152d Reviewed-by: Andreas Holzammer <andreas.holzammer@kdab.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/tst_webchannel.qml19
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/auto/qml/tst_webchannel.qml b/tests/auto/qml/tst_webchannel.qml
index f1042ca..6cb24b0 100644
--- a/tests/auto/qml/tst_webchannel.qml
+++ b/tests/auto/qml/tst_webchannel.qml
@@ -51,7 +51,7 @@ TestCase {
id: myObj
property int myProperty: 1
- signal mySignal(var arg)
+ signal mySignal(var arg, QtObject object)
function myMethod(arg)
{
@@ -174,9 +174,11 @@ TestCase {
function test_signal()
{
var signalReceivedArg;
+ var signalReceivedObject;
var channel = client.createChannel(function(channel) {
- channel.objects.myObj.mySignal.connect(function(arg) {
+ channel.objects.myObj.mySignal.connect(function(arg, object) {
signalReceivedArg = arg;
+ signalReceivedObject = object;
});
});
client.awaitInit();
@@ -187,9 +189,16 @@ TestCase {
client.awaitIdle(); // initialization
- myObj.mySignal("test");
+ myObj.mySignal("test", myObj);
compare(signalReceivedArg, "test");
+ compare(signalReceivedObject.__id__, "myObj");
+
+ var newObj = myFactory.create("newObj");
+ myObj.mySignal(newObj, newObj);
+
+ compare(signalReceivedArg.objectName, newObj.objectName);
+ compare(signalReceivedObject.objectName, newObj.objectName);
}
function test_grouping()
@@ -393,14 +402,14 @@ TestCase {
client.awaitIdle();
- myObj.mySignal(42);
+ myObj.mySignal(42, myObj);
compare(signalArg, 42);
msg = client.awaitMessage();
compare(msg.type, JSClient.QWebChannelMessageTypes.disconnectFromSignal);
compare(msg.object, "myObj");
- myObj.mySignal(0);
+ myObj.mySignal(0, myObj);
compare(signalArg, 42);
}
}