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:
parent
c8d2195791
commit
b825c49c2e
@ -354,6 +354,12 @@ public:
|
||||
failure in debug builds) to remove an item with the index negative or
|
||||
greater or equal than the number of items in the control.
|
||||
|
||||
If there is a currently selected item below the item being deleted,
|
||||
i.e. if GetSelection() returns a valid index greater than or equal to
|
||||
@a n, the selection is invalidated when this function is called.
|
||||
However if the selected item appears before the item being deleted, the
|
||||
selection is preserved unchanged.
|
||||
|
||||
@param n
|
||||
The zero-based item index.
|
||||
|
||||
|
@ -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();
|
||||
|
@ -40,6 +40,7 @@ protected:
|
||||
CPPUNIT_TEST( Set ); \
|
||||
CPPUNIT_TEST( SetSelection ); \
|
||||
CPPUNIT_TEST( SetString ); \
|
||||
CPPUNIT_TEST( SelectionAfterDelete ); \
|
||||
WXUISIM_TEST( SimSelect );
|
||||
|
||||
void Append();
|
||||
@ -52,6 +53,7 @@ protected:
|
||||
void Set();
|
||||
void SetSelection();
|
||||
void SetString();
|
||||
void SelectionAfterDelete();
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
virtual void SimSelect();
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user