diff options
author | Marius Bugge Monsen <mmonsen@trolltech.com> | 2009-05-08 19:05:47 +0200 |
---|---|---|
committer | Marius Bugge Monsen <mmonsen@trolltech.com> | 2009-05-08 19:05:47 +0200 |
commit | 0b083c3f2d573614a1cbd76e328c0818c29a3307 (patch) | |
tree | 09bce2ec087132710563f804812b0719bbd6df39 /tests | |
parent | 082d3802ebdfc4b4bb6a536827f7ff1edce36a67 (diff) |
Expand the QtGraphicsListView::layout() test to check the indexes of the visual items.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/qgraphicslistview/tst_qgraphicslistview.cpp | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/tests/qgraphicslistview/tst_qgraphicslistview.cpp b/tests/qgraphicslistview/tst_qgraphicslistview.cpp index 1a21a40..6b54fc1 100644 --- a/tests/qgraphicslistview/tst_qgraphicslistview.cpp +++ b/tests/qgraphicslistview/tst_qgraphicslistview.cpp @@ -72,6 +72,7 @@ protected: GraphicsListView *view; }; +Q_DECLARE_METATYPE(QList<int>) Q_DECLARE_METATYPE(QList<QRectF>) tst_QtGraphicsListView::tst_QtGraphicsListView() @@ -387,6 +388,7 @@ void tst_QtGraphicsListView::layout_data() QTest::addColumn<qreal>("horizontalOffset"); QTest::addColumn<qreal>("verticalOffset"); QTest::addColumn<QList<QRectF> >("expectedGeometries"); + QTest::addColumn<QList<int> >("expectedIndexes"); QTest::newRow("no items, vertical") << 0 @@ -394,7 +396,8 @@ void tst_QtGraphicsListView::layout_data() << QSizeF(100, 100) << 0 << 0. << 0. - << QList<QRectF>(); + << QList<QRectF>() + << QList<int>(); QTest::newRow("one item, vertical, all visible") @@ -403,7 +406,8 @@ void tst_QtGraphicsListView::layout_data() << QSizeF(100, 100) << 0 << 0. << 0. - << (QList<QRectF>() << QRectF(0, 0, 20, 20)); + << (QList<QRectF>() << QRectF(0, 0, 20, 20)) + << (QList<int>() << 0); QTest::newRow("five items, vertical, all visible") @@ -417,7 +421,9 @@ void tst_QtGraphicsListView::layout_data() << QRectF(0, 20, 20, 20) << QRectF(0, 40, 20, 20) << QRectF(0, 60, 20, 20) - << QRectF(0, 80, 20, 20)); + << QRectF(0, 80, 20, 20)) + << (QList<int>() + << 0 << 1 << 2 << 3 << 4); QTest::newRow("ten items, vertical, five visible") << 10 @@ -430,7 +436,9 @@ void tst_QtGraphicsListView::layout_data() << QRectF(0, 20, 20, 20) << QRectF(0, 40, 20, 20) << QRectF(0, 60, 20, 20) - << QRectF(0, 80, 20, 20)); + << QRectF(0, 80, 20, 20)) + << (QList<int>() + << 0 << 1 << 2 << 3 << 4); QTest::newRow("ten items, vertical, five visible, first item five") << 10 @@ -443,7 +451,9 @@ void tst_QtGraphicsListView::layout_data() << QRectF(0, 20, 20, 20) << QRectF(0, 40, 20, 20) << QRectF(0, 60, 20, 20) - << QRectF(0, 80, 20, 20)); + << QRectF(0, 80, 20, 20)) + << (QList<int>() + << 5 << 6 << 7 << 8 << 9); QTest::newRow("ten items, vertical, five visible, vertical offset") << 10 @@ -457,7 +467,9 @@ void tst_QtGraphicsListView::layout_data() << QRectF(0, 30, 20, 20) << QRectF(0, 50, 20, 20) << QRectF(0, 70, 20, 20) - << QRectF(0, 90, 20, 20)); + << QRectF(0, 90, 20, 20)) + << (QList<int>() + << 0 << 1 << 2 << 3 << 4 << 5); QTest::newRow("no items, horizontal") << 0 @@ -465,7 +477,8 @@ void tst_QtGraphicsListView::layout_data() << QSizeF(100, 100) << 0 << 0. << 0. - << QList<QRectF>(); + << QList<QRectF>() + << QList<int>(); QTest::newRow("one item, horizontal, all visible") @@ -474,7 +487,8 @@ void tst_QtGraphicsListView::layout_data() << QSizeF(100, 100) << 0 << 0. << 0. - << (QList<QRectF>() << QRectF(0, 0, 20, 20)); + << (QList<QRectF>() << QRectF(0, 0, 20, 20)) + << (QList<int>() << 0); QTest::newRow("five items, horizontal, all visible") @@ -488,7 +502,9 @@ void tst_QtGraphicsListView::layout_data() << QRectF(20, 0, 20, 20) << QRectF(40, 0, 20, 20) << QRectF(60, 0, 20, 20) - << QRectF(80, 0, 20, 20)); + << QRectF(80, 0, 20, 20)) + << (QList<int>() + << 0 << 1 << 2 << 3 << 4); QTest::newRow("ten items, horizontal, five visible") << 10 @@ -501,7 +517,9 @@ void tst_QtGraphicsListView::layout_data() << QRectF(20, 0, 20, 20) << QRectF(40, 0, 20, 20) << QRectF(60, 0, 20, 20) - << QRectF(80, 0, 20, 20)); + << QRectF(80, 0, 20, 20)) + << (QList<int>() + << 0 << 1 << 2 << 3 << 4); QTest::newRow("ten items, horizontal, five visible, first item five") << 10 @@ -514,7 +532,9 @@ void tst_QtGraphicsListView::layout_data() << QRectF(20, 0, 20, 20) << QRectF(40, 0, 20, 20) << QRectF(60, 0, 20, 20) - << QRectF(80, 0, 20, 20)); + << QRectF(80, 0, 20, 20)) + << (QList<int>() + << 5 << 6 << 7 << 8 << 9); QTest::newRow("ten items, horizontal, five visible, horizontal offset") << 10 @@ -528,7 +548,9 @@ void tst_QtGraphicsListView::layout_data() << QRectF(30, 0, 20, 20) << QRectF(50, 0, 20, 20) << QRectF(70, 0, 20, 20) - << QRectF(90, 0, 20, 20)); + << QRectF(90, 0, 20, 20)) + << (QList<int>() + << 0 << 1 << 2 << 3 << 4 << 5); } void tst_QtGraphicsListView::layout() @@ -540,6 +562,7 @@ void tst_QtGraphicsListView::layout() QFETCH(qreal, horizontalOffset); QFETCH(qreal, verticalOffset); QFETCH(QList<QRectF>, expectedGeometries); + QFETCH(QList<int>, expectedIndexes); QtListDefaultModel model; for (int i = 0; i < count; ++i) @@ -555,8 +578,11 @@ void tst_QtGraphicsListView::layout() view->doLayout(); QCOMPARE(view->viewItems().count(), expectedGeometries.count()); - for (int j = 0; j < expectedGeometries.count(); ++j) + QCOMPARE(view->viewItems().count(), expectedIndexes.count()); + for (int j = 0; j < expectedGeometries.count(); ++j) { QCOMPARE(view->viewItems().at(j)->geometry(), expectedGeometries.at(j)); + QCOMPARE(view->viewItems().at(j)->index(), expectedIndexes.at(j)); + } } QTEST_MAIN(tst_QtGraphicsListView) |