diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-01-13 04:59:30 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-01-13 04:59:30 (GMT) |
commit | 72942b7dab497b656fad8eeb6240fe310a31be29 (patch) | |
tree | acc99ae238d8f50eed884d90b0c21321ecd3cc1c /tests | |
parent | 3526db3b8832c357b368014e6c8ebab63d4071da (diff) | |
download | Qt-72942b7dab497b656fad8eeb6240fe310a31be29.zip Qt-72942b7dab497b656fad8eeb6240fe310a31be29.tar.gz Qt-72942b7dab497b656fad8eeb6240fe310a31be29.tar.bz2 |
Add an autotest for QVariant method params
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativeecmascript/testtypes.h | 2 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 16 |
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index 7724335..6c6ad1f 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -624,6 +624,8 @@ public: Q_INVOKABLE int method_default(int a, int b = 19) { invoke(20); m_actuals << a << b; return b; } + Q_INVOKABLE void method_QVariant(QVariant a, QVariant b = QVariant()) { invoke(21); m_actuals << a << b; } + private: friend class MyInvokableBaseObject; void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 90006a9..034adf7 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -1786,6 +1786,22 @@ void tst_qdeclarativeecmascript::callQtInvokables() QCOMPARE(o.invoked(), -3); QCOMPARE(o.actuals().count(), 1); QCOMPARE(o.actuals().at(0), QVariant(9)); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QVariant(9)").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 21); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(9)); + QCOMPARE(o.actuals().at(1), QVariant()); + + o.reset(); + QCOMPARE(engine->evaluate("object.method_QVariant(\"Hello\", \"World\")").isUndefined(), true); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 21); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(QString("Hello"))); + QCOMPARE(o.actuals().at(1), QVariant(QString("World"))); } // QTBUG-13047 (check that you can pass registered object types as args) |