aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlcomponent
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlcomponent')
-rw-r--r--tests/auto/qml/qqmlcomponent/data/QtObjectComponent#2.qml3
-rw-r--r--tests/auto/qml/qqmlcomponent/data/QtObjectComponent.qml3
-rw-r--r--tests/auto/qml/qqmlcomponent/qqmlcomponent.pro2
-rw-r--r--tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp24
4 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlcomponent/data/QtObjectComponent#2.qml b/tests/auto/qml/qqmlcomponent/data/QtObjectComponent#2.qml
new file mode 100644
index 0000000000..431c659424
--- /dev/null
+++ b/tests/auto/qml/qqmlcomponent/data/QtObjectComponent#2.qml
@@ -0,0 +1,3 @@
+import QtQml 2.0
+
+QtObject {}
diff --git a/tests/auto/qml/qqmlcomponent/data/QtObjectComponent.qml b/tests/auto/qml/qqmlcomponent/data/QtObjectComponent.qml
new file mode 100644
index 0000000000..431c659424
--- /dev/null
+++ b/tests/auto/qml/qqmlcomponent/data/QtObjectComponent.qml
@@ -0,0 +1,3 @@
+import QtQml 2.0
+
+QtObject {}
diff --git a/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro b/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro
index 9f8c8a4e24..0d501ebefd 100644
--- a/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro
+++ b/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro
@@ -8,6 +8,8 @@ SOURCES += tst_qqmlcomponent.cpp \
HEADERS += ../../shared/testhttpserver.h
+RESOURCES += data/QtObjectComponent.qml
+
include (../../shared/util.pri)
TESTDATA = data/*
diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
index f2b0b9973e..3c78f6601e 100644
--- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
+++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
@@ -117,6 +117,8 @@ private slots:
void recursion();
void recursionContinuation();
void callingContextForInitialProperties();
+ void relativeUrl_data();
+ void relativeUrl();
private:
QQmlEngine engine;
@@ -581,6 +583,28 @@ void tst_qqmlcomponent::callingContextForInitialProperties()
QVERIFY(checker->scopeObject->metaObject()->indexOfProperty("incubatedObject") != -1);
}
+void tst_qqmlcomponent::relativeUrl_data()
+{
+ QTest::addColumn<QUrl>("url");
+
+ QTest::addRow("fromLocalFile") << QUrl::fromLocalFile("data/QtObjectComponent.qml");
+ QTest::addRow("fromLocalFileHash") << QUrl::fromLocalFile("data/QtObjectComponent#2.qml");
+ QTest::addRow("constructor") << QUrl("data/QtObjectComponent.qml");
+ QTest::addRow("absolute") << QUrl::fromLocalFile(QFINDTESTDATA("data/QtObjectComponent.qml"));
+ QTest::addRow("qrc") << QUrl("qrc:/data/QtObjectComponent.qml");
+}
+
+void tst_qqmlcomponent::relativeUrl()
+{
+ QFETCH(QUrl, url);
+
+ QQmlComponent component(&engine);
+ // Shouldn't assert in QQmlTypeLoader; we want QQmlComponent to assume that
+ // data/QtObjectComponent.qml refers to the data/QtObjectComponent.qml in the current working directory.
+ component.loadUrl(url);
+ QVERIFY2(!component.isError(), qPrintable(component.errorString()));
+}
+
QTEST_MAIN(tst_qqmlcomponent)
#include "tst_qqmlcomponent.moc"