diff options
author | Alan Alpert <aalpert@rim.com> | 2012-12-08 13:57:12 -0800 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-27 20:40:28 +0100 |
commit | 1f3038d2144603c687d85b0a7962322d3c9ae422 (patch) | |
tree | 461b411e8b5b98a0f37495a51e24687d4ca675f5 /tests | |
parent | f7ada9b9325c7adc10da6a3a4e7f887452682260 (diff) |
Delay loading implicit import
As a performance improvement to avoid extra filesystem access, only
import "." if it is needed for type resolution.
Change-Id: If9be25deb3205f8c81f9f418404d9fb41bebb84f
Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
Diffstat (limited to 'tests')
4 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/LocalLast2.qml b/tests/auto/qml/qqmllanguage/data/LocalLast2.qml new file mode 100644 index 0000000000..a6acfcde7c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/LocalLast2.qml @@ -0,0 +1,2 @@ +import QtQuick 2.0 +MouseArea {} diff --git a/tests/auto/qml/qqmllanguage/data/localOrderTest.qml b/tests/auto/qml/qqmllanguage/data/localOrderTest.qml new file mode 100644 index 0000000000..a6a9a4d627 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/localOrderTest.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 +import org.qtproject.installedtest 1.0 + +LocalLast2 { + property QtObject item: LocalLast {} +} + diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 3121d10265..5a924a901a 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -140,6 +140,7 @@ private slots: void readonly(); void receivers(); void registeredCompositeType(); + void implicitImportsLast(); void basicRemote_data(); void basicRemote(); @@ -2470,6 +2471,12 @@ void tst_qqmllanguage::importsOrder_data() << (!qmlCheckTypes()?"QQuickRectangle":"")// i.e. from org.qtproject.installedtest, not data/LocalLast.qml << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/org/qtproject/installedtest/ and in ") << false; + QTest::newRow("local last 3") << //Forces it to load the local qmldir to resolve types, but they shouldn't override anything + "import org.qtproject.installedtest 1.0\n" + "LocalLast {LocalLast2{}}" + << (!qmlCheckTypes()?"QQuickRectangle":"")// i.e. from org.qtproject.installedtest, not data/LocalLast.qml + << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/org/qtproject/installedtest/ and in ") + << false; } void tst_qqmllanguage::importsOrder() @@ -3142,6 +3149,30 @@ void tst_qqmllanguage::scopedProperties() QVERIFY(o->property("success").toBool()); } +// 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_qqmllanguage::implicitImportsLast() +{ + if (qmlCheckTypes()) + QSKIP("This test is about maintaining the same choice when type is ambiguous."); + + if (engine.importPathList() == defaultImportPathList) + engine.addImportPath(testFile("lib")); + + QQmlComponent component(&engine, testFile("localOrderTest.qml")); + VERIFY_ERRORS(0); + QObject *object = qobject_cast<QObject *>(component.create()); + QVERIFY(object != 0); + QVERIFY(QString(object->metaObject()->className()).startsWith(QLatin1String("QQuickMouseArea"))); + QObject* object2 = object->property("item").value<QObject*>(); + QVERIFY(object2 != 0); + QCOMPARE(QString(object2->metaObject()->className()), QLatin1String("QQuickRectangle")); + + engine.setImportPathList(defaultImportPathList); +} + + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/data/implicit2/temptest2.qml b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/temptest2.qml index 0fa9f6e051..051c6f8904 100644 --- a/tests/auto/qml/qqmlmoduleplugin/data/implicit2/temptest2.qml +++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/temptest2.qml @@ -1,8 +1,10 @@ import QtQuick 2.0 // the type loader will implicitly search "." for a qmldir +// to try and find the missing type of AItem // and the qmldir has various syntax errors in it. Item { id: root + AItem{} } |