diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2020-12-17 13:53:45 +0100 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2021-01-27 16:54:38 +0100 |
commit | 061254ed1252eab63e8aca886b6229740cfd27c1 (patch) | |
tree | b7285a4805378fd021f2bca46eea2292500d520f /tests | |
parent | 9b239b7fac12f04a5368cf8bf32a5e011c37d504 (diff) |
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 <andreas.buhr@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
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 <QTest> +#include <QSignalSpy> + #include <QtNetwork/QDnsLookup> #include <QtNetwork/QHostAddress> @@ -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<QDnsLookup::Type> 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<QString> 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<QHostAddress> 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" |