diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-04-23 13:30:16 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-04-23 14:13:47 (GMT) |
commit | 310496564dabe5f3038c64feff6f444074ee65b1 (patch) | |
tree | 760cb267101c59fa5672d42ea86b89cf03954e33 /tests/auto | |
parent | 08cc1ca928c197a0c94ff791da34e0a79eaed61b (diff) | |
download | Qt-310496564dabe5f3038c64feff6f444074ee65b1.zip Qt-310496564dabe5f3038c64feff6f444074ee65b1.tar.gz Qt-310496564dabe5f3038c64feff6f444074ee65b1.tar.bz2 |
correctly handle remote disconnects
about the only error case for a PeekNamedPipe() which does not actually
want to read anything is some kind of disconnect. so ignore the error
code and just handle the error as a close.
Task-number: 247144
Reviewed-by: thiago
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index e62b657..deabda6 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -95,6 +95,7 @@ private slots: void longPath(); void waitForDisconnect(); + void waitForDisconnectByServer(); void removeServer(); @@ -785,6 +786,25 @@ void tst_QLocalSocket::waitForDisconnect() QVERIFY(timer.elapsed() < 2000); } +void tst_QLocalSocket::waitForDisconnectByServer() +{ + QString name = "tst_localsocket"; + LocalServer server; + QVERIFY(server.listen(name)); + LocalSocket socket; + QSignalSpy spy(&socket, SIGNAL(disconnected())); + QVERIFY(spy.isValid()); + socket.connectToServer(name); + QVERIFY(socket.waitForConnected(3000)); + QVERIFY(server.waitForNewConnection(3000)); + QLocalSocket *serverSocket = server.nextPendingConnection(); + QVERIFY(serverSocket); + serverSocket->close(); + QVERIFY(serverSocket->state() == QLocalSocket::UnconnectedState); + QVERIFY(socket.waitForDisconnected(3000)); + QCOMPARE(spy.count(), 1); +} + void tst_QLocalSocket::removeServer() { // this is a hostile takeover, but recovering from a crash results in the same |