summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp')
-rw-r--r--tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
index 941abf9039..df76dfc47f 100644
--- a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
+++ b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp
@@ -52,6 +52,7 @@ private slots:
void isConstant();
void isFinal();
void gadget();
+ void readAndWriteWithLazyRegistration();
public:
enum EnumType { EnumType1 };
@@ -131,6 +132,56 @@ void tst_QMetaProperty::gadget()
}
}
+struct CustomReadObject : QObject
+{
+ Q_OBJECT
+};
+
+struct CustomWriteObject : QObject
+{
+ Q_OBJECT
+};
+
+struct CustomWriteObjectChild : CustomWriteObject
+{
+ Q_OBJECT
+};
+
+struct TypeLazyRegistration : QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(CustomReadObject *read MEMBER _read)
+ Q_PROPERTY(CustomWriteObject *write MEMBER _write)
+
+ CustomReadObject *_read;
+ CustomWriteObject *_write;
+
+public:
+ TypeLazyRegistration()
+ : _read()
+ , _write()
+ {}
+};
+
+void tst_QMetaProperty::readAndWriteWithLazyRegistration()
+{
+ QCOMPARE(QMetaType::type("CustomReadObject*"), int(QMetaType::UnknownType));
+ QCOMPARE(QMetaType::type("CustomWriteObject*"), int(QMetaType::UnknownType));
+
+ TypeLazyRegistration o;
+ QVERIFY(o.property("read").isValid());
+ QVERIFY(QMetaType::type("CustomReadObject*") != QMetaType::UnknownType);
+ QCOMPARE(QMetaType::type("CustomWriteObject*"), int(QMetaType::UnknownType));
+
+ CustomWriteObjectChild data;
+ QVariant value = QVariant::fromValue(&data); // this register CustomWriteObjectChild
+ // check if base classes are not registered automatically, otherwise this test would be meaningless
+ QCOMPARE(QMetaType::type("CustomWriteObject*"), int(QMetaType::UnknownType));
+ QVERIFY(o.setProperty("write", value));
+ QVERIFY(QMetaType::type("CustomWriteObject*") != QMetaType::UnknownType);
+ QCOMPARE(o.property("write").value<CustomWriteObjectChild*>(), &data);
+}
+
QTEST_MAIN(tst_QMetaProperty)
#include "tst_qmetaproperty.moc"