aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2024-03-25 14:13:50 +0100
committerUlf Hermann <ulf.hermann@qt.io>2024-04-03 20:37:18 +0200
commit6314d305ee0d9064ca848980ef2dab1793c191b8 (patch)
tree9b0b471a41a3171e7938c0e99842aa12404105e4 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parentaa2e2333376cefd1c7b8c3931097eb6dd4b96dd9 (diff)
Generate qmldir files for extra directories with QML files
Those qmldir files contain only a prefer directive for the canonical resource location of the module. This way, any time another component from the implicit import is requested, it will not be located in the extra directory (where it probably doesn't exist), but instead in the canonical location. Since people may have manually written qmldir files with different content in those places, or worse, relied on the other components to be inaccessible, we need a new policy to opt into this. Fixes: QTBUG-111763 Change-Id: If236feb7dd7c8d704b813ea56482ff758799d0a7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 82cc1fe954..22e04e0df3 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -162,6 +162,8 @@ private slots:
void methodOnListLookup();
void methods();
void modulePrefix();
+ void multiDirectory_data();
+ void multiDirectory();
void multiForeign();
void multiLookup();
void multipleCtors();
@@ -2608,13 +2610,13 @@ void tst_QmlCppCodegen::invisibleSingleton()
qmlClearTypeRegistrations();
QQmlEngine engine;
- const QUrl copy(u"qrc:/qt/qml/TestTypes/hidden/Main.qml"_s);
+ const QUrl copy(u"qrc:/qt/qml/HiddenTestTypes/hidden/Main.qml"_s);
QQmlComponent c(&engine, copy);
QVERIFY2(c.isReady(), qPrintable(c.errorString()));
QTest::ignoreMessage(
QtWarningMsg,
- "qrc:/qt/qml/TestTypes/hidden/Main.qml:4:5: "
+ "qrc:/qt/qml/HiddenTestTypes/hidden/Main.qml:4:5: "
"Unable to assign [undefined] to QColor");
QScopedPointer<QObject> o(c.create());
QVERIFY(!o.isNull());
@@ -3293,6 +3295,29 @@ void tst_QmlCppCodegen::modulePrefix()
QCOMPARE(rootObject->property("baz").toString(), QStringLiteral("ItIsTheSingleton"));
}
+void tst_QmlCppCodegen::multiDirectory_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addRow("from qt_add_qml_module")
+ << QUrl(u"qrc:/qt/qml/TestTypes/extra/extra.qml"_s);
+#ifndef VERY_OLD_CMAKE
+ QTest::addRow("from qt_target_qml_sources")
+ << QUrl(u"qrc:/qt/qml/TestTypes/extra2/extra.qml"_s);
+#endif
+}
+
+void tst_QmlCppCodegen::multiDirectory()
+{
+ QFETCH(QUrl, url);
+ QQmlEngine engine;
+ QQmlComponent component(&engine, url);
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> rootObject(component.create());
+ QVERIFY(rootObject);
+
+ QCOMPARE(rootObject->property("r").value<QRectF>(), QRectF(4, 6, 8, 10));
+}
+
void tst_QmlCppCodegen::multiForeign()
{
QQmlEngine engine;