]> git.saurik.com Git - wxWidgets.git/blame - tests/controls/bitmaptogglebuttontest.cpp
fixing typo
[wxWidgets.git] / tests / controls / bitmaptogglebuttontest.cpp
CommitLineData
232fdc63
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/controls/bitmaptogglebuttontest.cpp
3// Purpose: wxBitmapToggleButton unit test
4// Author: Steven Lamerton
5// Created: 2010-07-17
6// RCS-ID: $Id$
7// Copyright: (c) 2010 Steven Lamerton
8///////////////////////////////////////////////////////////////////////////////
9
10#include "testprec.h"
11
663a3ae1
SL
12#if wxUSE_TOGGLEBTN
13
232fdc63
VZ
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
323d36e4
VZ
18#include "wx/tglbtn.h"
19
20#ifdef wxHAS_BITMAPTOGGLEBUTTON
21
232fdc63
VZ
22#ifndef WX_PRECOMP
23 #include "wx/app.h"
24#endif // WX_PRECOMP
25
26#include "testableframe.h"
27#include "wx/uiaction.h"
28#include "wx/artprov.h"
232fdc63
VZ
29
30class BitmapToggleButtonTestCase : public CppUnit::TestCase
31{
32public:
33 BitmapToggleButtonTestCase() { }
34
35 void setUp();
36 void tearDown();
37
38private:
39 CPPUNIT_TEST_SUITE( BitmapToggleButtonTestCase );
40 WXUISIM_TEST( Click );
41 CPPUNIT_TEST( Value );
42 CPPUNIT_TEST_SUITE_END();
43
44 void Click();
45 void Value();
46
47 wxBitmapToggleButton* m_button;
48
49 DECLARE_NO_COPY_CLASS(BitmapToggleButtonTestCase)
50};
51
52// register in the unnamed registry so that these tests are run by default
53CPPUNIT_TEST_SUITE_REGISTRATION( BitmapToggleButtonTestCase );
54
e3778b4d 55// also include in its own registry so that these tests can be run alone
232fdc63
VZ
56CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( BitmapToggleButtonTestCase,
57 "BitmapToggleButtonTestCase" );
58
59void BitmapToggleButtonTestCase::setUp()
60{
61 m_button = new wxBitmapToggleButton(wxTheApp->GetTopWindow(), wxID_ANY,
62 wxArtProvider::GetIcon(wxART_INFORMATION,
63 wxART_OTHER,
64 wxSize(32, 32)));
65 m_button->Update();
66 m_button->Refresh();
67}
68
69void BitmapToggleButtonTestCase::tearDown()
70{
71 wxDELETE(m_button);
72}
73
74void BitmapToggleButtonTestCase::Click()
75{
76#if wxUSE_UIACTIONSIMULATOR
ce7fe42e 77 EventCounter clicked(m_button, wxEVT_TOGGLEBUTTON);
232fdc63
VZ
78
79 wxUIActionSimulator sim;
80
81 //We move in slightly to account for window decorations
82 sim.MouseMove(m_button->GetScreenPosition() + wxPoint(10, 10));
83 wxYield();
84
85 sim.MouseClick();
86 wxYield();
87
744d91d4 88 CPPUNIT_ASSERT_EQUAL(1, clicked.GetCount());
232fdc63
VZ
89 CPPUNIT_ASSERT(m_button->GetValue());
90
744d91d4 91 clicked.Clear();
232fdc63
VZ
92 wxMilliSleep(1000);
93
94 sim.MouseClick();
95 wxYield();
96
744d91d4 97 CPPUNIT_ASSERT_EQUAL(1, clicked.GetCount());
232fdc63
VZ
98 CPPUNIT_ASSERT(!m_button->GetValue());
99#endif // wxUSE_UIACTIONSIMULATOR
100}
101
102void BitmapToggleButtonTestCase::Value()
103{
ce7fe42e 104 EventCounter clicked(m_button, wxEVT_BUTTON);
232fdc63
VZ
105
106 m_button->SetValue(true);
107
108 CPPUNIT_ASSERT(m_button->GetValue());
109
110 m_button->SetValue(false);
111
112 CPPUNIT_ASSERT(!m_button->GetValue());
113
744d91d4 114 CPPUNIT_ASSERT_EQUAL( 0, clicked.GetCount() );
232fdc63 115}
663a3ae1 116
323d36e4
VZ
117#endif // wxHAS_BITMAPTOGGLEBUTTON
118
119#endif // wxUSE_TOGGLEBTN