Stabilize QDnsLookup test
Use 15s instead of 10 (one check took 7.5s on my development machine, even). Port to QTR_VERIFY_WITH_TIMEOUT instead of rolling our own waitForDone(), as that reports (within limits) by how much the timeout was exceeded. Change-Id: Id76a66d5f4fe3a4e814915add329eb4de3d264a7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
fa0ff2988e
commit
b1afa3bed4
@ -32,16 +32,7 @@
|
||||
#include <QtNetwork/QDnsLookup>
|
||||
#include <QtNetwork/QHostAddress>
|
||||
|
||||
static bool waitForDone(QDnsLookup *lookup)
|
||||
{
|
||||
if (lookup->isFinished())
|
||||
return true;
|
||||
|
||||
QObject::connect(lookup, SIGNAL(finished()),
|
||||
&QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||
QTestEventLoop::instance().enterLoop(10);
|
||||
return !QTestEventLoop::instance().timeout();
|
||||
}
|
||||
static const int Timeout = 15000; // 15s
|
||||
|
||||
class tst_QDnsLookup: public QObject
|
||||
{
|
||||
@ -231,8 +222,7 @@ void tst_QDnsLookup::lookup()
|
||||
lookup.setType(static_cast<QDnsLookup::Type>(type));
|
||||
lookup.setName(domain);
|
||||
lookup.lookup();
|
||||
QVERIFY(waitForDone(&lookup));
|
||||
QVERIFY(lookup.isFinished());
|
||||
QTRY_VERIFY_WITH_TIMEOUT(lookup.isFinished(), Timeout);
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
if (lookup.errorString() == QStringLiteral("Not yet supported on Android"))
|
||||
@ -331,8 +321,7 @@ void tst_QDnsLookup::lookupReuse()
|
||||
lookup.setType(QDnsLookup::A);
|
||||
lookup.setName(domainName("a-single"));
|
||||
lookup.lookup();
|
||||
QVERIFY(waitForDone(&lookup));
|
||||
QVERIFY(lookup.isFinished());
|
||||
QTRY_VERIFY_WITH_TIMEOUT(lookup.isFinished(), Timeout);
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
if (lookup.errorString() == QStringLiteral("Not yet supported on Android"))
|
||||
@ -348,8 +337,7 @@ void tst_QDnsLookup::lookupReuse()
|
||||
lookup.setType(QDnsLookup::AAAA);
|
||||
lookup.setName(domainName("aaaa-single"));
|
||||
lookup.lookup();
|
||||
QVERIFY(waitForDone(&lookup));
|
||||
QVERIFY(lookup.isFinished());
|
||||
QTRY_VERIFY_WITH_TIMEOUT(lookup.isFinished(), Timeout);
|
||||
QCOMPARE(int(lookup.error()), int(QDnsLookup::NoError));
|
||||
QVERIFY(!lookup.hostAddressRecords().isEmpty());
|
||||
QCOMPARE(lookup.hostAddressRecords().first().name(), domainName("aaaa-single"));
|
||||
@ -366,8 +354,7 @@ void tst_QDnsLookup::lookupAbortRetry()
|
||||
lookup.setName(domainName("a-single"));
|
||||
lookup.lookup();
|
||||
lookup.abort();
|
||||
QVERIFY(waitForDone(&lookup));
|
||||
QVERIFY(lookup.isFinished());
|
||||
QTRY_VERIFY_WITH_TIMEOUT(lookup.isFinished(), Timeout);
|
||||
QCOMPARE(int(lookup.error()), int(QDnsLookup::OperationCancelledError));
|
||||
QVERIFY(lookup.hostAddressRecords().isEmpty());
|
||||
|
||||
@ -375,8 +362,7 @@ void tst_QDnsLookup::lookupAbortRetry()
|
||||
lookup.setType(QDnsLookup::AAAA);
|
||||
lookup.setName(domainName("aaaa-single"));
|
||||
lookup.lookup();
|
||||
QVERIFY(waitForDone(&lookup));
|
||||
QVERIFY(lookup.isFinished());
|
||||
QTRY_VERIFY_WITH_TIMEOUT(lookup.isFinished(), Timeout);
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
if (lookup.errorString() == QStringLiteral("Not yet supported on Android"))
|
||||
|
Loading…
Reference in New Issue
Block a user