aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmltypeloader
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2019-07-12 20:47:41 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2019-07-17 13:09:50 +0200
commit140634d2029bfcffd77b16175906082bd03d2d0c (patch)
tree1803d693e778dfcd50b10720a2f57b2bbb3da71a /tests/auto/qml/qqmltypeloader
parentd2c6ac8d5eaa1d4b53b647f01c53d821bbba4665 (diff)
Add support for implicit module imports
This allows a module to make another module import with the same minor version and in the same qualified namespace. This will be used to make import QtQuick 2.5 implicitly import QtQml 2.5, to maintain compatibility. It used to be implemented by means of calling C++ type registration functions directly. Change-Id: I64c7bfe25d75b9a45f5d44a10d035fc2f86d30ca Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmltypeloader')
-rw-r--r--tests/auto/qml/qqmltypeloader/data/implicitimporttest.qml5
-rw-r--r--tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitimport/Test.qml3
-rw-r--r--tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitimport/qmldir2
-rw-r--r--tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp11
4 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmltypeloader/data/implicitimporttest.qml b/tests/auto/qml/qqmltypeloader/data/implicitimporttest.qml
new file mode 100644
index 0000000000..7a054e199b
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/implicitimporttest.qml
@@ -0,0 +1,5 @@
+import modulewithimplicitimport 2.0 as MyNS
+MyNS.Test {
+ MyNS.Item {} // Implicitly imported from QtQuick
+ MyNS.ListModel {}
+}
diff --git a/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitimport/Test.qml b/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitimport/Test.qml
new file mode 100644
index 0000000000..2f78302506
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitimport/Test.qml
@@ -0,0 +1,3 @@
+import QtQuick 2.0
+Item {
+}
diff --git a/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitimport/qmldir b/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitimport/qmldir
new file mode 100644
index 0000000000..10e8f90f62
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/imports/modulewithimplicitimport/qmldir
@@ -0,0 +1,2 @@
+import QtQuick
+Test 2.0 Test.qml
diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
index 7d69b4a156..2993b4b3c8 100644
--- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
+++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
@@ -59,6 +59,7 @@ private slots:
void multiSingletonModule();
void implicitComponentModule();
void qrcRootPathUrl();
+ void implicitImport();
};
void tst_QQMLTypeLoader::testLoadComplete()
@@ -513,6 +514,16 @@ void tst_QQMLTypeLoader::qrcRootPathUrl()
QCOMPARE(component.status(), QQmlComponent::Ready);
}
+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());
+}
+
QTEST_MAIN(tst_QQMLTypeLoader)
#include "tst_qqmltypeloader.moc"