aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2017-12-11 12:44:47 +0100
committerMichael Brasser <michael.brasser@live.com>2017-12-21 16:02:50 +0000
commit52bc4fbfbae6aa1569dc134dd103e966f04bc2e6 (patch)
tree91c5f84c6623f14338b95b5acbb40c66cb7d1aaf /tests/auto/qml
parentcbdbbe79ec141e66f3160a1332e49518f9682517 (diff)
Use potentially intercepted URL as ID for compilation units
We generally have to pass a URL and a file name everywhere because the logical URL might be something else than the actual file being loaded. For example a QQmlFileSelector might modify the URL to be loaded for a specific file. This resulting URL, however, should not be used to resolve further URLs defined in the file loaded that way. As we need to access QQmlTypeLoader::m_url as string more often now, cache it and avoid frequent translations between QUrl and QString. Furthermore, QQmlDataBlob's URLs are changed to follow the same semantics. The finalUrl is the one that should be used to resolve further URLs, the url is the one used to load the content, and subject to any redirects or interceptions. This changes the semantics of URL redirects. Previously a redirected URL was used as the base URL for furher URL resolution. This doesn't work because redirection occurs after interception and interception should not influence the resolution of further URLs. We now use the original URL as base URL for resolution of further URLs and rely on the server to redirect those, too. Task-number: QTBUG-61209 Change-Id: I93822f820bed2515995de3cb118099218b510ca4 Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/qml.pro1
-rw-r--r--tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp21
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro
index 12a8bd3829..42a5400dc1 100644
--- a/tests/auto/qml/qml.pro
+++ b/tests/auto/qml/qml.pro
@@ -8,6 +8,7 @@ PUBLICTESTS += \
qjsvalueiterator \
qjsonbinding \
qqmlfile \
+ qqmlfileselector
!boot2qt {
PUBLICTESTS += \
diff --git a/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp b/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp
index 648e4490ee..2c62353630 100644
--- a/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp
+++ b/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp
@@ -33,6 +33,7 @@
#include <QQmlApplicationEngine>
#include <QFileSelector>
#include <QQmlContext>
+#include <QLoggingCategory>
#include <qqmlinfo.h>
#include "../../shared/util.h"
@@ -44,6 +45,7 @@ public:
private slots:
void basicTest();
+ void basicTestCached();
void applicationEngineTest();
};
@@ -62,6 +64,25 @@ void tst_qqmlfileselector::basicTest()
delete object;
}
+void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message)
+{
+ if (type == QtDebugMsg
+ && QByteArray(context.category) == QByteArray("qt.qml.diskcache")
+ && message.contains("QML source file has moved to a different location.")) {
+ QFAIL(message.toUtf8());
+ }
+}
+
+void tst_qqmlfileselector::basicTestCached()
+{
+ basicTest(); // Seed the cache, in case basicTestCached() is run on its own
+ QtMessageHandler defaultHandler = qInstallMessageHandler(&messageHandler);
+ QLoggingCategory::setFilterRules("qt.qml.diskcache.debug=true");
+ basicTest(); // Run again and check that the file is in the cache now
+ QLoggingCategory::setFilterRules(QString());
+ qInstallMessageHandler(defaultHandler);
+}
+
void tst_qqmlfileselector::applicationEngineTest()
{
QQmlApplicationEngine engine;