From 5671daa48746aeca3d1864be1196746c09e87077 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Sat, 12 Jun 2021 12:17:33 +0200 Subject: [PATCH] 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 Reviewed-by: Richard Moe Gustavsen (cherry picked from commit 2933e67f4547ec7ae14c9d370d20aff5a99327d0) Reviewed-by: Qt Cherry-pick Bot --- .../itemviews/qabstractitemview/tst_qabstractitemview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 9dcef394e0f..386c6ccd9a9 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -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) {