summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2022-01-05 12:43:52 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-01-08 04:51:12 +0000
commit7819edabf65e79700b476d77a8eeb5e481a466e1 (patch)
tree1a15d41e38c159e6eb550daed4751832d057e861
parentd0bcbbebc3db44afbc2222566213cb1c9b2fe525 (diff)
Revert "Implement QTest::qWait() in terms of QTest::qWaitFor()"
This reverts commit 5c908c826313143a65ef7e95e5af6625fe1ba813. git-bisect points to this commit as the cause for serious test regressions in the qtwebengine module where test time execution goes up 10 times (at least for debug builds), causing timeouts. The reason for the time regression in test execution is caused as the 'processEvents' call is no longer executed with 'remaining' time: QCoreApplication::processEvents(QEventLoop::AllEvents, remaining) 'processEvents' do not spin for the whole duration and instead it calls 'predicate' after all event processing but before proceeding with new events. This introduces significant Chromium's message pump lag and makes test execution much slower. In case of relanding this change we need to go through all tests and extend timeouts, which is not feasible at the moment. This is a quick-fix for 6.3. Change-Id: I90696479bfb9f0a0b8a8acc5bb7e7058b7d0c462 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit f2d0b327e4e6a6c4b72998c290d554d6c4a8f5b6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/corelib/kernel/qtestsupport_core.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/corelib/kernel/qtestsupport_core.cpp b/src/corelib/kernel/qtestsupport_core.cpp
index 01ff571379..f5b6ed18cd 100644
--- a/src/corelib/kernel/qtestsupport_core.cpp
+++ b/src/corelib/kernel/qtestsupport_core.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2021 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -107,7 +107,23 @@ Q_CORE_EXPORT void QTest::qSleep(int ms)
*/
Q_CORE_EXPORT void QTest::qWait(int ms)
{
- (void)qWaitFor([]() { return false; }, ms);
+ // Ideally this method would be implemented in terms of qWaitFor, with
+ // a predicate that always returns false, but due to a compiler bug in
+ // GCC 6 we can't do that.
+
+ Q_ASSERT(QCoreApplication::instance());
+
+ QDeadlineTimer timer(ms, Qt::PreciseTimer);
+ int remaining = ms;
+ do {
+ QCoreApplication::processEvents(QEventLoop::AllEvents, remaining);
+ QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
+ remaining = timer.remainingTime();
+ if (remaining <= 0)
+ break;
+ QTest::qSleep(qMin(10, remaining));
+ remaining = timer.remainingTime();
+ } while (remaining > 0);
}
QT_END_NAMESPACE