Move the early-failure checks in QTRY_IMPL()
These checks should not be included in the #expr reported when the test fails. They're an internal implementation detail of the loop. Split a long line while I was about it. Change-Id: Iaea0478967d01cd72ef5a5e9a6501d4be2324b18 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit 4048efc80c3085b7174b746bec1fa8406c56ed42) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
c731bffdc2
commit
ed93b197b5
@ -159,23 +159,25 @@ inline void useVerifyThrowsException() {}
|
|||||||
QTest::qWait(0); \
|
QTest::qWait(0); \
|
||||||
} \
|
} \
|
||||||
int qt_test_i = 0; \
|
int qt_test_i = 0; \
|
||||||
for (; qt_test_i < timeoutValue && !(expr); qt_test_i += step) { \
|
for (; qt_test_i < timeoutValue && !QTest::currentTestFailed() \
|
||||||
|
&& !(expr); qt_test_i += step) { \
|
||||||
QTest::qWait(step); \
|
QTest::qWait(step); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define QTRY_TIMEOUT_DEBUG_IMPL(expr, timeoutValue, step)\
|
#define QTRY_TIMEOUT_DEBUG_IMPL(expr, timeoutValue, step) \
|
||||||
if (!(expr)) { \
|
if (!QTest::currentTestFailed() && !(expr)) { \
|
||||||
QTRY_LOOP_IMPL((expr), 2 * (timeoutValue), step); \
|
QTRY_LOOP_IMPL((expr), 2 * (timeoutValue), step); \
|
||||||
if (expr) { \
|
if (expr) { \
|
||||||
QFAIL(qPrintable(QTest::Internal::formatTryTimeoutDebugMessage(u8"" #expr, timeoutValue, timeoutValue + qt_test_i))); \
|
QFAIL(qPrintable(QTest::Internal::formatTryTimeoutDebugMessage(\
|
||||||
|
u8"" #expr, timeoutValue, timeoutValue + qt_test_i))); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define QTRY_IMPL(expr, timeout)\
|
#define QTRY_IMPL(expr, timeout)\
|
||||||
const int qt_test_step = timeout < 350 ? timeout / 7 + 1 : 50; \
|
const int qt_test_step = timeout < 350 ? timeout / 7 + 1 : 50; \
|
||||||
const int qt_test_timeoutValue = timeout; \
|
const int qt_test_timeoutValue = timeout; \
|
||||||
{ QTRY_LOOP_IMPL(QTest::currentTestFailed() || (expr), qt_test_timeoutValue, qt_test_step); } \
|
{ QTRY_LOOP_IMPL((expr), qt_test_timeoutValue, qt_test_step); } \
|
||||||
QTRY_TIMEOUT_DEBUG_IMPL(QTest::currentTestFailed() || (expr), qt_test_timeoutValue, qt_test_step)
|
QTRY_TIMEOUT_DEBUG_IMPL((expr), qt_test_timeoutValue, qt_test_step)
|
||||||
|
|
||||||
// Will try to wait for the expression to become true while allowing event processing
|
// Will try to wait for the expression to become true while allowing event processing
|
||||||
#define QTRY_VERIFY_WITH_TIMEOUT(expr, timeout) \
|
#define QTRY_VERIFY_WITH_TIMEOUT(expr, timeout) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user