Commit 39efe3c8 authored by Joerg Bornemann's avatar Joerg Bornemann
Browse files

Fix glitch in tst_QLocalSocket::sendData


In one code path the test checked for the emission of a readyRead()
signal without waiting for it.
This code path was never hit, neither on Windows nor on Unix platforms.

Change-Id: Ifbe464400a2a1ba8eab49bd60315289040e6bbde
Reviewed-by: default avatarOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Showing with 6 additions and 3 deletions
...@@ -525,6 +525,7 @@ void tst_QLocalSocket::sendData() ...@@ -525,6 +525,7 @@ void tst_QLocalSocket::sendData()
// test creating a connection // test creating a connection
socket.connectToServer(name); socket.connectToServer(name);
bool timedOut = true; bool timedOut = true;
int expectedReadyReadSignals = 0;
QCOMPARE(server.waitForNewConnection(3000, &timedOut), canListen); QCOMPARE(server.waitForNewConnection(3000, &timedOut), canListen);
...@@ -548,15 +549,17 @@ void tst_QLocalSocket::sendData() ...@@ -548,15 +549,17 @@ void tst_QLocalSocket::sendData()
out << testLine << endl; out << testLine << endl;
bool wrote = serverSocket->waitForBytesWritten(3000); bool wrote = serverSocket->waitForBytesWritten(3000);
if (!socket.canReadLine()) if (!socket.canReadLine()) {
expectedReadyReadSignals = 1;
QVERIFY(socket.waitForReadyRead()); QVERIFY(socket.waitForReadyRead());
}
QVERIFY(socket.bytesAvailable() >= 0); QVERIFY(socket.bytesAvailable() >= 0);
QCOMPARE(socket.bytesToWrite(), (qint64)0); QCOMPARE(socket.bytesToWrite(), (qint64)0);
QCOMPARE(socket.flush(), false); QCOMPARE(socket.flush(), false);
QCOMPARE(socket.isValid(), canListen); QCOMPARE(socket.isValid(), canListen);
QCOMPARE(socket.readBufferSize(), (qint64)0); QCOMPARE(socket.readBufferSize(), (qint64)0);
QCOMPARE(spyReadyRead.count(), 1); QCOMPARE(spyReadyRead.count(), expectedReadyReadSignals);
QVERIFY(testLine.startsWith(in.readLine())); QVERIFY(testLine.startsWith(in.readLine()));
...@@ -571,7 +574,7 @@ void tst_QLocalSocket::sendData() ...@@ -571,7 +574,7 @@ void tst_QLocalSocket::sendData()
QCOMPARE(spyDisconnected.count(), canListen ? 1 : 0); QCOMPARE(spyDisconnected.count(), canListen ? 1 : 0);
QCOMPARE(spyError.count(), canListen ? 0 : 1); QCOMPARE(spyError.count(), canListen ? 0 : 1);
QCOMPARE(spyStateChanged.count(), canListen ? 4 : 2); QCOMPARE(spyStateChanged.count(), canListen ? 4 : 2);
QCOMPARE(spyReadyRead.count(), canListen ? 1 : 0); QCOMPARE(spyReadyRead.count(), canListen ? expectedReadyReadSignals : 0);
server.close(); server.close();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment