summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtesteventloop.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/testlib/qtesteventloop.h')
-rw-r--r--src/testlib/qtesteventloop.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/testlib/qtesteventloop.h b/src/testlib/qtesteventloop.h
index 7a04c82da3..6e90880690 100644
--- a/src/testlib/qtesteventloop.h
+++ b/src/testlib/qtesteventloop.h
@@ -25,8 +25,9 @@ public:
: QObject(parent), _timeout(false)
{}
- inline void enterLoopMSecs(int ms);
- inline void enterLoop(int secs) { enterLoopMSecs(secs * 1000); }
+ void enterLoopMSecs(int ms) { enterLoop(std::chrono::milliseconds{ms}); };
+ void enterLoop(int secs) { enterLoop(std::chrono::seconds{secs}); }
+ inline void enterLoop(std::chrono::milliseconds msecs);
inline void changeInterval(int secs)
{ killTimer(timerId); timerId = startTimer(secs * 1000); }
@@ -36,7 +37,7 @@ public:
inline static QTestEventLoop &instance()
{
- static QPointer<QTestEventLoop> testLoop;
+ Q_CONSTINIT static QPointer<QTestEventLoop> testLoop;
if (testLoop.isNull())
testLoop = new QTestEventLoop(QCoreApplication::instance());
return *static_cast<QTestEventLoop *>(testLoop);
@@ -55,17 +56,18 @@ private:
Q_DECL_UNUSED_MEMBER uint reserved :31;
};
-inline void QTestEventLoop::enterLoopMSecs(int ms)
+inline void QTestEventLoop::enterLoop(std::chrono::milliseconds msecs)
{
Q_ASSERT(!loop);
_timeout = false;
- if (QTest::currentTestFailed())
+ if (QTest::runningTest() && QTest::currentTestResolved())
return;
+ using namespace std::chrono_literals;
QEventLoop l;
// if tests want to measure sub-second precision, use a precise timer
- timerId = startTimer(ms, ms < 1000 ? Qt::PreciseTimer : Qt::CoarseTimer);
+ timerId = startTimer(msecs, msecs < 1s ? Qt::PreciseTimer : Qt::CoarseTimer);
loop = &l;
l.exec();