aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-11-02 12:15:40 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-11-02 14:00:29 +0100
commit50ba4ffdf48461d38f4dd2137a0fbbc916c9eb0a (patch)
tree6caac8e7a67d27f0a9025523ec6e6a418196740a /tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
parente826636a0bebd0d73e6c17038b24ee2a42d92ead (diff)
QML: Allow singleton types to be extended
It seems we never stated that singletons can not be extended in our documentation. Therefore this is technically a bug fix and doesn't need separate documentation. Change-Id: I7877289bd5a52ecf709f80ba1975137981ec65f0 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.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 40a2ee887a..9a9f13ee0a 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -342,6 +342,7 @@ private slots:
void registerValueTypes();
void extendedNamespace();
void factorySingleton();
+ void extendedSingleton();
private:
QQmlEngine engine;
@@ -6065,6 +6066,28 @@ void tst_qqmllanguage::factorySingleton()
QCOMPARE(obj->property("mine").toInt(), 314);
}
+void tst_qqmllanguage::extendedSingleton()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine);
+ c.setData("import StaticTest\n"
+ "import QtQml\n"
+ "QtObject {\n"
+ " property int a: ExtendedSingleton.foo\n"
+ " property int b: NamespaceExtendedSingleton.foo\n"
+ " property int c: ExtendedSingleton.extension\n"
+ " property int d: NamespaceExtendedSingleton.Bar\n"
+ "}", QUrl());
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> obj(c.create());
+ QVERIFY(!obj.isNull());
+
+ QCOMPARE(obj->property("a").toInt(), 315);
+ QCOMPARE(obj->property("b").toInt(), 316);
+ QCOMPARE(obj->property("c").toInt(), 42);
+ QCOMPARE(obj->property("d").toInt(), 9);
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"