diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-09-08 16:03:12 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-09 03:18:12 +0000 |
commit | a84169b8ff5722c0657d47fee6b0883b4d7dd0d4 (patch) | |
tree | 7740767b6e6d87da9bc7f77f3cabaa8ff845ff0b /tests | |
parent | f38b580004fd2117485040120670b78fa295b7ad (diff) |
Fix generation of names in qmldir files
Dots in QML module names are useless because you cannot instantiate a
component with a dot in its name. We might as well strip all the
extensions when adding components to a qmldir file. This takes care of
.ui.qml as well.
Furthermore, JavaScript files must not be listed because they cannot be
instantiated as QML components.
Change-Id: I9782420ea79fef1d5eedef97cf7a748b96ddbe2b
Fixes: QTBUG-96301
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Tapani Mattila <tapani.mattila@qt.io>
(cherry picked from commit 14a3b34906be5b749ebc6b6c1d8f6807fff8fd88)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qmlbasicapp/BasicExtension/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/auto/qml/qmlbasicapp/BasicExtension/Less.js | 1 | ||||
-rw-r--r-- | tests/auto/qml/qmlbasicapp/BasicExtension/More.ui.qml | 3 | ||||
-rw-r--r-- | tests/auto/qml/qmlbasicapp/main.qml | 1 | ||||
-rw-r--r-- | tests/auto/qml/qmlbasicapp/tst_qmlbasicapp.cpp | 12 |
5 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlbasicapp/BasicExtension/CMakeLists.txt b/tests/auto/qml/qmlbasicapp/BasicExtension/CMakeLists.txt index 14384512c5..3a1074bf53 100644 --- a/tests/auto/qml/qmlbasicapp/BasicExtension/CMakeLists.txt +++ b/tests/auto/qml/qmlbasicapp/BasicExtension/CMakeLists.txt @@ -11,4 +11,6 @@ qt6_add_qml_module(additional_qml_module URI "BasicExtension" QML_FILES Extension.qml + More.ui.qml + Less.js ) diff --git a/tests/auto/qml/qmlbasicapp/BasicExtension/Less.js b/tests/auto/qml/qmlbasicapp/BasicExtension/Less.js new file mode 100644 index 0000000000..585b645dca --- /dev/null +++ b/tests/auto/qml/qmlbasicapp/BasicExtension/Less.js @@ -0,0 +1 @@ +function bar() {} diff --git a/tests/auto/qml/qmlbasicapp/BasicExtension/More.ui.qml b/tests/auto/qml/qmlbasicapp/BasicExtension/More.ui.qml new file mode 100644 index 0000000000..014d794229 --- /dev/null +++ b/tests/auto/qml/qmlbasicapp/BasicExtension/More.ui.qml @@ -0,0 +1,3 @@ +import QtQml + +QtObject { objectName: "ui.qml" } diff --git a/tests/auto/qml/qmlbasicapp/main.qml b/tests/auto/qml/qmlbasicapp/main.qml index 85dfa394d2..dc572d29af 100644 --- a/tests/auto/qml/qmlbasicapp/main.qml +++ b/tests/auto/qml/qmlbasicapp/main.qml @@ -57,4 +57,5 @@ Clock { // this class is defined in QML (Clock.qml) hours: time.hour minutes: time.minute property Extension extension // from BasicExtension + property More more: More {} } diff --git a/tests/auto/qml/qmlbasicapp/tst_qmlbasicapp.cpp b/tests/auto/qml/qmlbasicapp/tst_qmlbasicapp.cpp index f6adfaa943..4d62fc46b6 100644 --- a/tests/auto/qml/qmlbasicapp/tst_qmlbasicapp.cpp +++ b/tests/auto/qml/qmlbasicapp/tst_qmlbasicapp.cpp @@ -57,6 +57,10 @@ void tst_basicapp::loadComponent() const int minute = o->property("minutes").toInt(); QVERIFY(minute >= time.minute() - 1); QVERIFY(minute <= time.minute() + 1); + + QObject *more = qvariant_cast<QObject*>(o->property("more")); + QVERIFY(more); + QCOMPARE(more->objectName(), QStringLiteral("ui.qml")); } void tst_basicapp::resourceFiles() @@ -123,6 +127,14 @@ void tst_basicapp::qmldirContents() QVERIFY(qmldirInResources.open(QIODevice::ReadOnly)); QCOMPARE(qmldirInResources.readAll(), contents); } + + { + QFile qmldir(QCoreApplication::applicationDirPath() + "/BasicExtension/qmldir"); + QVERIFY(qmldir.open(QIODevice::ReadOnly)); + const QByteArray contents = qmldir.readAll(); + QVERIFY(contents.contains("More 1.0 More.ui.qml")); + QVERIFY(!contents.contains("Less.js")); + } } QTEST_MAIN(tst_basicapp) |