aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-05-14 16:11:14 +0200
committerUlf Hermann <ulf.hermann@qt.io>2021-05-19 11:46:37 +0200
commit4b46972be3c34c1b5506ba7d8c97f4520e2c17d6 (patch)
tree49fdcfb5561a1e892bc602e420e295764cb0cd9b /tests
parentd6c98f192922b3ceab5eb65e651a7f0588b482e9 (diff)
Add a ParentProperty classinfo and use that to find parents
This is more robust than just going by the "parent" name. Task-number: QTBUG-93662 Change-Id: If099733de6ad0f3bb7cb75b8915789f66b554f85 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp5
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h16
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
index 8f7e0efb40..c23cc19364 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
@@ -218,4 +218,9 @@ void tst_qmltyperegistrar::finalProperty()
QCOMPARE(qmltypesData.count("Property { name: \"fff\"; type: \"int\"; isFinal: true }"), 1);
}
+void tst_qmltyperegistrar::parentProperty()
+{
+ QCOMPARE(qmltypesData.count("parentProperty: \"ppp\""), 1);
+}
+
QTEST_MAIN(tst_qmltyperegistrar)
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
index 94b4d3b3a2..77243b3f82 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
@@ -290,6 +290,21 @@ struct SelfExtensionHack
QML_VALUE_TYPE(recterei)
};
+class ParentProperty : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QObject *ppp READ ppp BINDABLE pppBindable)
+ QML_ELEMENT
+ Q_CLASSINFO("ParentProperty", "ppp")
+public:
+
+ QObject *ppp() const { return m_parent.value(); }
+ QBindable<QObject *> pppBindable() { return QBindable<QObject *>(&m_parent); }
+
+private:
+ QProperty<QObject *> m_parent;
+};
+
class tst_qmltyperegistrar : public QObject
{
Q_OBJECT
@@ -315,6 +330,7 @@ private slots:
void requiredProperty();
void hiddenAccessor();
void finalProperty();
+ void parentProperty();
private:
QByteArray qmltypesData;