diff options
Diffstat (limited to 'tests/webchannel/tst_webchannel.cpp')
-rw-r--r-- | tests/webchannel/tst_webchannel.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/webchannel/tst_webchannel.cpp b/tests/webchannel/tst_webchannel.cpp index 7fbe5f9..c8f212c 100644 --- a/tests/webchannel/tst_webchannel.cpp +++ b/tests/webchannel/tst_webchannel.cpp @@ -50,6 +50,8 @@ TestWebChannel::TestWebChannel(QObject *parent) : QObject(parent) + , m_lastInt(0) + , m_lastDouble(0) { } @@ -58,6 +60,21 @@ TestWebChannel::~TestWebChannel() } +void TestWebChannel::setInt(int i) +{ + m_lastInt = i; +} + +void TestWebChannel::setDouble(double d) +{ + m_lastDouble = d; +} + +void TestWebChannel::setVariant(const QVariant &v) +{ + m_lastVariant = v; +} + void TestWebChannel::testInitChannel() { QWebChannel channel; @@ -214,6 +231,33 @@ void TestWebChannel::testInfoForObject() } } +void TestWebChannel::testInvokeMethodConversion() +{ + QWebChannel channel; + + QJsonArray args; + args.append(QJsonValue(1000)); + + { + int method = metaObject()->indexOfMethod("setInt(int)"); + QVERIFY(method != -1); + QVERIFY(channel.d->publisher->invokeMethod(this, method, args, QJsonValue())); + QCOMPARE(m_lastInt, args.at(0).toInt()); + } + { + int method = metaObject()->indexOfMethod("setDouble(double)"); + QVERIFY(method != -1); + QVERIFY(channel.d->publisher->invokeMethod(this, method, args, QJsonValue())); + QCOMPARE(m_lastDouble, args.at(0).toDouble()); + } + { + int method = metaObject()->indexOfMethod("setVariant(QVariant)"); + QVERIFY(method != -1); + QVERIFY(channel.d->publisher->invokeMethod(this, method, args, QJsonValue())); + QCOMPARE(m_lastVariant, args.at(0).toVariant()); + } +} + static QHash<QString, QObject*> createObjects(QObject *parent) { const int num = 100; |