]>
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
6 // Copyright: (c) 2010 Steven Lamerton
7 ///////////////////////////////////////////////////////////////////////////////
22 class GaugeTestCase
: public CppUnit::TestCase
31 CPPUNIT_TEST_SUITE( GaugeTestCase
);
32 CPPUNIT_TEST( Direction
);
33 CPPUNIT_TEST( Range
);
34 CPPUNIT_TEST( Value
);
35 CPPUNIT_TEST_SUITE_END();
43 DECLARE_NO_COPY_CLASS(GaugeTestCase
)
46 // register in the unnamed registry so that these tests are run by default
47 CPPUNIT_TEST_SUITE_REGISTRATION( GaugeTestCase
);
49 // also include in its own registry so that these tests can be run alone
50 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( GaugeTestCase
, "GaugeTestCase" );
52 void GaugeTestCase::setUp()
54 m_gauge
= new wxGauge(wxTheApp
->GetTopWindow(), wxID_ANY
, 100);
57 void GaugeTestCase::tearDown()
59 wxTheApp
->GetTopWindow()->DestroyChildren();
62 void GaugeTestCase::Direction()
64 //We should default to a horizontal gauge
65 CPPUNIT_ASSERT(!m_gauge
->IsVertical());
68 m_gauge
= new wxGauge(wxTheApp
->GetTopWindow(), wxID_ANY
, 100,
69 wxDefaultPosition
, wxDefaultSize
, wxGA_VERTICAL
);
71 CPPUNIT_ASSERT(m_gauge
->IsVertical());
74 m_gauge
= new wxGauge(wxTheApp
->GetTopWindow(), wxID_ANY
, 100,
75 wxDefaultPosition
, wxDefaultSize
, wxGA_HORIZONTAL
);
77 CPPUNIT_ASSERT(!m_gauge
->IsVertical());
80 void GaugeTestCase::Range()
82 CPPUNIT_ASSERT_EQUAL(100, m_gauge
->GetRange());
84 m_gauge
->SetRange(50);
86 CPPUNIT_ASSERT_EQUAL(50, m_gauge
->GetRange());
90 CPPUNIT_ASSERT_EQUAL(0, m_gauge
->GetRange());
93 void GaugeTestCase::Value()
95 CPPUNIT_ASSERT_EQUAL(0, m_gauge
->GetValue());
97 m_gauge
->SetValue(50);
99 CPPUNIT_ASSERT_EQUAL(50, m_gauge
->GetValue());
101 m_gauge
->SetValue(0);
103 CPPUNIT_ASSERT_EQUAL(0, m_gauge
->GetValue());
105 m_gauge
->SetValue(100);
107 CPPUNIT_ASSERT_EQUAL(100, m_gauge
->GetValue());