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 <richard.gustavsen@qt.io>
This commit is contained in:
Santhosh Kumar 2024-09-17 15:22:26 +02:00
parent 790f16dd54
commit ec124524ec
1 changed files with 16 additions and 5 deletions

View File

@ -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());
}