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/QDnsLookup>
|
||||||
#include <QtNetwork/QHostAddress>
|
#include <QtNetwork/QHostAddress>
|
||||||
|
|
||||||
static bool waitForDone(QDnsLookup *lookup)
|
static const int Timeout = 15000; // 15s
|
||||||
{
|
|
||||||
if (lookup->isFinished())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
QObject::connect(lookup, SIGNAL(finished()),
|
|
||||||
&QTestEventLoop::instance(), SLOT(exitLoop()));
|
|
||||||
QTestEventLoop::instance().enterLoop(10);
|
|
||||||
return !QTestEventLoop::instance().timeout();
|
|
||||||
}
|
|
||||||
|
|
||||||
class tst_QDnsLookup: public QObject
|
class tst_QDnsLookup: public QObject
|
||||||
{
|
{
|
||||||
@ -231,8 +222,7 @@ void tst_QDnsLookup::lookup()
|
|||||||
lookup.setType(static_cast<QDnsLookup::Type>(type));
|
lookup.setType(static_cast<QDnsLookup::Type>(type));
|
||||||
lookup.setName(domain);
|
lookup.setName(domain);
|
||||||
lookup.lookup();
|
lookup.lookup();
|
||||||
QVERIFY(waitForDone(&lookup));
|
QTRY_VERIFY_WITH_TIMEOUT(lookup.isFinished(), Timeout);
|
||||||
QVERIFY(lookup.isFinished());
|
|
||||||
|
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
if (lookup.errorString() == QStringLiteral("Not yet supported on Android"))
|
if (lookup.errorString() == QStringLiteral("Not yet supported on Android"))
|
||||||
@ -331,8 +321,7 @@ void tst_QDnsLookup::lookupReuse()
|
|||||||
lookup.setType(QDnsLookup::A);
|
lookup.setType(QDnsLookup::A);
|
||||||
lookup.setName(domainName("a-single"));
|
lookup.setName(domainName("a-single"));
|
||||||
lookup.lookup();
|
lookup.lookup();
|
||||||
QVERIFY(waitForDone(&lookup));
|
QTRY_VERIFY_WITH_TIMEOUT(lookup.isFinished(), Timeout);
|
||||||
QVERIFY(lookup.isFinished());
|
|
||||||
|
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
if (lookup.errorString() == QStringLiteral("Not yet supported on Android"))
|
if (lookup.errorString() == QStringLiteral("Not yet supported on Android"))
|
||||||
@ -348,8 +337,7 @@ void tst_QDnsLookup::lookupReuse()
|
|||||||
lookup.setType(QDnsLookup::AAAA);
|
lookup.setType(QDnsLookup::AAAA);
|
||||||
lookup.setName(domainName("aaaa-single"));
|
lookup.setName(domainName("aaaa-single"));
|
||||||
lookup.lookup();
|
lookup.lookup();
|
||||||
QVERIFY(waitForDone(&lookup));
|
QTRY_VERIFY_WITH_TIMEOUT(lookup.isFinished(), Timeout);
|
||||||
QVERIFY(lookup.isFinished());
|
|
||||||
QCOMPARE(int(lookup.error()), int(QDnsLookup::NoError));
|
QCOMPARE(int(lookup.error()), int(QDnsLookup::NoError));
|
||||||
QVERIFY(!lookup.hostAddressRecords().isEmpty());
|
QVERIFY(!lookup.hostAddressRecords().isEmpty());
|
||||||
QCOMPARE(lookup.hostAddressRecords().first().name(), domainName("aaaa-single"));
|
QCOMPARE(lookup.hostAddressRecords().first().name(), domainName("aaaa-single"));
|
||||||
@ -366,8 +354,7 @@ void tst_QDnsLookup::lookupAbortRetry()
|
|||||||
lookup.setName(domainName("a-single"));
|
lookup.setName(domainName("a-single"));
|
||||||
lookup.lookup();
|
lookup.lookup();
|
||||||
lookup.abort();
|
lookup.abort();
|
||||||
QVERIFY(waitForDone(&lookup));
|
QTRY_VERIFY_WITH_TIMEOUT(lookup.isFinished(), Timeout);
|
||||||
QVERIFY(lookup.isFinished());
|
|
||||||
QCOMPARE(int(lookup.error()), int(QDnsLookup::OperationCancelledError));
|
QCOMPARE(int(lookup.error()), int(QDnsLookup::OperationCancelledError));
|
||||||
QVERIFY(lookup.hostAddressRecords().isEmpty());
|
QVERIFY(lookup.hostAddressRecords().isEmpty());
|
||||||
|
|
||||||
@ -375,8 +362,7 @@ void tst_QDnsLookup::lookupAbortRetry()
|
|||||||
lookup.setType(QDnsLookup::AAAA);
|
lookup.setType(QDnsLookup::AAAA);
|
||||||
lookup.setName(domainName("aaaa-single"));
|
lookup.setName(domainName("aaaa-single"));
|
||||||
lookup.lookup();
|
lookup.lookup();
|
||||||
QVERIFY(waitForDone(&lookup));
|
QTRY_VERIFY_WITH_TIMEOUT(lookup.isFinished(), Timeout);
|
||||||
QVERIFY(lookup.isFinished());
|
|
||||||
|
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
if (lookup.errorString() == QStringLiteral("Not yet supported on Android"))
|
if (lookup.errorString() == QStringLiteral("Not yet supported on Android"))
|
||||||
|
Loading…
Reference in New Issue
Block a user