diff options
Diffstat (limited to 'tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp')
-rw-r--r-- | tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 23e2ec8516..8396fd4ec7 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -4922,13 +4922,27 @@ void tst_QTreeView::taskQTBUG_61476() const QPoint pos = rect.center(); QTest::mousePress(tv.viewport(), Qt::LeftButton, {}, pos); - if (tv.style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, nullptr, &tv) == - QEvent::MouseButtonPress) + const bool expandsOnPress = + (tv.style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, nullptr, &tv) == QEvent::MouseButtonPress); + if (expandsOnPress) QTRY_VERIFY(!tv.isExpanded(mi)); QTest::mouseRelease(tv.viewport(), Qt::LeftButton, {}, pos); QTRY_VERIFY(!tv.isExpanded(mi)); QCOMPARE(lastTopLevel->checkState(), Qt::Checked); + + // Test that it does not toggle the check state of a previously selected item when collapsing an + // item causes it to position the item under the mouse to be the decoration for the selected item + tv.expandAll(); + tv.verticalScrollBar()->setValue(tv.verticalScrollBar()->maximum()); + // It is not enough to programmatically select the item, we need to have it clicked on + QTest::mouseClick(tv.viewport(), Qt::LeftButton, {}, tv.visualRect(lastTopLevel->index()).center()); + QTest::mousePress(tv.viewport(), Qt::LeftButton, {}, pos); + if (expandsOnPress) + QTRY_VERIFY(!tv.isExpanded(mi)); + QTest::mouseRelease(tv.viewport(), Qt::LeftButton, nullptr, pos); + QTRY_VERIFY(!tv.isExpanded(mi)); + QCOMPARE(lastTopLevel->checkState(), Qt::Checked); } QTEST_MAIN(tst_QTreeView) |