From 061254ed1252eab63e8aca886b6229740cfd27c1 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 17 Dec 2020 13:53:45 +0100 Subject: QDnsLookup - port to the new property system Read/write/notify properties, 3 out of 5 defined in this class. Task-number: QTBUG-85520 Change-Id: Ic6c74f90a2fa3c71d71cf9a5d557f1b6fc489d35 Reviewed-by: Andreas Buhr Reviewed-by: Sona Kurazyan --- .../network/kernel/qdnslookup/tst_qdnslookup.cpp | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'tests') diff --git a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp index 23afb2219c..f462330fdf 100644 --- a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp +++ b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp @@ -29,6 +29,8 @@ #include +#include + #include #include @@ -49,6 +51,7 @@ private slots: void lookup(); void lookupReuse(); void lookupAbortRetry(); + void bindingsAndProperties(); }; void tst_QDnsLookup::initTestCase() @@ -375,5 +378,51 @@ void tst_QDnsLookup::lookupAbortRetry() QCOMPARE(lookup.hostAddressRecords().first().value(), QHostAddress("2001:db8::1")); } +void tst_QDnsLookup::bindingsAndProperties() +{ + QFETCH_GLOBAL(const QString, tld); + if (tld == QStringLiteral("idn")) + return; + + QDnsLookup lookup; + + lookup.setType(QDnsLookup::A); + QProperty dnsTypeProp; + lookup.bindableType().setBinding(Qt::makePropertyBinding(dnsTypeProp)); + const QSignalSpy typeChangeSpy(&lookup, &QDnsLookup::typeChanged); + + dnsTypeProp = QDnsLookup::AAAA; + QCOMPARE(typeChangeSpy.count(), 1); + QCOMPARE(lookup.type(), QDnsLookup::AAAA); + + dnsTypeProp.setBinding(lookup.bindableType().makeBinding()); + lookup.setType(QDnsLookup::A); + QCOMPARE(dnsTypeProp.value(), QDnsLookup::A); + + QProperty nameProp; + lookup.bindableName().setBinding(Qt::makePropertyBinding(nameProp)); + const QSignalSpy nameChangeSpy(&lookup, &QDnsLookup::nameChanged); + + nameProp = QStringLiteral("a-plus-aaaa"); + QCOMPARE(nameChangeSpy.count(), 1); + QCOMPARE(lookup.name(), QStringLiteral("a-plus-aaaa")); + + nameProp.setBinding(lookup.bindableName().makeBinding()); + lookup.setName(QStringLiteral("a-single")); + QCOMPARE(nameProp.value(), QStringLiteral("a-single")); + + QProperty nameserverProp; + lookup.bindableNameserver().setBinding(Qt::makePropertyBinding(nameserverProp)); + const QSignalSpy nameserverChangeSpy(&lookup, &QDnsLookup::nameserverChanged); + + nameserverProp = QHostAddress::LocalHost; + QCOMPARE(nameserverChangeSpy.count(), 1); + QCOMPARE(lookup.nameserver(), QHostAddress::LocalHost); + + nameserverProp.setBinding(lookup.bindableNameserver().makeBinding()); + lookup.setNameserver(QHostAddress::Any); + QCOMPARE(nameserverProp.value(), QHostAddress::Any); +} + QTEST_MAIN(tst_QDnsLookup) #include "tst_qdnslookup.moc" -- cgit v1.2.3