aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmltypeloader
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-06-17 15:42:05 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-06-24 18:26:14 +0200
commit36df81b3bc6d721d5598d5163b0a9659de4a69ee (patch)
treed9032e08f4d27daa9e4b16a2c2e622ed2fa6951b /tests/auto/qml/qqmltypeloader
parent6de0287d7c3aa4251fe6eb4f970d73ce11cf07fc (diff)
Discern between "auto" and versioned imports in qmldirs
You can now import the latest version, a specific version, or, "auto" which is the same version as the parent module. [ChangeLog][QtQml] You can now procedurally add module imports to modules, using qmlRegisterModuleImport(). However, actual import statements in qmldir files should be preferred wherever possible. Fixes: QTBUG-84899 Change-Id: I3b32dd8b07a19d31b6538b9a6bb436840862f345 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmltypeloader')
-rw-r--r--tests/auto/qml/qqmltypeloader/data/implicitautoimporttest.qml8
-rw-r--r--tests/auto/qml/qqmltypeloader/data/implicitversionedimporttest.qml8
-rw-r--r--tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitautoimport/Test.qml3
-rw-r--r--tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitautoimport/qmldir3
-rw-r--r--tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitversionedimport/Test.qml3
-rw-r--r--tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitversionedimport/qmldir2
-rw-r--r--tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp23
7 files changed, 46 insertions, 4 deletions
diff --git a/tests/auto/qml/qqmltypeloader/data/implicitautoimporttest.qml b/tests/auto/qml/qqmltypeloader/data/implicitautoimporttest.qml
new file mode 100644
index 0000000000..e32bac3c89
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/implicitautoimporttest.qml
@@ -0,0 +1,8 @@
+import modulewithimplicitautoimport 2.11 as MyNS
+MyNS.Test {
+ MyNS.Item { // Implicitly imported from QtQuick
+ // containmentMask added in 2.11. Version is forwarded.
+ objectName: containmentMask.objectName
+ }
+ MyNS.ListModel {}
+}
diff --git a/tests/auto/qml/qqmltypeloader/data/implicitversionedimporttest.qml b/tests/auto/qml/qqmltypeloader/data/implicitversionedimporttest.qml
new file mode 100644
index 0000000000..ae09eba4e0
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/implicitversionedimporttest.qml
@@ -0,0 +1,8 @@
+import modulewithimplicitversionedimport 2.0 as MyNS
+MyNS.Test {
+ MyNS.Item { // Implicitly imported from QtQuick
+ // containmentMask added in 2.11. Despite version 2.0 above, the module imports 2.15.
+ objectName: containmentMask.objectName
+ }
+ MyNS.ListModel {}
+}
diff --git a/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitautoimport/Test.qml b/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitautoimport/Test.qml
new file mode 100644
index 0000000000..2f78302506
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitautoimport/Test.qml
@@ -0,0 +1,3 @@
+import QtQuick 2.0
+Item {
+}
diff --git a/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitautoimport/qmldir b/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitautoimport/qmldir
new file mode 100644
index 0000000000..468eb296f7
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitautoimport/qmldir
@@ -0,0 +1,3 @@
+import QtQuick auto
+Test 2.0 Test.qml
+Dummy 2.22 Test.qml
diff --git a/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitversionedimport/Test.qml b/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitversionedimport/Test.qml
new file mode 100644
index 0000000000..2f78302506
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitversionedimport/Test.qml
@@ -0,0 +1,3 @@
+import QtQuick 2.0
+Item {
+}
diff --git a/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitversionedimport/qmldir b/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitversionedimport/qmldir
new file mode 100644
index 0000000000..71bbbb99d0
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitversionedimport/qmldir
@@ -0,0 +1,2 @@
+import QtQuick 2.15
+Test 2.0 Test.qml
diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
index 3843d9a720..e1fdb0e221 100644
--- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
+++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
@@ -579,10 +579,25 @@ void tst_QQMLTypeLoader::implicitImport()
{
QQmlEngine engine;
engine.addImportPath(testFile("imports"));
- QQmlComponent component(&engine, testFileUrl("implicitimporttest.qml"));
- QVERIFY2(component.isReady(), qPrintable(component.errorString()));
- QScopedPointer<QObject> obj(component.create());
- QVERIFY(!obj.isNull());
+ {
+ QQmlComponent component(&engine, testFileUrl("implicitimporttest.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("implicitautoimporttest.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("implicitversionedimporttest.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+ }
+
}
void tst_QQMLTypeLoader::compositeSingletonCycle()