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). Pick-to: 6.3 6.2 Change-Id: Ie90aadc62372397db695fd2b34fe1f5252ce8d37 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
0477c78a04
commit
0a9f3ce3c8
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user