summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJanne Anttila <janne.anttila@digia.com>2013-04-17 15:05:41 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-17 19:48:55 +0200
commit2d73648c716f9375cdf5ae80771f5ead0d11eedf (patch)
treefba6cf64d3c2272d4e01a17d7aea2dd18efc6806 /tests
parent0775f88c6638411893749042bfe88e0ef789cf9c (diff)
Fix tst_networkselftest build for WEC7.
WEC7 does not have time() function. Let's use Qt APIs to query time and initialize random number generator, Qt APIs have already been adapted to work on all supported platforms. In addition use QByteArray instead of QString to avoid unnecessary type conversions later on with toLatin1(). Change-Id: I1ae3729397b0f4a1bd138022a4e122021e10f1e9 Reviewed-by: Björn Breitmeyer <bjoern.breitmeyer@kdab.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Andreas Holzammer <andreas.holzammer@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/other/networkselftest/tst_networkselftest.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp
index 2932387bdb..108ec466c9 100644
--- a/tests/auto/other/networkselftest/tst_networkselftest.cpp
+++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp
@@ -41,8 +41,7 @@
#include <QtTest/QtTest>
#include <QtNetwork/QtNetwork>
-
-#include <time.h>
+#include <QtCore/QDateTime>
#ifndef QT_NO_BEARERMANAGEMENT
#include <QtNetwork/qnetworkconfigmanager.h>
@@ -531,13 +530,9 @@ void tst_NetworkSelfTest::imapServer()
void tst_NetworkSelfTest::httpServer()
{
- QString uniqueExtension;
- qsrand(time(0));
-#ifndef Q_OS_WINCE
- uniqueExtension = QString("%1%2%3").arg((qulonglong)this).arg(qrand()).arg((qulonglong)time(0));
-#else
- uniqueExtension = QString("%1%2").arg((qulonglong)this).arg(qrand());
-#endif
+ QByteArray uniqueExtension = QByteArray::number((qulonglong)this) +
+ QByteArray::number((qulonglong)qrand()) +
+ QByteArray::number((qulonglong)QDateTime::currentDateTime().toTime_t());
netChat(80, QList<Chat>()
// HTTP/0.9 chat:
@@ -603,7 +598,7 @@ void tst_NetworkSelfTest::httpServer()
// HTTP/1.0 PUT
<< Chat::Reconnect
- << Chat::send("PUT /dav/networkselftest-" + uniqueExtension.toLatin1() + ".txt HTTP/1.0\r\n"
+ << Chat::send("PUT /dav/networkselftest-" + uniqueExtension + ".txt HTTP/1.0\r\n"
"Content-Length: 5\r\n"
"Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
"Connection: close\r\n"
@@ -616,7 +611,7 @@ void tst_NetworkSelfTest::httpServer()
// check that the file did get uploaded
<< Chat::Reconnect
- << Chat::send("HEAD /dav/networkselftest-" + uniqueExtension.toLatin1() + ".txt HTTP/1.0\r\n"
+ << Chat::send("HEAD /dav/networkselftest-" + uniqueExtension + ".txt HTTP/1.0\r\n"
"Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
"Connection: close\r\n"
"\r\n")
@@ -628,7 +623,7 @@ void tst_NetworkSelfTest::httpServer()
// HTTP/1.0 DELETE
<< Chat::Reconnect
- << Chat::send("DELETE /dav/networkselftest-" + uniqueExtension.toLatin1() + ".txt HTTP/1.0\r\n"
+ << Chat::send("DELETE /dav/networkselftest-" + uniqueExtension + ".txt HTTP/1.0\r\n"
"Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
"Connection: close\r\n"
"\r\n")