From ec124524ec743db742e17e0674648e4ba74aa5e1 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Date: Tue, 17 Sep 2024 15:22:26 +0200 Subject: [PATCH] Try verify scheduled polish in the table view for resize test case In the table view auto test, the section resize was performed through mouse events (press, move and release operation). The scheduled polish is validated immediately after those events before checking for the change in section sizes. This can cause the resize test cases to be flaky, as there is a chance that the scheduled polish would have updated the view even before we assumed that the polish had been scheduled. This patch changes the condition by try verifying the scheduled polish. Fixes: QTBUG-128934 Pick-to: 6.8 Change-Id: I6520fbbca4e34b4f47035b36f8c92f77431d82a6 Reviewed-by: Richard Moe Gustavsen --- .../qquicktableview/tst_qquicktableview.cpp | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index 4801f6ffcb..f505e8306d 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -6563,9 +6563,12 @@ void tst_QQuickTableView::columnResizing() QTest::mouseMove(window, startPos + dragLength); QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, startPos + dragLength); + // There is a probable chance that the polish scheduled during the resize would have + // been completed even before the mouse release events, so it's better to try to verify + // instead of always assuming that the polish has been scheduled at this stage. + QTRY_VERIFY(!QQuickTest::qIsPolishScheduled(tableView)); const qreal newColumnWidth = columnStartWidth + dragLength.x() - startDragDist.x(); QCOMPARE(tableView->explicitColumnWidth(column), newColumnWidth); - WAIT_UNTIL_POLISHED; QCOMPARE(tableView->columnWidth(column), newColumnWidth); QCOMPARE(currentIndexSpy.count(), 0); @@ -6614,9 +6617,12 @@ void tst_QQuickTableView::rowResizing() QTest::mouseMove(window, startPos + dragLength); QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, startPos + dragLength); + // There is a probable chance that the polish scheduled during the resize would have + // been completed even before the mouse release events, so it's better to try to verify + // instead of always assuming that the polish has been scheduled at this stage. + QTRY_VERIFY(!QQuickTest::qIsPolishScheduled(tableView)); const qreal newRowHeight = rowStartHeight + dragLength.y() - startDragDist.y(); QCOMPARE(tableView->explicitRowHeight(row), newRowHeight); - WAIT_UNTIL_POLISHED; QCOMPARE(tableView->rowHeight(row), newRowHeight); QCOMPARE(currentIndexSpy.count(), 0); @@ -6679,11 +6685,14 @@ void tst_QQuickTableView::rowAndColumnResizing() QTest::mouseMove(window, startPos + dragLength); QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, startPos + dragLength); + // There is a probable chance that the polish scheduled during the resize would have + // been completed even before the mouse release events, so it's better to try to verify + // instead of always assuming that the polish has been scheduled at this stage. + QTRY_VERIFY(!QQuickTest::qIsPolishScheduled(tableView)); const qreal newColumnWidth = columnStartWidth + dragLength.x() - startDragDist.x(); const qreal newRowHeight = rowStartHeight + dragLength.y() - startDragDist.y(); QCOMPARE(tableView->explicitColumnWidth(rowAndColumn), newColumnWidth); QCOMPARE(tableView->explicitRowHeight(rowAndColumn), newRowHeight); - WAIT_UNTIL_POLISHED; QCOMPARE(tableView->columnWidth(rowAndColumn), newColumnWidth); QCOMPARE(tableView->rowHeight(rowAndColumn), newRowHeight); @@ -7850,8 +7859,10 @@ void tst_QQuickTableView::checkColumnRowResizeAfterReorder() QTest::mouseMove(window, startPos + dragLength); QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, startPos + dragLength); - WAIT_UNTIL_POLISHED; - + // There is a probable chance that the polish scheduled during the resize would have + // been completed even before the mouse release events, so it's better to try to verify + // instead of always assuming that the polish has been scheduled at this stage. + QTRY_VERIFY(!QQuickTest::qIsPolishScheduled(tableView)); QCOMPARE(tableView->explicitColumnWidth(moveIndex), columnStartWidth + dragLength.x() - startDragDist.x()); QCOMPARE(tableView->explicitRowHeight(moveIndex), rowStartHeight + dragLength.y() - startDragDist.y()); }