diff options
Diffstat (limited to 'tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp')
-rw-r--r-- | tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp index c1df8ec467..810fdecafd 100644 --- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp +++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp @@ -42,6 +42,7 @@ private slots: void cacheModuleScripts(); void reuseStaticMappings(); void invalidateSaveLoadCache(); + void duplicateIdsInInlineComponents(); void inlineComponentDoesNotCauseConstantInvalidation_data(); void inlineComponentDoesNotCauseConstantInvalidation(); @@ -1186,6 +1187,77 @@ void tst_qmldiskcache::invalidateSaveLoadCache() QVERIFY(unit->unitData() != oldUnit->unitData()); } +void tst_qmldiskcache::duplicateIdsInInlineComponents() +{ + // Exercise the case of loading strange generalized group properties from .qmlc. + + QQmlEngine engine; + + TestCompiler testCompiler(&engine); + QVERIFY(testCompiler.tempDir.isValid()); + + const QByteArray contents = QByteArrayLiteral(R"( + import QtQml + QtObject { + component First : QtObject { + property QtObject aa: QtObject { + id: a + } + property Binding bb: Binding { + a.objectName: "test1" + } + } + + component Second : QtObject { + property QtObject aa: QtObject { + id: a + } + property Binding bb: Binding { + a.objectName: "test2" + } + + property Component cc: QtObject { + property QtObject aa: QtObject { + id: a + } + property Binding bb: Binding { + a.objectName: "test3" + } + } + } + + property First first: First {} + property Second second: Second {} + property QtObject third: second.cc.createObject(); + + objectName: first.aa.objectName + second.aa.objectName + third.aa.objectName; + } + )"); + + { + testCompiler.clearCache(); + QVERIFY2(testCompiler.compile(contents), qPrintable(testCompiler.lastErrorString)); + QVERIFY2(testCompiler.verify(), qPrintable(testCompiler.lastErrorString)); + } + + { + CleanlyLoadingComponent component(&engine, testCompiler.testFilePath); + + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->objectName(), "test1test2test3"); + } + + engine.clearComponentCache(); + + { + CleanlyLoadingComponent component(&engine, testCompiler.testFilePath); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->objectName(), "test1test2test3"); + } +} + void tst_qmldiskcache::inlineComponentDoesNotCauseConstantInvalidation_data() { QTest::addColumn<QByteArray>("code"); |