summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2019-06-12 18:06:23 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-06-14 10:42:33 +0200
commit84e89c1e9e00d4fab576b876cfa80e92b5602982 (patch)
treebbe8c928a20bdbf71c3bf6305e64fa46f6c9d16c /tests
parentfeb06decfe5355a14c982f7ddb427a262ad2b393 (diff)
Convert uses of QTime as a timer to QElapsedTimer
Change-Id: I2297f61efa5adf9ea5194c7f3ff68574cbcf452c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp3
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp7
-rw-r--r--tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp3
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp15
-rw-r--r--tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp3
-rw-r--r--tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp3
-rw-r--r--tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp3
-rw-r--r--tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp19
-rw-r--r--tests/auto/corelib/thread/qthread/tst_qthread.cpp20
-rw-r--r--tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp8
-rw-r--r--tests/auto/network/access/qftp/tst_qftp.cpp3
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp23
-rw-r--r--tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp6
-rw-r--r--tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp5
-rw-r--r--tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp3
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp11
-rw-r--r--tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp3
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp3
-rw-r--r--tests/auto/opengl/qglthreads/tst_qglthreads.cpp19
-rw-r--r--tests/auto/other/networkselftest/tst_networkselftest.cpp5
-rw-r--r--tests/auto/other/qobjectrace/tst_qobjectrace.cpp2
-rw-r--r--tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp7
-rw-r--r--tests/auto/testlib/selftests/sleep/tst_sleep.cpp3
-rw-r--r--tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp10
-rw-r--r--tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp3
25 files changed, 103 insertions, 87 deletions
diff --git a/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
index a68f7d5a4e..6305e08b6a 100644
--- a/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+++ b/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
@@ -28,6 +28,7 @@
#include <qtconcurrentthreadengine.h>
#include <qexception.h>
#include <QThread>
+#include <QElapsedTimer>
#include <QtTest/QtTest>
using namespace QtConcurrent;
@@ -382,7 +383,7 @@ void tst_QtConcurrentThreadEngine::cancelQueuedSlowUser()
{
const int times = 100;
- QTime t;
+ QElapsedTimer t;
t.start();
{
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index c51994c1c1..e4ff3c2a08 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -32,6 +32,7 @@
#include <QtTest/QtTest>
#include <QtCore/QProcess>
#include <QtCore/QDir>
+#include <QtCore/QElapsedTimer>
#include <QtCore/QFile>
#include <QtCore/QThread>
#include <QtCore/QTemporaryDir>
@@ -420,7 +421,7 @@ void tst_QProcess::echoTest()
process.write(input);
- QTime stopWatch;
+ QElapsedTimer stopWatch;
stopWatch.start();
do {
QVERIFY(process.isOpen());
@@ -479,7 +480,7 @@ void tst_QProcess::echoTest2()
QVERIFY(spy1.isValid());
QVERIFY(spy2.isValid());
- QTime stopWatch;
+ QElapsedTimer stopWatch;
stopWatch.start();
forever {
QTestEventLoop::instance().enterLoop(1);
@@ -2072,7 +2073,7 @@ void tst_QProcess::fileWriterProcess()
stdinStr += line;
}
- QTime stopWatch;
+ QElapsedTimer stopWatch;
stopWatch.start();
const QString fileName = m_temporaryDir.path() + QLatin1String("/fileWriterProcess.txt");
const QString binary = QDir::currentPath() + QLatin1String("/fileWriterProcess/fileWriterProcess");
diff --git a/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp
index 55deb8eb1a..fa2d5e3723 100644
--- a/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp
+++ b/tests/auto/corelib/kernel/qsharedmemory/tst_qsharedmemory.cpp
@@ -34,6 +34,7 @@
#include <QSharedMemory>
#include <QTest>
#include <QThread>
+#include <QElapsedTimer>
#define EXISTING_SHARE "existing"
#define EXISTING_SIZE 1024
@@ -645,7 +646,7 @@ public:
char *memory = (char*)producer.data();
memory[1] = '0';
- QTime timer;
+ QElapsedTimer timer;
timer.start();
int i = 0;
while (i < 5 && timer.elapsed() < 5000) {
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index b7c87418c7..262dbea913 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -38,6 +38,7 @@
#include <qtimer.h>
#include <qthread.h>
+#include <qelapsedtimer.h>
#if defined Q_OS_UNIX
#include <unistd.h>
@@ -526,7 +527,7 @@ public:
QBasicTimer m_timer;
int m_interval;
- QTime m_startedTime;
+ QElapsedTimer m_elapsedTimer;
QEventLoop eventLoop;
inline RestartedTimerFiresTooSoonObject()
@@ -538,7 +539,7 @@ public:
static int interval = 1000;
m_interval = interval;
- m_startedTime.start();
+ m_elapsedTimer.start();
m_timer.start(interval, this);
// alternate between single-shot and 1 sec
@@ -552,7 +553,7 @@ public:
m_timer.stop();
- int elapsed = m_startedTime.elapsed();
+ int elapsed = m_elapsedTimer.elapsed();
if (elapsed < m_interval / 2) {
// severely too early!
@@ -590,10 +591,10 @@ public:
public slots:
void longLastingSlot()
{
- // Don't use timers for this, because we are testing them.
- QTime time;
- time.start();
- while (time.elapsed() < 200) {
+ // Don't use QTimer for this, because we are testing it.
+ QElapsedTimer control;
+ control.start();
+ while (control.elapsed() < 200) {
for (int c = 0; c < 100000; c++) {} // Mindless looping.
}
if (++count >= 2) {
diff --git a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp
index c4fb623130..32306e8003 100644
--- a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp
@@ -35,6 +35,7 @@
#include <QBuffer>
#include <QByteArray>
#include <QDebug>
+#include <QElapsedTimer>
#include <QFile>
#include <QTcpSocket>
#include <QTemporaryDir>
@@ -996,7 +997,7 @@ struct CompareIndicesForArray
void tst_QTextStream::performance()
{
// Phase #1 - test speed of reading a huge text file with QFile.
- QTime stopWatch;
+ QElapsedTimer stopWatch;
const int N = 3;
const char * readMethods[N] = {
diff --git a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp
index cc197cabba..9b5a273131 100644
--- a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp
+++ b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp
@@ -31,6 +31,7 @@
#include <QAtomicInt>
#include <QCoreApplication>
+#include <QElapsedTimer>
#include <limits.h>
@@ -851,7 +852,7 @@ void tst_QAtomicInt::operators()
void tst_QAtomicInt::testAndSet_loop()
{
- QTime stopWatch;
+ QElapsedTimer stopWatch;
stopWatch.start();
int iterations = 10000000;
diff --git a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp
index b2ef516b4e..a322a1c11d 100644
--- a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp
+++ b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp
@@ -27,6 +27,7 @@
****************************************************************************/
#include <QCoreApplication>
#include <QDebug>
+#include <QElapsedTimer>
#include <QtTest/QtTest>
#include <QtConcurrent>
@@ -878,7 +879,7 @@ void tst_QFutureWatcher::incrementalFilterResults()
void tst_QFutureWatcher::qfutureSynchronizer()
{
int taskCount = 1000;
- QTime t;
+ QElapsedTimer t;
t.start();
{
diff --git a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
index 8e97229752..45fcf9657d 100644
--- a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
+++ b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
@@ -29,6 +29,7 @@
#include <QtTest/QtTest>
#include <qcoreapplication.h>
#include <qreadwritelock.h>
+#include <qelapsedtimer.h>
#include <qmutex.h>
#include <qthread.h>
#include <qwaitcondition.h>
@@ -237,7 +238,7 @@ void tst_QReadWriteLock::tryReadLock()
testsTurn.release();
threadsTurn.acquire();
- QTime timer;
+ QElapsedTimer timer;
timer.start();
QVERIFY(!readWriteLock.tryLockForRead(1000));
QVERIFY(timer.elapsed() >= 1000);
@@ -500,7 +501,7 @@ public:
int holdTime;
int waitTime;
bool print;
- QTime t;
+ QElapsedTimer t;
inline ReadLockLoopThread(QReadWriteLock &l, int runTime, int holdTime=0, int waitTime=0, bool print=false)
:testRwlock(l)
,runTime(runTime)
@@ -536,7 +537,7 @@ public:
int holdTime;
int waitTime;
bool print;
- QTime t;
+ QElapsedTimer t;
inline WriteLockLoopThread(QReadWriteLock &l, int runTime, int holdTime=0, int waitTime=0, bool print=false)
:testRwlock(l)
,runTime(runTime)
@@ -574,7 +575,7 @@ public:
int runTime;
int waitTime;
int maxval;
- QTime t;
+ QElapsedTimer t;
inline WriteLockCountThread(QReadWriteLock &l, int runTime, int waitTime, int maxval)
:testRwlock(l)
,runTime(runTime)
@@ -615,7 +616,7 @@ public:
QReadWriteLock &testRwlock;
int runTime;
int waitTime;
- QTime t;
+ QElapsedTimer t;
inline ReadLockCountThread(QReadWriteLock &l, int runTime, int waitTime)
:testRwlock(l)
,runTime(runTime)
@@ -873,7 +874,7 @@ void tst_QReadWriteLock::deleteOnUnlock()
DeleteOnUnlockThread thread2(&lock, &startup, &waitMutex);
- QTime t;
+ QElapsedTimer t;
t.start();
while(t.elapsed() < 4000) {
lock = new QReadWriteLock();
@@ -899,7 +900,7 @@ void tst_QReadWriteLock::uncontendedLocks()
uint count=0;
int millisecs=1000;
{
- QTime t;
+ QElapsedTimer t;
t.start();
while(t.elapsed() <millisecs)
{
@@ -908,7 +909,7 @@ void tst_QReadWriteLock::uncontendedLocks()
}
{
QReadWriteLock rwlock;
- QTime t;
+ QElapsedTimer t;
t.start();
while(t.elapsed() <millisecs)
{
@@ -919,7 +920,7 @@ void tst_QReadWriteLock::uncontendedLocks()
}
{
QReadWriteLock rwlock;
- QTime t;
+ QElapsedTimer t;
t.start();
while(t.elapsed() <millisecs)
{
diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
index f72b662c94..19922b1ea5 100644
--- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp
+++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
@@ -29,7 +29,7 @@
#include <QtTest/QtTest>
#include <qcoreapplication.h>
-#include <qdatetime.h>
+#include <qelapsedtimer.h>
#include <qmutex.h>
#include <qthread.h>
#include <qtimer.h>
@@ -244,8 +244,8 @@ public:
QMutexLocker locker(&mutex);
elapsed = 0;
- QTime time;
- time.start();
+ QElapsedTimer timer;
+ timer.start();
switch (sleepType) {
case Second:
sleep(interval);
@@ -257,7 +257,7 @@ public:
usleep(interval);
break;
}
- elapsed = time.elapsed();
+ elapsed = timer.elapsed();
cond.wakeOne();
}
@@ -601,8 +601,7 @@ void tst_QThread::msleep()
thread.interval = 120;
thread.start();
QVERIFY(thread.wait(five_minutes));
-#if defined (Q_OS_WIN)
- // Since the resolution of QTime is so coarse...
+#if defined (Q_OS_WIN) // May no longer be needed
QVERIFY(thread.elapsed >= 100);
#else
QVERIFY(thread.elapsed >= 120);
@@ -616,8 +615,7 @@ void tst_QThread::usleep()
thread.interval = 120000;
thread.start();
QVERIFY(thread.wait(five_minutes));
-#if defined (Q_OS_WIN)
- // Since the resolution of QTime is so coarse...
+#if defined (Q_OS_WIN) // May no longer be needed
QVERIFY(thread.elapsed >= 100);
#else
QVERIFY(thread.elapsed >= 120);
@@ -948,9 +946,9 @@ void tst_QThread::stressTest()
if (EmulationDetector::isRunningArmOnX86())
QSKIP("Qemu uses too much memory for each thread. Test would run out of memory.");
- QTime t;
- t.start();
- while (t.elapsed() < one_minute) {
+ QElapsedTimer timer;
+ timer.start();
+ while (timer.elapsed() < one_minute) {
Current_Thread t;
t.start();
t.wait(one_minute);
diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
index 27b49602fc..f41cbe2601 100644
--- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
+++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
@@ -27,7 +27,7 @@
**
****************************************************************************/
#include <QtTest/QtTest>
-#include <qdatetime.h>
+#include <qelapsedtimer.h>
#include <qthreadpool.h>
#include <qstring.h>
#include <qmutex.h>
@@ -882,7 +882,7 @@ void tst_QThreadPool::priorityStart()
void tst_QThreadPool::waitForDone()
{
- QTime total, pass;
+ QElapsedTimer total, pass;
total.start();
QThreadPool threadPool;
@@ -1113,7 +1113,7 @@ void tst_QThreadPool::tryTake()
void tst_QThreadPool::destroyingWaitsForTasksToFinish()
{
- QTime total, pass;
+ QElapsedTimer total, pass;
total.start();
while (total.elapsed() < 10000) {
@@ -1204,7 +1204,7 @@ void tst_QThreadPool::stressTest()
}
};
- QTime total;
+ QElapsedTimer total;
total.start();
while (total.elapsed() < 30000) {
Task t;
diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp
index e07588d6c6..63de0083f0 100644
--- a/tests/auto/network/access/qftp/tst_qftp.cpp
+++ b/tests/auto/network/access/qftp/tst_qftp.cpp
@@ -43,6 +43,7 @@
#include <QtNetwork/private/qnetworksession_p.h>
#include <QTcpServer>
#include <QHostInfo>
+#include <QElapsedTimer>
#include <QTcpSocket>
#include "../../../network-settings.h"
@@ -2160,7 +2161,7 @@ void tst_QFtp::qtbug7359Crash()
QFtp ftp;
ftp.connectToHost("127.0.0.1");
- QTime t;
+ QElapsedTimer t;
int elapsed;
t.start();
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index 8867e4dbaa..e85147095c 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -32,6 +32,7 @@
#include <QtCore/QDataStream>
#include <QtCore/QUrl>
#include <QtCore/QEventLoop>
+#include <QtCore/QElapsedTimer>
#include <QtCore/QFile>
#include <QtCore/QRandomGenerator>
#include <QtCore/QRegularExpression>
@@ -1149,7 +1150,7 @@ protected:
}
// now write in "blocking mode", this is where the rate measuring starts
- QTime timer;
+ QElapsedTimer timer;
timer.start();
//const qint64 writtenBefore = dataIndex;
//qint64 measuredTotalBytes = wantedSize - writtenBefore;
@@ -1248,7 +1249,7 @@ protected:
}
qint64 bytesRead = 0;
- QTime stopWatch;
+ QElapsedTimer stopWatch;
stopWatch.start();
do {
if (device->bytesAvailable() == 0) {
@@ -5153,8 +5154,8 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp()
const int rate = 200; // in kB per sec
RateControlledReader reader(server, reply.data(), rate, bufferSize);
- QTime loopTime;
- loopTime.start();
+ QElapsedTimer loopTimer;
+ loopTimer.start();
const int result = waitForFinish(reply);
if (notEnoughDataForFastSender) {
@@ -5164,7 +5165,7 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp()
QVERIFY2(result == Success, msgWaitForFinished(reply));
- const int elapsedTime = loopTime.elapsed();
+ const int elapsedTime = loopTimer.elapsed();
server.wait();
reader.wrapUp();
@@ -5450,12 +5451,12 @@ void tst_QNetworkReply::rateControl()
RateControlledReader reader(sender, reply.data(), rate, 20);
// this test is designed to run for 25 seconds at most
- QTime loopTime;
- loopTime.start();
+ QElapsedTimer loopTimer;
+ loopTimer.start();
QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
- int elapsedTime = loopTime.elapsed();
+ int elapsedTime = loopTimer.elapsed();
if (!errorSpy.isEmpty()) {
qDebug() << "ERROR!" << errorSpy[0][0] << reply->errorString();
@@ -6125,8 +6126,8 @@ void tst_QNetworkReply::httpConnectionCount()
}
int pendingConnectionCount = 0;
- QTime time;
- time.start();
+ QElapsedTimer timer;
+ timer.start();
while(pendingConnectionCount <= 20) {
QTestEventLoop::instance().enterLoop(1);
@@ -6138,7 +6139,7 @@ void tst_QNetworkReply::httpConnectionCount()
}
// at max. wait 10 sec
- if (time.elapsed() > 10000)
+ if (timer.elapsed() > 10000)
break;
}
diff --git a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp
index 01168cc0d6..ffc63ee46a 100644
--- a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp
+++ b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp
@@ -32,7 +32,7 @@
#include <qcoreapplication.h>
#include <qdatastream.h>
#include <qhostaddress.h>
-#include <qdatetime.h>
+#include <qelapsedtimer.h>
#ifdef Q_OS_UNIX
#include <unistd.h>
@@ -403,7 +403,7 @@ void tst_PlatformSocketEngine::udpLoopbackPerformance()
QHostAddress localhost = QHostAddress::LocalHost;
qlonglong readBytes = 0;
- QTime timer;
+ QElapsedTimer timer;
timer.start();
while (timer.elapsed() < 5000) {
udpSocket2.write(message1.data(), message1.size());
@@ -462,7 +462,7 @@ void tst_PlatformSocketEngine::tcpLoopbackPerformance()
QByteArray message1(messageSize, '@');
QByteArray answer(messageSize, '@');
- QTime timer;
+ QElapsedTimer timer;
timer.start();
qlonglong readBytes = 0;
while (timer.elapsed() < 5000) {
diff --git a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp
index cdc6fef663..64241014d7 100644
--- a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp
+++ b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp
@@ -38,6 +38,7 @@
#include <qhostaddress.h>
#include <qtcpsocket.h>
#include <qdebug.h>
+#include <qelapsedtimer.h>
#include <qtcpserver.h>
#include "../../../network-settings.h"
@@ -397,7 +398,7 @@ void tst_QHttpSocketEngine::tcpLoopbackPerformance()
QByteArray message1(messageSize, '@');
QByteArray answer(messageSize, '@');
- QTime timer;
+ QElapsedTimer timer;
timer.start();
qlonglong readBytes = 0;
while (timer.elapsed() < 30000) {
@@ -629,7 +630,7 @@ void tst_QHttpSocketEngine::downloadBigFile()
bytesAvailable = 0;
- QTime stopWatch;
+ QElapsedTimer stopWatch;
stopWatch.start();
QTestEventLoop::instance().enterLoop(60);
diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
index f53c75c6a4..732f7eef00 100644
--- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
@@ -32,6 +32,7 @@
#include <qtextstream.h>
#include <qdatastream.h>
+#include <qelapsedtimer.h>
#include <QtNetwork/qlocalsocket.h>
#include <QtNetwork/qlocalserver.h>
@@ -1031,7 +1032,7 @@ void tst_QLocalSocket::waitForDisconnect()
QLocalSocket *serverSocket = server.nextPendingConnection();
QVERIFY(serverSocket);
socket.disconnectFromServer();
- QTime timer;
+ QElapsedTimer timer;
timer.start();
QVERIFY(serverSocket->waitForDisconnected(3000));
QVERIFY(timer.elapsed() < 2000);
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index abe9845213..c500c6b3c3 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -66,7 +66,7 @@
#endif
#include <QTextStream>
#include <QThread>
-#include <QTime>
+#include <QElapsedTimer>
#include <QTimer>
#include <QDebug>
// RVCT compiles also unused inline methods
@@ -237,7 +237,6 @@ private:
qint64 bytesAvailable;
qint64 expectedLength;
bool readingBody;
- QTime timer;
QByteArray expectedReplyIMAP_cached;
@@ -1518,7 +1517,7 @@ void tst_QTcpSocket::downloadBigFile()
expectedLength = 0;
readingBody = false;
- QTime stopWatch;
+ QElapsedTimer stopWatch;
stopWatch.start();
enterLoop(600);
@@ -2482,7 +2481,7 @@ void tst_QTcpSocket::suddenRemoteDisconnect()
QEventLoop loop;
connect(&serverProcess, SIGNAL(finished(int)), &loop, SLOT(quit()));
connect(&clientProcess, SIGNAL(finished(int)), &loop, SLOT(quit()));
- QTime stopWatch;
+ QElapsedTimer stopWatch;
stopWatch.start();
QTimer::singleShot(20000, &loop, SLOT(quit()));
@@ -2522,7 +2521,7 @@ void tst_QTcpSocket::connectToMultiIP()
// rationale: this domain resolves to 3 A-records, 2 of them are
// invalid. QTcpSocket should never spend more than 30 seconds per IP, and
// 30s*2 = 60s.
- QTime stopWatch;
+ QElapsedTimer stopWatch;
stopWatch.start();
socket->connectToHost("multi.dev.qt-project.org", 80);
QVERIFY(socket->waitForConnected(60500));
@@ -2714,7 +2713,7 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorWaitForConnected()
QTcpSocket socket;
socket.connectToHost(QtNetworkSettings::httpServerName(), 12346);
- QTime timer;
+ QElapsedTimer timer;
timer.start();
socket.waitForConnected(10000);
QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong");
diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
index a4b22cb000..0f419e9de4 100644
--- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
@@ -40,6 +40,7 @@
#include <qhostinfo.h>
#include <qtcpsocket.h>
#include <qmap.h>
+#include <qelapsedtimer.h>
#include <qnetworkdatagram.h>
#include <QNetworkProxy>
#include <QNetworkInterface>
@@ -922,7 +923,7 @@ void tst_QUdpSocket::performance()
client.connectToHost(serverAddress, server.localPort());
QVERIFY(client.waitForConnected(10000));
- QTime stopWatch;
+ QElapsedTimer stopWatch;
stopWatch.start();
qint64 nbytes = 0;
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
index 7912063bc8..491f52a66b 100644
--- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
@@ -29,6 +29,7 @@
#include <QtCore/qglobal.h>
#include <QtCore/qthread.h>
+#include <QtCore/qelapsedtimer.h>
#include <QtNetwork/qhostaddress.h>
#include <QtNetwork/qhostinfo.h>
#include <QtNetwork/qnetworkproxy.h>
@@ -1989,7 +1990,7 @@ public slots:
QTestEventLoop::instance().exitLoop();
}
void waitSomeMore(QSslSocket *socket) {
- QTime t;
+ QElapsedTimer t;
t.start();
while (!socket->encryptedBytesAvailable()) {
QCoreApplication::processEvents(QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents, 250);
diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
index b7b5b505a0..8a38d0f517 100644
--- a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
+++ b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
@@ -33,6 +33,7 @@
#include <qpa/qplatformintegration.h>
#include <QtWidgets/QApplication>
#include <QtOpenGL/QtOpenGL>
+#include <qelapsedtimer.h>
#include "tst_qglthreads.h"
#ifndef QT_OPENGL_ES_2
@@ -74,9 +75,9 @@ public:
}
void run() {
- QTime time;
- time.start();
- while (time.elapsed() < RUNNING_TIME) {
+ QElapsedTimer timer;
+ timer.start();
+ while (timer.elapsed() < RUNNING_TIME) {
lock();
waitForReadyToSwap();
@@ -291,11 +292,11 @@ public:
}
void run() {
- QTime time;
- time.start();
+ QElapsedTimer timer;
+ timer.start();
failure = false;
- while (time.elapsed() < RUNNING_TIME && !failure) {
+ while (timer.elapsed() < RUNNING_TIME && !failure) {
m_widget->makeCurrent();
@@ -466,13 +467,13 @@ public:
public slots:
void draw() {
bool beginFailed = false;
- QTime time;
- time.start();
+ QElapsedTimer timer;
+ timer.start();
int rotAngle = 10;
device->prepareDevice();
QPaintDevice *paintDevice = device->realPaintDevice();
QSize s(paintDevice->width(), paintDevice->height());
- while (time.elapsed() < RUNNING_TIME) {
+ while (timer.elapsed() < RUNNING_TIME) {
QPainter p;
if (!p.begin(paintDevice)) {
beginFailed = true;
diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp
index dc353d2090..1b125d8825 100644
--- a/tests/auto/other/networkselftest/tst_networkselftest.cpp
+++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp
@@ -29,6 +29,7 @@
#include <QtTest/QtTest>
#include <QtNetwork/QtNetwork>
#include <QtCore/QDateTime>
+#include <QtCore/QElapsedTimer>
#include <QtCore/QTextStream>
#include <QtCore/QRandomGenerator>
#include <QtCore/QStandardPaths>
@@ -195,7 +196,7 @@ static bool doSocketFlush(QTcpSocket *socket, int timeout = 4000)
#ifndef QT_NO_SSL
QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket);
#endif
- QTime timer;
+ QElapsedTimer timer;
timer.start();
int t = timeout;
forever {
@@ -421,7 +422,7 @@ void tst_NetworkSelfTest::serverReachability()
QTcpSocket socket;
socket.connectToHost(QtNetworkSettings::serverName(), 12346);
- QTime timer;
+ QElapsedTimer timer;
timer.start();
socket.waitForConnected(10000);
QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong");
diff --git a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp
index 22782f6b09..473b377b85 100644
--- a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp
+++ b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp
@@ -85,7 +85,7 @@ class RaceThread : public QThread
{
Q_OBJECT
RaceObject *object;
- QTime stopWatch;
+ QElapsedTimer stopWatch;
public:
RaceThread()
diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
index b617151a36..44dd4a74cf 100644
--- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -32,6 +32,7 @@
#include <QtSql>
#include <QtSql/private/qsqltablemodel_p.h>
#include <QThread>
+#include <QElapsedTimer>
const QString test(qTableName("test", __FILE__, QSqlDatabase())),
test2(qTableName("test2", __FILE__, QSqlDatabase())),
@@ -1804,12 +1805,12 @@ void tst_QSqlTableModel::sqlite_bigTable()
QSqlQuery q(db);
QVERIFY_SQL( q, exec("create table "+bigtable+"(id int primary key, name varchar)"));
QVERIFY_SQL( q, prepare("insert into "+bigtable+"(id, name) values (?, ?)"));
- QTime startTime;
- startTime.start();
+ QElapsedTimer timing;
+ timing.start();
for (int i = 0; i < 10000; ++i) {
q.addBindValue(i);
q.addBindValue(QString::number(i));
- if(i%1000 == 0 && startTime.elapsed() > 5000)
+ if (i % 1000 == 0 && timing.elapsed() > 5000)
qDebug() << i << "records written";
QVERIFY_SQL( q, exec());
}
diff --git a/tests/auto/testlib/selftests/sleep/tst_sleep.cpp b/tests/auto/testlib/selftests/sleep/tst_sleep.cpp
index b7b141afd0..95cb68521d 100644
--- a/tests/auto/testlib/selftests/sleep/tst_sleep.cpp
+++ b/tests/auto/testlib/selftests/sleep/tst_sleep.cpp
@@ -28,6 +28,7 @@
#include <QtCore/QCoreApplication>
+#include <QtCore/QElapsedTimer>
#include <QtTest/QtTest>
class tst_Sleep: public QObject
@@ -41,7 +42,7 @@ private slots:
void tst_Sleep::sleep()
{
- QTime t;
+ QElapsedTimer t;
t.start();
QTest::qSleep(100);
diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
index 1a0d7a9289..d8fbb8e041 100644
--- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
+++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
@@ -33,7 +33,7 @@
#include <QSlider>
#include <QStyle>
#include <QStyleOption>
-#include <QTime>
+#include <QElapsedTimer>
#include <QDebug>
#include <QtTest/private/qtesthelpers_p.h>
@@ -91,7 +91,7 @@ private slots:
void connectedSliders();
private:
- void waitUntilTimeElapsed(const QTime& t, int ms);
+ void waitUntilTimeElapsed(const QElapsedTimer &t, int ms);
QWidget *topLevel;
Slider *slider;
@@ -2053,11 +2053,11 @@ void tst_QAbstractSlider::setValue()
QVERIFY(sliderMovedTimeStamp < valueChangedTimeStamp);
}
-void tst_QAbstractSlider::waitUntilTimeElapsed(const QTime& t, int ms)
+void tst_QAbstractSlider::waitUntilTimeElapsed(const QElapsedTimer &t, int ms)
{
const int eps = 80;
while (t.elapsed() < ms + eps)
- QTest::qWait(qMax(ms - t.elapsed() + eps, 25));
+ QTest::qWait(qMax(int(ms - t.elapsed() + eps), 25));
}
void tst_QAbstractSlider::setRepeatAction()
@@ -2073,7 +2073,7 @@ void tst_QAbstractSlider::setRepeatAction()
QCOMPARE(spy.count(), 0);
QCOMPARE(slider->value(), 55);
- QTime t;
+ QElapsedTimer t;
t.start();
QTest::qWait(300);
QCOMPARE(spy.count(), 0);
diff --git a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp
index 752e39c23f..d40c8c2fd6 100644
--- a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp
+++ b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp
@@ -34,6 +34,7 @@
#include <QTcpServer>
#include <QTcpSocket>
#include <QTimer>
+#include <QElapsedTimer>
#include <QtDebug>
#include <QtTest/QtTest>
#include <QXmlDefaultHandler>
@@ -259,7 +260,7 @@ public:
// Delibrately wait a maximum of 10 seconds for the sake
// of the test, so it doesn't unduly hang
const int waitTime = qMax(10000, msecs);
- QTime t;
+ QElapsedTimer t;
t.start();
while (t.elapsed() < waitTime) {
QCoreApplication::processEvents();