summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2018-04-16 23:41:46 +0200
committerMilian Wolff <milian.wolff@kdab.com>2019-03-25 20:30:09 +0000
commit984c4e6b4dd05561bb39f6daf305e520dfa9f0e6 (patch)
treec061038b12c5e3e7c4b2034c27cbde09362dd206 /tests
parent7a673eb1a6902ef6f2eb03d6beab139282b1e4a5 (diff)
downloadqtwebchannel-984c4e6b4dd05561bb39f6daf305e520dfa9f0e6.tar.gz
Always rebuild the class info for wrapped objects
When a new transport is accessing a previously wrapped object, we used to send potentially outdated property values. [ChangeLog][QWebChannel][General] Send current property values when another transport is accessing a previously wrapped object. Fixes: QTBUG-62388 Change-Id: I5cd5772b42c3cb9860e945bb85f77f0e3b6d6ea0 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/webchannel/tst_webchannel.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/tests/auto/webchannel/tst_webchannel.cpp b/tests/auto/webchannel/tst_webchannel.cpp
index 790e5ac..24778c7 100644
--- a/tests/auto/webchannel/tst_webchannel.cpp
+++ b/tests/auto/webchannel/tst_webchannel.cpp
@@ -1127,13 +1127,22 @@ void TestWebChannel::qtbug62388_wrapObjectMultipleTransports()
auto queryObjectInfo = [&channel](QObject *obj, QWebChannelAbstractTransport *transport) {
return channel.d_func()->publisher->wrapResult(QVariant::fromValue(obj), transport).toObject();
};
- const auto objectInfo = queryObjectInfo(&obj, m_dummyTransport);
- QCOMPARE(objectInfo.length(), 3);
- QVERIFY(objectInfo.contains("id"));
- QVERIFY(objectInfo.contains("__QObject*__"));
- QVERIFY(objectInfo.contains("data"));
- QVERIFY(objectInfo.value("__QObject*__").isBool() && objectInfo.value("__QObject*__").toBool());
+ auto verifyObjectInfo = [&obj](const QJsonObject &objectInfo) {
+
+ QCOMPARE(objectInfo.length(), 3);
+ QVERIFY(objectInfo.contains("id"));
+ QVERIFY(objectInfo.contains("__QObject*__"));
+ QVERIFY(objectInfo.contains("data"));
+ QVERIFY(objectInfo.value("__QObject*__").isBool() && objectInfo.value("__QObject*__").toBool());
+
+ const auto propIndex = obj.metaObject()->indexOfProperty("prop");
+ const auto prop = objectInfo["data"].toObject()["properties"].toArray()[propIndex].toArray()[3].toString();
+ QCOMPARE(prop, obj.prop());
+ };
+
+ const auto objectInfo = queryObjectInfo(&obj, m_dummyTransport);
+ verifyObjectInfo(objectInfo);
const auto id = objectInfo.value("id").toString();
@@ -1143,7 +1152,17 @@ void TestWebChannel::qtbug62388_wrapObjectMultipleTransports()
initTransport(&transport);
QCOMPARE(queryObjectInfo(&obj, &transport), objectInfo);
- // don't crash when the transport is destroyed
+ obj.setProp("asdf");
+
+ const auto objectInfo2 = queryObjectInfo(&obj, m_dummyTransport);
+ QVERIFY(objectInfo2 != objectInfo);
+ verifyObjectInfo(objectInfo2);
+
+ DummyTransport transport2;
+ initTransport(&transport2);
+ QCOMPARE(queryObjectInfo(&obj, &transport2), objectInfo2);
+
+ // don't crash when the transports are destroyed
}
QTEST_MAIN(TestWebChannel)