aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-11-02 10:57:59 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-11-02 14:00:23 +0100
commite826636a0bebd0d73e6c17038b24ee2a42d92ead (patch)
tree0a2ea355eb83af6ac636bec0e5fb0028b81ffbe2 /tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
parent6f968781c4c8a278a7743b0904fb2bdf4c6ddf1a (diff)
QML: Allow singletons to be created with a factory function
This is in line with what we do on qmlRegisterSingletonType(), and it allows us to return singleton objects created independently of the instantiation mechanism. Change-Id: Ia6a077f5d22241593acd8cc87b3f65ae20f95667 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp')
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 74b7c0e64e..40a2ee887a 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -341,6 +341,7 @@ private slots:
void checkURLtoURLObject();
void registerValueTypes();
void extendedNamespace();
+ void factorySingleton();
private:
QQmlEngine engine;
@@ -6048,6 +6049,22 @@ void tst_qqmllanguage::extendedNamespace()
QCOMPARE(obj->property("fromExtension").toInt(), 9);
}
+void tst_qqmllanguage::factorySingleton()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine);
+ c.setData("import StaticTest\n"
+ "import QtQml\n"
+ "QtObject {\n"
+ " property int mine: FactorySingleton.foo\n"
+ "}", QUrl());
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> obj(c.create());
+ QVERIFY(!obj.isNull());
+
+ QCOMPARE(obj->property("mine").toInt(), 314);
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"