Document and test wxItemContainer::Delete() selection handling

Add test checking that selection is reset when deleting the selected
item or any item before, but not after, it.

Also explicitly document this behaviour.
This commit is contained in:
Vadim Zeitlin
2018-12-15 22:49:33 +01:00
parent c8d2195791
commit b825c49c2e
3 changed files with 35 additions and 0 deletions

View File

@@ -270,6 +270,33 @@ void ItemContainerTestCase::SetString()
#endif
}
void ItemContainerTestCase::SelectionAfterDelete()
{
wxItemContainer * const container = GetContainer();
container->Append("item 0");
container->Append("item 1");
container->Append("item 2");
container->Append("item 3");
container->SetSelection(1);
CHECK( container->GetSelection() == 1 );
container->Delete(3);
CHECK( container->GetSelection() == 1 );
container->Delete(1);
CHECK( container->GetSelection() == wxNOT_FOUND );
container->SetSelection(1);
container->Delete(1);
CHECK( container->GetSelection() == wxNOT_FOUND );
container->SetSelection(0);
container->Delete(0);
CHECK( container->GetSelection() == wxNOT_FOUND );
}
void ItemContainerTestCase::SetSelection()
{
wxItemContainer * const container = GetContainer();