// register in the unnamed registry so that these tests are run by default
CPPUNIT_TEST_SUITE_REGISTRATION( TreeCtrlTestCase );
-// also include in it's own registry so that these tests can be run alone
+// also include in its own registry so that these tests can be run alone
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TreeCtrlTestCase, "TreeCtrlTestCase" );
// ----------------------------------------------------------------------------
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_TREE_ITEM_ACTIVATED);
+ EventCounter rclick(m_tree, wxEVT_TREE_ITEM_RIGHT_CLICK);
wxUIActionSimulator sim;
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_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_TREE_BEGIN_LABEL_EDIT);
+ EventCounter endedit(m_tree, wxEVT_TREE_END_LABEL_EDIT);
wxUIActionSimulator sim;
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_TREE_KEY_DOWN);
wxUIActionSimulator sim;
sim.Text("aAbB");
wxYield();
- CPPUNIT_ASSERT_EQUAL(4, 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_TREE_ITEM_COLLAPSED);
+ EventCounter collapsing(m_tree, wxEVT_TREE_ITEM_COLLAPSING);
+ EventCounter expanded(m_tree, wxEVT_TREE_ITEM_EXPANDED);
+ EventCounter expanding(m_tree, wxEVT_TREE_ITEM_EXPANDING);
wxUIActionSimulator sim;
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_TREE_SEL_CHANGED);
+ EventCounter changing(m_tree, wxEVT_TREE_SEL_CHANGING);
wxUIActionSimulator sim;
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_TREE_ITEM_MENU);
wxUIActionSimulator sim;
wxRect pos;
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
m_tree->SelectItem(m_root);
+ m_tree->SetFocus();
sim.Char(WXK_RIGHT);
wxYield();