diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-06-06 08:39:59 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-06-09 15:46:30 +0200 |
commit | fe8e388418608b4d07b3d8325915af05d386b993 (patch) | |
tree | 44613c79dcc0f7384c5073583576e5e91aaacf64 /tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | |
parent | 38da583642529038c1d226f54946134a7261b654 (diff) |
QML: Fix overload resolution for QObject* types
Amazingly, QObject pointers were not supported at all so far.
Pick-to: 6.5 6.6
Change-Id: I61b28705d3bebf9602bdeee05aadcb085f39b184
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 2684157840..ab880957ac 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -3191,6 +3191,17 @@ void tst_qqmlecmascript::callQtInvokables() QCOMPARE(o->invoked(), -1); // no function got called due to incompatible arguments } + { + o->reset(); + QQmlComponent comp(&qmlengine, testFileUrl("qmlTypeWrapperArgs3.qml")); + QScopedPointer<QObject> root {comp.createWithInitialProperties({{"invokableObject", QVariant::fromValue(o)}}) }; + QVERIFY(root); + QCOMPARE(o->error(), false); + QCOMPARE(o->actuals().size(), 2); + QCOMPARE(o->actuals().at(0).metaType(), QMetaType::fromType<QQmlComponentAttached *>()); + QCOMPARE(o->actuals().at(1).metaType(), QMetaType::fromType<SingletonWithEnum *>()); + } + o->reset(); QVERIFY(EVALUATE_VALUE("object.method_QObject(undefined)", QV4::Primitive::undefinedValue())); QCOMPARE(o->error(), false); @@ -3522,6 +3533,27 @@ void tst_qqmlecmascript::callQtInvokables() QCOMPARE(o->error(), false); QCOMPARE(o->invoked(), -1); QCOMPARE(o->actuals(), QVariantList()); + + o->reset(); + QVERIFY(EVALUATE_VALUE("object.method_component(object.someComponent())", + QV4::Primitive::undefinedValue())); + QCOMPARE(o->error(), false); + QCOMPARE(o->invoked(), 42); + QCOMPARE(o->actuals(), QVariantList() << QVariant::fromValue(o->someComponent())); + + o->reset(); + QVERIFY(EVALUATE_VALUE("object.method_component(object.someTypeObject())", + QV4::Primitive::undefinedValue())); + QCOMPARE(o->error(), false); + QCOMPARE(o->invoked(), 43); + QCOMPARE(o->actuals(), QVariantList() << QVariant::fromValue(o->someTypeObject())); + + o->reset(); + QVERIFY(EVALUATE_VALUE("object.method_component('qrc:/somewhere/else')", + QV4::Primitive::undefinedValue())); + QCOMPARE(o->error(), false); + QCOMPARE(o->invoked(), 44); + QCOMPARE(o->actuals(), QVariantList() << QVariant::fromValue(QUrl("qrc:/somewhere/else"))); } void tst_qqmlecmascript::resolveClashingProperties() |