aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2018-04-24 11:35:43 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-04-27 05:22:13 +0000
commitf6bbeeb417102c61e8bf23f41e412ed9753a348d (patch)
treeb45c2341c4e2ee8197da7cda87da6adc7c1617b4 /tests
parent8e20747e94fb24baf9eabbd034efe5c2cf810d55 (diff)
Normalize URL before loading types
This prevents loading of types with slightly different paths multiple times, like "qrc:/One.qml" and "qrc:///One.qml". Task-number: QTBUG-65723 Change-Id: I6e26db6d1d271b2ed37b97eb990618843e99c372 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlengine/data/qrcurls.js1
-rw-r--r--tests/auto/qml/qqmlengine/data/qrcurls.qml4
-rw-r--r--tests/auto/qml/qqmlengine/qqmlengine.pro4
-rw-r--r--tests/auto/qml/qqmlengine/tst_qqmlengine.cpp27
4 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlengine/data/qrcurls.js b/tests/auto/qml/qqmlengine/data/qrcurls.js
new file mode 100644
index 0000000000..15a4d5a70c
--- /dev/null
+++ b/tests/auto/qml/qqmlengine/data/qrcurls.js
@@ -0,0 +1 @@
+function someFunction() {}
diff --git a/tests/auto/qml/qqmlengine/data/qrcurls.qml b/tests/auto/qml/qqmlengine/data/qrcurls.qml
new file mode 100644
index 0000000000..e879577e10
--- /dev/null
+++ b/tests/auto/qml/qqmlengine/data/qrcurls.qml
@@ -0,0 +1,4 @@
+import QtQml 2.0
+
+QtObject {
+}
diff --git a/tests/auto/qml/qqmlengine/qqmlengine.pro b/tests/auto/qml/qqmlengine/qqmlengine.pro
index 8d1e149d62..d2eb92bfd5 100644
--- a/tests/auto/qml/qqmlengine/qqmlengine.pro
+++ b/tests/auto/qml/qqmlengine/qqmlengine.pro
@@ -12,3 +12,7 @@ boot2qt: {
# GC corruption test is too heavy for qemu-arm
DEFINES += SKIP_GCCORRUPTION_TEST
}
+
+RESOURCES += \
+ data/qrcurls.qml \
+ data/qrcurls.js
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
index 52e18011cb..6ae786469d 100644
--- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
+++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
@@ -77,6 +77,7 @@ private slots:
void testGCCorruption();
void testGroupedPropertyRevisions();
void componentFromEval();
+ void qrcUrls();
public slots:
QObject *createAQObjectForOwnershipTest ()
@@ -897,6 +898,32 @@ void tst_qqmlengine::componentFromEval()
QVERIFY(!item.isNull());
}
+void tst_qqmlengine::qrcUrls()
+{
+ QQmlEngine engine;
+ QQmlEnginePrivate *pEngine = QQmlEnginePrivate::get(&engine);
+
+ {
+ QQmlRefPointer<QQmlTypeData> oneQml(pEngine->typeLoader.getType(QUrl("qrc:/qrcurls.qml")),
+ QQmlRefPointer<QQmlTypeData>::Adopt);
+ QVERIFY(oneQml != nullptr);
+ QQmlRefPointer<QQmlTypeData> twoQml(pEngine->typeLoader.getType(QUrl("qrc:///qrcurls.qml")),
+ QQmlRefPointer<QQmlTypeData>::Adopt);
+ QVERIFY(twoQml != nullptr);
+ QCOMPARE(oneQml, twoQml);
+ }
+
+ {
+ QQmlRefPointer<QQmlTypeData> oneJS(pEngine->typeLoader.getType(QUrl("qrc:/qrcurls.js")),
+ QQmlRefPointer<QQmlTypeData>::Adopt);
+ QVERIFY(oneJS != nullptr);
+ QQmlRefPointer<QQmlTypeData> twoJS(pEngine->typeLoader.getType(QUrl("qrc:///qrcurls.js")),
+ QQmlRefPointer<QQmlTypeData>::Adopt);
+ QVERIFY(twoJS != nullptr);
+ QCOMPARE(oneJS, twoJS);
+ }
+}
+
QTEST_MAIN(tst_qqmlengine)
#include "tst_qqmlengine.moc"