diff options
Diffstat (limited to 'tests/auto/qml/qqmlengine/tst_qqmlengine.cpp')
| -rw-r--r-- | tests/auto/qml/qqmlengine/tst_qqmlengine.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index b82a1f4174..bf68de0d2f 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -79,6 +79,7 @@ private slots: void lockedRootObject(); void crossReferencingSingletonsDeletion(); void bindingInstallUseAfterFree(); + void attachedObjectOfUnregistered(); public slots: QObject *createAQObjectForOwnershipTest () @@ -1708,6 +1709,42 @@ void tst_qqmlengine::bindingInstallUseAfterFree() QVERIFY(o); } +class UnregisteredAttached : public QObject +{ + Q_OBJECT +public: + UnregisteredAttached(QObject *parent = nullptr) : QObject(parent) {} +}; + +class Unregistered : public QObject +{ + Q_OBJECT + QML_ATTACHED(UnregisteredAttached) +public: + static UnregisteredAttached *qmlAttachedProperties(QObject *obj) + { + return new UnregisteredAttached(obj); + } +}; + +void tst_qqmlengine::attachedObjectOfUnregistered() +{ + QObject o; + + QObject *a = qmlAttachedPropertiesObject<Unregistered>(&o); + QVERIFY(a); + QVERIFY(qobject_cast<UnregisteredAttached *>(a)); + + QObject *b = qmlAttachedPropertiesObject<Unregistered>(&o); + QCOMPARE(a, b); + + QObject o2; + QObject *c = qmlAttachedPropertiesObject<Unregistered>(&o2); + QVERIFY(c); + QVERIFY(qobject_cast<UnregisteredAttached *>(c)); + QVERIFY(c != a); +} + QTEST_MAIN(tst_qqmlengine) #include "tst_qqmlengine.moc" |
