1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/bitmaptogglebuttontest.cpp
3 // Purpose: wxBitmapToggleButton unit test
4 // Author: Steven Lamerton
6 // Copyright: (c) 2010 Steven Lamerton
7 ///////////////////////////////////////////////////////////////////////////////
17 #include "wx/tglbtn.h"
19 #ifdef wxHAS_BITMAPTOGGLEBUTTON
25 #include "testableframe.h"
26 #include "wx/uiaction.h"
27 #include "wx/artprov.h"
29 class BitmapToggleButtonTestCase
: public CppUnit::TestCase
32 BitmapToggleButtonTestCase() { }
38 CPPUNIT_TEST_SUITE( BitmapToggleButtonTestCase
);
39 WXUISIM_TEST( Click
);
40 CPPUNIT_TEST( Value
);
41 CPPUNIT_TEST_SUITE_END();
46 wxBitmapToggleButton
* m_button
;
48 DECLARE_NO_COPY_CLASS(BitmapToggleButtonTestCase
)
51 // register in the unnamed registry so that these tests are run by default
52 CPPUNIT_TEST_SUITE_REGISTRATION( BitmapToggleButtonTestCase
);
54 // also include in its own registry so that these tests can be run alone
55 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( BitmapToggleButtonTestCase
,
56 "BitmapToggleButtonTestCase" );
58 void BitmapToggleButtonTestCase::setUp()
60 m_button
= new wxBitmapToggleButton(wxTheApp
->GetTopWindow(), wxID_ANY
,
61 wxArtProvider::GetIcon(wxART_INFORMATION
,
68 void BitmapToggleButtonTestCase::tearDown()
73 void BitmapToggleButtonTestCase::Click()
75 #if wxUSE_UIACTIONSIMULATOR
76 EventCounter
clicked(m_button
, wxEVT_TOGGLEBUTTON
);
78 wxUIActionSimulator sim
;
80 //We move in slightly to account for window decorations
81 sim
.MouseMove(m_button
->GetScreenPosition() + wxPoint(10, 10));
87 CPPUNIT_ASSERT_EQUAL(1, clicked
.GetCount());
88 CPPUNIT_ASSERT(m_button
->GetValue());
96 CPPUNIT_ASSERT_EQUAL(1, clicked
.GetCount());
97 CPPUNIT_ASSERT(!m_button
->GetValue());
98 #endif // wxUSE_UIACTIONSIMULATOR
101 void BitmapToggleButtonTestCase::Value()
103 EventCounter
clicked(m_button
, wxEVT_BUTTON
);
105 m_button
->SetValue(true);
107 CPPUNIT_ASSERT(m_button
->GetValue());
109 m_button
->SetValue(false);
111 CPPUNIT_ASSERT(!m_button
->GetValue());
113 CPPUNIT_ASSERT_EQUAL( 0, clicked
.GetCount() );
116 #endif // wxHAS_BITMAPTOGGLEBUTTON
118 #endif // wxUSE_TOGGLEBTN