diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-07-17 11:55:27 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-07-18 18:22:09 +0000 |
commit | 790e2f37d451933c4fe24c64e655e65e9e9c0a05 (patch) | |
tree | 10db6695a76d88cc4e907e81a5ee68cf4f2666b2 /tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | |
parent | 1c2242e610b44eb305f66803dff978186c063f91 (diff) |
tst_qquicktableview: make checkRowColumnCount() more stable
tst_QQuickTableView::checkRowColumnCount() was prone to fail, since
it compared the maximum number of created delegate items to the
initial count before flicking. But as we flick, TableView will normally
need to load and show an extra column and/or row compared to the start.
Change-Id: If39ae6eeff9a85acbc84cc61b8b94ee68565e347
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktableview/tst_qquicktableview.cpp')
-rw-r--r-- | tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index db73d916af..8e02703826 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -911,6 +911,18 @@ void tst_QQuickTableView::checkRowColumnCount() const int qmlCountAfterInit = view->rootObject()->property(maxDelegateCountProp).toInt(); QCOMPARE(tableViewCount, qmlCountAfterInit); + // This test will keep track of the maximum number of delegate items TableView + // had to show at any point while flicking (in countingtableview.qml). Because + // of the geometries chosen for TableView and the delegate, only complete columns + // will be shown at start-up. But as we flick around, we expect the count to + // increase with one extra column. This is because TableView sometimes end up + // showing half a column on the left side, and half a column on the right side. + const QRect loadedTable = tableViewPrivate->loadedTable; + QVERIFY(loadedTable.height() > loadedTable.width()); + QCOMPARE(tableViewPrivate->loadedTableOuterRect.width(), tableView->width()); + QCOMPARE(tableViewPrivate->loadedTableOuterRect.height(), tableView->height()); + const int expectedMaxCountAfterFlick = qmlCountAfterInit + loadedTable.height(); + // Flick a long distance right tableView->setContentX(tableView->width() * 2); tableView->polish(); @@ -918,7 +930,7 @@ void tst_QQuickTableView::checkRowColumnCount() WAIT_UNTIL_POLISHED; const int qmlCountAfterRightFlick = view->rootObject()->property(maxDelegateCountProp).toInt(); - QCOMPARE(qmlCountAfterRightFlick, qmlCountAfterInit); + QCOMPARE(qmlCountAfterRightFlick, expectedMaxCountAfterFlick); // Flick a long distance down tableView->setContentX(tableView->height() * 2); @@ -927,7 +939,7 @@ void tst_QQuickTableView::checkRowColumnCount() WAIT_UNTIL_POLISHED; const int qmlCountAfterDownFlick = view->rootObject()->property(maxDelegateCountProp).toInt(); - QCOMPARE(qmlCountAfterDownFlick, qmlCountAfterInit); + QCOMPARE(qmlCountAfterDownFlick, expectedMaxCountAfterFlick); // Flick a long distance left tableView->setContentX(0); @@ -936,7 +948,7 @@ void tst_QQuickTableView::checkRowColumnCount() WAIT_UNTIL_POLISHED; const int qmlCountAfterLeftFlick = view->rootObject()->property(maxDelegateCountProp).toInt(); - QCOMPARE(qmlCountAfterLeftFlick, qmlCountAfterInit); + QCOMPARE(qmlCountAfterLeftFlick, expectedMaxCountAfterFlick); // Flick a long distance up tableView->setContentY(0); @@ -945,7 +957,7 @@ void tst_QQuickTableView::checkRowColumnCount() WAIT_UNTIL_POLISHED; const int qmlCountAfterUpFlick = view->rootObject()->property(maxDelegateCountProp).toInt(); - QCOMPARE(qmlCountAfterUpFlick, qmlCountAfterInit); + QCOMPARE(qmlCountAfterUpFlick, expectedMaxCountAfterFlick); } void tst_QQuickTableView::modelSignals() |