aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-02-01 15:03:19 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-02-01 16:51:51 +0100
commitf6fc35b45b449fe7aaca3237f29393a12fc3f90c (patch)
treebd808ac4fd916f49417f08e0e32105e614c7f0fd /tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
parent24ec3b3e7fa09900d791dcaedb0820a0b1890336 (diff)
QmlCompiler: Allow for multiple extensions per object
Previously, the assumption was that each object could only have a single extension object. As proven by the new qqmllanguage test this is not the case. Each registered object in the type hierarchy can have its own extension. Therefore, adjust the algorithms that generate qmltypes and iterate the extension objects when analyzing them. This leads us to the realization that anonymous types can in fact meaningfully carry extensions and implement interfaces. Adapt qmltyperegistrar accordingly. For the test to compile, however, we need to realize that the class declaring interfaces needs to befriend all potential subclass's QmlInterface structs. Fix that, too. The rabbit hole went deep. Change-Id: Ia451897e927e03b95c3062e829edf1dfcd216613 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp')
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 454ae59ad3..5e40387ceb 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -347,6 +347,8 @@ private slots:
void extendedSingleton();
void qtbug_85932();
+ void multiExtension();
+
private:
QQmlEngine engine;
QStringList defaultImportPathList;
@@ -6128,6 +6130,25 @@ void tst_qqmllanguage::qtbug_85932()
QCOMPARE(allWarnings.at(1).toString(), warning2);
}
+void tst_qqmllanguage::multiExtension()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine);
+ c.setData("import StaticTest\nMultiExtension {}", QUrl());
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QCOMPARE(o->property("a").toInt(), int('a'));
+ QCOMPARE(o->property("b").toInt(), int('b'));
+ QCOMPARE(o->property("p").toInt(), int('p'));
+ QCOMPARE(o->property("e").toInt(), int('e'));
+
+ // Extension properties override base object properties
+ QCOMPARE(o->property("c").toInt(), 12);
+ QCOMPARE(o->property("d").toInt(), 22);
+ QCOMPARE(o->property("f").toInt(), 31);
+ QCOMPARE(o->property("g").toInt(), 44);
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"