aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlimport
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-02-22 18:13:34 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2019-03-20 06:11:44 +0000
commit0b7e479235aec74f051af4d5ef95e74753b59c6d (patch)
treee6d23fc3dc6991f495246b2b54416517e9407261 /tests/auto/qml/qqmlimport
parentdb292d1fe70a0cfaf315a72d099441cf3969e284 (diff)
Create import directory from intercepted URL, not orignial one
If the qmldir URL got intercepted, we should use the intercepted URL to get to the contents to be loaded. Fixes: QTBUG-73843 Change-Id: I51715575e767ed429a8237517f47196677409fe0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlimport')
-rw-r--r--tests/auto/qml/qqmlimport/data/interceptQmldir.qml7
-rw-r--r--tests/auto/qml/qqmlimport/data/intercepted/View.qml5
-rw-r--r--tests/auto/qml/qqmlimport/data/intercepted/qmldir2
-rw-r--r--tests/auto/qml/qqmlimport/tst_qqmlimport.cpp28
4 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlimport/data/interceptQmldir.qml b/tests/auto/qml/qqmlimport/data/interceptQmldir.qml
new file mode 100644
index 0000000000..bf485b2282
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/data/interceptQmldir.qml
@@ -0,0 +1,7 @@
+import QtQml 2.2
+
+import "$(INTERCEPT)" as Intercepted
+
+QtObject {
+ property QtObject view: Intercepted.View {}
+}
diff --git a/tests/auto/qml/qqmlimport/data/intercepted/View.qml b/tests/auto/qml/qqmlimport/data/intercepted/View.qml
new file mode 100644
index 0000000000..92aa3af95a
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/data/intercepted/View.qml
@@ -0,0 +1,5 @@
+import QtQml 2.2
+
+QtObject {
+ property int foo: 12
+}
diff --git a/tests/auto/qml/qqmlimport/data/intercepted/qmldir b/tests/auto/qml/qqmlimport/data/intercepted/qmldir
new file mode 100644
index 0000000000..ab31de73d8
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/data/intercepted/qmldir
@@ -0,0 +1,2 @@
+module SomeModule
+View 1.0 View.qml
diff --git a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
index 70aaa9678e..a3cb68fdcb 100644
--- a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
+++ b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
@@ -28,6 +28,7 @@
#include <QtTest/QtTest>
#include <QQmlApplicationEngine>
+#include <QQmlAbstractUrlInterceptor>
#include <QtQuick/qquickview.h>
#include <QtQuick/qquickitem.h>
#include <private/qqmlimport_p.h>
@@ -43,6 +44,7 @@ private slots:
void uiFormatLoading();
void completeQmldirPaths_data();
void completeQmldirPaths();
+ void interceptQmldir();
void cleanup();
};
@@ -185,6 +187,32 @@ void tst_QQmlImport::completeQmldirPaths()
QCOMPARE(QQmlImports::completeQmldirPaths(uri, basePaths, majorVersion, minorVersion), expectedPaths);
}
+class QmldirUrlInterceptor : public QQmlAbstractUrlInterceptor {
+public:
+ QUrl intercept(const QUrl &url, DataType type) override
+ {
+ if (type != UrlString && !url.isEmpty() && url.isValid()) {
+ QString str = url.toString(QUrl::None);
+ return str.replace(QStringLiteral("$(INTERCEPT)"), QStringLiteral("intercepted"));
+ }
+ return url;
+ }
+};
+
+void tst_QQmlImport::interceptQmldir()
+{
+ QQmlEngine engine;
+ QmldirUrlInterceptor interceptor;
+ engine.setUrlInterceptor(&interceptor);
+
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("interceptQmldir.qml"));
+ QVERIFY(component.isReady());
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+}
+
+
QTEST_MAIN(tst_QQmlImport)
#include "tst_qqmlimport.moc"