]>
git.saurik.com Git - wxWidgets.git/blob - tests/controls/gaugetest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/gaugetest.cpp
3 // Purpose: wxGauge unit test
4 // Author: Steven Lamerton
7 // Copyright: (c) 2010 Steven Lamerton
8 ///////////////////////////////////////////////////////////////////////////////
23 class GaugeTestCase
: public CppUnit::TestCase
32 CPPUNIT_TEST_SUITE( GaugeTestCase
);
33 CPPUNIT_TEST( Direction
);
34 CPPUNIT_TEST( Range
);
35 CPPUNIT_TEST( Value
);
36 CPPUNIT_TEST_SUITE_END();
44 DECLARE_NO_COPY_CLASS(GaugeTestCase
)
47 // register in the unnamed registry so that these tests are run by default
48 CPPUNIT_TEST_SUITE_REGISTRATION( GaugeTestCase
);
50 // also include in it's own registry so that these tests can be run alone
51 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( GaugeTestCase
, "GaugeTestCase" );
53 void GaugeTestCase::setUp()
55 m_gauge
= new wxGauge(wxTheApp
->GetTopWindow(), wxID_ANY
, 100);
58 void GaugeTestCase::tearDown()
60 wxTheApp
->GetTopWindow()->DestroyChildren();
63 void GaugeTestCase::Direction()
65 //We should default to a horizontal gauge
66 CPPUNIT_ASSERT(!m_gauge
->IsVertical());
69 m_gauge
= new wxGauge(wxTheApp
->GetTopWindow(), wxID_ANY
, 100,
70 wxDefaultPosition
, wxDefaultSize
, wxGA_VERTICAL
);
72 CPPUNIT_ASSERT(m_gauge
->IsVertical());
75 m_gauge
= new wxGauge(wxTheApp
->GetTopWindow(), wxID_ANY
, 100,
76 wxDefaultPosition
, wxDefaultSize
, wxGA_HORIZONTAL
);
78 CPPUNIT_ASSERT(!m_gauge
->IsVertical());
81 void GaugeTestCase::Range()
83 CPPUNIT_ASSERT_EQUAL(100, m_gauge
->GetRange());
85 m_gauge
->SetRange(50);
87 CPPUNIT_ASSERT_EQUAL(50, m_gauge
->GetRange());
91 CPPUNIT_ASSERT_EQUAL(0, m_gauge
->GetRange());
94 void GaugeTestCase::Value()
96 CPPUNIT_ASSERT_EQUAL(0, m_gauge
->GetValue());
98 m_gauge
->SetValue(50);
100 CPPUNIT_ASSERT_EQUAL(50, m_gauge
->GetValue());
102 m_gauge
->SetValue(0);
104 CPPUNIT_ASSERT_EQUAL(0, m_gauge
->GetValue());
106 m_gauge
->SetValue(100);
108 CPPUNIT_ASSERT_EQUAL(100, m_gauge
->GetValue());