aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-07-13 15:34:05 +1000
committerQt by Nokia <qt-info@nokia.com>2012-07-17 03:52:04 +0200
commit20cecd7b003f27485789e93b4c2b6f5f734e5bea (patch)
tree2dd4a623ac459176d6c541eff8c5217dcaaa1f5b /tests/auto/qml
parentd6bd6cd323f91b9cb01d94c560cf8b40dafeb790 (diff)
Select appropriate version for located module components
When a located module is imported with a version specifier, ensure that the components resolved from that module use the appropriate version. Task-number: QTBUG-26473 Change-Id: I33209ddef3fe9bb0ab9d096dfe19aff233744afc Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/localModule/TestComponent.1.0.qml6
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/localModule/TestComponent.1.1.qml6
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/localModule/TestComponent.2.0.qml6
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/localModule/qmldir3
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp51
5 files changed, 72 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlmoduleplugin/data/localModule/TestComponent.1.0.qml b/tests/auto/qml/qqmlmoduleplugin/data/localModule/TestComponent.1.0.qml
new file mode 100644
index 0000000000..ad757fdc47
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/data/localModule/TestComponent.1.0.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+
+Item {
+ property int majorVersion: 1
+ property int minorVersion: 0
+}
diff --git a/tests/auto/qml/qqmlmoduleplugin/data/localModule/TestComponent.1.1.qml b/tests/auto/qml/qqmlmoduleplugin/data/localModule/TestComponent.1.1.qml
new file mode 100644
index 0000000000..531912b465
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/data/localModule/TestComponent.1.1.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+
+Item {
+ property int majorVersion: 1
+ property int minorVersion: 1
+}
diff --git a/tests/auto/qml/qqmlmoduleplugin/data/localModule/TestComponent.2.0.qml b/tests/auto/qml/qqmlmoduleplugin/data/localModule/TestComponent.2.0.qml
new file mode 100644
index 0000000000..74c9948b69
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/data/localModule/TestComponent.2.0.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+
+Item {
+ property int majorVersion: 2
+ property int minorVersion: 0
+}
diff --git a/tests/auto/qml/qqmlmoduleplugin/data/localModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/data/localModule/qmldir
new file mode 100644
index 0000000000..052e2d9182
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/data/localModule/qmldir
@@ -0,0 +1,3 @@
+TestComponent 1.0 TestComponent.1.0.qml
+TestComponent 1.1 TestComponent.1.1.qml
+TestComponent 2.0 TestComponent.2.0.qml
diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
index b6490753eb..67b3d00196 100644
--- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
@@ -72,6 +72,8 @@ private slots:
void implicitQmldir_data();
void importsNested();
void importsNested_data();
+ void importLocalModule();
+ void importLocalModule_data();
private:
QString m_importsDirectory;
@@ -395,6 +397,55 @@ void tst_qqmlmoduleplugin::importsNested()
}
}
+void tst_qqmlmoduleplugin::importLocalModule()
+{
+ QFETCH(QString, qml);
+ QFETCH(int, majorVersion);
+ QFETCH(int, minorVersion);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(qml.toUtf8(), testFileUrl("empty.qml"));
+
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("majorVersion").value<int>(), majorVersion);
+ QCOMPARE(object->property("minorVersion").value<int>(), minorVersion);
+}
+
+void tst_qqmlmoduleplugin::importLocalModule_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<int>("majorVersion");
+ QTest::addColumn<int>("minorVersion");
+
+ QTest::newRow("default version")
+ << "import \"localModule\"\n"
+ "TestComponent {}"
+ << 2 << 0;
+
+ QTest::newRow("specific version")
+ << "import \"localModule\" 1.1\n"
+ "TestComponent {}"
+ << 1 << 1;
+
+ QTest::newRow("lesser version")
+ << "import \"localModule\" 1.0\n"
+ "TestComponent {}"
+ << 1 << 0;
+
+ // Note: this does not match the behaviour of installed modules, which fail for this case:
+ QTest::newRow("nonexistent version")
+ << "import \"localModule\" 1.3\n"
+ "TestComponent {}"
+ << 1 << 1;
+
+ QTest::newRow("high version")
+ << "import \"localModule\" 2.0\n"
+ "TestComponent {}"
+ << 2 << 0;
+}
+
QTEST_MAIN(tst_qqmlmoduleplugin)
#include "tst_qqmlmoduleplugin.moc"