aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlimport
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlimport')
-rw-r--r--tests/auto/qml/qqmlimport/CMakeLists.txt7
-rw-r--r--tests/auto/qml/qqmlimport/Preferred.qml5
-rw-r--r--tests/auto/qml/qqmlimport/data/ModuleWithPrefer/Preferred.qml5
-rw-r--r--tests/auto/qml/qqmlimport/data/ModuleWithPrefer/qmldir3
-rw-r--r--tests/auto/qml/qqmlimport/data/prefer.qml3
-rw-r--r--tests/auto/qml/qqmlimport/tst_qqmlimport.cpp12
6 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlimport/CMakeLists.txt b/tests/auto/qml/qqmlimport/CMakeLists.txt
index dba34c1a0b..3d4f01da2c 100644
--- a/tests/auto/qml/qqmlimport/CMakeLists.txt
+++ b/tests/auto/qml/qqmlimport/CMakeLists.txt
@@ -36,6 +36,13 @@ qt_internal_add_test(tst_qqmlimport
TESTDATA ${test_data}
)
+qt_internal_add_resource(tst_qqmlimport "preferred"
+ PREFIX
+ "/qqmlimport/ModuleWithPrefer/"
+ FILES
+ "Preferred.qml"
+)
+
## Scopes:
#####################################################################
diff --git a/tests/auto/qml/qqmlimport/Preferred.qml b/tests/auto/qml/qqmlimport/Preferred.qml
new file mode 100644
index 0000000000..8fda58451e
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/Preferred.qml
@@ -0,0 +1,5 @@
+import QtQml
+
+QtObject {
+ objectName: "right"
+}
diff --git a/tests/auto/qml/qqmlimport/data/ModuleWithPrefer/Preferred.qml b/tests/auto/qml/qqmlimport/data/ModuleWithPrefer/Preferred.qml
new file mode 100644
index 0000000000..a4af255b56
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/data/ModuleWithPrefer/Preferred.qml
@@ -0,0 +1,5 @@
+import QtQml
+
+QtObject {
+ objectName: "wrong"
+}
diff --git a/tests/auto/qml/qqmlimport/data/ModuleWithPrefer/qmldir b/tests/auto/qml/qqmlimport/data/ModuleWithPrefer/qmldir
new file mode 100644
index 0000000000..99f2a28cd1
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/data/ModuleWithPrefer/qmldir
@@ -0,0 +1,3 @@
+module ModuleWithPrefer
+prefer :/qqmlimport/ModuleWithPrefer/
+Preferred 1.0 Preferred.qml
diff --git a/tests/auto/qml/qqmlimport/data/prefer.qml b/tests/auto/qml/qqmlimport/data/prefer.qml
new file mode 100644
index 0000000000..7a6764e08f
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/data/prefer.qml
@@ -0,0 +1,3 @@
+import ModuleWithPrefer
+
+Preferred {}
diff --git a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
index df3d2ba625..4f2b4f6b13 100644
--- a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
+++ b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
@@ -55,6 +55,7 @@ private slots:
void importDependenciesPrecedence();
void cleanup();
void envResourceImportPath();
+ void preferResourcePath();
};
void tst_QQmlImport::cleanup()
@@ -89,6 +90,17 @@ void tst_QQmlImport::envResourceImportPath()
QVERIFY((importPaths.contains(path.startsWith(u':') ? QLatin1String("qrc") + path : path)));
}
+void tst_QQmlImport::preferResourcePath()
+{
+ QQmlEngine engine;
+ engine.addImportPath(dataDirectory());
+
+ QQmlComponent component(&engine, testFileUrl("prefer.qml"));
+ QVERIFY2(component.isReady(), component.errorString().toUtf8());
+ QScopedPointer<QObject> o(component.create());
+ QCOMPARE(o->objectName(), "right");
+}
+
void tst_QQmlImport::testDesignerSupported()
{
QQuickView *window = new QQuickView();