Move getting the unit test event count from wxTestableFrame to the EventCounter class. This reduces the need to have wxTestableFrame pointers all over the unit testing code and should reduce bugs caused by counting the wrong events.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70871 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
6c6b938377
commit
744d91d41f
@ -74,10 +74,7 @@ void BitmapToggleButtonTestCase::tearDown()
|
||||
void BitmapToggleButtonTestCase::Click()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_button, wxEVT_COMMAND_TOGGLEBUTTON_CLICKED);
|
||||
EventCounter clicked(m_button, wxEVT_COMMAND_TOGGLEBUTTON_CLICKED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -88,25 +85,23 @@ void BitmapToggleButtonTestCase::Click()
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, clicked.GetCount());
|
||||
CPPUNIT_ASSERT(m_button->GetValue());
|
||||
|
||||
clicked.Clear();
|
||||
wxMilliSleep(1000);
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, clicked.GetCount());
|
||||
CPPUNIT_ASSERT(!m_button->GetValue());
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
}
|
||||
|
||||
void BitmapToggleButtonTestCase::Value()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_button, wxEVT_COMMAND_BUTTON_CLICKED);
|
||||
EventCounter clicked(m_button, wxEVT_COMMAND_BUTTON_CLICKED);
|
||||
|
||||
m_button->SetValue(true);
|
||||
|
||||
@ -116,7 +111,7 @@ void BitmapToggleButtonTestCase::Value()
|
||||
|
||||
CPPUNIT_ASSERT(!m_button->GetValue());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 0, frame->GetEventCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 0, clicked.GetCount() );
|
||||
}
|
||||
|
||||
#endif // wxHAS_BITMAPTOGGLEBUTTON
|
||||
|
@ -122,35 +122,36 @@ void BookCtrlBaseTestCase::PageManagement()
|
||||
|
||||
void BookCtrlBaseTestCase::ChangeEvents()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
wxBookCtrlBase * const base = GetBase();
|
||||
|
||||
base->SetSelection(0);
|
||||
|
||||
EventCounter count(base, GetChangingEvent());
|
||||
EventCounter count1(base, GetChangedEvent());
|
||||
EventCounter changing(base, GetChangingEvent());
|
||||
EventCounter changed(base, GetChangedEvent());
|
||||
|
||||
base->SetSelection(1);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangingEvent()));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangedEvent()));
|
||||
CPPUNIT_ASSERT_EQUAL(1, changing.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, changed.GetCount());
|
||||
|
||||
changed.Clear();
|
||||
changing.Clear();
|
||||
base->ChangeSelection(2);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(GetChangingEvent()));
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(GetChangedEvent()));
|
||||
CPPUNIT_ASSERT_EQUAL(0, changing.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, changed.GetCount());
|
||||
|
||||
base->AdvanceSelection();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangingEvent()));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangedEvent()));
|
||||
CPPUNIT_ASSERT_EQUAL(1, changing.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, changed.GetCount());
|
||||
|
||||
changed.Clear();
|
||||
changing.Clear();
|
||||
base->AdvanceSelection(false);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangingEvent()));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangedEvent()));
|
||||
CPPUNIT_ASSERT_EQUAL(1, changing.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, changed.GetCount());
|
||||
}
|
||||
|
||||
void BookCtrlBaseTestCase::Image()
|
||||
|
@ -80,12 +80,9 @@ void ButtonTestCase::tearDown()
|
||||
|
||||
void ButtonTestCase::Click()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
//We use the internal class EventCounter which handles connecting and
|
||||
//disconnecting the control to the wxTestableFrame
|
||||
EventCounter count(m_button, wxEVT_COMMAND_BUTTON_CLICKED);
|
||||
EventCounter clicked(m_button, wxEVT_COMMAND_BUTTON_CLICKED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -97,15 +94,12 @@ void ButtonTestCase::Click()
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 1, clicked.GetCount() );
|
||||
}
|
||||
|
||||
void ButtonTestCase::Disabled()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_button, wxEVT_COMMAND_BUTTON_CLICKED);
|
||||
EventCounter clicked(m_button, wxEVT_COMMAND_BUTTON_CLICKED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -118,7 +112,7 @@ void ButtonTestCase::Disabled()
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 0, frame->GetEventCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 0, clicked.GetCount() );
|
||||
}
|
||||
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
|
@ -83,10 +83,7 @@ void CheckBoxTestCase::tearDown()
|
||||
|
||||
void CheckBoxTestCase::Check()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_check, wxEVT_COMMAND_CHECKBOX_CLICKED);
|
||||
EventCounter clicked(m_check, wxEVT_COMMAND_CHECKBOX_CLICKED);
|
||||
|
||||
//We should be unchecked by default
|
||||
CPPUNIT_ASSERT(!m_check->IsChecked());
|
||||
@ -108,7 +105,7 @@ void CheckBoxTestCase::Check()
|
||||
CPPUNIT_ASSERT(!m_check->IsChecked());
|
||||
|
||||
//None of these should send events
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, clicked.GetCount());
|
||||
}
|
||||
|
||||
#ifdef wxHAS_3STATE_CHECKBOX
|
||||
|
@ -65,10 +65,7 @@ void CheckListBoxTestCase::tearDown()
|
||||
|
||||
void CheckListBoxTestCase::Check()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_check, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED);
|
||||
EventCounter toggled(m_check, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED);
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 0");
|
||||
@ -83,7 +80,7 @@ void CheckListBoxTestCase::Check()
|
||||
m_check->Check(1, false);
|
||||
|
||||
//We should not get any events when changing this from code
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, toggled.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(true, m_check->IsChecked(0));
|
||||
CPPUNIT_ASSERT_EQUAL(false, m_check->IsChecked(1));
|
||||
|
||||
|
@ -129,17 +129,14 @@ void ComboBoxTestCase::Size()
|
||||
void ComboBoxTestCase::PopDismiss()
|
||||
{
|
||||
#if defined(__WXMSW__) || defined(__WXGTK210__)
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_combo, wxEVT_COMMAND_COMBOBOX_DROPDOWN);
|
||||
EventCounter count1(m_combo, wxEVT_COMMAND_COMBOBOX_CLOSEUP);
|
||||
EventCounter drop(m_combo, wxEVT_COMMAND_COMBOBOX_DROPDOWN);
|
||||
EventCounter close(m_combo, wxEVT_COMMAND_COMBOBOX_CLOSEUP);
|
||||
|
||||
m_combo->Popup();
|
||||
m_combo->Dismiss();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_COMBOBOX_DROPDOWN));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_COMBOBOX_CLOSEUP));
|
||||
CPPUNIT_ASSERT_EQUAL(1, drop.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, close.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -62,26 +62,20 @@ void FrameTestCase::tearDown()
|
||||
void FrameTestCase::Iconize()
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
wxTestableFrame* testframe = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_frame, wxEVT_ICONIZE);
|
||||
EventCounter iconize(m_frame, wxEVT_ICONIZE);
|
||||
|
||||
m_frame->Iconize();
|
||||
m_frame->Iconize(false);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, testframe->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(2, iconize.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void FrameTestCase::Close()
|
||||
{
|
||||
wxTestableFrame* testframe = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_frame, wxEVT_CLOSE_WINDOW);
|
||||
EventCounter close(m_frame, wxEVT_CLOSE_WINDOW);
|
||||
|
||||
m_frame->Close();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, testframe->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, close.GetCount());
|
||||
}
|
||||
|
@ -126,12 +126,9 @@ void GridTestCase::tearDown()
|
||||
void GridTestCase::CellEdit()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_grid, wxEVT_GRID_CELL_CHANGING);
|
||||
EventCounter count1(m_grid, wxEVT_GRID_CELL_CHANGED);
|
||||
EventCounter count2(m_grid, wxEVT_GRID_EDITOR_CREATED);
|
||||
EventCounter changing(m_grid, wxEVT_GRID_CELL_CHANGING);
|
||||
EventCounter changed(m_grid, wxEVT_GRID_CELL_CHANGED);
|
||||
EventCounter created(m_grid, wxEVT_GRID_EDITOR_CREATED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -144,31 +141,28 @@ void GridTestCase::CellEdit()
|
||||
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_EDITOR_CREATED));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_CELL_CHANGING));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_CELL_CHANGED));
|
||||
CPPUNIT_ASSERT_EQUAL(1, created.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, changing.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, changed.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void GridTestCase::CellClick()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_grid, wxEVT_GRID_CELL_LEFT_CLICK);
|
||||
EventCounter count1(m_grid, wxEVT_GRID_CELL_LEFT_DCLICK);
|
||||
EventCounter count2(m_grid, wxEVT_GRID_CELL_RIGHT_CLICK);
|
||||
EventCounter count3(m_grid, wxEVT_GRID_CELL_RIGHT_DCLICK);
|
||||
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 = frame->ClientToScreen(point + wxPoint(m_grid->GetRowLabelSize(),
|
||||
m_grid->GetColLabelSize())
|
||||
+ wxPoint(2, 2));
|
||||
point = m_grid->ClientToScreen(point + wxPoint(m_grid->GetRowLabelSize(),
|
||||
m_grid->GetColLabelSize())
|
||||
+ wxPoint(2, 2));
|
||||
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
@ -176,44 +170,43 @@ void GridTestCase::CellClick()
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_CELL_LEFT_CLICK));
|
||||
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, frame->GetEventCount(wxEVT_GRID_CELL_LEFT_CLICK));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_CELL_LEFT_DCLICK));
|
||||
CPPUNIT_ASSERT_EQUAL(1, lclick.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, ldclick.GetCount());
|
||||
|
||||
sim.MouseClick(wxMOUSE_BTN_RIGHT);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_CELL_RIGHT_CLICK));
|
||||
CPPUNIT_ASSERT_EQUAL(1, rclick.GetCount());
|
||||
rclick.Clear();
|
||||
|
||||
sim.MouseDblClick(wxMOUSE_BTN_RIGHT);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_CELL_RIGHT_CLICK));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_CELL_RIGHT_DCLICK));
|
||||
CPPUNIT_ASSERT_EQUAL(1, rclick.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, rdclick.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void GridTestCase::CellSelect()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_grid, wxEVT_GRID_SELECT_CELL);
|
||||
EventCounter cell(m_grid, wxEVT_GRID_SELECT_CELL);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
wxRect rect = m_grid->CellToRect(0, 0);
|
||||
wxPoint point = m_grid->CalcScrolledPosition(rect.GetPosition());
|
||||
point = frame->ClientToScreen(point + wxPoint(m_grid->GetRowLabelSize(),
|
||||
m_grid->GetColLabelSize())
|
||||
+ wxPoint(4, 4));
|
||||
point = m_grid->ClientToScreen(point + wxPoint(m_grid->GetRowLabelSize(),
|
||||
m_grid->GetColLabelSize())
|
||||
+ wxPoint(4, 4));
|
||||
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
@ -221,7 +214,9 @@ void GridTestCase::CellSelect()
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_SELECT_CELL));
|
||||
CPPUNIT_ASSERT_EQUAL(1, cell.GetCount());
|
||||
|
||||
cell.Clear();
|
||||
|
||||
m_grid->SetGridCursor(1, 1);
|
||||
m_grid->GoToCell(1, 0);
|
||||
@ -232,20 +227,17 @@ void GridTestCase::CellSelect()
|
||||
sim.MouseDblClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(3, frame->GetEventCount(wxEVT_GRID_SELECT_CELL));
|
||||
CPPUNIT_ASSERT_EQUAL(3, cell.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void GridTestCase::LabelClick()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_grid, wxEVT_GRID_LABEL_LEFT_CLICK);
|
||||
EventCounter count1(m_grid, wxEVT_GRID_LABEL_LEFT_DCLICK);
|
||||
EventCounter count2(m_grid, wxEVT_GRID_LABEL_RIGHT_CLICK);
|
||||
EventCounter count3(m_grid, wxEVT_GRID_LABEL_RIGHT_DCLICK);
|
||||
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;
|
||||
|
||||
@ -258,17 +250,18 @@ void GridTestCase::LabelClick()
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_LABEL_LEFT_CLICK));
|
||||
CPPUNIT_ASSERT_EQUAL(1, lclick.GetCount());
|
||||
|
||||
sim.MouseDblClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_LABEL_LEFT_DCLICK));
|
||||
CPPUNIT_ASSERT_EQUAL(1, ldclick.GetCount());
|
||||
|
||||
sim.MouseClick(wxMOUSE_BTN_RIGHT);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_LABEL_RIGHT_CLICK));
|
||||
CPPUNIT_ASSERT_EQUAL(1, rclick.GetCount());
|
||||
rclick.Clear();
|
||||
|
||||
sim.MouseDblClick(wxMOUSE_BTN_RIGHT);
|
||||
wxYield();
|
||||
@ -277,12 +270,12 @@ void GridTestCase::LabelClick()
|
||||
{
|
||||
//Right double click not supported with native headers so we get two
|
||||
//right click events
|
||||
CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_GRID_LABEL_RIGHT_CLICK));
|
||||
CPPUNIT_ASSERT_EQUAL(2, rclick.GetCount());
|
||||
}
|
||||
else
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_LABEL_RIGHT_CLICK));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_LABEL_RIGHT_DCLICK));
|
||||
CPPUNIT_ASSERT_EQUAL(1, rclick.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, rdclick.GetCount());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -292,10 +285,7 @@ void GridTestCase::SortClick()
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
m_grid->SetSortingColumn(0);
|
||||
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_grid, wxEVT_GRID_COL_SORT);
|
||||
EventCounter sort(m_grid, wxEVT_GRID_COL_SORT);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -308,18 +298,15 @@ void GridTestCase::SortClick()
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, sort.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void GridTestCase::Size()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__)
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_grid, wxEVT_GRID_COL_SIZE);
|
||||
EventCounter count1(m_grid, wxEVT_GRID_ROW_SIZE);
|
||||
EventCounter colsize(m_grid, wxEVT_GRID_COL_SIZE);
|
||||
EventCounter rowsize(m_grid, wxEVT_GRID_ROW_SIZE);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -338,7 +325,7 @@ void GridTestCase::Size()
|
||||
sim.MouseUp();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_COL_SIZE));
|
||||
CPPUNIT_ASSERT_EQUAL(1, colsize.GetCount());
|
||||
|
||||
pt = m_grid->ClientToScreen(wxPoint(5, m_grid->GetColLabelSize() +
|
||||
m_grid->GetRowSize(0)));
|
||||
@ -346,17 +333,14 @@ void GridTestCase::Size()
|
||||
sim.MouseDragDrop(pt.x, pt.y, pt.x, pt.y + 50);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_ROW_SIZE));
|
||||
CPPUNIT_ASSERT_EQUAL(1, rowsize.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void GridTestCase::RangeSelect()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_grid, wxEVT_GRID_RANGE_SELECT);
|
||||
EventCounter select(m_grid, wxEVT_GRID_RANGE_SELECT);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -377,7 +361,7 @@ void GridTestCase::RangeSelect()
|
||||
sim.MouseUp();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_RANGE_SELECT));
|
||||
CPPUNIT_ASSERT_EQUAL(1, select.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -656,11 +640,8 @@ void GridTestCase::CellFormatting()
|
||||
void GridTestCase::Editable()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
//As the grid is not editable we shouldn't create an editor
|
||||
EventCounter count(m_grid, wxEVT_GRID_EDITOR_CREATED);
|
||||
EventCounter created(m_grid, wxEVT_GRID_EDITOR_CREATED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -680,18 +661,15 @@ void GridTestCase::Editable()
|
||||
sim.Char(WXK_RETURN);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, created.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void GridTestCase::ReadOnly()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
//As the cell is readonly we shouldn't create an editor
|
||||
EventCounter count(m_grid, wxEVT_GRID_EDITOR_CREATED);
|
||||
EventCounter created(m_grid, wxEVT_GRID_EDITOR_CREATED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -714,7 +692,7 @@ void GridTestCase::ReadOnly()
|
||||
sim.Char(WXK_RETURN);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, created.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -94,10 +94,7 @@ void HyperlinkCtrlTestCase::Url()
|
||||
void HyperlinkCtrlTestCase::Click()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__)
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_hyperlink, wxEVT_COMMAND_HYPERLINK);
|
||||
EventCounter hyperlink(m_hyperlink, wxEVT_COMMAND_HYPERLINK);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -107,7 +104,7 @@ void HyperlinkCtrlTestCase::Click()
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, hyperlink.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -187,9 +187,6 @@ void ListBaseTestCase::ItemClick()
|
||||
if ( wxGetUserId().Lower().Matches("buildslave*") )
|
||||
return;
|
||||
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60);
|
||||
@ -200,10 +197,10 @@ void ListBaseTestCase::ItemClick()
|
||||
list->SetItem(0, 1, "first column");
|
||||
list->SetItem(0, 2, "second column");
|
||||
|
||||
EventCounter count(list, wxEVT_COMMAND_LIST_ITEM_SELECTED);
|
||||
EventCounter count1(list, wxEVT_COMMAND_LIST_ITEM_FOCUSED);
|
||||
EventCounter count2(list, wxEVT_COMMAND_LIST_ITEM_ACTIVATED);
|
||||
EventCounter count3(list, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK);
|
||||
EventCounter selected(list, wxEVT_COMMAND_LIST_ITEM_SELECTED);
|
||||
EventCounter focused(list, wxEVT_COMMAND_LIST_ITEM_FOCUSED);
|
||||
EventCounter activated(list, wxEVT_COMMAND_LIST_ITEM_ACTIVATED);
|
||||
EventCounter rclick(list, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -227,10 +224,10 @@ void ListBaseTestCase::ItemClick()
|
||||
|
||||
// when the first item was selected the focus changes to it, but not
|
||||
// on subsequent clicks
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_FOCUSED));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_SELECTED));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_ACTIVATED));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK));
|
||||
CPPUNIT_ASSERT_EQUAL(1, focused.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, selected.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, activated.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, rclick.GetCount());
|
||||
|
||||
//tidy up when we are finished
|
||||
list->ClearAll();
|
||||
@ -240,12 +237,9 @@ void ListBaseTestCase::ItemClick()
|
||||
void ListBaseTestCase::KeyDown()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
EventCounter count(list, wxEVT_COMMAND_LIST_KEY_DOWN);
|
||||
EventCounter keydown(list, wxEVT_COMMAND_LIST_KEY_DOWN);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -253,20 +247,17 @@ void ListBaseTestCase::KeyDown()
|
||||
sim.Text("aAbB");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(6, keydown.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void ListBaseTestCase::DeleteItems()
|
||||
{
|
||||
#ifndef __WXOSX__
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
EventCounter count(list, wxEVT_COMMAND_LIST_DELETE_ITEM);
|
||||
EventCounter count1(list, wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS);
|
||||
EventCounter deleteitem(list, wxEVT_COMMAND_LIST_DELETE_ITEM);
|
||||
EventCounter deleteall(list, wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS);
|
||||
|
||||
|
||||
list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60);
|
||||
@ -294,19 +285,16 @@ void ListBaseTestCase::DeleteItems()
|
||||
list->ClearAll();
|
||||
list->DeleteAllItems();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_LIST_DELETE_ITEM));
|
||||
CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS));
|
||||
CPPUNIT_ASSERT_EQUAL(2, deleteitem.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(2, deleteall.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void ListBaseTestCase::InsertItem()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
EventCounter count(list, wxEVT_COMMAND_LIST_INSERT_ITEM);
|
||||
EventCounter insert(list, wxEVT_COMMAND_LIST_INSERT_ITEM);
|
||||
|
||||
list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60);
|
||||
|
||||
@ -317,7 +305,7 @@ void ListBaseTestCase::InsertItem()
|
||||
list->InsertItem(item);
|
||||
list->InsertItem(1, "more text");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_LIST_INSERT_ITEM));
|
||||
CPPUNIT_ASSERT_EQUAL(2, insert.GetCount());
|
||||
}
|
||||
|
||||
void ListBaseTestCase::Find()
|
||||
@ -401,11 +389,8 @@ void ListBaseTestCase::EditLabel()
|
||||
list->InsertItem(0, "Item 0");
|
||||
list->InsertItem(1, "Item 1");
|
||||
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(list, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT);
|
||||
EventCounter count1(list, wxEVT_COMMAND_LIST_END_LABEL_EDIT);
|
||||
EventCounter beginedit(list, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT);
|
||||
EventCounter endedit(list, wxEVT_COMMAND_LIST_END_LABEL_EDIT);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -416,8 +401,8 @@ void ListBaseTestCase::EditLabel()
|
||||
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_END_LABEL_EDIT));
|
||||
CPPUNIT_ASSERT_EQUAL(1, beginedit.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, endedit.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -184,8 +184,8 @@ void ListBoxTestCase::ClickEvents()
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(frame, wxEVT_COMMAND_LISTBOX_SELECTED);
|
||||
EventCounter count1(frame, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
|
||||
EventCounter selected(frame, wxEVT_COMMAND_LISTBOX_SELECTED);
|
||||
EventCounter dclicked(frame, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -205,12 +205,12 @@ void ListBoxTestCase::ClickEvents()
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, selected.GetCount());
|
||||
|
||||
sim.MouseDblClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, dclicked.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -220,8 +220,8 @@ void ListBoxTestCase::ClickNotOnItem()
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(frame, wxEVT_COMMAND_LISTBOX_SELECTED);
|
||||
EventCounter count1(frame, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
|
||||
EventCounter selected(frame, wxEVT_COMMAND_LISTBOX_SELECTED);
|
||||
EventCounter dclicked(frame, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -252,7 +252,8 @@ void ListBoxTestCase::ClickNotOnItem()
|
||||
wxYield();
|
||||
|
||||
//If we are not clicking on an item we shouldn't have any events
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, selected.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, dclicked.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -97,12 +97,9 @@ void ListCtrlTestCase::EditLabel()
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
void ListCtrlTestCase::ColumnDrag()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_list, wxEVT_COMMAND_LIST_COL_BEGIN_DRAG);
|
||||
EventCounter count1(m_list, wxEVT_COMMAND_LIST_COL_DRAGGING);
|
||||
EventCounter count2(m_list, wxEVT_COMMAND_LIST_COL_END_DRAG);
|
||||
EventCounter begindrag(m_list, wxEVT_COMMAND_LIST_COL_BEGIN_DRAG);
|
||||
EventCounter dragging(m_list, wxEVT_COMMAND_LIST_COL_DRAGGING);
|
||||
EventCounter enddrag(m_list, wxEVT_COMMAND_LIST_COL_END_DRAG);
|
||||
|
||||
m_list->InsertColumn(0, "Column 0");
|
||||
m_list->InsertColumn(1, "Column 1");
|
||||
@ -126,20 +123,17 @@ void ListCtrlTestCase::ColumnDrag()
|
||||
sim.MouseUp();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG));
|
||||
CPPUNIT_ASSERT(frame->GetEventCount(wxEVT_COMMAND_LIST_COL_DRAGGING) > 0);
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_COL_END_DRAG));
|
||||
CPPUNIT_ASSERT_EQUAL(1, begindrag.GetCount());
|
||||
CPPUNIT_ASSERT(dragging.GetCount() > 0);
|
||||
CPPUNIT_ASSERT_EQUAL(1, enddrag.GetCount());
|
||||
|
||||
m_list->ClearAll();
|
||||
}
|
||||
|
||||
void ListCtrlTestCase::ColumnClick()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_list, wxEVT_COMMAND_LIST_COL_CLICK);
|
||||
EventCounter count1(m_list, wxEVT_COMMAND_LIST_COL_RIGHT_CLICK);
|
||||
EventCounter colclick(m_list, wxEVT_COMMAND_LIST_COL_CLICK);
|
||||
EventCounter colrclick(m_list, wxEVT_COMMAND_LIST_COL_RIGHT_CLICK);
|
||||
|
||||
|
||||
m_list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60);
|
||||
@ -153,8 +147,8 @@ void ListCtrlTestCase::ColumnClick()
|
||||
sim.MouseClick(wxMOUSE_BTN_RIGHT);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_COL_CLICK));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK));
|
||||
CPPUNIT_ASSERT_EQUAL(1, colclick.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, colrclick.GetCount());
|
||||
|
||||
m_list->ClearAll();
|
||||
}
|
||||
|
@ -129,17 +129,14 @@ void OwnerDrawnComboBoxTestCase::Size()
|
||||
|
||||
void OwnerDrawnComboBoxTestCase::PopDismiss()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_combo, wxEVT_COMMAND_COMBOBOX_DROPDOWN);
|
||||
EventCounter count1(m_combo, wxEVT_COMMAND_COMBOBOX_CLOSEUP);
|
||||
EventCounter drop(m_combo, wxEVT_COMMAND_COMBOBOX_DROPDOWN);
|
||||
EventCounter close(m_combo, wxEVT_COMMAND_COMBOBOX_CLOSEUP);
|
||||
|
||||
m_combo->Popup();
|
||||
m_combo->Dismiss();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_COMBOBOX_DROPDOWN));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_COMBOBOX_CLOSEUP));
|
||||
CPPUNIT_ASSERT_EQUAL(1, drop.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, close.GetCount());
|
||||
}
|
||||
|
||||
void OwnerDrawnComboBoxTestCase::Sort()
|
||||
|
@ -71,10 +71,7 @@ void RadioButtonTestCase::Click()
|
||||
{
|
||||
// GTK does not support selecting a single radio button
|
||||
#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__)
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_radio, wxEVT_COMMAND_RADIOBUTTON_SELECTED);
|
||||
EventCounter selected(m_radio, wxEVT_COMMAND_RADIOBUTTON_SELECTED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -83,17 +80,14 @@ void RadioButtonTestCase::Click()
|
||||
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 1, selected.GetCount() );
|
||||
#endif
|
||||
}
|
||||
|
||||
void RadioButtonTestCase::Value()
|
||||
{
|
||||
#ifndef __WXGTK__
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_radio, wxEVT_COMMAND_RADIOBUTTON_SELECTED);
|
||||
EventCounter selected(m_radio, wxEVT_COMMAND_RADIOBUTTON_SELECTED);
|
||||
|
||||
m_radio->SetValue(true);
|
||||
|
||||
@ -103,7 +97,7 @@ void RadioButtonTestCase::Value()
|
||||
|
||||
CPPUNIT_ASSERT(!m_radio->GetValue());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, selected.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -121,11 +121,8 @@ void RichTextCtrlTestCase::CharacterEvent()
|
||||
// There seems to be an event sequence problem on GTK+ that causes the events
|
||||
// to be disconnected before they're processed, generating spurious errors.
|
||||
#if !defined(__WXGTK__)
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_rich, wxEVT_COMMAND_RICHTEXT_CHARACTER);
|
||||
EventCounter count1(m_rich, wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED);
|
||||
EventCounter character(m_rich, wxEVT_COMMAND_RICHTEXT_CHARACTER);
|
||||
EventCounter content(m_rich, wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED);
|
||||
|
||||
m_rich->SetFocus();
|
||||
|
||||
@ -133,16 +130,19 @@ void RichTextCtrlTestCase::CharacterEvent()
|
||||
sim.Text("abcdef");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount(wxEVT_COMMAND_RICHTEXT_CHARACTER));
|
||||
CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount(wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED));
|
||||
CPPUNIT_ASSERT_EQUAL(6, character.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(6, content.GetCount());
|
||||
|
||||
character.Clear();
|
||||
content.Clear();
|
||||
|
||||
//As these are not characters they shouldn't count
|
||||
sim.Char(WXK_RETURN);
|
||||
sim.Char(WXK_SHIFT);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_COMMAND_RICHTEXT_CHARACTER));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED));
|
||||
CPPUNIT_ASSERT_EQUAL(0, character.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, content.GetCount());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@ -153,11 +153,8 @@ void RichTextCtrlTestCase::DeleteEvent()
|
||||
// There seems to be an event sequence problem on GTK+ that causes the events
|
||||
// to be disconnected before they're processed, generating spurious errors.
|
||||
#if !defined(__WXGTK__)
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_rich, wxEVT_COMMAND_RICHTEXT_DELETE);
|
||||
EventCounter count1(m_rich, wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED);
|
||||
EventCounter deleteevent(m_rich, wxEVT_COMMAND_RICHTEXT_DELETE);
|
||||
EventCounter contentdelete(m_rich, wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED);
|
||||
|
||||
m_rich->SetFocus();
|
||||
|
||||
@ -167,9 +164,9 @@ void RichTextCtrlTestCase::DeleteEvent()
|
||||
sim.Char(WXK_DELETE);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_RICHTEXT_DELETE));
|
||||
CPPUNIT_ASSERT_EQUAL(2, deleteevent.GetCount());
|
||||
//Only one as the delete doesn't delete anthing
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED));
|
||||
CPPUNIT_ASSERT_EQUAL(1, contentdelete.GetCount());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@ -180,10 +177,7 @@ void RichTextCtrlTestCase::ReturnEvent()
|
||||
// There seems to be an event sequence problem on GTK+ that causes the events
|
||||
// to be disconnected before they're processed, generating spurious errors.
|
||||
#if !defined(__WXGTK__)
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_rich, wxEVT_COMMAND_RICHTEXT_RETURN);
|
||||
EventCounter returnevent(m_rich, wxEVT_COMMAND_RICHTEXT_RETURN);
|
||||
|
||||
m_rich->SetFocus();
|
||||
|
||||
@ -191,44 +185,41 @@ void RichTextCtrlTestCase::ReturnEvent()
|
||||
sim.Char(WXK_RETURN);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, returnevent.GetCount());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::StyleEvent()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_rich, wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED);
|
||||
EventCounter stylechanged(m_rich, wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED);
|
||||
|
||||
m_rich->SetValue("Sometext");
|
||||
m_rich->SetStyle(0, 8, wxTextAttr(*wxRED, *wxWHITE));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED));
|
||||
CPPUNIT_ASSERT_EQUAL(1, stylechanged.GetCount());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::BufferResetEvent()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_rich, wxEVT_COMMAND_RICHTEXT_BUFFER_RESET);
|
||||
EventCounter reset(m_rich, wxEVT_COMMAND_RICHTEXT_BUFFER_RESET);
|
||||
|
||||
m_rich->AppendText("more text!");
|
||||
m_rich->SetValue("");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, reset.GetCount());
|
||||
|
||||
reset.Clear();
|
||||
m_rich->AppendText("more text!");
|
||||
m_rich->Clear();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, reset.GetCount());
|
||||
|
||||
reset.Clear();
|
||||
|
||||
//We expect a buffer reset here as setvalue clears the existing text
|
||||
m_rich->SetValue("replace");
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, reset.GetCount());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::UrlEvent()
|
||||
@ -236,10 +227,7 @@ void RichTextCtrlTestCase::UrlEvent()
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
// Mouse up event not being caught on GTK+
|
||||
#if !defined(__WXGTK__)
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_rich, wxEVT_COMMAND_TEXT_URL);
|
||||
EventCounter url(m_rich, wxEVT_COMMAND_TEXT_URL);
|
||||
|
||||
m_rich->BeginURL("http://www.wxwidgets.org");
|
||||
m_rich->WriteText("http://www.wxwidgets.org");
|
||||
@ -252,7 +240,7 @@ void RichTextCtrlTestCase::UrlEvent()
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, url.GetCount());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@ -261,10 +249,7 @@ void RichTextCtrlTestCase::TextEvent()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
#if !defined(__WXGTK__)
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_rich, wxEVT_COMMAND_TEXT_UPDATED);
|
||||
EventCounter updated(m_rich, wxEVT_COMMAND_TEXT_UPDATED);
|
||||
|
||||
m_rich->SetFocus();
|
||||
|
||||
@ -273,7 +258,7 @@ void RichTextCtrlTestCase::TextEvent()
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("abcdef", m_rich->GetValue());
|
||||
CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(6, updated.GetCount());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@ -424,10 +409,7 @@ void RichTextCtrlTestCase::Editable()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
#if !defined(__WXGTK__)
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_rich, wxEVT_COMMAND_TEXT_UPDATED);
|
||||
EventCounter updated(m_rich, wxEVT_COMMAND_TEXT_UPDATED);
|
||||
|
||||
m_rich->SetFocus();
|
||||
|
||||
@ -436,14 +418,15 @@ void RichTextCtrlTestCase::Editable()
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("abcdef", m_rich->GetValue());
|
||||
CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(6, updated.GetCount());
|
||||
updated.Clear();
|
||||
|
||||
m_rich->SetEditable(false);
|
||||
sim.Text("gh");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("abcdef", m_rich->GetValue());
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, updated.GetCount());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -87,11 +87,8 @@ void SliderTestCase::tearDown()
|
||||
void SliderTestCase::PageUpDown()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_slider, wxEVT_SCROLL_PAGEUP);
|
||||
EventCounter count1(m_slider, wxEVT_SCROLL_PAGEDOWN);
|
||||
EventCounter pageup(m_slider, wxEVT_SCROLL_PAGEUP);
|
||||
EventCounter pagedown(m_slider, wxEVT_SCROLL_PAGEDOWN);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -102,19 +99,16 @@ void SliderTestCase::PageUpDown()
|
||||
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_PAGEUP));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_PAGEDOWN));
|
||||
CPPUNIT_ASSERT_EQUAL(1, pageup.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, pagedown.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void SliderTestCase::LineUpDown()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_slider, wxEVT_SCROLL_LINEUP);
|
||||
EventCounter count1(m_slider, wxEVT_SCROLL_LINEDOWN);
|
||||
EventCounter lineup(m_slider, wxEVT_SCROLL_LINEUP);
|
||||
EventCounter linedown(m_slider, wxEVT_SCROLL_LINEDOWN);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -125,8 +119,8 @@ void SliderTestCase::LineUpDown()
|
||||
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_LINEUP));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_LINEDOWN));
|
||||
CPPUNIT_ASSERT_EQUAL(1, lineup.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, linedown.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -193,12 +187,9 @@ void SliderTestCase::Range()
|
||||
void SliderTestCase::Thumb()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__)
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_slider, wxEVT_SCROLL_THUMBTRACK);
|
||||
EventCounter count1(m_slider, wxEVT_SCROLL_THUMBRELEASE);
|
||||
EventCounter count2(m_slider, wxEVT_SCROLL_CHANGED);
|
||||
EventCounter track(m_slider, wxEVT_SCROLL_THUMBTRACK);
|
||||
EventCounter release(m_slider, wxEVT_SCROLL_THUMBRELEASE);
|
||||
EventCounter changed(m_slider, wxEVT_SCROLL_CHANGED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -216,10 +207,10 @@ void SliderTestCase::Thumb()
|
||||
sim.MouseUp();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT(frame->GetEventCount(wxEVT_SCROLL_THUMBTRACK) != 0);
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_THUMBRELEASE));
|
||||
CPPUNIT_ASSERT(track.GetCount() != 0);
|
||||
CPPUNIT_ASSERT_EQUAL(1, release.GetCount());
|
||||
#ifdef __WXMSW__
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_CHANGED));
|
||||
CPPUNIT_ASSERT_EQUAL(1, changed.GetCount());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -70,10 +70,7 @@ void SpinCtrlDoubleTestCase::tearDown()
|
||||
void SpinCtrlDoubleTestCase::Arrows()
|
||||
{
|
||||
#ifndef __WXGTK__
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_spin, wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED);
|
||||
EventCounter updated(m_spin, wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -83,13 +80,14 @@ void SpinCtrlDoubleTestCase::Arrows()
|
||||
sim.Char(WXK_UP);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, updated.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1.0, m_spin->GetValue());
|
||||
updated.Clear();
|
||||
|
||||
sim.Char(WXK_DOWN);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, updated.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0.0, m_spin->GetValue());
|
||||
#endif
|
||||
}
|
||||
|
@ -68,10 +68,7 @@ void SpinCtrlTestCase::tearDown()
|
||||
void SpinCtrlTestCase::Arrows()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_spin, wxEVT_COMMAND_SPINCTRL_UPDATED);
|
||||
EventCounter updated(m_spin, wxEVT_COMMAND_SPINCTRL_UPDATED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -81,14 +78,15 @@ void SpinCtrlTestCase::Arrows()
|
||||
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, updated.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, m_spin->GetValue());
|
||||
updated.Clear();
|
||||
|
||||
sim.Char(WXK_DOWN);
|
||||
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, updated.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, m_spin->GetValue());
|
||||
#endif
|
||||
}
|
||||
|
@ -147,10 +147,7 @@ void TextCtrlTestCase::ReadOnly()
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_READONLY);
|
||||
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_text, wxEVT_COMMAND_TEXT_UPDATED);
|
||||
EventCounter updated(m_text, wxEVT_COMMAND_TEXT_UPDATED);
|
||||
|
||||
m_text->SetFocus();
|
||||
|
||||
@ -159,7 +156,7 @@ void TextCtrlTestCase::ReadOnly()
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("", m_text->GetValue());
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, updated.GetCount());
|
||||
|
||||
// SetEditable() is supposed to override wxTE_READONLY
|
||||
m_text->SetEditable(true);
|
||||
@ -168,7 +165,7 @@ void TextCtrlTestCase::ReadOnly()
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("abcdef", m_text->GetValue());
|
||||
CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(6, updated.GetCount());
|
||||
|
||||
delete m_text;
|
||||
m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
@ -178,11 +175,8 @@ void TextCtrlTestCase::ReadOnly()
|
||||
void TextCtrlTestCase::MaxLength()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_text, wxEVT_COMMAND_TEXT_UPDATED);
|
||||
EventCounter count1(m_text, wxEVT_COMMAND_TEXT_MAXLEN);
|
||||
EventCounter updated(m_text, wxEVT_COMMAND_TEXT_UPDATED);
|
||||
EventCounter maxlen(m_text, wxEVT_COMMAND_TEXT_MAXLEN);
|
||||
|
||||
m_text->SetFocus();
|
||||
m_text->SetMaxLength(10);
|
||||
@ -191,27 +185,33 @@ void TextCtrlTestCase::MaxLength()
|
||||
sim.Text("abcdef");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_COMMAND_TEXT_MAXLEN));
|
||||
CPPUNIT_ASSERT_EQUAL(0, maxlen.GetCount());
|
||||
|
||||
sim.Text("ghij");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_COMMAND_TEXT_MAXLEN));
|
||||
CPPUNIT_ASSERT_EQUAL(10, frame->GetEventCount(wxEVT_COMMAND_TEXT_UPDATED));
|
||||
CPPUNIT_ASSERT_EQUAL(0, maxlen.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(10, updated.GetCount());
|
||||
|
||||
maxlen.Clear();
|
||||
updated.Clear();
|
||||
|
||||
sim.Text("k");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TEXT_MAXLEN));
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_COMMAND_TEXT_UPDATED));
|
||||
CPPUNIT_ASSERT_EQUAL(1, maxlen.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, updated.GetCount());
|
||||
|
||||
maxlen.Clear();
|
||||
updated.Clear();
|
||||
|
||||
m_text->SetMaxLength(0);
|
||||
|
||||
sim.Text("k");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_COMMAND_TEXT_MAXLEN));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TEXT_UPDATED));
|
||||
CPPUNIT_ASSERT_EQUAL(0, maxlen.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, updated.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -315,10 +315,7 @@ void TextCtrlTestCase::Url()
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_MULTILINE | wxTE_RICH | wxTE_AUTO_URL);
|
||||
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_text, wxEVT_COMMAND_TEXT_URL);
|
||||
EventCounter url(m_text, wxEVT_COMMAND_TEXT_URL);
|
||||
|
||||
m_text->AppendText("http://www.wxwidgets.org");
|
||||
|
||||
@ -327,7 +324,7 @@ void TextCtrlTestCase::Url()
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, url.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -41,40 +41,45 @@ void TextEntryTestCase::SetValue()
|
||||
|
||||
void TextEntryTestCase::TextChangeEvents()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(GetTestWindow(), wxEVT_COMMAND_TEXT_UPDATED);
|
||||
EventCounter updated(GetTestWindow(), wxEVT_COMMAND_TEXT_UPDATED);
|
||||
|
||||
wxTextEntry * const entry = GetTestEntry();
|
||||
|
||||
// notice that SetValue() generates an event even if the text didn't change
|
||||
entry->SetValue("");
|
||||
CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->SetValue("foo");
|
||||
CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->SetValue("foo");
|
||||
CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->ChangeValue("bar");
|
||||
CPPUNIT_ASSERT_EQUAL( 0, frame->GetEventCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 0, updated.GetCount() );
|
||||
|
||||
entry->AppendText("bar");
|
||||
CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->Replace(3, 6, "baz");
|
||||
CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->Remove(0, 3);
|
||||
CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->WriteText("foo");
|
||||
CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->Clear();
|
||||
CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
}
|
||||
|
||||
void TextEntryTestCase::CheckStringSelection(const char *sel)
|
||||
@ -176,13 +181,10 @@ void TextEntryTestCase::Replace()
|
||||
void TextEntryTestCase::Editable()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
wxTextEntry * const entry = GetTestEntry();
|
||||
wxWindow * const window = GetTestWindow();
|
||||
|
||||
EventCounter count(window, wxEVT_COMMAND_TEXT_UPDATED);
|
||||
EventCounter updated(window, wxEVT_COMMAND_TEXT_UPDATED);
|
||||
|
||||
window->SetFocus();
|
||||
wxYield();
|
||||
@ -192,14 +194,16 @@ void TextEntryTestCase::Editable()
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("abcdef", entry->GetValue());
|
||||
CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(6, updated.GetCount());
|
||||
|
||||
updated.Clear();
|
||||
|
||||
entry->SetEditable(false);
|
||||
sim.Text("gh");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("abcdef", entry->GetValue());
|
||||
CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, updated.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -64,10 +64,7 @@ void ToggleButtonTestCase::tearDown()
|
||||
void ToggleButtonTestCase::Click()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_button, wxEVT_COMMAND_TOGGLEBUTTON_CLICKED);
|
||||
EventCounter clicked(m_button, wxEVT_COMMAND_TOGGLEBUTTON_CLICKED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -78,23 +75,21 @@ void ToggleButtonTestCase::Click()
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, clicked.GetCount());
|
||||
CPPUNIT_ASSERT(m_button->GetValue());
|
||||
clicked.Clear();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, clicked.GetCount());
|
||||
CPPUNIT_ASSERT(!m_button->GetValue());
|
||||
#endif
|
||||
}
|
||||
|
||||
void ToggleButtonTestCase::Value()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_button, wxEVT_COMMAND_BUTTON_CLICKED);
|
||||
EventCounter clicked(m_button, wxEVT_COMMAND_BUTTON_CLICKED);
|
||||
|
||||
m_button->SetValue(true);
|
||||
|
||||
@ -104,7 +99,7 @@ void ToggleButtonTestCase::Value()
|
||||
|
||||
CPPUNIT_ASSERT(!m_button->GetValue());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 0, frame->GetEventCount() );
|
||||
CPPUNIT_ASSERT_EQUAL( 0, clicked.GetCount() );
|
||||
}
|
||||
|
||||
#endif //wxUSE_TOGGLEBTN
|
||||
|
@ -239,11 +239,8 @@ void TreeCtrlTestCase::SelectItemMulti()
|
||||
void TreeCtrlTestCase::ItemClick()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_tree, wxEVT_COMMAND_TREE_ITEM_ACTIVATED);
|
||||
EventCounter count1(m_tree, wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK);
|
||||
EventCounter activated(m_tree, wxEVT_COMMAND_TREE_ITEM_ACTIVATED);
|
||||
EventCounter rclick(m_tree, wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -262,35 +259,29 @@ void TreeCtrlTestCase::ItemClick()
|
||||
sim.MouseClick(wxMOUSE_BTN_RIGHT);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_ACTIVATED));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK));
|
||||
CPPUNIT_ASSERT_EQUAL(1, activated.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, rclick.GetCount());
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
}
|
||||
|
||||
void TreeCtrlTestCase::DeleteItem()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_tree, wxEVT_COMMAND_TREE_DELETE_ITEM);
|
||||
EventCounter deleteitem(m_tree, wxEVT_COMMAND_TREE_DELETE_ITEM);
|
||||
|
||||
wxTreeItemId todelete = m_tree->AppendItem(m_root, "deleteme");
|
||||
m_tree->Delete(todelete);
|
||||
// We do not test DeleteAllItems() as under some versions of Windows events
|
||||
// are not generated.
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, deleteitem.GetCount());
|
||||
}
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
void TreeCtrlTestCase::LabelEdit()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_tree, wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT);
|
||||
EventCounter count1(m_tree, wxEVT_COMMAND_TREE_END_LABEL_EDIT);
|
||||
EventCounter beginedit(m_tree, wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT);
|
||||
EventCounter endedit(m_tree, wxEVT_COMMAND_TREE_END_LABEL_EDIT);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -300,20 +291,17 @@ void TreeCtrlTestCase::LabelEdit()
|
||||
sim.Text("newroottext");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, beginedit.GetCount());
|
||||
|
||||
sim.Char(WXK_RETURN);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, endedit.GetCount());
|
||||
}
|
||||
|
||||
void TreeCtrlTestCase::KeyDown()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_tree, wxEVT_COMMAND_TREE_KEY_DOWN);
|
||||
EventCounter keydown(m_tree, wxEVT_COMMAND_TREE_KEY_DOWN);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -321,22 +309,19 @@ void TreeCtrlTestCase::KeyDown()
|
||||
sim.Text("aAbB");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(6, keydown.GetCount());
|
||||
}
|
||||
|
||||
#if !defined(__WXGTK__)
|
||||
|
||||
void TreeCtrlTestCase::CollapseExpandEvents()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
m_tree->CollapseAll();
|
||||
|
||||
EventCounter count(m_tree, wxEVT_COMMAND_TREE_ITEM_COLLAPSED);
|
||||
EventCounter count1(m_tree, wxEVT_COMMAND_TREE_ITEM_COLLAPSING);
|
||||
EventCounter count2(m_tree, wxEVT_COMMAND_TREE_ITEM_EXPANDED);
|
||||
EventCounter count3(m_tree, wxEVT_COMMAND_TREE_ITEM_EXPANDING);
|
||||
EventCounter collapsed(m_tree, wxEVT_COMMAND_TREE_ITEM_COLLAPSED);
|
||||
EventCounter collapsing(m_tree, wxEVT_COMMAND_TREE_ITEM_COLLAPSING);
|
||||
EventCounter expanded(m_tree, wxEVT_COMMAND_TREE_ITEM_EXPANDED);
|
||||
EventCounter expanding(m_tree, wxEVT_COMMAND_TREE_ITEM_EXPANDING);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -352,26 +337,23 @@ void TreeCtrlTestCase::CollapseExpandEvents()
|
||||
sim.MouseDblClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_EXPANDING));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_EXPANDED));
|
||||
CPPUNIT_ASSERT_EQUAL(1, expanding.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, expanded.GetCount());
|
||||
|
||||
sim.MouseDblClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_COLLAPSING));
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_COLLAPSED));
|
||||
CPPUNIT_ASSERT_EQUAL(1, collapsing.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, collapsed.GetCount());
|
||||
}
|
||||
|
||||
void TreeCtrlTestCase::SelectionChange()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
m_tree->ExpandAll();
|
||||
m_tree->UnselectAll();
|
||||
|
||||
EventCounter count(m_tree, wxEVT_COMMAND_TREE_SEL_CHANGED);
|
||||
EventCounter count1(m_tree, wxEVT_COMMAND_TREE_SEL_CHANGING);
|
||||
EventCounter changed(m_tree, wxEVT_COMMAND_TREE_SEL_CHANGED);
|
||||
EventCounter changing(m_tree, wxEVT_COMMAND_TREE_SEL_CHANGING);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -395,18 +377,15 @@ void TreeCtrlTestCase::SelectionChange()
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_TREE_SEL_CHANGED));
|
||||
CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_TREE_SEL_CHANGING));
|
||||
CPPUNIT_ASSERT_EQUAL(2, changed.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(2, changing.GetCount());
|
||||
}
|
||||
|
||||
#endif // !__WXGTK__
|
||||
|
||||
void TreeCtrlTestCase::Menu()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_tree, wxEVT_COMMAND_TREE_ITEM_MENU);
|
||||
EventCounter menu(m_tree, wxEVT_COMMAND_TREE_ITEM_MENU);
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
wxRect pos;
|
||||
@ -421,7 +400,7 @@ void TreeCtrlTestCase::Menu()
|
||||
sim.MouseClick(wxMOUSE_BTN_RIGHT);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_MENU));
|
||||
CPPUNIT_ASSERT_EQUAL(1, menu.GetCount());
|
||||
}
|
||||
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
|
@ -97,10 +97,7 @@ void WindowTestCase::tearDown()
|
||||
void WindowTestCase::ShowHideEvent()
|
||||
{
|
||||
#if defined(__WXMSW__) || defined (__WXPM__)
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_window, wxEVT_SHOW);
|
||||
EventCounter show(m_window, wxEVT_SHOW);
|
||||
|
||||
CPPUNIT_ASSERT(m_window->IsShown());
|
||||
|
||||
@ -112,19 +109,16 @@ void WindowTestCase::ShowHideEvent()
|
||||
|
||||
CPPUNIT_ASSERT(m_window->IsShown());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(2, show.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void WindowTestCase::KeyEvent()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_window, wxEVT_KEY_DOWN);
|
||||
EventCounter count1(m_window, wxEVT_KEY_UP);
|
||||
EventCounter count2(m_window, wxEVT_CHAR);
|
||||
EventCounter keydown(m_window, wxEVT_KEY_DOWN);
|
||||
EventCounter keyup(m_window, wxEVT_KEY_UP);
|
||||
EventCounter keychar(m_window, wxEVT_CHAR);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -134,31 +128,28 @@ void WindowTestCase::KeyEvent()
|
||||
sim.Char(WXK_SHIFT);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(5, frame->GetEventCount(wxEVT_KEY_DOWN));
|
||||
CPPUNIT_ASSERT_EQUAL(5, frame->GetEventCount(wxEVT_KEY_UP));
|
||||
CPPUNIT_ASSERT_EQUAL(4, frame->GetEventCount(wxEVT_CHAR));
|
||||
CPPUNIT_ASSERT_EQUAL(5, keydown.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(5, keyup.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(4, keychar.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void WindowTestCase::FocusEvent()
|
||||
{
|
||||
#ifndef __WXOSX__
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count(m_window, wxEVT_SET_FOCUS);
|
||||
EventCounter count1(m_window, wxEVT_KILL_FOCUS);
|
||||
EventCounter setfocus(m_window, wxEVT_SET_FOCUS);
|
||||
EventCounter killfocus(m_window, wxEVT_KILL_FOCUS);
|
||||
|
||||
m_window->SetFocus();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SET_FOCUS));
|
||||
CPPUNIT_ASSERT_EQUAL(1, setfocus.GetCount());
|
||||
CPPUNIT_ASSERT(m_window->HasFocus());
|
||||
|
||||
wxButton* button = new wxButton(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
|
||||
button->SetFocus();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_KILL_FOCUS));
|
||||
CPPUNIT_ASSERT_EQUAL(1, killfocus.GetCount());
|
||||
CPPUNIT_ASSERT(!m_window->HasFocus());
|
||||
#endif
|
||||
}
|
||||
|
@ -120,10 +120,7 @@ void HtmlWindowTestCase::Title()
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
void HtmlWindowTestCase::CellClick()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count1(m_win, wxEVT_COMMAND_HTML_CELL_CLICKED);
|
||||
EventCounter clicked(m_win, wxEVT_COMMAND_HTML_CELL_CLICKED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -137,15 +134,12 @@ void HtmlWindowTestCase::CellClick()
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, clicked.GetCount());
|
||||
}
|
||||
|
||||
void HtmlWindowTestCase::LinkClick()
|
||||
{
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter count1(m_win, wxEVT_COMMAND_HTML_LINK_CLICKED);
|
||||
EventCounter clicked(m_win, wxEVT_COMMAND_HTML_LINK_CLICKED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
@ -159,7 +153,7 @@ void HtmlWindowTestCase::LinkClick()
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, clicked.GetCount());
|
||||
}
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
|
@ -31,27 +31,7 @@ void wxTestableFrame::OnEvent(wxEvent& evt)
|
||||
|
||||
int wxTestableFrame::GetEventCount(wxEventType type)
|
||||
{
|
||||
if (type == wxEVT_ANY)
|
||||
{
|
||||
//Get the total event count
|
||||
long total = 0;
|
||||
|
||||
for(wxLongToLongHashMap::iterator iter = m_count.begin();
|
||||
iter != m_count.end();
|
||||
iter++)
|
||||
{
|
||||
total += iter->second;
|
||||
iter->second = 0;
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
else
|
||||
{
|
||||
long count = m_count[type];
|
||||
m_count[type] = 0;
|
||||
return count;
|
||||
}
|
||||
return m_count[type];
|
||||
}
|
||||
|
||||
void wxTestableFrame::ClearEventCount(wxEventType type)
|
||||
@ -63,24 +43,19 @@ EventCounter::EventCounter(wxWindow* win, wxEventType type) : m_type(type),
|
||||
m_win(win)
|
||||
|
||||
{
|
||||
m_frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
m_frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame);
|
||||
|
||||
m_win->Connect(m_type,
|
||||
wxEventHandler(wxTestableFrame::OnEvent),
|
||||
NULL,
|
||||
m_frame);
|
||||
m_win->Connect(m_type, wxEventHandler(wxTestableFrame::OnEvent),
|
||||
NULL, m_frame);
|
||||
}
|
||||
|
||||
EventCounter::~EventCounter()
|
||||
{
|
||||
m_win->Disconnect(m_type,
|
||||
wxEventHandler(wxTestableFrame::OnEvent),
|
||||
NULL,
|
||||
m_frame);
|
||||
m_win->Disconnect(m_type, wxEventHandler(wxTestableFrame::OnEvent),
|
||||
NULL, m_frame);
|
||||
|
||||
//This stops spurious counts from previous tests
|
||||
m_frame->ClearEventCount(m_type);
|
||||
Clear();
|
||||
|
||||
m_frame = NULL;
|
||||
m_win = NULL;
|
||||
|
@ -18,13 +18,12 @@ public:
|
||||
|
||||
void OnEvent(wxEvent& evt);
|
||||
|
||||
//wxEVT_ANY get the count for all events or a type can be specified
|
||||
int GetEventCount(wxEventType type = wxEVT_ANY);
|
||||
private:
|
||||
friend class EventCounter;
|
||||
|
||||
//Used to clear an event count, after disconnecting a counter for example
|
||||
int GetEventCount(wxEventType type);
|
||||
void ClearEventCount(wxEventType type);
|
||||
|
||||
private:
|
||||
wxLongToLongHashMap m_count;
|
||||
};
|
||||
|
||||
@ -34,6 +33,9 @@ public:
|
||||
EventCounter(wxWindow* win, wxEventType type);
|
||||
~EventCounter();
|
||||
|
||||
int GetCount() { return m_frame->GetEventCount(m_type); }
|
||||
void Clear() { m_frame->ClearEventCount(m_type); }
|
||||
|
||||
private:
|
||||
wxEventType m_type;
|
||||
wxTestableFrame* m_frame;
|
||||
|
Loading…
Reference in New Issue
Block a user