diff options
author | Joerg Bornemann <joerg.bornemann@nokia.com> | 2009-09-03 16:05:19 (GMT) |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@nokia.com> | 2009-09-04 09:21:01 (GMT) |
commit | 16f9fc8ea2d9e30c1098c4435adc213d645b971f (patch) | |
tree | ef0f521aca40dcad41f39cdd11e3aebd199ad74f | |
parent | 3035e9cd81dcadb23d77c69d4b1e96ec1550d67c (diff) | |
download | Qt-16f9fc8ea2d9e30c1098c4435adc213d645b971f.zip Qt-16f9fc8ea2d9e30c1098c4435adc213d645b971f.tar.gz Qt-16f9fc8ea2d9e30c1098c4435adc213d645b971f.tar.bz2 |
tst_QLocalSocket::writeToClientAndDisconnect added
In this test case the server writes data to the client and disconnects
at once. After this, the client socket must still be able to read the
data and then close itself.
Task-number: 260631
Reviewed-by: phartman
-rw-r--r-- | tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index a8cef92..fdfbd8a 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -107,8 +107,11 @@ private slots: void recycleServer(); + void writeToClientAndDisconnect(); + void debug(); + #ifdef Q_OS_SYMBIAN private: void unlink(QString serverName); @@ -870,6 +873,33 @@ void tst_QLocalSocket::recycleServer() QVERIFY(server.nextPendingConnection() != 0); } +void tst_QLocalSocket::writeToClientAndDisconnect() +{ +#ifdef Q_OS_SYMBIAN + unlink("writeAndDisconnectServer"); +#endif + + QLocalServer server; + QLocalSocket client; + + QVERIFY(server.listen("writeAndDisconnectServer")); + client.connectToServer("writeAndDisconnectServer"); + QVERIFY(client.waitForConnected(200)); + QVERIFY(server.waitForNewConnection(200)); + QLocalSocket* clientSocket = server.nextPendingConnection(); + QVERIFY(clientSocket); + + char buffer[100]; + memset(buffer, 0, sizeof(buffer)); + QCOMPARE(clientSocket->write(buffer, sizeof(buffer)), (qint64)sizeof(buffer)); + clientSocket->flush(); + clientSocket->disconnectFromServer(); + qApp->processEvents(); // give the socket the chance to receive data + QCOMPARE(client.read(buffer, sizeof(buffer)), (qint64)sizeof(buffer)); + qApp->processEvents(); // give the socket the chance to close itself + QCOMPARE(client.state(), QLocalSocket::UnconnectedState); +} + void tst_QLocalSocket::debug() { // Make sure this compiles |