]> git.saurik.com Git - wxWidgets.git/blame - tests/controls/gaugetest.cpp
Fixed capitalisation
[wxWidgets.git] / tests / controls / gaugetest.cpp
CommitLineData
232fdc63
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/controls/gaugetest.cpp
3// Purpose: wxGauge unit test
4// Author: Steven Lamerton
5// Created: 2010-07-15
232fdc63
VZ
6// Copyright: (c) 2010 Steven Lamerton
7///////////////////////////////////////////////////////////////////////////////
8
9#include "testprec.h"
10
11#if wxUSE_GAUGE
12
13#ifdef __BORLANDC__
14 #pragma hdrstop
15#endif
16
17#ifndef WX_PRECOMP
18 #include "wx/app.h"
19 #include "wx/gauge.h"
20#endif // WX_PRECOMP
21
22class GaugeTestCase : public CppUnit::TestCase
23{
24public:
25 GaugeTestCase() { }
26
27 void setUp();
28 void tearDown();
29
30private:
31 CPPUNIT_TEST_SUITE( GaugeTestCase );
32 CPPUNIT_TEST( Direction );
33 CPPUNIT_TEST( Range );
34 CPPUNIT_TEST( Value );
35 CPPUNIT_TEST_SUITE_END();
36
37 void Direction();
38 void Range();
39 void Value();
40
41 wxGauge* m_gauge;
42
43 DECLARE_NO_COPY_CLASS(GaugeTestCase)
44};
45
46// register in the unnamed registry so that these tests are run by default
47CPPUNIT_TEST_SUITE_REGISTRATION( GaugeTestCase );
48
e3778b4d 49// also include in its own registry so that these tests can be run alone
232fdc63
VZ
50CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( GaugeTestCase, "GaugeTestCase" );
51
52void GaugeTestCase::setUp()
53{
54 m_gauge = new wxGauge(wxTheApp->GetTopWindow(), wxID_ANY, 100);
55}
56
57void GaugeTestCase::tearDown()
58{
59 wxTheApp->GetTopWindow()->DestroyChildren();
60}
61
62void GaugeTestCase::Direction()
63{
64 //We should default to a horizontal gauge
65 CPPUNIT_ASSERT(!m_gauge->IsVertical());
66
67 wxDELETE(m_gauge);
68 m_gauge = new wxGauge(wxTheApp->GetTopWindow(), wxID_ANY, 100,
69 wxDefaultPosition, wxDefaultSize, wxGA_VERTICAL);
70
71 CPPUNIT_ASSERT(m_gauge->IsVertical());
72
73 wxDELETE(m_gauge);
74 m_gauge = new wxGauge(wxTheApp->GetTopWindow(), wxID_ANY, 100,
75 wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL);
76
77 CPPUNIT_ASSERT(!m_gauge->IsVertical());
78}
79
80void GaugeTestCase::Range()
81{
82 CPPUNIT_ASSERT_EQUAL(100, m_gauge->GetRange());
83
84 m_gauge->SetRange(50);
85
86 CPPUNIT_ASSERT_EQUAL(50, m_gauge->GetRange());
87
88 m_gauge->SetRange(0);
89
90 CPPUNIT_ASSERT_EQUAL(0, m_gauge->GetRange());
91}
92
93void GaugeTestCase::Value()
94{
95 CPPUNIT_ASSERT_EQUAL(0, m_gauge->GetValue());
96
97 m_gauge->SetValue(50);
98
99 CPPUNIT_ASSERT_EQUAL(50, m_gauge->GetValue());
100
101 m_gauge->SetValue(0);
102
103 CPPUNIT_ASSERT_EQUAL(0, m_gauge->GetValue());
104
105 m_gauge->SetValue(100);
106
107 CPPUNIT_ASSERT_EQUAL(100, m_gauge->GetValue());
108}
109
110#endif //wxUSE_GAUGE