summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2020-09-10 09:01:13 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2020-09-10 20:08:12 +0200
commite15153a7388f3b1d5e89acb9d2f692007e920591 (patch)
treec0d3ff70486066d8c4b6a1aa9b83f7731074da09 /tests/auto/corelib
parent219ed70957cc93640a79e1f8098987256efbe212 (diff)
tst_QTimer::remainingTime(): get rid of QTest::currentTestFailed()
Looks this is redundant in fact and unneeded. The check can never be evaluated to true, since if so, it would mean it had failed in the previous iteration, in which we already handled the exit from the loop. Fixed also some comments. Task-number: QTBUG-83419 Change-Id: I4fe56bfac39cd58b1166967f3ccb80cdff882748 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index 45035ef770..ff345def85 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -153,30 +153,33 @@ void tst_QTimer::remainingTime()
// We let tested (which isn't a single-shot) run repeatedly, to verify
// it *does* repeat, and check that the single-shot tester, starting
// at the same time, does finish first each time, by about the right duration.
- tester.start(); // start tester again
+ tester.start(); // Start tester again.
});
QObject::connect(&tester, &QTimer::timeout, [&]() {
- // we expect that remainingTime is at most 150
const int remainingTime = tested.remainingTime();
+ // We expect that remainingTime is at most 150 and not overdue.
const bool remainingTimeInRange = remainingTime > 0
&& remainingTime <= expectedRemainingTime;
- if (QTest::currentTestFailed() || !remainingTimeInRange)
- testIteration = desiredTestCount; // to exit the QTRY_...() on failure
- else
+ if (remainingTimeInRange)
++testIteration;
+ else
+ testIteration = desiredTestCount; // We are going to fail on QVERIFY2()
+ // below, so we don't want to iterate
+ // anymore and quickly exit the QTRY_...()
+ // with this failure.
if (testIteration == desiredTestCount)
- QObject::disconnect(connection); // don't start tester again
+ QObject::disconnect(connection); // Last iteration, don't start tester again.
QVERIFY2(remainingTimeInRange, qPrintable("Remaining time "
+ QByteArray::number(remainingTime) + "ms outside expected range (0ms, "
+ QByteArray::number(expectedRemainingTime) + "ms]"));
});
tested.start(testedInterval);
- tester.start(testerInterval); // start tester for the 1st time
+ tester.start(testerInterval); // Start tester for the 1st time.
// Test it desiredTestCount times, give it reasonable amount of time
- // (twice as much as needed)
+ // (twice as much as needed).
QTRY_COMPARE_WITH_TIMEOUT(testIteration, desiredTestCount,
testedInterval * desiredTestCount * 2);
}