aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2022-03-31 16:28:24 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2022-11-28 17:10:07 +0100
commit6656567a4085e3d6de01226fb7b1ec16ee7ba08c (patch)
tree9d021e9f3c17d468dcc6bc1be52c0e595019a662 /tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
parent6cd8d209ec472a658a330f25b84f92cd61e0d4cf (diff)
Introduce type based overload of Qt.createComponent
Add type based createComponent overloads based on QQmlComponent::loadFromModule. They provide a way to instantiate a component by its type, specified by a URI and typename pair. This enables creating Components for inline component types and C++ only types. Support for directly passing the type is deferred to a later commit, as it needs some care to work together with the compiler. As the string based overload matches a mistaken call to the URL based createComponent with parent and mode swapped (due to anything being convertible to string), we add a check to detect this specific error case and give a helpful error message. [ChangeLog][QtQml] Qt.createComponent now supports creating a Component from its module and type name (passed as strings). Task-number: QTBUG-97156 Fixes: QTBUG-26278 Change-Id: I89e7430fe02d52f57230bfa1b0bfbcbfd0ead4b7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp')
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 2922b02643..f591a87dcb 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -1964,11 +1964,11 @@ void tst_qqmlecmascript::componentCreation_data()
<< "null";
QTest::newRow("invalidSecondArg")
<< "invalidSecondArg"
- << "" // We cannot catch this case as coercing a string to a number is valid in JavaScript
+ << ":40: TypeError: Invalid arguments; did you swap mode and parent"
<< "";
QTest::newRow("invalidThirdArg")
<< "invalidThirdArg"
- << ":45: TypeError: Passing incompatible arguments to C++ functions from JavaScript is not allowed."
+ << ":45: TypeError: Invalid arguments; did you swap mode and parent"
<< "";
QTest::newRow("invalidMode")
<< "invalidMode"