aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-02-01 11:01:50 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-02-02 11:10:48 +0000
commit693b17076c688aee8de21eb34800d99e6b96c501 (patch)
treea4710e152a11725882150a50d0c2c72c02ba2cbf /tests
parentab238e839fc10a85a6711c429e883c7e839596f3 (diff)
CMake: Include upper case .js and .mjs files in qmldir
You can use them as singletons. Fixes: QTBUG-100326 Change-Id: I8e07600657bd43ba8376279ffe39cfa5d3213c38 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit bf38043b6107cb10bca4be78ecc8bbc20338a61b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmlbasicapp/BasicExtension/CMakeLists.txt3
-rw-r--r--tests/auto/qml/qmlbasicapp/BasicExtension/ESModule.mjs1
-rw-r--r--tests/auto/qml/qmlbasicapp/BasicExtension/Less.js2
-rw-r--r--tests/auto/qml/qmlbasicapp/BasicExtension/lowerCase.js1
-rw-r--r--tests/auto/qml/qmlbasicapp/BasicExtension/lowerCaseModule.mjs1
-rw-r--r--tests/auto/qml/qmlbasicapp/main.qml2
-rw-r--r--tests/auto/qml/qmlbasicapp/tst_qmlbasicapp.cpp8
7 files changed, 16 insertions, 2 deletions
diff --git a/tests/auto/qml/qmlbasicapp/BasicExtension/CMakeLists.txt b/tests/auto/qml/qmlbasicapp/BasicExtension/CMakeLists.txt
index 3a1074bf53..a08c71a294 100644
--- a/tests/auto/qml/qmlbasicapp/BasicExtension/CMakeLists.txt
+++ b/tests/auto/qml/qmlbasicapp/BasicExtension/CMakeLists.txt
@@ -13,4 +13,7 @@ qt6_add_qml_module(additional_qml_module
Extension.qml
More.ui.qml
Less.js
+ ESModule.mjs
+ lowerCase.js
+ lowerCaseModule.mjs
)
diff --git a/tests/auto/qml/qmlbasicapp/BasicExtension/ESModule.mjs b/tests/auto/qml/qmlbasicapp/BasicExtension/ESModule.mjs
new file mode 100644
index 0000000000..e1424dc501
--- /dev/null
+++ b/tests/auto/qml/qmlbasicapp/BasicExtension/ESModule.mjs
@@ -0,0 +1 @@
+export function eee() { return "eee" }
diff --git a/tests/auto/qml/qmlbasicapp/BasicExtension/Less.js b/tests/auto/qml/qmlbasicapp/BasicExtension/Less.js
index 585b645dca..a808d7be27 100644
--- a/tests/auto/qml/qmlbasicapp/BasicExtension/Less.js
+++ b/tests/auto/qml/qmlbasicapp/BasicExtension/Less.js
@@ -1 +1 @@
-function bar() {}
+function bar() { return "bar" }
diff --git a/tests/auto/qml/qmlbasicapp/BasicExtension/lowerCase.js b/tests/auto/qml/qmlbasicapp/BasicExtension/lowerCase.js
new file mode 100644
index 0000000000..9d90c9c6f1
--- /dev/null
+++ b/tests/auto/qml/qmlbasicapp/BasicExtension/lowerCase.js
@@ -0,0 +1 @@
+function a() { return "a" }
diff --git a/tests/auto/qml/qmlbasicapp/BasicExtension/lowerCaseModule.mjs b/tests/auto/qml/qmlbasicapp/BasicExtension/lowerCaseModule.mjs
new file mode 100644
index 0000000000..f35813109c
--- /dev/null
+++ b/tests/auto/qml/qmlbasicapp/BasicExtension/lowerCaseModule.mjs
@@ -0,0 +1 @@
+export function fff() { return "fff" }
diff --git a/tests/auto/qml/qmlbasicapp/main.qml b/tests/auto/qml/qmlbasicapp/main.qml
index dc572d29af..a01b56d35d 100644
--- a/tests/auto/qml/qmlbasicapp/main.qml
+++ b/tests/auto/qml/qmlbasicapp/main.qml
@@ -58,4 +58,6 @@ Clock { // this class is defined in QML (Clock.qml)
minutes: time.minute
property Extension extension // from BasicExtension
property More more: More {}
+ property string fromESModule: ESModule.eee()
+ property string fromJSFile: Less.bar()
}
diff --git a/tests/auto/qml/qmlbasicapp/tst_qmlbasicapp.cpp b/tests/auto/qml/qmlbasicapp/tst_qmlbasicapp.cpp
index 4d62fc46b6..2fd7ef634b 100644
--- a/tests/auto/qml/qmlbasicapp/tst_qmlbasicapp.cpp
+++ b/tests/auto/qml/qmlbasicapp/tst_qmlbasicapp.cpp
@@ -61,6 +61,9 @@ void tst_basicapp::loadComponent()
QObject *more = qvariant_cast<QObject*>(o->property("more"));
QVERIFY(more);
QCOMPARE(more->objectName(), QStringLiteral("ui.qml"));
+
+ QCOMPARE(o->property("fromESModule").toString(), QStringLiteral("eee"));
+ QCOMPARE(o->property("fromJSFile").toString(), QStringLiteral("bar"));
}
void tst_basicapp::resourceFiles()
@@ -133,7 +136,10 @@ void tst_basicapp::qmldirContents()
QVERIFY(qmldir.open(QIODevice::ReadOnly));
const QByteArray contents = qmldir.readAll();
QVERIFY(contents.contains("More 1.0 More.ui.qml"));
- QVERIFY(!contents.contains("Less.js"));
+ QVERIFY(contents.contains("Less.js"));
+ QVERIFY(contents.contains("ESModule.mjs"));
+ QVERIFY(!contents.contains("lowerCase.js"));
+ QVERIFY(!contents.contains("lowerCaseModule.mjs"));
}
}