summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/kernel/qdnslookup_appless
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-01-23 18:25:39 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-30 16:39:46 +0100
commite54dc7c2b5b9aa14989f26a718eb99d7516af4a0 (patch)
tree248372c55bede52c63ab0cc367cdfc8c350ba619 /tests/auto/network/kernel/qdnslookup_appless
parentd9468a975210ecb58ff199e931f47df5b99b267f (diff)
Add support for DNS lookups using native APIs
The QDnsLookup class provides asynchronous APIs for performing DNS lookups. For now, the following lookups are supported: - A and AAAA - CNAME as defined per RFC 1035 - MX as defined per RFC 1035 - NS as defined per RFC 1035 - PTR as defined per RFC 1035 - SRV as defined per RFC 2782 - TXT as defined per RFC 1035 Task-number: QTBUG-10481 Change-Id: I46c1741ec23615863eeca3a1231d5e3f8942495e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/network/kernel/qdnslookup_appless')
-rw-r--r--tests/auto/network/kernel/qdnslookup_appless/qdnslookup_appless.pro7
-rw-r--r--tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp92
2 files changed, 99 insertions, 0 deletions
diff --git a/tests/auto/network/kernel/qdnslookup_appless/qdnslookup_appless.pro b/tests/auto/network/kernel/qdnslookup_appless/qdnslookup_appless.pro
new file mode 100644
index 0000000000..25d76b5739
--- /dev/null
+++ b/tests/auto/network/kernel/qdnslookup_appless/qdnslookup_appless.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+
+TARGET = tst_qdnslookup_appless
+
+SOURCES += tst_qdnslookup_appless.cpp
+
+QT = core network testlib
diff --git a/tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp b/tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp
new file mode 100644
index 0000000000..a183cfdc8a
--- /dev/null
+++ b/tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org>
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QCoreApplication>
+#include <QtNetwork/QDnsLookup>
+#include <QtTest/QtTest>
+
+class tst_QDnsLookup_Appless : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void noApplication();
+ void recreateApplication();
+ void destroyApplicationDuringLookup();
+};
+
+void tst_QDnsLookup_Appless::noApplication()
+{
+ QTest::ignoreMessage(QtWarningMsg, "QDnsLookup requires a QCoreApplication");
+ QDnsLookup dns(QDnsLookup::A, "troll.no");
+ dns.lookup();
+}
+
+void tst_QDnsLookup_Appless::recreateApplication()
+{
+ int argc = 0;
+ char **argv = 0;
+ for (int i = 0; i < 10; ++i) {
+ QCoreApplication app(argc, argv);
+ QDnsLookup dns(QDnsLookup::A, "lupinella.troll.no");
+ dns.lookup();
+ if (!dns.isFinished()) {
+ QObject::connect(&dns, SIGNAL(finished()),
+ &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ }
+ QVERIFY(dns.isFinished());
+ }
+}
+
+void tst_QDnsLookup_Appless::destroyApplicationDuringLookup()
+{
+ int argc = 0;
+ char **argv = 0;
+ for (int i = 0; i < 10; ++i) {
+ QCoreApplication app(argc, argv);
+ QDnsLookup dns(QDnsLookup::A, "lupinella.troll.no");
+ dns.lookup();
+ }
+}
+
+QTEST_APPLESS_MAIN(tst_QDnsLookup_Appless)
+#include "tst_qdnslookup_appless.moc"