Stabilize flaky scrollerSmoothScroll test case

This test failed when checking for a pre-condition of the tested scenario,
so skip the test if that condition isn't met, as the test won't test
anything.

Amends b1fdcc8c0fefe0660302494618032342b623e199.

Task-number: QTBUG-64543
Change-Id: I135cd5b45efcae111305b9be338eb5429d3b97d5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 2933e67f4547ec7ae14c9d370d20aff5a99327d0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Volker Hilsheimer 2021-06-12 12:17:33 +02:00 committed by Qt Cherry-pick Bot
parent 39a42035d1
commit 5671daa487

View File

@ -2783,9 +2783,11 @@ void tst_QAbstractItemView::scrollerSmoothScroll()
QListWidgetItem *pressItem = view.item(23);
QPoint dragPosition = view.visualRect(view.indexFromItem(pressItem)).center();
// the mouse press changes the current item temporarily, but the press is delayed
// by the gesture machinery
// by the gesture machinery. this is not what we are testing here, so skip the test
// if this fails within a reasonable amount of time.
QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::NoModifier, dragPosition);
QTRY_COMPARE(view.currentItem(), pressItem);
if (!(QTest::qWaitFor([&]{ return view.currentItem() == pressItem; })))
QSKIP("Current item didn't change on press, skipping test");
// QAIV will reset the current item when the scroller changes state to Dragging
for (int y = 0; y < QApplication::startDragDistance() * 2; ++y) {