From 9130c4a6bfbd4effe22ed89f7c9ead37dd58f2e7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 28 Jun 2017 09:23:39 +0200 Subject: [PATCH] tst_QSocks5SocketEngine::downloadBigFile(): Output elapsed time Print time in the error handler to get some diagnostics about when the network connection is dropped. Task-number: QTBUG-61673 Change-Id: I376bec81f52d75c9b601f2af9b7e0b63f5883bb0 Reviewed-by: Simon Hausmann --- .../tst_qsocks5socketengine.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp index 18da122000..1212ea20e5 100644 --- a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -728,6 +728,10 @@ void tst_QSocks5SocketEngine::downloadBigFile() QTcpSocket socket; qint64 bytesAvailable = 0; + + QElapsedTimer stopWatch; + stopWatch.start(); + connect(&socket, &QAbstractSocket::connected, &QTestEventLoop::instance(), &QTestEventLoop::exitLoop); connect(&socket, &QIODevice::readyRead, @@ -743,10 +747,11 @@ void tst_QSocks5SocketEngine::downloadBigFile() }); connect(&socket, QOverload::of(&QAbstractSocket::error), - [&socket] (QAbstractSocket::SocketError errorCode) + [&socket, &stopWatch] (QAbstractSocket::SocketError errorCode) { qWarning().noquote().nospace() << QTest::currentTestFunction() - << ": error " << errorCode << ": " << socket.errorString(); + << ": error " << errorCode << ": " << socket.errorString() + << " (" << stopWatch.elapsed() << "ms)"; }); socket.connectToHost(QtNetworkSettings::serverName(), 80); @@ -763,11 +768,7 @@ void tst_QSocks5SocketEngine::downloadBigFile() QVERIFY(socket.write("\r\n") > 0); QVERIFY(socket.write("\r\n") > 0); - - - QTime stopWatch; - stopWatch.start(); - + stopWatch.restart(); QTestEventLoop::instance().enterLoop(60); if (QTestEventLoop::instance().timeout()) QFAIL("Network operation timed out");