Test DESELECTED events in both virtual and non-virtual listctrls.
This commit is contained in:
@@ -203,6 +203,7 @@ void ListBaseTestCase::ItemClick()
|
||||
EventCounter focused(list, wxEVT_LIST_ITEM_FOCUSED);
|
||||
EventCounter activated(list, wxEVT_LIST_ITEM_ACTIVATED);
|
||||
EventCounter rclick(list, wxEVT_LIST_ITEM_RIGHT_CLICK);
|
||||
EventCounter deselected(list, wxEVT_LIST_ITEM_DESELECTED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@@ -224,6 +225,15 @@ void ListBaseTestCase::ItemClick()
|
||||
sim.MouseClick(wxMOUSE_BTN_RIGHT);
|
||||
wxYield();
|
||||
|
||||
// We want a point within the listctrl but below any items
|
||||
point = list->ClientToScreen(pos.GetPosition()) + wxPoint(10, 50);
|
||||
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
// when the first item was selected the focus changes to it, but not
|
||||
// on subsequent clicks
|
||||
|
||||
@@ -234,6 +244,7 @@ void ListBaseTestCase::ItemClick()
|
||||
#ifndef _WX_GENERIC_LISTCTRL_H_
|
||||
CPPUNIT_ASSERT_EQUAL(1, focused.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, selected.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, deselected.GetCount());
|
||||
#endif
|
||||
CPPUNIT_ASSERT_EQUAL(1, activated.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, rclick.GetCount());
|
||||
|
@@ -23,6 +23,8 @@
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/listctrl.h"
|
||||
#include "testableframe.h"
|
||||
#include "wx/uiaction.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
@@ -39,9 +41,11 @@ public:
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( VirtListCtrlTestCase );
|
||||
CPPUNIT_TEST( UpdateSelection );
|
||||
WXUISIM_TEST( DeselectedEvent );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void UpdateSelection();
|
||||
void DeselectedEvent();
|
||||
|
||||
wxListCtrl *m_list;
|
||||
|
||||
@@ -105,4 +109,42 @@ void VirtListCtrlTestCase::UpdateSelection()
|
||||
CPPUNIT_ASSERT_EQUAL( 1, m_list->GetSelectedItemCount() );
|
||||
}
|
||||
|
||||
void VirtListCtrlTestCase::DeselectedEvent()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
m_list->AppendColumn("Col0");
|
||||
m_list->SetItemCount(1);
|
||||
wxListCtrl* const list = m_list;
|
||||
|
||||
EventCounter selected(list, wxEVT_LIST_ITEM_SELECTED);
|
||||
EventCounter deselected(list, wxEVT_LIST_ITEM_DESELECTED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
wxRect pos;
|
||||
list->GetItemRect(0, pos);
|
||||
|
||||
//We move in slightly so we are not on the edge
|
||||
wxPoint point = list->ClientToScreen(pos.GetPosition()) + wxPoint(10, 10);
|
||||
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
// We want a point within the listctrl but below any items
|
||||
point = list->ClientToScreen(pos.GetPosition()) + wxPoint(10, 50);
|
||||
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, selected.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, deselected.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // wxUSE_LISTCTRL
|
||||
|
Reference in New Issue
Block a user