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