tst_qtcpserver: Test pauseAccepting/resumeAccepting
Currently untested The socks case is odd: after accepting the first connection it shows as unconnected. Details as for why is unknown, out of scope of adding this test. Pick-to: 6.0 Change-Id: I0e7658f23b89f3af8db379b001ee33a844f3bec4 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
f7d7060b60
commit
6035fd8f2c
@ -113,6 +113,8 @@ private slots:
|
||||
|
||||
void canAccessPendingConnectionsWhileNotListening();
|
||||
|
||||
void pauseAccepting();
|
||||
|
||||
private:
|
||||
bool shouldSkipIpv6TestsForBrokenGetsockopt();
|
||||
#ifdef SHOULD_CHECK_SYSCALL_SUPPORT
|
||||
@ -1046,5 +1048,36 @@ void tst_QTcpServer::canAccessPendingConnectionsWhileNotListening()
|
||||
QCOMPARE(&socket, server.nextPendingConnection());
|
||||
}
|
||||
|
||||
void tst_QTcpServer::pauseAccepting()
|
||||
{
|
||||
QTcpServer server;
|
||||
QSignalSpy spy(&server, &QTcpServer::newConnection);
|
||||
QVERIFY(server.listen());
|
||||
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
const auto address = QHostAddress(setProxy ? QtNetworkSettings::socksProxyServerIp()
|
||||
: QHostAddress::LocalHost);
|
||||
|
||||
const int NumSockets = 6;
|
||||
QTcpSocket sockets[NumSockets];
|
||||
sockets[0].connectToHost(address, server.serverPort());
|
||||
QVERIFY(spy.wait());
|
||||
QCOMPARE(spy.count(), 1);
|
||||
|
||||
server.pauseAccepting();
|
||||
for (int i = 1; i < NumSockets; ++i)
|
||||
sockets[i].connectToHost(address, server.serverPort());
|
||||
QVERIFY(!spy.wait(400));
|
||||
QCOMPARE(spy.count(), 1);
|
||||
|
||||
server.resumeAccepting();
|
||||
if (setProxy) {
|
||||
QEXPECT_FAIL("", "The socks proxy does weird things after accepting the first connection",
|
||||
Abort);
|
||||
}
|
||||
QVERIFY(spy.wait());
|
||||
QCOMPARE(spy.count(), 6);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QTcpServer)
|
||||
#include "tst_qtcpserver.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user