diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2012-08-24 08:24:27 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-27 09:52:13 (GMT) |
commit | 7982f6ad2703e13edbf80d55e537871bf1cd548d (patch) | |
tree | ad23b8bbbe93704d01702948f8abd10bba748004 /tests | |
parent | 99e6ea17e257664467d49f4803952b7dd92f72da (diff) | |
download | Qt-7982f6ad2703e13edbf80d55e537871bf1cd548d.zip Qt-7982f6ad2703e13edbf80d55e537871bf1cd548d.tar.gz Qt-7982f6ad2703e13edbf80d55e537871bf1cd548d.tar.bz2 |
Take account of hidden items in QListView when using scrollTo.
This is a backport of 799ceebad8a2dbe1ca0e60a11c7d6ca0c2c8b7a9 from
qtbase.
Task-number: QTBUG-21804
Change-Id: I757b9598f354cdfa62c08d0c2613ded93fe88804
Reviewed-by: Jani Honkonen <jani.honkonen@digia.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qlistview/tst_qlistview.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 155ace9..9759790 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -134,6 +134,7 @@ private slots: void taskQTBUG_21804_hiddenItemsAndScrollingWithKeys(); void spacing_data(); void spacing(); + void testScrollToWithHidden(); }; // Testing get/set functions @@ -2232,5 +2233,33 @@ void tst_QListView::spacing() } } +void tst_QListView::testScrollToWithHidden() +{ + QListView lv; + + QStringListModel model; + QStringList list; + for (int i = 0; i < 30; i++) + list << QString::number(i); + model.setStringList(list); + lv.setModel(&model); + + lv.setRowHidden(1, true); + lv.setSpacing(5); + + lv.show(); + QTest::qWaitForWindowShown(&lv); + + QCOMPARE(lv.verticalScrollBar()->value(), 0); + + lv.scrollTo(model.index(26, 0)); + int expectedScrollBarValue = lv.verticalScrollBar()->value(); + QVERIFY(expectedScrollBarValue != 0); + + lv.scrollTo(model.index(25, 0)); + QCOMPARE(expectedScrollBarValue, lv.verticalScrollBar()->value()); +} + + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" |