From 3c5e438890db63ecde98c84d221f87a3af52e1bf Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 11 Apr 2016 17:17:19 +0200 Subject: Allow target path version in a parent module For example, the QML Engine is now able to locate QtQml.Models 2.x in both of the following target/installation paths: - QT_INSTALL_QML/QtQml/Models.2 - QT_INSTALL_QML/QtQml.2/Models This is required for QtQuick Controls 2. The target path of the module is QT_INSTALL_QML/QtQuick/Controls.2. The built-in styles are installed as sub-directories to be able to locate them from the controls module. Some of the built-in styles provide their own C++ extensions via style- specific imports (eg. the Material attached property is imported from QtQuick.Controls.Material 2.0). The problem is that the QML Engine does not find the module from QT_INSTALL_QML/QtQuick/Controls.2/Material, but requires it to be installed outside the main controls module ie. QT_INSTALL_QML/QtQuick/Controls/Material(.2). This makes it a) hard to locate the styles from the main controls module, and b) conflicts with the target path of QtQuick Controls 1. [ChangeLog][QtQml] Made the QML Engine capable of locating QML sub- modules from within a versioned parent module path. For example, QtQml.Models 2.x can be either in QT_INSTALL_QML/QtQml/Models.2 or in QT_INSTALL_QML/QtQml.2/Models. Change-Id: I2fe4bbdd6d04dd1e80cbe9b3e7e02617658a0756 Task-number: QTBUG-52556 Reviewed-by: J-P Nurmi Reviewed-by: Shawn Rutledge Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlimport/tst_qqmlimport.cpp | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests/auto/qml/qqmlimport') diff --git a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp index bfa7e2f13f..68739886c4 100644 --- a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp +++ b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp @@ -41,6 +41,8 @@ private slots: void importPathOrder(); void testDesignerSupported(); void uiFormatLoading(); + void completeQmldirPaths_data(); + void completeQmldirPaths(); void cleanup(); }; @@ -146,6 +148,43 @@ void tst_QQmlImport::importPathOrder() QCOMPARE(expectedImportPaths, engine.importPathList()); } +Q_DECLARE_METATYPE(QQmlImports::ImportVersion) + +void tst_QQmlImport::completeQmldirPaths_data() +{ + QTest::addColumn("uri"); + QTest::addColumn("basePaths"); + QTest::addColumn("majorVersion"); + QTest::addColumn("minorVersion"); + QTest::addColumn("expectedPaths"); + + QTest::newRow("QtQml") << "QtQml" << (QStringList() << "qtbase/qml/" << "path/to/qml") << 2 << 7 + << (QStringList() << "qtbase/qml/QtQml.2.7/qmldir" << "path/to/qml/QtQml.2.7/qmldir" + << "qtbase/qml/QtQml.2/qmldir" << "path/to/qml/QtQml.2/qmldir" + << "qtbase/qml/QtQml/qmldir" << "path/to/qml/QtQml/qmldir"); + + QTest::newRow("QtQml.Models") << "QtQml.Models" << QStringList("qtbase/qml/") << 2 << 2 + << (QStringList() << "qtbase/qml/QtQml/Models.2.2/qmldir" << "qtbase/qml/QtQml.2.2/Models/qmldir" + << "qtbase/qml/QtQml/Models.2/qmldir" << "qtbase/qml/QtQml.2/Models/qmldir" + << "qtbase/qml/QtQml/Models/qmldir"); + + QTest::newRow("org.qt-project.foo.bar") << "org.qt-project.foo.bar" << QStringList("qtbase/qml/") << 0 << 1 + << (QStringList() << "qtbase/qml/org/qt-project/foo/bar.0.1/qmldir" << "qtbase/qml/org/qt-project/foo.0.1/bar/qmldir" << "qtbase/qml/org/qt-project.0.1/foo/bar/qmldir" << "qtbase/qml/org.0.1/qt-project/foo/bar/qmldir" + << "qtbase/qml/org/qt-project/foo/bar.0/qmldir" << "qtbase/qml/org/qt-project/foo.0/bar/qmldir" << "qtbase/qml/org/qt-project.0/foo/bar/qmldir" << "qtbase/qml/org.0/qt-project/foo/bar/qmldir" + << "qtbase/qml/org/qt-project/foo/bar/qmldir"); +} + +void tst_QQmlImport::completeQmldirPaths() +{ + QFETCH(QString, uri); + QFETCH(QStringList, basePaths); + QFETCH(int, majorVersion); + QFETCH(int, minorVersion); + QFETCH(QStringList, expectedPaths); + + QCOMPARE(QQmlImports::completeQmldirPaths(uri, basePaths, majorVersion, minorVersion), expectedPaths); +} + QTEST_MAIN(tst_QQmlImport) #include "tst_qqmlimport.moc" -- cgit v1.2.3