diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-07-19 13:39:32 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-07-21 10:16:47 +0000 |
commit | a605cdc3ff84de3a4107f19bc90a5251f6801f6c (patch) | |
tree | aba6c3b23e3881c95fab22206ef45acbb27be048 /tests/auto/quick/qquicktableview | |
parent | c298fd7eb0c0c262ee2d03768e7d86bb7a5276a0 (diff) |
tst_qquicktableview: check size hint for row/column, not implicit size
The tests as it stood were wrong. We should not check that each
item in a row/column has the size of the delegate, but instead
check that each item has the same size as the sizeHint for the
given row/column it's in.
Change-Id: Iac01f8137b04ec701e575c5abafbbe30ebafabe6
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktableview')
-rw-r--r-- | tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index e4692ec1fe..1cedde4f79 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -230,7 +230,7 @@ void tst_QQuickTableView::checkImplicitSizeDelegate() void tst_QQuickTableView::checkColumnWidthWithoutProvider() { // Checks that a function isn't assigned to the columnWidthProvider property - // and that the column width is equal to the implicitWidth of the delegate. + // and that the column width is then equal to sizeHintForColumn. LOAD_TABLEVIEW("alternatingrowheightcolumnwidth.qml"); auto model = TestModelAsVariant(10, 10); @@ -240,10 +240,13 @@ void tst_QQuickTableView::checkColumnWidthWithoutProvider() WAIT_UNTIL_POLISHED; - for (auto fxItem : tableViewPrivate->loadedItems) { - // expectedWidth mirrors the implicit width of the delegate - qreal expectedWidth = fxItem->cell.x() % 2 ? 30 : 40; - QCOMPARE(fxItem->item->width(), expectedWidth); + QRect table = tableViewPrivate->loadedTable; + for (int column = table.left(); column <= table.right(); ++column) { + const qreal expectedColumnWidth = tableViewPrivate->sizeHintForColumn(column); + for (int row = table.top(); row <= table.bottom(); ++row) { + const auto item = tableViewPrivate->loadedTableItem(QPoint(column, row))->item; + QCOMPARE(item->width(), expectedColumnWidth); + } } } @@ -308,7 +311,7 @@ void tst_QQuickTableView::checkColumnWidthProviderNotCallable() void tst_QQuickTableView::checkRowHeightWithoutProvider() { // Checks that a function isn't assigned to the rowHeightProvider property - // and that the row height is equal to the implicitHeight of the delegate. + // and that the row height is then equal to sizeHintForRow. LOAD_TABLEVIEW("alternatingrowheightcolumnwidth.qml"); auto model = TestModelAsVariant(10, 10); @@ -318,10 +321,13 @@ void tst_QQuickTableView::checkRowHeightWithoutProvider() WAIT_UNTIL_POLISHED; - for (auto fxItem : tableViewPrivate->loadedItems) { - // expectedHeight mirrors the implicit height of the delegate - qreal expectedHeight = fxItem->cell.y() % 2 ? 30 : 40; - QCOMPARE(fxItem->item->height(), expectedHeight); + QRect table = tableViewPrivate->loadedTable; + for (int row = table.top(); row <= table.bottom(); ++row) { + const qreal expectedRowHeight = tableViewPrivate->sizeHintForRow(row); + for (int column = table.left(); column <= table.right(); ++column) { + const auto item = tableViewPrivate->loadedTableItem(QPoint(column, row))->item; + QCOMPARE(item->height(), expectedRowHeight); + } } } |