summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-11-25 17:04:12 +1000
committerQt by Nokia <qt-info@nokia.com>2011-11-28 08:13:41 +0100
commite15548d3e49a8937856c78d8e6c1133d46df57ee (patch)
tree009ed1d5d605848e71586c9929e0605953ad5d17 /tests/manual
parentcbcdb5f4cf7e52c3e184d87cc8716d6a9dcc9728 (diff)
Fix sanity check of network test server
Some of Qt's autotests depend on access to a test server. For each test that used the test server, tests/auto/network-settings.h created a global object to verify at startup that host lookups to the test server will succeed (and abort the test otherwise). There are two problems with that approach: First, the sanity check happens before main(), and thus before the test framework has started logging test results. This means that if the sanity check aborts the test, the failure message will not be visible in the test output if logging to a file or will cause the output to be malformed if logging to the console in XML format. Second, since Qt 4.7, the host lookup uses a class that connects to the QCoreApplication instance, which doesn't exist before main(), and this caused all tests that included network-settings.h to output an error message from QObject::connect() at the beginning of the test. Both of these problems are solved by removing the global object from network-settings.h and instead performing the sanity check in the initTestCase() function of each test. Task-number: QTBUG-22876 Change-Id: Id49c1826906327bf571686cc11527f0265e5af44 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/network_stresstest/tst_network_stresstest.cpp6
-rw-r--r--tests/manual/qnetworkreply/main.cpp9
2 files changed, 13 insertions, 2 deletions
diff --git a/tests/manual/network_stresstest/tst_network_stresstest.cpp b/tests/manual/network_stresstest/tst_network_stresstest.cpp
index ca5486e09b..8337118bbf 100644
--- a/tests/manual/network_stresstest/tst_network_stresstest.cpp
+++ b/tests/manual/network_stresstest/tst_network_stresstest.cpp
@@ -93,6 +93,7 @@ private:
public slots:
void initTestCase_data();
+ void initTestCase();
void init();
void slotReadAll() { byteCounter += static_cast<QIODevice *>(sender())->readAll().size(); }
@@ -133,6 +134,11 @@ void tst_NetworkStressTest::initTestCase_data()
QTest::newRow("remote") << false << QtNetworkSettings::serverName() << 80;
}
+void tst_NetworkStressTest::initTestCase()
+{
+ QVERIFY(QtNetworkSettings::verifyTestNetworkSettings());
+}
+
void tst_NetworkStressTest::init()
{
// clear the internal cache
diff --git a/tests/manual/qnetworkreply/main.cpp b/tests/manual/qnetworkreply/main.cpp
index 56f3260e38..8033251d06 100644
--- a/tests/manual/qnetworkreply/main.cpp
+++ b/tests/manual/qnetworkreply/main.cpp
@@ -54,10 +54,10 @@
class tst_qnetworkreply : public QObject
{
Q_OBJECT
- private slots:
+private slots:
+ void initTestCase();
void limiting_data();
void limiting();
-
};
QNetworkReply *reply;
@@ -90,6 +90,11 @@ protected:
QTime stopwatch;
};
+void tst_qnetworkreply::initTestCase()
+{
+ QVERIFY(QtNetworkSettings::verifyTestNetworkSettings());
+}
+
void tst_qnetworkreply::limiting_data()
{
QTest::addColumn<QUrl>("url");