]>
Commit | Line | Data |
---|---|---|
232fdc63 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: tests/controls/toolbooktest.cpp | |
3 | // Purpose: wxToolbook unit test | |
4 | // Author: Steven Lamerton | |
5 | // Created: 2010-07-02 | |
232fdc63 VZ |
6 | // Copyright: (c) 2010 Steven Lamerton |
7 | /////////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | #include "testprec.h" | |
10 | ||
11 | #if wxUSE_TOOLBOOK | |
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/toolbook.h" | |
23 | #include "wx/toolbar.h" | |
24 | #include "bookctrlbasetest.h" | |
25 | ||
26 | class ToolbookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase | |
27 | { | |
28 | public: | |
29 | ToolbookTestCase() { } | |
30 | ||
31 | virtual void setUp(); | |
32 | virtual void tearDown(); | |
33 | ||
34 | private: | |
35 | virtual wxBookCtrlBase *GetBase() const { return m_toolbook; } | |
36 | ||
37 | virtual wxEventType GetChangedEvent() const | |
ce7fe42e | 38 | { return wxEVT_TOOLBOOK_PAGE_CHANGED; } |
232fdc63 VZ |
39 | |
40 | virtual wxEventType GetChangingEvent() const | |
ce7fe42e | 41 | { return wxEVT_TOOLBOOK_PAGE_CHANGING; } |
232fdc63 | 42 | |
6f71e062 VZ |
43 | virtual void Realize() { m_toolbook->GetToolBar()->Realize(); } |
44 | ||
232fdc63 VZ |
45 | CPPUNIT_TEST_SUITE( ToolbookTestCase ); |
46 | wxBOOK_CTRL_BASE_TESTS(); | |
47 | CPPUNIT_TEST( ToolBar ); | |
48 | CPPUNIT_TEST_SUITE_END(); | |
49 | ||
50 | void ToolBar(); | |
51 | ||
52 | wxToolbook *m_toolbook; | |
53 | ||
54 | DECLARE_NO_COPY_CLASS(ToolbookTestCase) | |
55 | }; | |
56 | ||
57 | // register in the unnamed registry so that these tests are run by default | |
58 | CPPUNIT_TEST_SUITE_REGISTRATION( ToolbookTestCase ); | |
59 | ||
e3778b4d | 60 | // also include in its own registry so that these tests can be run alone |
232fdc63 VZ |
61 | CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ToolbookTestCase, "ToolbookTestCase" ); |
62 | ||
63 | void ToolbookTestCase::setUp() | |
64 | { | |
65 | m_toolbook = new wxToolbook(wxTheApp->GetTopWindow(), wxID_ANY, wxDefaultPosition, wxSize(400, 200)); | |
66 | AddPanels(); | |
67 | } | |
68 | ||
69 | void ToolbookTestCase::tearDown() | |
70 | { | |
71 | wxDELETE(m_toolbook); | |
72 | } | |
73 | ||
74 | void ToolbookTestCase::ToolBar() | |
75 | { | |
76 | wxToolBar* toolbar = static_cast<wxToolBar*>(m_toolbook->GetToolBar()); | |
77 | ||
78 | CPPUNIT_ASSERT(toolbar); | |
79 | CPPUNIT_ASSERT_EQUAL(3, toolbar->GetToolsCount()); | |
80 | } | |
81 | ||
82 | #endif //wxUSE_TOOLBOOK |