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