diff options
Diffstat (limited to 'tests/auto/qlistview/tst_qlistview.cpp')
-rw-r--r-- | tests/auto/qlistview/tst_qlistview.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 6e211ae045..a5ff153b7c 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -119,6 +119,8 @@ private slots: void task262152_setModelColumnNavigate(); void taskQTBUG_2233_scrollHiddenItems_data(); void taskQTBUG_2233_scrollHiddenItems(); + void taskQTBUG_633_changeModelData(); + void taskQTBUG_435_deselectOnViewportClick(); }; // Testing get/set functions @@ -1132,6 +1134,7 @@ void tst_QListView::selection() #endif v.show(); + QTest::qWaitForWindowShown(&v); QApplication::processEvents(); v.setSelection(selectionRect, QItemSelectionModel::ClearAndSelect); @@ -1184,6 +1187,7 @@ void tst_QListView::scrollTo() lv.setModel(&model); lv.setFixedSize(100, 200); lv.show(); + QTest::qWaitForWindowShown(&lv); //by default, the list view scrolls per item and has no wrapping QModelIndex index = model.index(6,0); @@ -1782,6 +1786,7 @@ void tst_QListView::task262152_setModelColumnNavigate() view.setModelColumn(1); view.show(); + QTest::qWaitForWindowShown(&view); QTest::qWait(100); QTest::keyClick(&view, Qt::Key_Down); QTest::qWait(100); @@ -1829,5 +1834,47 @@ void tst_QListView::taskQTBUG_2233_scrollHiddenItems() } } +void tst_QListView::taskQTBUG_633_changeModelData() +{ + QListView view; + view.setFlow(QListView::LeftToRight); + QStandardItemModel model(5,1); + for (int i = 0; i < model.rowCount(); ++i) { + model.setData( model.index(i, 0), QString::number(i)); + } + + view.setModel(&model); + view.show(); + QTest::qWaitForWindowShown(&view); + model.setData( model.index(1, 0), QLatin1String("long long text")); + QTest::qWait(100); //leave time for relayouting the items + QRect rectLongText = view.visualRect(model.index(1,0)); + QRect rect2 = view.visualRect(model.index(2,0)); + QVERIFY( ! rectLongText.intersects(rect2) ); +} + +void tst_QListView::taskQTBUG_435_deselectOnViewportClick() +{ + QListView view; + QStringListModel model( QStringList() << "1" << "2" << "3" << "4"); + view.setModel(&model); + view.setSelectionMode(QAbstractItemView::ExtendedSelection); + view.selectAll(); + QCOMPARE(view.selectionModel()->selectedIndexes().count(), model.rowCount()); + + + QPoint p = view.visualRect(model.index(model.rowCount() - 1)).center() + QPoint(0, 20); + //first the left button + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p); + QVERIFY(!view.selectionModel()->hasSelection()); + + view.selectAll(); + QCOMPARE(view.selectionModel()->selectedIndexes().count(), model.rowCount()); + + //and now the right button + QTest::mouseClick(view.viewport(), Qt::RightButton, 0, p); + QVERIFY(!view.selectionModel()->hasSelection()); +} + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" |