diff options
author | Andy Shaw <andy.shaw@qt.io> | 2020-11-06 13:30:12 +0100 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2020-12-09 11:42:56 +0100 |
commit | 27c254203b3e7dd6d3a4445feb205fbe98c32d30 (patch) | |
tree | 2830b29326555d9b50fb794e647f3325d2fd45b8 /tests/auto/quick | |
parent | a586e2d141f68dfa0295f9e28f564e53af1d5641 (diff) |
Show a tableview even if the syncView has an empty model
By showing the tableview, we can be sure that headerviews will be
visible even in the syncView has an empty model.
Fixes: QTBUG-87526
Change-Id: I68c8b119122a2d2f88c2afbeb2d6c71a83a3ce33
Pick-to: 5.15 6.0
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r-- | tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index ce77028841..2bd7c38a11 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -176,6 +176,7 @@ private slots: void checkSyncView_connect_late_data(); void checkSyncView_connect_late(); void checkSyncView_pageFlicking(); + void checkSyncView_emptyModel(); void delegateWithRequiredProperties(); void checkThatFetchMoreIsCalledWhenScrolledToTheEndOfTable(); void replaceModel(); @@ -2738,6 +2739,48 @@ void tst_QQuickTableView::checkSyncView_pageFlicking() QVERIFY(tableViewPrivate->scheduledRebuildOptions & QQuickTableViewPrivate::RebuildOption::CalculateNewTopLeftRow); } +void tst_QQuickTableView::checkSyncView_emptyModel() +{ + // When a tableview has a syncview with an empty model then it should still be + // showing the tableview without depending on the syncview. This is particularly + // important for headerviews for example + LOAD_TABLEVIEW("syncviewsimple.qml"); + GET_QML_TABLEVIEW(tableViewH); + GET_QML_TABLEVIEW(tableViewV); + GET_QML_TABLEVIEW(tableViewHV); + QQuickTableView *views[] = {tableViewH, tableViewV, tableViewHV}; + + auto model = TestModelAsVariant(100, 100); + + for (auto view : views) + view->setModel(model); + + WAIT_UNTIL_POLISHED_ARG(tableViewHV); + + // Check that geometry properties are mirrored + QCOMPARE(tableViewH->columnSpacing(), tableView->columnSpacing()); + QCOMPARE(tableViewH->rowSpacing(), 0); + QCOMPARE(tableViewH->contentWidth(), tableView->contentWidth()); + QVERIFY(tableViewH->contentHeight() > 0); + QCOMPARE(tableViewV->columnSpacing(), 0); + QCOMPARE(tableViewV->rowSpacing(), tableView->rowSpacing()); + QCOMPARE(tableViewV->contentHeight(), tableView->contentHeight()); + QVERIFY(tableViewV->contentWidth() > 0); + + QCOMPARE(tableViewH->contentX(), tableView->contentX()); + QCOMPARE(tableViewH->contentY(), 0); + QCOMPARE(tableViewV->contentX(), 0); + QCOMPARE(tableViewV->contentY(), tableView->contentY()); + QCOMPARE(tableViewHV->contentX(), tableView->contentX()); + QCOMPARE(tableViewHV->contentY(), tableView->contentY()); + + QCOMPARE(tableViewHPrivate->loadedTableOuterRect.left(), tableViewPrivate->loadedTableOuterRect.left()); + QCOMPARE(tableViewHPrivate->loadedTableOuterRect.top(), 0); + + QCOMPARE(tableViewVPrivate->loadedTableOuterRect.top(), tableViewPrivate->loadedTableOuterRect.top()); + QCOMPARE(tableViewVPrivate->loadedTableOuterRect.left(), 0); +} + void tst_QQuickTableView::checkThatFetchMoreIsCalledWhenScrolledToTheEndOfTable() { LOAD_TABLEVIEW("plaintableview.qml"); |