diff options
author | Robin Burchell <robin.burchell@collabora.co.uk> | 2010-04-19 11:52:18 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2010-04-19 12:25:56 (GMT) |
commit | d935191592bfe275b6122841de8fa76778be02af (patch) | |
tree | 9a49a047bed799188f778b6604b089eec268eab1 /tests/auto/qlistview | |
parent | dfe8898ec80c81c05b548bd0ac72dea480f5bf36 (diff) | |
download | Qt-d935191592bfe275b6122841de8fa76778be02af.zip Qt-d935191592bfe275b6122841de8fa76778be02af.tar.gz Qt-d935191592bfe275b6122841de8fa76778be02af.tar.bz2 |
Add a test to QListView to check initialisation of style option index, similar to QTreeView test.
Reviewed-by: Olivier Goffart
Merge-request: 565
Diffstat (limited to 'tests/auto/qlistview')
-rw-r--r-- | tests/auto/qlistview/tst_qlistview.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index f5c32cd..330f803 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -124,6 +124,7 @@ private slots: void taskQTBUG_2678_spacingAndWrappedText(); void taskQTBUG_5877_skippingItemInPageDownUp(); void taskQTBUG_9455_wrongScrollbarRanges(); + void styleOptionViewItem(); }; // Testing get/set functions @@ -1971,5 +1972,35 @@ void tst_QListView::taskQTBUG_9455_wrongScrollbarRanges() QCOMPARE(w.verticalScrollBar()->maximum(), w.contentsSize().height() - w.viewport()->geometry().height()); } +void tst_QListView::styleOptionViewItem() +{ + class MyDelegate : public QStyledItemDelegate + { + public: + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const + { + QVERIFY(qstyleoption_cast<const QStyleOptionViewItemV4 *>(&option)); + QStyleOptionViewItemV4 opt(option); + initStyleOption(&opt, index); + + QCOMPARE(opt.index, index); + + QStyledItemDelegate::paint(painter, option, index); + } + }; + + QListView view; + QStandardItemModel model; + view.setModel(&model); + MyDelegate delegate; + view.setItemDelegate(&delegate); + model.appendRow(QList<QStandardItem*>() + << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") ); + + // Run test + view.showMaximized(); + QApplication::processEvents(); +} + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" |