diff options
author | Marius Bugge Monsen <mmonsen@trolltech.com> | 2009-06-05 10:22:44 +0200 |
---|---|---|
committer | Marius Bugge Monsen <mmonsen@trolltech.com> | 2009-06-05 10:22:44 +0200 |
commit | 63ca79ec8816c94bf54bbc7b4ad25a36e0251f1b (patch) | |
tree | e715baab7a81327bc36df565f9a04f355e4d13a4 /tests | |
parent | 6bc4e40c716a7a3db4f4fa8dc9431aa4c502bddd (diff) |
Add QtGraphicsTableView::itemForCell(int,int). Change the test to use this function when checking the item geometry.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/qgraphicstableview/tst_qgraphicstableview.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/tests/qgraphicstableview/tst_qgraphicstableview.cpp b/tests/qgraphicstableview/tst_qgraphicstableview.cpp index 7ac1939..172bbed 100644 --- a/tests/qgraphicstableview/tst_qgraphicstableview.cpp +++ b/tests/qgraphicstableview/tst_qgraphicstableview.cpp @@ -137,32 +137,32 @@ void tst_QtGraphicsTableView::layout_data() QTest::addColumn<QtCell>("firstCell"); QTest::addColumn<qreal>("horizontalOffset"); QTest::addColumn<qreal>("verticalOffset"); - QTest::addColumn<QList<QRectF> >("expectedGeometries"); QTest::addColumn<QList<QtCell> >("expectedCells"); + QTest::addColumn<QList<QRectF> >("expectedGeometries"); QTest::newRow("no cells") << 0 << 0 // table dimensions << QSizeF(100, 100) // view size << QtCell() // first view row and column << 0. << 0. // offsets - << QList<QRectF>() // expected geometries - << QList<QtCell>(); // expected cells + << QList<QtCell>() // expected cells + << QList<QRectF>(); // expected geometries QTest::newRow("1 row, 1 column, all visible") << 1 << 1 << QSizeF(100, 100) << QtCell() << 0. << 0. - << (QList<QRectF>() << QRectF(0, 0, 100, 30)) - << (QList<QtCell>() << QtCell(0, 0)); + << (QList<QtCell>() << QtCell(0, 0)) + << (QList<QRectF>() << QRectF(0, 0, 100, 30)); QTest::newRow("5 rows, 5 columns, 3 visible") << 5 << 5 << QSizeF(100, 100) << QtCell() << 0. << 0. - << (QList<QRectF>() << QRectF(0, 0, 100, 30) << QRectF(0, 30, 100, 30) << QRectF(0, 60, 100, 30)) - << (QList<QtCell>() << QtCell(0, 0) << QtCell(1, 0) << QtCell(2, 0)); + << (QList<QtCell>() << QtCell(0, 0) << QtCell(1, 0) << QtCell(2, 0)) + << (QList<QRectF>() << QRectF(0, 0, 100, 30) << QRectF(0, 30, 100, 30) << QRectF(0, 60, 100, 30)); // ### FIXME: add more data-sets } @@ -175,8 +175,8 @@ void tst_QtGraphicsTableView::layout() QFETCH(QtCell, firstCell); QFETCH(qreal, horizontalOffset); QFETCH(qreal, verticalOffset); - QFETCH(QList<QRectF>, expectedGeometries); QFETCH(QList<QtCell>, expectedCells); + QFETCH(QList<QRectF>, expectedGeometries); QtTableDefaultModel model(rowCount, columnCount); @@ -188,15 +188,12 @@ void tst_QtGraphicsTableView::layout() view->setVerticalOffset(verticalOffset); view->doLayout(); - // ### FIXME: this section relies on the order of the child items (internal functionality) - QList<QGraphicsItem*> items = view->childItems(); - QCOMPARE(items.count(), expectedGeometries.count()); - QCOMPARE(items.count(), expectedCells.count()); - for (int j = 0; j < expectedGeometries.count(); ++j) { - QtGraphicsTableViewItem *item = static_cast<QtGraphicsTableViewItem*>(items.at(j)); + for (int j = 0; j < expectedCells.count(); ++j) { + QtCell cell = expectedCells.at(j); + QtGraphicsTableViewItem *item = view->itemForCell(cell.row, cell.column); + QCOMPARE(item->row(), cell.row); + QCOMPARE(item->column(), cell.column); QCOMPARE(item->geometry(), expectedGeometries.at(j)); - QCOMPARE(item->row(), expectedCells.at(j).row); - QCOMPARE(item->column(), expectedCells.at(j).column); } } |