diff options
author | Joerg Bornemann <joerg.bornemann@trolltech.com> | 2009-07-02 12:53:13 (GMT) |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@trolltech.com> | 2009-07-08 12:29:15 (GMT) |
commit | e21e83b9b81801257337902102ea1b267227de4a (patch) | |
tree | 150dc1e36707aae3e58894220263f855552eb1e9 /tests/auto | |
parent | 94c44ba8d6d1220d00a844d95f9dfb15165ea983 (diff) | |
download | Qt-e21e83b9b81801257337902102ea1b267227de4a.zip Qt-e21e83b9b81801257337902102ea1b267227de4a.tar.gz Qt-e21e83b9b81801257337902102ea1b267227de4a.tar.bz2 |
added auto test tst_QLocalSocket::readBufferOverflow
This test handles the case when one limits the size of the socket's
read buffer and more data than the buffer size is available.
Reviewed-by: ossi
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index 4f1eb1d..0f636a4 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -80,6 +80,8 @@ private slots: void sendData_data(); void sendData(); + void readBufferOverflow(); + void fullPath(); void hitMaximumConnections_data(); @@ -531,6 +533,37 @@ void tst_QLocalSocket::sendData() QCOMPARE(spy.count(), (canListen ? 1 : 0)); } +void tst_QLocalSocket::readBufferOverflow() +{ + const int readBufferSize = 128; + const int dataBufferSize = readBufferSize * 2; + const QString serverName = QLatin1String("myPreciousTestServer"); + LocalServer server; + server.listen(serverName); + QVERIFY(server.isListening()); + + LocalSocket client; + client.setReadBufferSize(readBufferSize); + client.connectToServer(serverName); + + bool timedOut = true; + QVERIFY(server.waitForNewConnection(3000, &timedOut)); + QVERIFY(!timedOut); + + QCOMPARE(client.state(), QLocalSocket::ConnectedState); + QVERIFY(server.hasPendingConnections()); + + QLocalSocket* serverSocket = server.nextPendingConnection(); + char* buffer = (char*)qMalloc(dataBufferSize); + memset(buffer, 0, dataBufferSize); + serverSocket->write(buffer, dataBufferSize); + serverSocket->flush(); + qFree(buffer); + + QVERIFY(client.waitForReadyRead()); + QCOMPARE(client.readAll().size(), dataBufferSize); +} + // QLocalSocket/Server can take a name or path, check that it works as expected void tst_QLocalSocket::fullPath() { |