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