void TreeCtrlTestCase::ItemClick() { #if wxUSE_UIACTIONSIMULATOR EventCounter activated(m_tree, wxEVT_TREE_ITEM_ACTIVATED); EventCounter rclick(m_tree, wxEVT_TREE_ITEM_RIGHT_CLICK); wxUIActionSimulator sim; wxRect pos; m_tree->GetBoundingRect(m_child1, pos, true); // We move in slightly so we are not on the edge wxPoint point = m_tree->ClientToScreen(pos.GetPosition()) + wxPoint(4, 4); sim.MouseMove(point); wxYield(); sim.MouseDblClick(); wxYield(); sim.MouseClick(wxMOUSE_BTN_RIGHT); wxYield(); CPPUNIT_ASSERT_EQUAL(1, activated.GetCount()); CPPUNIT_ASSERT_EQUAL(1, rclick.GetCount()); #endif // wxUSE_UIACTIONSIMULATOR }
void GridTestCase::LabelClick() { #if wxUSE_UIACTIONSIMULATOR EventCounter lclick(m_grid, wxEVT_GRID_LABEL_LEFT_CLICK); EventCounter ldclick(m_grid, wxEVT_GRID_LABEL_LEFT_DCLICK); EventCounter rclick(m_grid, wxEVT_GRID_LABEL_RIGHT_CLICK); EventCounter rdclick(m_grid, wxEVT_GRID_LABEL_RIGHT_DCLICK); wxUIActionSimulator sim; wxPoint pos(m_grid->GetRowLabelSize() + 2, 2); pos = m_grid->ClientToScreen(pos); sim.MouseMove(pos); wxYield(); sim.MouseClick(); wxYield(); CPPUNIT_ASSERT_EQUAL(1, lclick.GetCount()); sim.MouseDblClick(); wxYield(); CPPUNIT_ASSERT_EQUAL(1, ldclick.GetCount()); sim.MouseClick(wxMOUSE_BTN_RIGHT); wxYield(); CPPUNIT_ASSERT_EQUAL(1, rclick.GetCount()); rclick.Clear(); sim.MouseDblClick(wxMOUSE_BTN_RIGHT); wxYield(); if( ms_nativeheader ) { //Right double click not supported with native headers so we get two //right click events CPPUNIT_ASSERT_EQUAL(2, rclick.GetCount()); } else { CPPUNIT_ASSERT_EQUAL(1, rclick.GetCount()); CPPUNIT_ASSERT_EQUAL(1, rdclick.GetCount()); } #endif }
void GridTestCase::CellClick() { #if wxUSE_UIACTIONSIMULATOR EventCounter lclick(m_grid, wxEVT_GRID_CELL_LEFT_CLICK); EventCounter ldclick(m_grid, wxEVT_GRID_CELL_LEFT_DCLICK); EventCounter rclick(m_grid, wxEVT_GRID_CELL_RIGHT_CLICK); EventCounter rdclick(m_grid, wxEVT_GRID_CELL_RIGHT_DCLICK); wxUIActionSimulator sim; wxRect rect = m_grid->CellToRect(0, 0); wxPoint point = m_grid->CalcScrolledPosition(rect.GetPosition()); point = m_grid->ClientToScreen(point + wxPoint(m_grid->GetRowLabelSize(), m_grid->GetColLabelSize()) + wxPoint(2, 2)); sim.MouseMove(point); wxYield(); sim.MouseClick(); wxYield(); CPPUNIT_ASSERT_EQUAL(1, lclick.GetCount()); lclick.Clear(); sim.MouseDblClick(); wxYield(); //A double click event sends a single click event first //test to ensure this still happens in the future CPPUNIT_ASSERT_EQUAL(1, lclick.GetCount()); CPPUNIT_ASSERT_EQUAL(1, ldclick.GetCount()); sim.MouseClick(wxMOUSE_BTN_RIGHT); wxYield(); CPPUNIT_ASSERT_EQUAL(1, rclick.GetCount()); rclick.Clear(); sim.MouseDblClick(wxMOUSE_BTN_RIGHT); wxYield(); CPPUNIT_ASSERT_EQUAL(1, rclick.GetCount()); CPPUNIT_ASSERT_EQUAL(1, rdclick.GetCount()); #endif }
void ListBaseTestCase::ItemClick() { #if wxUSE_UIACTIONSIMULATOR #ifdef __WXMSW__ // FIXME: This test fails on MSW buildbot slaves although works fine on // development machine, no idea why. It seems to be a problem with // wxUIActionSimulator rather the wxListCtrl control itself however. if ( IsAutomaticTest() ) return; #endif // __WXMSW__ wxListCtrl* const list = GetList(); list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60); list->InsertColumn(1, "Column 1", wxLIST_FORMAT_LEFT, 50); list->InsertColumn(2, "Column 2", wxLIST_FORMAT_LEFT, 40); list->InsertItem(0, "Item 0"); list->SetItem(0, 1, "first column"); list->SetItem(0, 2, "second column"); EventCounter selected(list, wxEVT_LIST_ITEM_SELECTED); EventCounter focused(list, wxEVT_LIST_ITEM_FOCUSED); EventCounter activated(list, wxEVT_LIST_ITEM_ACTIVATED); EventCounter rclick(list, wxEVT_LIST_ITEM_RIGHT_CLICK); 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, 5); sim.MouseMove(point); wxYield(); sim.MouseClick(); wxYield(); sim.MouseDblClick(); wxYield(); sim.MouseClick(wxMOUSE_BTN_RIGHT); wxYield(); // when the first item was selected the focus changes to it, but not // on subsequent clicks // FIXME: This test fail under wxGTK & wxOSX because we get 3 FOCUSED events and // 2 SELECTED ones instead of the one of each we expect for some // reason, this needs to be debugged as it may indicate a bug in the // generic wxListCtrl implementation. #ifndef _WX_GENERIC_LISTCTRL_H_ CPPUNIT_ASSERT_EQUAL(1, focused.GetCount()); CPPUNIT_ASSERT_EQUAL(1, selected.GetCount()); #endif CPPUNIT_ASSERT_EQUAL(1, activated.GetCount()); CPPUNIT_ASSERT_EQUAL(1, rclick.GetCount()); //tidy up when we are finished list->ClearAll(); #endif // wxUSE_UIACTIONSIMULATOR }