From efb5a3a52e72a69309c10b6da704fb91258a9cc7 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Tue, 21 Feb 2012 13:54:11 +1000 Subject: [PATCH] Changed qnetworkreply unittest to return correct code - Changed waitForFinished() to return correct return code Change-Id: Ic6b0dfa195254783a2106011c4a108d907d73557 Reviewed-by: Rohan McGovern Reviewed-by: Jason McDonald --- .../auto/network/access/qnetworkreply/tst_qnetworkreply.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index c214b5f..5b34fa7 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -1300,19 +1300,17 @@ QString tst_QNetworkReply::runCustomRequest(const QNetworkRequest &request, int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply) { - int code = Success; int count = 0; connect(reply, SIGNAL(finished()), SLOT(finished())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(gotError())); - + returnCode = Success; loop = new QEventLoop; QSignalSpy spy(reply, SIGNAL(downloadProgress(qint64,qint64))); while (!reply->isFinished()) { - QTimer::singleShot(10000, loop, SLOT(quit())); - code = loop->exec(); - if (count == spy.count() && !reply->isFinished()) { - code = Timeout; + QTimer::singleShot(5000, loop, SLOT(quit())); + if ( loop->exec() == Timeout && count == spy.count() && !reply->isFinished()) { + returnCode = Timeout; break; } count = spy.count(); @@ -1320,7 +1318,7 @@ int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply) delete loop; loop = 0; - return code; + return returnCode; } void tst_QNetworkReply::finished() -- 2.7.4