diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/testobject.cpp | 9 | ||||
-rw-r--r-- | tests/auto/qml/testobject.h | 7 | ||||
-rw-r--r-- | tests/auto/qml/tst_webchannel.qml | 3 |
3 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/qml/testobject.cpp b/tests/auto/qml/testobject.cpp index 2be7773..4968bf4 100644 --- a/tests/auto/qml/testobject.cpp +++ b/tests/auto/qml/testobject.cpp @@ -33,13 +33,22 @@ QT_BEGIN_NAMESPACE TestObject::TestObject(QObject* parent) : QObject(parent) + , embeddedObject(new QObject(this)) { + embeddedObject->setObjectName("embedded"); } TestObject::~TestObject() { } +QVariantMap TestObject::objectMap() const +{ + QVariantMap map; + map.insert("subObject", QVariant::fromValue(embeddedObject)); + return map; +} + void TestObject::triggerSignals() { emit testSignalBool(true); diff --git a/tests/auto/qml/testobject.h b/tests/auto/qml/testobject.h index e025ea6..5813dae 100644 --- a/tests/auto/qml/testobject.h +++ b/tests/auto/qml/testobject.h @@ -31,22 +31,29 @@ #define TESTOBJECT_H #include <QObject> +#include <QVariantMap> QT_BEGIN_NAMESPACE class TestObject : public QObject { Q_OBJECT + Q_PROPERTY(QVariantMap objectMap READ objectMap CONSTANT) public: explicit TestObject(QObject *parent = Q_NULLPTR); ~TestObject(); + QVariantMap objectMap() const; + public slots: void triggerSignals(); signals: void testSignalBool(bool testBool); void testSignalInt(int testInt); + +private: + QObject *embeddedObject; }; QT_END_NAMESPACE diff --git a/tests/auto/qml/tst_webchannel.qml b/tests/auto/qml/tst_webchannel.qml index 6da6c4b..298376f 100644 --- a/tests/auto/qml/tst_webchannel.qml +++ b/tests/auto/qml/tst_webchannel.qml @@ -297,6 +297,9 @@ TestCase { compare(channel.objects.myFactory.objects.length, 2); compare(channel.objects.myFactory.objects[0].objectName, "bar"); compare(channel.objects.myFactory.objects[1].objectName, "baz"); + // map property as well + compare(channel.objects.testObject.objectMap.subObject.objectName, + "embedded"); // also works with properties that reference other registered objects compare(channel.objects.myFactory.otherObject, channel.objects.myObj); |