aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2019-07-03 15:13:46 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2019-07-09 16:52:55 +0200
commit910f98031fdd834a22af0da21c9ff6ae145f61c5 (patch)
tree03062e2ec8ccca2a1bbdc2c6e69587de1eedbe76 /tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
parentf2cb10ebc4946b10526fa22581913ccc04cea164 (diff)
Add support for C++ accessible typed parameters and return types in qml functions
These can be declared using the new typescript-like syntax and using type names that are also used for signal parameters and property types. This merely affects their signature on the C++ side and allows the corresponding invocation. Change-Id: Icaed4ee0dc7aa71330f99d96e073a2a63d409bbe Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp')
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index ac7874b701..11e46beb41 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -208,6 +208,7 @@ private slots:
void remoteLoadCrash();
void signalWithDefaultArg();
void signalParameterTypes();
+ void functionParameterTypes();
// regression tests for crashes
void crash1();
@@ -623,9 +624,7 @@ void tst_qqmllanguage::errors_data()
QTest::newRow("bareQmlImport") << "bareQmlImport.qml" << "bareQmlImport.errors.txt" << false;
- QTest::newRow("typeAnnotations") << "typeAnnotations.qml" << "typeAnnotations.errors.txt" << false;
QTest::newRow("typeAnnotations.2") << "typeAnnotations.2.qml" << "typeAnnotations.2.errors.txt" << false;
- QTest::newRow("typeAnnotations.3") << "typeAnnotations.3.qml" << "typeAnnotations.3.errors.txt" << false;
}
@@ -3702,6 +3701,30 @@ void tst_qqmllanguage::signalParameterTypes()
}
}
+void tst_qqmllanguage::functionParameterTypes()
+{
+ QQmlComponent component(&engine, testFileUrl("functionParameterTypes.qml"));
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY2(!obj.isNull(), qPrintable(component.errorString()));
+ const QMetaObject *metaObject = obj->metaObject();
+
+ {
+ QMetaMethod slot = metaObject->method(metaObject->indexOfSlot("returnItem()"));
+ QVERIFY(slot.isValid());
+ QCOMPARE(slot.returnType(), QMetaType::type("QObject*"));
+ QObject *returnedPtr = nullptr;
+ slot.invoke(obj.data(), Qt::DirectConnection, Q_RETURN_ARG(QObject*, returnedPtr));
+ QCOMPARE(returnedPtr, obj.data());
+ }
+
+ {
+ QMetaMethod slot = metaObject->method(metaObject->indexOfSlot("takeString(QString)"));
+ QVERIFY(slot.isValid());
+ QCOMPARE(slot.parameterCount(), 1);
+ QCOMPARE(slot.parameterType(0), int(QMetaType::QString));
+ }
+}
+
// QTBUG-20639
void tst_qqmllanguage::globalEnums()
{