diff options
author | Alan Alpert <aalpert@rim.com> | 2012-12-05 19:36:37 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-08 21:59:24 (GMT) |
commit | 6e939f63b4e7b8ed678f4d551ada35dfb2e76e11 (patch) | |
tree | de6ab6e7f01c3013ffa6865d856b84ffb222eff6 /tests/auto/declarative/qdeclarativelanguage | |
parent | f5b9d1817c798227fd6be688f11b7159d5b0492f (diff) | |
download | Qt-6e939f63b4e7b8ed678f4d551ada35dfb2e76e11.zip Qt-6e939f63b4e7b8ed678f4d551ada35dfb2e76e11.tar.gz Qt-6e939f63b4e7b8ed678f4d551ada35dfb2e76e11.tar.bz2 |
Delay loading implicit import
As a performance improvement to avoid accessing the filesystem
unnecessarily, 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: I5ac2a9fac85559eb96cba93c29d17068fe8171da
Manual cherry-pick of qtquick1/dc96bfd00152e25f007511f64bff7c413f657886
Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativelanguage')
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 0000000..4bf7eb2 --- /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 0000000..d5db212 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/localOrderTest.qml @@ -0,0 +1,7 @@ +import QtQuick 1.0 +import org.qtproject.installedtest 1.0 + +LocalLast2 { + property QtObject item: LocalLast {} +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 40ff989..6068dfd 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -136,6 +136,7 @@ private slots: void reservedWords(); void inlineAssignmentsOverrideBindings(); void nestedComponentRoots(); + void implicitImportsLast(); void basicRemote_data(); void basicRemote(); @@ -1820,6 +1821,11 @@ void tst_qdeclarativelanguage::importsOrder_data() "LocalLast {}" << (!qmlCheckTypes()?"QDeclarativeRectangle":"")// i.e. from org.qtproject.installedtest, not data/LocalLast.qml << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/org/qtproject/installedtest and in local directory"); + QTest::newRow("local last 3") << + "import org.qtproject.installedtest 1.0\n" + "LocalLast {LocalLast2{}}" + << (!qmlCheckTypes()?"QDeclarativeRectangle":"")// i.e. from org.qtproject.installedtest, not data/LocalLast.qml + << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/org/qtproject/installedtest and in local directory"); } void tst_qdeclarativelanguage::importsOrder() @@ -2024,6 +2030,23 @@ void tst_qdeclarativelanguage::aliasPropertyChangeSignals() } } +// 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.", SkipAll); + QDeclarativeComponent component(&engine, TEST_FILE("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" |