diff options
Diffstat (limited to 'tests/auto/qml/qqmlproperty')
-rw-r--r-- | tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index 6cd1eafafd..62ccec5794 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -1157,6 +1157,17 @@ void tst_qqmlproperty::read() QVERIFY(v.canConvert(QMetaType::QObjectStar)); QVERIFY(qvariant_cast<QObject *>(v) == o.qObject()); } + { + QQmlEngine engine; + PropertyObject o; + QQmlProperty p(&o, "qObject", &engine); + QCOMPARE(p.propertyTypeCategory(), QQmlProperty::Object); + + QCOMPARE(p.propertyType(), qMetaTypeId<MyQObject*>()); + QVariant v = p.read(); + QVERIFY(v.canConvert(QMetaType::QObjectStar)); + QVERIFY(qvariant_cast<QObject *>(v) == o.qObject()); + } // Object property { @@ -1432,6 +1443,23 @@ void tst_qqmlproperty::write() QCOMPARE(newData.value<QObject*>(), newObject); QCOMPARE(newData.value<MyQObject*>(), newObject); } + { + QQmlEngine engine; + PropertyObject o; + QQmlProperty p(&o, QString("qObject"), &engine); + QCOMPARE(o.qObject(), (QObject*)0); + QObject *newObject = new MyQObject(this); + QCOMPARE(p.write(QVariant::fromValue(newObject)), true); + QCOMPARE(o.qObject(), newObject); + QVariant data = p.read(); + QCOMPARE(data.value<QObject*>(), newObject); + QCOMPARE(data.value<MyQObject*>(), newObject); + // Incompatible types can not be written. + QCOMPARE(p.write(QVariant::fromValue(new MyQmlObject(this))), false); + QVariant newData = p.read(); + QCOMPARE(newData.value<QObject*>(), newObject); + QCOMPARE(newData.value<MyQObject*>(), newObject); + } } void tst_qqmlproperty::reset() |