From 5a235da270a4ea65b7ef1edf31a761c41dbfcc88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 22 Nov 2017 14:16:42 +0100 Subject: tst_QTcpSocket: fix disconnectWhileLookingUp ... and unblacklist it on Windows. From what I can tell there is no particular reason why this test fails other than that it is a little too slow sometimes (these things happen). So, to fix the test I bumped the timeout, but to avoid the test running for longer on every test-run it now also ends when the socket enters the "Unconnected" state. Previously it failed 171/500 times, and after this patch it failed 0/1000 times. Change-Id: I4266bff6b91aaaf502ee66265d01c3a177706402 Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira Reviewed-by: Jesus Fernandez --- tests/auto/network/socket/qtcpsocket/BLACKLIST | 2 -- tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp | 9 ++++++++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'tests/auto/network/socket') diff --git a/tests/auto/network/socket/qtcpsocket/BLACKLIST b/tests/auto/network/socket/qtcpsocket/BLACKLIST index 5fc2589323..96e59e5678 100644 --- a/tests/auto/network/socket/qtcpsocket/BLACKLIST +++ b/tests/auto/network/socket/qtcpsocket/BLACKLIST @@ -6,8 +6,6 @@ windows windows [invalidProxy:socks5-on-http] windows -[disconnectWhileLookingUp] -windows [timeoutConnect:ip] windows ] diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 7340817ade..f64a88cc05 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -1447,8 +1447,15 @@ void tst_QTcpSocket::disconnectWhileLookingUp() } // let anything queued happen + QEventLoop loop; - QTimer::singleShot(50, &loop, SLOT(quit())); + // If 'doClose' is false then we called '::waitForDisconnected' earlier, meaning + // we are already 'Unconnected'. So we don't need to wait for any potentially slow host lookups. + QTimer::singleShot(doClose ? 4000 : 50, &loop, SLOT(quit())); + connect(socket, &QTcpSocket::stateChanged, [&loop](QAbstractSocket::SocketState state) { + if (state == QAbstractSocket::UnconnectedState) + loop.exit(); // we don't need to wait for the timer to expire; we're done. + }); loop.exec(); // recheck -- cgit v1.2.3