aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2014-07-15 10:35:24 +0200
committerSean Harmer <sean.harmer@kdab.com>2014-07-25 16:29:36 +0200
commitfcb40ff6d71f4561401e6b2bd4d7fc706fff8eee (patch)
tree942096e3c60e7d08349fa5c1491620e6101146f3 /tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
parent38149bff7c4b89b59f73f4f4d6d5bd1ce9dafbc1 (diff)
qmlRegisterCustomExtendedType, qmlRegisterExtendedUncreatableType
There are cases in Qt3D where we'd like to be able to register uncreatable extended types. The main use case is having an abstract class that has an extension class so as to have a clean separation between the C++ and QML API. Implementations of the abstract can then be easily registered to QML and rely on the extension class for QML specific properties. The other feature we'll need in the near future is the ability to create extended QML types that use a custom parser. Two new type registration method were added to qqml.h to fulfill those needs. Unit tests for those are present in qqmlecmascript and qqmllanguage. Change-Id: I15b2cd791ffd36b537305af1873491c079d4094e Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp')
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index e77c15b79a..6364a8ebdd 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -232,6 +232,7 @@ private slots:
void customParserBindingScopes();
void customParserEvaluateEnum();
void customParserProperties();
+ void customParserWithExtendedObject();
void preservePropertyCacheOnGroupObjects();
void propertyCacheInSync();
@@ -3723,6 +3724,24 @@ void tst_qqmllanguage::customParserProperties()
QVERIFY(!testObject->property("someObject").isNull());
}
+void tst_qqmllanguage::customParserWithExtendedObject()
+{
+ QQmlComponent component(&engine, testFile("customExtendedParserProperties.qml"));
+ VERIFY_ERRORS(0);
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(!o.isNull());
+ SimpleObjectWithCustomParser *testObject = qobject_cast<SimpleObjectWithCustomParser*>(o.data());
+ QVERIFY(testObject);
+ QCOMPARE(testObject->customBindingsCount(), 0);
+ QCOMPARE(testObject->intProperty(), 42);
+ QCOMPARE(testObject->property("qmlString").toString(), QStringLiteral("Hello"));
+ QVERIFY(!testObject->property("someObject").isNull());
+
+ QVariant returnValue;
+ QVERIFY(QMetaObject::invokeMethod(o.data(), "getExtendedProperty", Q_RETURN_ARG(QVariant, returnValue)));
+ QCOMPARE(returnValue.toInt(), 1584);
+}
+
void tst_qqmllanguage::preservePropertyCacheOnGroupObjects()
{
QQmlComponent component(&engine, testFile("preservePropertyCacheOnGroupObjects.qml"));