diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-02-05 19:35:32 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-02-09 14:56:08 +0000 |
commit | 284e98a47fa36b0550d1ed0de962d52e9cde6cb1 (patch) | |
tree | c51f7e62e5ab36c780eb1fbd5fa109dca5be43d3 /tests | |
parent | 9bd117cb8c580a6b8b28eabd15f070282793ff3c (diff) |
Make time sensitive QScrollBar test fault tolerant
The auto-repeat timer of QScrollBar kicks in after 50ms, so if the test
takes too long and the timer fires during the qWait call or during event
delivery, then we might get multiple valueChanged emissions.
Detect that scenario and allow the test to XFAIL if things take
a significant time (more than 40ms vs the expected 1ms).
Change-Id: Ie90aadc62372397db695fd2b34fe1f5252ce8d37
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit 0a9f3ce3c87b6c54e7492f9e263f9e84c0cb62d0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp index 471a9bd3e4..fdd9ded575 100644 --- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp +++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp @@ -192,13 +192,20 @@ void tst_QScrollBar::QTBUG_42871() QMouseEvent mousePressEvent(QEvent::MouseButtonPress, pressPoint, globalPressPoint, Qt::LeftButton, Qt::LeftButton, {}); QApplication::sendEvent(&scrollBarWidget, &mousePressEvent); + QElapsedTimer timer; + timer.start(); QTest::qWait(1); QMouseEvent mouseReleaseEvent(QEvent::MouseButtonRelease, pressPoint, globalPressPoint, Qt::LeftButton, Qt::LeftButton, {}); QApplication::sendEvent(&scrollBarWidget, &mouseReleaseEvent); + if (timer.elapsed() > 40) { + // took too long, we need to tolerate auto-repeat + if (myHandler.updatesCount > 1) + QEXPECT_FAIL("", "Took too long to process events, repeat timer fired", Continue); + } // Check that the action was triggered once. QCOMPARE(myHandler.updatesCount, 1); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.count(), myHandler.updatesCount); } QTEST_MAIN(tst_QScrollBar) |