]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/controls/togglebuttontest.cpp
reusing existing API
[wxWidgets.git] / tests / controls / togglebuttontest.cpp
index 9d41429465b576ad46014fcacbc4661791c9abed..054b7c6574995ea43a371c8570af44e578bb6019 100644 (file)
@@ -48,7 +48,7 @@ private:
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( ToggleButtonTestCase );
 
-// 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( ToggleButtonTestCase, "ToggleButtonTestCase" );
 
 void ToggleButtonTestCase::setUp()
@@ -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_TOGGLEBUTTON);
 
     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_BUTTON);
 
     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