]> git.saurik.com Git - wxWidgets.git/blob - tests/controls/choicebooktest.cpp
5cb4509827853069cec603d10e64173949c3d334
[wxWidgets.git] / tests / controls / choicebooktest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/choicebooktest.cpp
3 // Purpose: wxChoicebook unit test
4 // Author: Steven Lamerton
5 // Created: 2010-07-02
6 // Copyright: (c) 2010 Steven Lamerton
7 ///////////////////////////////////////////////////////////////////////////////
8
9 #include "testprec.h"
10
11 #if wxUSE_CHOICEBOOK
12
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16
17 #ifndef WX_PRECOMP
18 #include "wx/app.h"
19 #include "wx/panel.h"
20 #endif // WX_PRECOMP
21
22 #include "wx/choicebk.h"
23 #include "bookctrlbasetest.h"
24
25 class ChoicebookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase
26 {
27 public:
28 ChoicebookTestCase() { }
29
30 virtual void setUp();
31 virtual void tearDown();
32
33 private:
34 virtual wxBookCtrlBase *GetBase() const { return m_choicebook; }
35
36 virtual wxEventType GetChangedEvent() const
37 { return wxEVT_CHOICEBOOK_PAGE_CHANGED; }
38
39 virtual wxEventType GetChangingEvent() const
40 { return wxEVT_CHOICEBOOK_PAGE_CHANGING; }
41
42 CPPUNIT_TEST_SUITE( ChoicebookTestCase );
43 wxBOOK_CTRL_BASE_TESTS();
44 CPPUNIT_TEST( Choice );
45 CPPUNIT_TEST_SUITE_END();
46
47 void Choice();
48
49 wxChoicebook *m_choicebook;
50
51 DECLARE_NO_COPY_CLASS(ChoicebookTestCase)
52 };
53
54 // register in the unnamed registry so that these tests are run by default
55 CPPUNIT_TEST_SUITE_REGISTRATION( ChoicebookTestCase );
56
57 // also include in its own registry so that these tests can be run alone
58 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ChoicebookTestCase, "ChoicebookTestCase" );
59
60 void ChoicebookTestCase::setUp()
61 {
62 m_choicebook = new wxChoicebook(wxTheApp->GetTopWindow(), wxID_ANY);
63 AddPanels();
64 }
65
66 void ChoicebookTestCase::tearDown()
67 {
68 wxDELETE(m_choicebook);
69 }
70
71 void ChoicebookTestCase::Choice()
72 {
73 wxChoice* choice = m_choicebook->GetChoiceCtrl();
74
75 CPPUNIT_ASSERT(choice);
76 CPPUNIT_ASSERT_EQUAL(3, choice->GetCount());
77 CPPUNIT_ASSERT_EQUAL("Panel 1", choice->GetString(0));
78 }
79
80 #endif //wxUSE_CHOICEBOOK