aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
diff options
context:
space:
mode:
authorAlan Alpert <aalpert@blackberry.com>2013-07-18 06:02:37 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-11 12:18:15 +0100
commit054e50babc340f1d8b6c037fca143f90dbd0c1f2 (patch)
treed15e6d1a746d28138bdf479024a51c94cb5fa8a2 /tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
parent98c47db70a72a8afbd86afd355dadb1ce9113361 (diff)
Intercept qmldir files with the url interceptor
There's another code path which loads qmldir files directly, and it did not use the interceptor when available. Note that this, like other interceptors, does not affect baseUrl and so any other qmldir file still must have paths relative from the initial URL. Change-Id: I620943c36d488d22fbaf1793514075d31ab76e3e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto/qml/qqmlengine/tst_qqmlengine.cpp')
-rw-r--r--tests/auto/qml/qqmlengine/tst_qqmlengine.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
index 42e17d5624..004514d39c 100644
--- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
+++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
@@ -680,6 +680,7 @@ void tst_qqmlengine::qtqmlModule()
class CustomSelector : public QQmlAbstractUrlInterceptor
{
public:
+ CustomSelector(const QUrl &base):m_base(base){}
virtual QUrl intercept(const QUrl &url, QQmlAbstractUrlInterceptor::DataType d)
{
if (url.scheme() != QStringLiteral("file"))
@@ -687,6 +688,9 @@ public:
if (!m_interceptionPoints.contains(d))
return url;
+ if (url.path().endsWith("Test.2/qmldir"))//Special case
+ return QUrl::fromLocalFile(m_base.path() + "interception/module/intercepted/qmldir");
+
QString alteredPath = url.path();
int a = alteredPath.lastIndexOf('/');
if (a < 0)
@@ -698,6 +702,7 @@ public:
return ret;
}
QList<QQmlAbstractUrlInterceptor::DataType> m_interceptionPoints;
+ QUrl m_base;
};
Q_DECLARE_METATYPE(QList<QQmlAbstractUrlInterceptor::DataType>);
@@ -729,6 +734,15 @@ void tst_qqmlengine::urlInterceptor_data()
<< testFileUrl("interception/qmldir/intercepted/doesNotExist.file").toString()
<< QStringLiteral("file:///intercepted/doesNotExist.file");
+ QTest::newRow("InterceptModule")//just a Test{}, needs to intercept the module import for it to work
+ << testFileUrl("interception/module/urlInterceptor.qml")
+ << (QList<QQmlAbstractUrlInterceptor::DataType>() << QQmlAbstractUrlInterceptor::QmldirFile )
+ << testFileUrl("interception/module/intercepted/doesNotExist.file").toString()
+ << QStringLiteral("intercepted")
+ << QStringLiteral("intercepted")
+ << testFileUrl("interception/module/intercepted/doesNotExist.file").toString()
+ << QStringLiteral("file:///doesNotExist.file");
+
QTest::newRow("InterceptStrings")
<< testFileUrl("interception/strings/urlInterceptor.qml")
<< (QList<QQmlAbstractUrlInterceptor::DataType>() << QQmlAbstractUrlInterceptor::UrlString)
@@ -751,7 +765,8 @@ void tst_qqmlengine::urlInterceptor()
QFETCH(QString, expectedAbsoluteUrl);
QQmlEngine e;
- CustomSelector cs;
+ e.setImportPathList(QStringList() << testFileUrl("interception/imports").toLocalFile());
+ CustomSelector cs(testFileUrl(""));
cs.m_interceptionPoints = interceptionPoint;
e.setUrlInterceptor(&cs);
QQmlComponent c(&e, testFile); //Note that this can get intercepted too