Document that wxDataViewCtrl::SetSelections() skips invalid items

Also add the unit test checking for this.
This commit is contained in:
Vadim Zeitlin
2020-10-12 17:05:59 +02:00
committed by Václav Slavík
parent 9457c35d42
commit 1f40a7e4e3
2 changed files with 27 additions and 0 deletions

View File

@@ -1675,6 +1675,9 @@ public:
/**
Sets the selection to the array of wxDataViewItems.
Note that if @a sel contains any invalid items, they are simply
ignored.
*/
virtual void SetSelections(const wxDataViewItemArray& sel);

View File

@@ -146,6 +146,30 @@ MultiColumnsDataViewCtrlTestCase::~MultiColumnsDataViewCtrlTestCase()
// the tests themselves
// ----------------------------------------------------------------------------
TEST_CASE_METHOD(MultiSelectDataViewCtrlTestCase,
"wxDVC::Selection",
"[wxDataViewCtrl][select]")
{
// Check selection round-trip.
wxDataViewItemArray sel;
sel.push_back(m_child1);
sel.push_back(m_grandchild);
REQUIRE_NOTHROW( m_dvc->SetSelections(sel) );
wxDataViewItemArray sel2;
CHECK( m_dvc->GetSelections(sel2) == sel.size() );
CHECK( sel2 == sel );
// Invalid items in GetSelections() input are supposed to be just skipped.
sel.clear();
sel.push_back(wxDataViewItem());
REQUIRE_NOTHROW( m_dvc->SetSelections(sel) );
CHECK( m_dvc->GetSelections(sel2) == 0 );
CHECK( sel2.empty() );
}
TEST_CASE_METHOD(MultiSelectDataViewCtrlTestCase,
"wxDVC::DeleteSelected",
"[wxDataViewCtrl][delete]")