From 9f7b341aae0bcab47ed51a5238fde5be37edc6b3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 11 May 2023 09:57:11 -0700 Subject: [PATCH] tst_QDnsLookup: create a dedicated test for IDN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of using initTestCase and QFETCH_GLOBAL, which make the rest of the tests repeat themselves with IDN data, which isn't necessary. Pick-to: 6.5 Change-Id: I3e3bfef633af4130a03afffd175e2537ba89dc04 Reviewed-by: Mårten Nordheim --- .../kernel/qdnslookup/tst_qdnslookup.cpp | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp index 764fe9aee4..1b0829bdf0 100644 --- a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp +++ b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp @@ -9,12 +9,17 @@ #include #include +using namespace Qt::StringLiterals; static const int Timeout = 15000; // 15s class tst_QDnsLookup: public QObject { Q_OBJECT + const QString normalDomain = u".test.qt-project.org"_s; + const QString idnDomain = u".alqualondë.test.qt-project.org"_s; + bool usingIdnDomain = false; + QString domainName(const QString &input); QString domainNameList(const QString &input); QStringList domainNameListAlternatives(const QString &input); @@ -24,6 +29,9 @@ public slots: private slots: void lookup_data(); void lookup(); + void lookupIdn_data() { lookup_data(); } + void lookupIdn(); + void lookupReuse(); void lookupAbortRetry(); void bindingsAndProperties(); @@ -31,9 +39,6 @@ private slots: void tst_QDnsLookup::initTestCase() { - QTest::addColumn("tld"); - QTest::newRow("normal") << ".test.qt-project.org"; - QTest::newRow("idn") << ".alqualond\xc3\xab.test.qt-project.org"; } QString tst_QDnsLookup::domainName(const QString &input) @@ -47,8 +52,9 @@ QString tst_QDnsLookup::domainName(const QString &input) return nodot; } - QFETCH_GLOBAL(QString, tld); - return input + tld; + if (usingIdnDomain) + return input + idnDomain; + return input + normalDomain; } QString tst_QDnsLookup::domainNameList(const QString &input) @@ -286,6 +292,13 @@ void tst_QDnsLookup::lookup() QCOMPARE(texts.join(';'), txt); } +void tst_QDnsLookup::lookupIdn() +{ + usingIdnDomain = true; + lookup(); + usingIdnDomain = false; +} + void tst_QDnsLookup::lookupReuse() { QDnsLookup lookup; @@ -340,10 +353,6 @@ void tst_QDnsLookup::lookupAbortRetry() void tst_QDnsLookup::bindingsAndProperties() { - QFETCH_GLOBAL(const QString, tld); - if (tld == QStringLiteral("idn")) - return; - QDnsLookup lookup; lookup.setType(QDnsLookup::A);