diff options
author | Andy Shaw <andy.shaw@theqtcompany.com> | 2015-12-15 13:50:29 +0100 |
---|---|---|
committer | Andy Shaw <andy.shaw@theqtcompany.com> | 2015-12-17 15:08:24 +0000 |
commit | caa0a639e7878f031a2059c86447529c077fbce0 (patch) | |
tree | 29615ee57f80cae43610e75b65eed977bedfa532 /tests/auto/qml/qqmlimport | |
parent | 142b97ce92c6b7d9ef9c5febebf748ea79ea4eea (diff) |
Rearrange the import paths so the qrc one is after the application path
By moving the qrc import path to be after the application one we ensure
that when the application starts up it will look for the imports in the
same way as it would both on deployment and development machine. This is
particularly important when building Qt statically because it should be
looking for the imports inside the resources.
Change-Id: I81f1b7e96c0f9df3671249668accad7adfd00df4
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests/auto/qml/qqmlimport')
-rw-r--r-- | tests/auto/qml/qqmlimport/tst_qqmlimport.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp index ab3d020c82..1f495c3581 100644 --- a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp +++ b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp @@ -43,6 +43,7 @@ class tst_QQmlImport : public QQmlDataTest Q_OBJECT private slots: + void importPathOrder(); void testDesignerSupported(); void uiFormatLoading(); void cleanup(); @@ -127,6 +128,29 @@ void tst_QQmlImport::uiFormatLoading() delete test; } +void tst_QQmlImport::importPathOrder() +{ + QStringList expectedImportPaths; + QString appDirPath = QCoreApplication::applicationDirPath(); + QString qml2Imports = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath); +#ifdef Q_OS_WIN + // The drive letter has a different case as QQmlImport will + // cause it to be converted after passing through QUrl + appDirPath[0] = appDirPath[0].toUpper(); + qml2Imports[0] = qml2Imports[0].toUpper(); +#endif + expectedImportPaths << appDirPath + << QLatin1String("qrc:/qt-project.org/imports") + << qml2Imports; + QQmlEngine engine; + QCOMPARE(expectedImportPaths, engine.importPathList()); + + // Add an import path + engine.addImportPath(QT_QMLTEST_DATADIR); + expectedImportPaths.prepend(QT_QMLTEST_DATADIR); + QCOMPARE(expectedImportPaths, engine.importPathList()); +} + QTEST_MAIN(tst_QQmlImport) #include "tst_qqmlimport.moc" |