diff options
author | Morten Engvoldsen <morten.engvoldsen@nokia.com> | 2010-10-07 19:23:54 (GMT) |
---|---|---|
committer | Morten Engvoldsen <morten.engvoldsen@nokia.com> | 2010-10-07 19:23:54 (GMT) |
commit | 4f1d524f992b0df3626ab63c001345c96ccea766 (patch) | |
tree | ddc248c09fbb041b09792dae680b2f494e9b4e4b /tests/auto/qtcpserver | |
parent | 34c8022c216f6e298b0b0f8250cdf17688534c5b (diff) | |
parent | 161f15e1e79ec5f23244da68340ba1e78f3ac4bb (diff) | |
download | Qt-4f1d524f992b0df3626ab63c001345c96ccea766.zip Qt-4f1d524f992b0df3626ab63c001345c96ccea766.tar.gz Qt-4f1d524f992b0df3626ab63c001345c96ccea766.tar.bz2 |
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Diffstat (limited to 'tests/auto/qtcpserver')
-rw-r--r-- | tests/auto/qtcpserver/tst_qtcpserver.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp index b2151b9..ab2a32d 100644 --- a/tests/auto/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp @@ -105,6 +105,8 @@ private slots: void invalidProxy(); void proxyFactory_data(); void proxyFactory(); + + void qtbug14268_peek(); }; // Testing get/set functions @@ -662,5 +664,56 @@ void tst_QTcpServer::proxyFactory() QTEST(int(server.serverError()), "expectedError"); } +class Qtbug14268Helper : public QObject +{ + Q_OBJECT +public: + QByteArray lastDataPeeked; +public slots: + void newConnection() { + QTcpServer* server=static_cast<QTcpServer*>(sender()); + QTcpSocket* s=server->nextPendingConnection(); + connect(s,SIGNAL(readyRead()),this,SLOT(onServerReadyRead())); + } + void onServerReadyRead() { + QTcpSocket* clientSocket=static_cast<QTcpSocket*>(sender()); + lastDataPeeked = clientSocket->peek(128*1024).toHex(); + QTestEventLoop::instance().exitLoop(); + } +}; + +// there is a similar test inside tst_qtcpsocket that uses the waitFor* functions instead +void tst_QTcpServer::qtbug14268_peek() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + QTcpServer server; + server.listen(); + + Qtbug14268Helper helper; + QObject::connect(&server, SIGNAL(newConnection()), &helper, SLOT(newConnection())); + + QTcpSocket client; + client.connectToHost(QHostAddress::LocalHost, server.serverPort()); + QVERIFY(client.waitForConnected(2000)); + + client.write("abc\n"); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(helper.lastDataPeeked == QByteArray("6162630a")); + + client.write("def\n"); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(helper.lastDataPeeked == QByteArray("6162630a6465660a")); + + client.write("ghi\n"); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(helper.lastDataPeeked == QByteArray("6162630a6465660a6768690a")); +} + QTEST_MAIN(tst_QTcpServer) #include "tst_qtcpserver.moc" |