diff options
Diffstat (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp')
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index e5366b5c48..21efb0336d 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -179,6 +179,7 @@ private slots: void importJs_data(); void importJs(); void explicitSelfImport(); + void importInternalType(); void qmlAttachedPropertiesObjectMethod(); void customOnProperty(); @@ -251,6 +252,7 @@ private slots: void rootObjectInCreationNotForSubObjects(); void lazyDeferredSubObject(); + void deferredProperties(); void noChildEvents(); @@ -3086,6 +3088,29 @@ void tst_qqmllanguage::explicitSelfImport() engine.setImportPathList(defaultImportPathList); } +void tst_qqmllanguage::importInternalType() +{ + QQmlEngine engine; + engine.addImportPath(dataDirectory()); + + { + QQmlComponent component(&engine); + component.setData("import modulewithinternaltypes 1.0\nPublicType{}", QUrl()); + VERIFY_ERRORS(0); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QVERIFY(obj->property("myInternalType").value<QObject*>() != 0); + } + { + QQmlComponent component(&engine); + component.setData("import modulewithinternaltypes 1.0\nPublicTypeWithExplicitImport{}", QUrl()); + VERIFY_ERRORS(0); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QVERIFY(obj->property("myInternalType").value<QObject*>() != 0); + } +} + void tst_qqmllanguage::qmlAttachedPropertiesObjectMethod() { QObject object; @@ -4330,6 +4355,53 @@ void tst_qqmllanguage::lazyDeferredSubObject() QCOMPARE(subObject->objectName(), QStringLiteral("custom")); } +// QTBUG-63200 +void tst_qqmllanguage::deferredProperties() +{ + QQmlComponent component(&engine, testFile("deferredProperties.qml")); + VERIFY_ERRORS(0); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + QObject *innerObj = object->findChild<QObject *>(QStringLiteral("innerobj")); + QVERIFY(!innerObj); + + QObject *outerObj = object->findChild<QObject *>(QStringLiteral("outerobj")); + QVERIFY(!outerObj); + + QObject *groupProperty = object->property("groupProperty").value<QObject *>(); + QVERIFY(!groupProperty); + + QQmlListProperty<QObject> listProperty = object->property("listProperty").value<QQmlListProperty<QObject>>(); + QCOMPARE(listProperty.count(&listProperty), 0); + + qmlExecuteDeferred(object.data()); + + innerObj = object->findChild<QObject *>(QStringLiteral("innerobj")); // MyDeferredListProperty.qml + QVERIFY(innerObj); + QCOMPARE(innerObj->property("wasCompleted"), QVariant(true)); + + outerObj = object->findChild<QObject *>(QStringLiteral("outerobj")); // deferredListProperty.qml + QVERIFY(outerObj); + QCOMPARE(outerObj->property("wasCompleted"), QVariant(true)); + + groupProperty = object->property("groupProperty").value<QObject *>(); + QCOMPARE(groupProperty, outerObj); + + listProperty = object->property("listProperty").value<QQmlListProperty<QObject>>(); + QCOMPARE(listProperty.count(&listProperty), 4); + + QCOMPARE(listProperty.at(&listProperty, 0)->objectName(), QStringLiteral("innerlist1")); // MyDeferredListProperty.qml + QCOMPARE(listProperty.at(&listProperty, 0)->property("wasCompleted"), QVariant(true)); + QCOMPARE(listProperty.at(&listProperty, 1)->objectName(), QStringLiteral("innerlist2")); // MyDeferredListProperty.qml + QCOMPARE(listProperty.at(&listProperty, 1)->property("wasCompleted"), QVariant(true)); + + QCOMPARE(listProperty.at(&listProperty, 2)->objectName(), QStringLiteral("outerlist1")); // deferredListProperty.qml + QCOMPARE(listProperty.at(&listProperty, 2)->property("wasCompleted"), QVariant(true)); + QCOMPARE(listProperty.at(&listProperty, 3)->objectName(), QStringLiteral("outerlist2")); // deferredListProperty.qml + QCOMPARE(listProperty.at(&listProperty, 3)->property("wasCompleted"), QVariant(true)); +} + void tst_qqmllanguage::noChildEvents() { QQmlComponent component(&engine); |