diff options
Diffstat (limited to 'example/tests/tests.cpp')
| -rw-r--r-- | example/tests/tests.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/example/tests/tests.cpp b/example/tests/tests.cpp index 8e175844..21888856 100644 --- a/example/tests/tests.cpp +++ b/example/tests/tests.cpp @@ -32,6 +32,7 @@ #include "QXmppJingleIq.h" #include "QXmppMessage.h" #include "QXmppPresence.h" +#include "QXmppRpcIq.h" #include "QXmppSession.h" #include "QXmppUtils.h" #include "tests.h" @@ -415,6 +416,59 @@ void TestXmlRpc::testStruct() "</struct></value>")); } +void TestXmlRpc::testInvoke() +{ + const QByteArray xml( + "<iq" + " id=\"rpc1\"" + " to=\"responder@company-a.com/jrpc-server\"" + " from=\"requester@company-b.com/jrpc-client\"" + " type=\"set\">" + "<query xmlns=\"jabber:iq:rpc\">" + "<methodCall>" + "<methodName>examples.getStateName</methodName>" + "<params>" + "<param>" + "<value><i4>6</i4></value>" + "</param>" + "</params>" + "</methodCall>" + "</query>" + "</iq>"); + + QXmppRpcInvokeIq iq; + parsePacket(iq, xml); + QCOMPARE(iq.interface(), QLatin1String("examples")); + QCOMPARE(iq.method(), QLatin1String("getStateName")); + QCOMPARE(iq.arguments(), QVariantList() << int(6)); + serializePacket(iq, xml); +} + +void TestXmlRpc::testResponse() +{ + const QByteArray xml( + "<iq" + " id=\"rpc1\"" + " to=\"requester@company-b.com/jrpc-client\"" + " from=\"responder@company-a.com/jrpc-server\"" + " type=\"result\">" + "<query xmlns=\"jabber:iq:rpc\">" + "<methodResponse>" + "<params>" + "<param>" + "<value><string>Colorado</string></value>" + "</param>" + "</params>" + "</methodResponse>" + "</query>" + "</iq>"); + + QXmppRpcResponseIq iq; + parsePacket(iq, xml); + QCOMPARE(iq.values(), QVariantList() << QString("Colorado")); + serializePacket(iq, xml); +} + int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); |
