summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlan Alpert <aalpert@rim.com>2012-12-03 08:48:18 -0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-05 19:20:51 +0100
commitdc96bfd00152e25f007511f64bff7c413f657886 (patch)
treeaa5ee99d99c5e8c64dbb36eb038398e2e399abab /tests
parentad86cd24157cc6ded679f40807591981fe52d540 (diff)
Delay loading implicit import
As a performance improvement to avoid accessing the filesystem unecessarily, only import "." implicitly if types cannot be found in the existing imports. This is not a behavior change for type resolution, because "." already has the lowest precedence for type resolution. Change-Id: I8a8f10f7a790e6a02fc2c07c443f7be1984fc979 Reviewed-by: Matthew Vogt <matthew.vogt@qinetic.com.au> Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/LocalLast2.qml2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml7
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp23
3 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/LocalLast2.qml b/tests/auto/declarative/qdeclarativelanguage/data/LocalLast2.qml
new file mode 100644
index 00000000..4bf7eb2e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/LocalLast2.qml
@@ -0,0 +1,2 @@
+import QtQuick 1.0
+MouseArea {}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml
new file mode 100644
index 00000000..bdb13756
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml
@@ -0,0 +1,7 @@
+import QtQuick 1.0
+import com.nokia.installedtest 1.0
+
+LocalLast2 {
+ property Item item: LocalLast {}
+}
+
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index e201807b..edbfeeb8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -132,6 +132,7 @@ private slots:
void reservedWords();
void inlineAssignmentsOverrideBindings();
void nestedComponentRoots();
+ void implicitImportsLast();
void basicRemote_data();
void basicRemote();
@@ -1806,6 +1807,11 @@ void tst_qdeclarativelanguage::importsOrder_data()
"LocalLast {}"
<< (!qmlCheckTypes()?"QDeclarativeRectangle":"")// i.e. from com.nokia.installedtest, not data/LocalLast.qml
<< (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest and in local directory");
+ QTest::newRow("local last 3") <<
+ "import com.nokia.installedtest 1.0\n"
+ "LocalLast {LocalLast2{}}"
+ << (!qmlCheckTypes()?"QDeclarativeRectangle":"")// i.e. from com.nokia.installedtest, not data/LocalLast.qml
+ << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest and in local directory");
}
void tst_qdeclarativelanguage::importsOrder()
@@ -2021,6 +2027,23 @@ void tst_qdeclarativelanguage::compatibilitySemicolon()
QVERIFY(o != 0);
}
+// Tests that the implicit import has lowest precedence, in the case where
+// there are conflicting types and types only found in the local import.
+// Tests that just check one (or the root) type are in ::importsOrder
+void tst_qdeclarativelanguage::implicitImportsLast()
+{
+ if (qmlCheckTypes())
+ QSKIP("This test is about maintaining the same choice when type is ambiguous.");
+ QDeclarativeComponent component(&engine, testFileUrl("localOrderTest.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = qobject_cast<QObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(QString(object->metaObject()->className()).startsWith(QLatin1String("QDeclarativeMouseArea")));
+ QObject* object2 = object->property("item").value<QObject*>();
+ QVERIFY(object2 != 0);
+ QCOMPARE(QString(object2->metaObject()->className()), QLatin1String("QDeclarativeRectangle"));
+}
+
QTEST_MAIN(tst_qdeclarativelanguage)
#include "tst_qdeclarativelanguage.moc"