1 /** ***** QxtRPCPeer loopback test ******/
4 #include <QCoreApplication>
12 class RPCTest: public QObject
19 void counterwave(QString);
20 void networkedwave(quint64,QString);
33 QVERIFY2(peer.attachSignal (this, SIGNAL( wave ( QString ) ) ),"cannot attach signal");
34 QVERIFY2(peer.attachSlot ( SIGNAL( wave ( QString ) ),this, SIGNAL( counterwave(QString )) ),"cannot attach slot");
36 QSignalSpy spy(this, SIGNAL(counterwave(QString)));
37 QSignalSpy spyr(&io, SIGNAL(readyRead()));
41 QCoreApplication::processEvents ();
42 QCoreApplication::processEvents ();
44 QVERIFY2 (spyr.count()> 0, "buffer not emitting readyRead" );
46 QVERIFY2 (spy.count()> 0, "no signal received" );
47 QVERIFY2 (spy.count()< 2, "wtf, two signals received?" );
49 QList<QVariant> arguments = spy.takeFirst();
50 QVERIFY2(arguments.at(0).toString()=="world","argument missmatch");
56 QVERIFY2(peer.attachSlot ( SIGNAL( wave ( QString ) ),this, SIGNAL( counterwave(QString )) ),"cannot attach slot");
58 QSignalSpy spy(this, SIGNAL(counterwave(QString)));
59 QSignalSpy spyr(&io, SIGNAL(readyRead()));
60 peer.call(SIGNAL(wave ( QString ) ),QString("world"));
62 QCoreApplication::processEvents ();
63 QCoreApplication::processEvents ();
66 QVERIFY2 (spyr.count()> 0, "buffer not emitting readyRead" );
68 QVERIFY2 (spy.count()> 0, "no signal received" );
69 QVERIFY2 (spy.count()< 2, "wtf, two signals received?" );
71 QList<QVariant> arguments = spy.takeFirst();
72 QVERIFY2(arguments.at(0).toString()=="world","argument missmatch");
77 QxtRPCPeer server(QxtRPCPeer::Server);
78 QVERIFY2(server.attachSlot (SIGNAL(wave(QString)),this,SIGNAL(networkedwave(quint64,QString))),"cannot attach slot");
81 QVERIFY(server.listen (QHostAddress::LocalHost, 23444));
84 QxtRPCPeer client(QxtRPCPeer::Client);
85 client.connect (QHostAddress::LocalHost, 23444);
86 QVERIFY(qobject_cast<QTcpSocket*>(client.socket())->waitForConnected ( 30000 ));
89 QSignalSpy spy(this, SIGNAL(networkedwave(quint64,QString)));
90 client.call(SIGNAL(wave(QString)),QString("world"));
93 QCoreApplication::processEvents ();
94 QCoreApplication::processEvents ();
95 QCoreApplication::processEvents ();
97 QVERIFY2 (spy.count()> 0, "no signal received" );
98 QVERIFY2 (spy.count()< 2, "wtf, two signals received?" );
100 QList<QVariant> arguments = spy.takeFirst();
101 QVERIFY2(arguments.at(1).toString()=="world","argument missmatch");
103 void cleanupTestCase()