tst_QDnsLookup: extend test coverage for property bindings

The pre-existing tests were not using the QTestPrivate helpers, so
extend them with the call to QTestPrivate::testReadWritePropertyBasics.

The updated test didn't reveal any problems with binding loops, so no
other action is required for now.

Task-number: QTBUG-116346
Change-Id: I51a17974a7f5bec3c969fcb55b6f28e3e9218eb5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 96a62cd1f5e5c5a915d60ba6d86a5ea44fc32acc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Ivan Solovev 2023-08-28 14:34:44 +02:00 committed by Qt Cherry-pick Bot
parent 654b74aa05
commit 94d9e05aa6
2 changed files with 35 additions and 0 deletions

View File

@ -10,6 +10,7 @@ qt_internal_add_test(tst_qdnslookup
tst_qdnslookup.cpp tst_qdnslookup.cpp
LIBRARIES LIBRARIES
Qt::Network Qt::Network
Qt::TestPrivate
) )
qt_internal_extend_target(tst_qdnslookup CONDITION WIN32 qt_internal_extend_target(tst_qdnslookup CONDITION WIN32

View File

@ -5,6 +5,7 @@
#include <QTest> #include <QTest>
#include <QSignalSpy> #include <QSignalSpy>
#include <QtTest/private/qpropertytesthelper_p.h>
#include <QtNetwork/QDnsLookup> #include <QtNetwork/QDnsLookup>
@ -52,6 +53,7 @@ private slots:
void setNameserver_data(); void setNameserver_data();
void setNameserver(); void setNameserver();
void bindingsAndProperties(); void bindingsAndProperties();
void automatedBindings();
}; };
static constexpr qsizetype HeaderSize = 6 * sizeof(quint16); static constexpr qsizetype HeaderSize = 6 * sizeof(quint16);
@ -638,5 +640,37 @@ void tst_QDnsLookup::bindingsAndProperties()
QCOMPARE(nameserverPortChangeSpy.size(), 1); QCOMPARE(nameserverPortChangeSpy.size(), 1);
} }
void tst_QDnsLookup::automatedBindings()
{
QDnsLookup lookup;
QTestPrivate::testReadWritePropertyBasics(lookup, u"aaaa"_s, u"txt"_s, "name");
if (QTest::currentTestFailed()) {
qDebug("Failed property test for QDnsLookup::name");
return;
}
QTestPrivate::testReadWritePropertyBasics(lookup, QDnsLookup::AAAA, QDnsLookup::TXT, "type");
if (QTest::currentTestFailed()) {
qDebug("Failed property test for QDnsLookup::type");
return;
}
QTestPrivate::testReadWritePropertyBasics(lookup, QHostAddress{QHostAddress::Any},
QHostAddress{QHostAddress::LocalHost},
"nameserver");
if (QTest::currentTestFailed()) {
qDebug("Failed property test for QDnsLookup::nameserver");
return;
}
QTestPrivate::testReadWritePropertyBasics(lookup, quint16(123), quint16(456),
"nameserverPort");
if (QTest::currentTestFailed()) {
qDebug("Failed property test for QDnsLookup::nameserverPort");
return;
}
}
QTEST_MAIN(tst_QDnsLookup) QTEST_MAIN(tst_QDnsLookup)
#include "tst_qdnslookup.moc" #include "tst_qdnslookup.moc"