diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/data/sequenceConvert.qml | 10 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/testtypes.h | 21 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 14 |
3 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConvert.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConvert.qml new file mode 100644 index 0000000000..405d784dfe --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConvert.qml @@ -0,0 +1,10 @@ +import QtQml 2.0 +import qt.test 1.0 + +QtObject { + Component.onCompleted: { + var myList = SequenceConvertObject.getValues() + SequenceConvertObject.call(myList) + } +} + diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index dead289b15..878dd79466 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -1748,6 +1748,27 @@ public slots: void selection(const QItemSelection &, int = 0) { funcCalled = QLatin1String("QItemSelection"); } }; +class SequenceConvertObject : public QObject +{ + Q_OBJECT + +public: + QString funcCalled; +public slots: + + Q_INVOKABLE QStringList getValues() const { + return QStringList() << QStringLiteral("one") << QStringLiteral("two"); + } + + Q_INVOKABLE void call(const QStringList &) { + funcCalled = QLatin1String("stringlist"); + } + + Q_INVOKABLE void call(const QList<int> &) { + funcCalled = QLatin1String("intlist"); + } +}; + struct ClassWithQProperty2 : public QObject { Q_OBJECT diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 8778a1e1ac..96fdd012e2 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -391,6 +391,7 @@ private slots: void urlSearchParamsConstruction(); void urlSearchParamsMethods(); void variantConversionMethod(); + void sequenceConversionMethod(); void gcCrashRegressionTest(); @@ -9497,6 +9498,19 @@ void tst_qqmlecmascript::variantConversionMethod() QCOMPARE(obj.funcCalled, QLatin1String("QModelIndex")); } +void tst_qqmlecmascript::sequenceConversionMethod() +{ + QQmlEngine qmlengine; + + SequenceConvertObject obj; + qmlRegisterSingletonInstance("qt.test", 1, 0, "SequenceConvertObject", &obj); + + QQmlComponent component(&qmlengine, testFileUrl("sequenceConvert.qml")); + QScopedPointer<QObject> o(component.create()); + QVERIFY(o != nullptr); + QCOMPARE(obj.funcCalled, QLatin1String("stringlist")); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" |