summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index 0ba9b6a58c..e8a942e6c4 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -200,6 +200,7 @@ private slots:
void setSocketOption();
void clientSendDataOnDelayedDisconnect();
+ void readNotificationsAfterBind();
protected slots:
void nonBlockingIMAP_hostFound();
@@ -2984,5 +2985,25 @@ void tst_QTcpSocket::clientSendDataOnDelayedDisconnect()
delete socket;
}
+// Test that the socket does not enable the read notifications in bind()
+void tst_QTcpSocket::readNotificationsAfterBind()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ QAbstractSocket socket(QAbstractSocket::TcpSocket, Q_NULLPTR);
+ QVERIFY2(socket.bind(), "Bind error!");
+
+ connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QSignalSpy spyReadyRead(&socket, SIGNAL(readyRead()));
+ socket.connectToHost(QtNetworkSettings::serverName(), 12346);
+
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY2(!QTestEventLoop::instance().timeout(), "Connection to closed port timed out instead of refusing, something is wrong");
+ QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
+ QCOMPARE(spyReadyRead.count(), 0);
+}
+
QTEST_MAIN(tst_QTcpSocket)
#include "tst_qtcpsocket.moc"