1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/bitmaptogglebuttontest.cpp
3 // Purpose: wxBitmapToggleButton unit test
4 // Author: Steven Lamerton
7 // Copyright: (c) 2010 Steven Lamerton
8 ///////////////////////////////////////////////////////////////////////////////
18 #include "wx/tglbtn.h"
20 #ifdef wxHAS_BITMAPTOGGLEBUTTON
26 #include "testableframe.h"
27 #include "wx/uiaction.h"
28 #include "wx/artprov.h"
30 class BitmapToggleButtonTestCase
: public CppUnit::TestCase
33 BitmapToggleButtonTestCase() { }
39 CPPUNIT_TEST_SUITE( BitmapToggleButtonTestCase
);
40 WXUISIM_TEST( Click
);
41 CPPUNIT_TEST( Value
);
42 CPPUNIT_TEST_SUITE_END();
47 wxBitmapToggleButton
* m_button
;
49 DECLARE_NO_COPY_CLASS(BitmapToggleButtonTestCase
)
52 // register in the unnamed registry so that these tests are run by default
53 CPPUNIT_TEST_SUITE_REGISTRATION( BitmapToggleButtonTestCase
);
55 // also include in its own registry so that these tests can be run alone
56 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( BitmapToggleButtonTestCase
,
57 "BitmapToggleButtonTestCase" );
59 void BitmapToggleButtonTestCase::setUp()
61 m_button
= new wxBitmapToggleButton(wxTheApp
->GetTopWindow(), wxID_ANY
,
62 wxArtProvider::GetIcon(wxART_INFORMATION
,
69 void BitmapToggleButtonTestCase::tearDown()
74 void BitmapToggleButtonTestCase::Click()
76 #if wxUSE_UIACTIONSIMULATOR
77 EventCounter
clicked(m_button
, wxEVT_TOGGLEBUTTON
);
79 wxUIActionSimulator sim
;
81 //We move in slightly to account for window decorations
82 sim
.MouseMove(m_button
->GetScreenPosition() + wxPoint(10, 10));
88 CPPUNIT_ASSERT_EQUAL(1, clicked
.GetCount());
89 CPPUNIT_ASSERT(m_button
->GetValue());
97 CPPUNIT_ASSERT_EQUAL(1, clicked
.GetCount());
98 CPPUNIT_ASSERT(!m_button
->GetValue());
99 #endif // wxUSE_UIACTIONSIMULATOR
102 void BitmapToggleButtonTestCase::Value()
104 EventCounter
clicked(m_button
, wxEVT_BUTTON
);
106 m_button
->SetValue(true);
108 CPPUNIT_ASSERT(m_button
->GetValue());
110 m_button
->SetValue(false);
112 CPPUNIT_ASSERT(!m_button
->GetValue());
114 CPPUNIT_ASSERT_EQUAL( 0, clicked
.GetCount() );
117 #endif // wxHAS_BITMAPTOGGLEBUTTON
119 #endif // wxUSE_TOGGLEBTN