summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArno Rehn <a.rehn@menlosystems.com>2019-02-04 15:05:50 +0100
committerArno Rehn <a.rehn@menlosystems.com>2019-02-04 14:53:24 +0000
commit38b5128c63ba38303f0587e03536ed546c1f2eca (patch)
tree40031b4b7e389a79b4728d5d4d64589f101c18f2 /tests
parent91c92ce0144eb8c0639aef012508e24d8b7e72a5 (diff)
downloadqtwebchannel-38b5128c63ba38303f0587e03536ed546c1f2eca.tar.gz
Correctly unwrap registered objects
Previously, only implicitly wrapped objects have been successfully unwrapped. "Officially" registered objects were not, and thus could not be passed to properties or as method arguments. Change-Id: I6b8644ed3be8db3a66c2c1d5bc167fc33a0b4165 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/webchannel/tst_webchannel.cpp19
-rw-r--r--tests/auto/webchannel/tst_webchannel.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/webchannel/tst_webchannel.cpp b/tests/auto/webchannel/tst_webchannel.cpp
index 6764204..e46d097 100644
--- a/tests/auto/webchannel/tst_webchannel.cpp
+++ b/tests/auto/webchannel/tst_webchannel.cpp
@@ -708,6 +708,25 @@ void TestWebChannel::testWrapRegisteredObject()
QCOMPARE(obj.objectName(), returnedId);
}
+void TestWebChannel::testUnwrapObject()
+{
+ QWebChannel channel;
+
+ {
+ TestObject obj;
+ obj.setObjectName("testObject");
+ channel.registerObject(obj.objectName(), &obj);
+ QObject *unwrapped = channel.d_func()->publisher->unwrapObject(obj.objectName());
+ QCOMPARE(unwrapped, &obj);
+ }
+ {
+ TestObject obj;
+ QJsonObject objectInfo = channel.d_func()->publisher->wrapResult(QVariant::fromValue(&obj), m_dummyTransport).toObject();
+ QObject *unwrapped = channel.d_func()->publisher->unwrapObject(objectInfo["id"].toString());
+ QCOMPARE(unwrapped, &obj);
+ }
+}
+
void TestWebChannel::testRemoveUnusedTransports()
{
QWebChannel channel;
diff --git a/tests/auto/webchannel/tst_webchannel.h b/tests/auto/webchannel/tst_webchannel.h
index 386f314..40e6fba 100644
--- a/tests/auto/webchannel/tst_webchannel.h
+++ b/tests/auto/webchannel/tst_webchannel.h
@@ -311,6 +311,7 @@ private slots:
void testSetPropertyConversion();
void testDisconnect();
void testWrapRegisteredObject();
+ void testUnwrapObject();
void testRemoveUnusedTransports();
void testPassWrappedObjectBack();
void testWrapValues();