]>
Commit | Line | Data |
---|---|---|
232fdc63 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: tests/controls/notebooktest.cpp | |
3 | // Purpose: wxNotebook 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_NOTEBOOK | |
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/notebook.h" | |
24 | #include "bookctrlbasetest.h" | |
25 | ||
26 | class NotebookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase | |
27 | { | |
28 | public: | |
29 | NotebookTestCase() { } | |
30 | ||
31 | virtual void setUp(); | |
32 | virtual void tearDown(); | |
33 | ||
34 | private: | |
35 | virtual wxBookCtrlBase *GetBase() const { return m_notebook; } | |
36 | ||
37 | virtual wxEventType GetChangedEvent() const | |
38 | { return wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED; } | |
39 | ||
40 | virtual wxEventType GetChangingEvent() const | |
41 | { return wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING; } | |
42 | ||
43 | ||
44 | CPPUNIT_TEST_SUITE( NotebookTestCase ); | |
45 | wxBOOK_CTRL_BASE_TESTS(); | |
46 | CPPUNIT_TEST( Image ); | |
47 | CPPUNIT_TEST( RowCount ); | |
48 | CPPUNIT_TEST_SUITE_END(); | |
49 | ||
50 | void RowCount(); | |
51 | ||
52 | wxNotebook *m_notebook; | |
53 | ||
54 | DECLARE_NO_COPY_CLASS(NotebookTestCase) | |
55 | }; | |
56 | ||
57 | // register in the unnamed registry so that these tests are run by default | |
58 | CPPUNIT_TEST_SUITE_REGISTRATION( NotebookTestCase ); | |
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( NotebookTestCase, "NotebookTestCase" ); |
62 | ||
63 | void NotebookTestCase::setUp() | |
64 | { | |
65 | m_notebook = new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY, | |
66 | wxDefaultPosition, wxSize(400, 200)); | |
67 | AddPanels(); | |
68 | } | |
69 | ||
70 | void NotebookTestCase::tearDown() | |
71 | { | |
72 | wxDELETE(m_notebook); | |
73 | } | |
74 | ||
75 | void NotebookTestCase::RowCount() | |
76 | { | |
77 | CPPUNIT_ASSERT_EQUAL(1, m_notebook->GetRowCount()); | |
78 | ||
79 | #ifdef __WXMSW__ | |
80 | wxDELETE(m_notebook); | |
81 | m_notebook = new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY, | |
82 | wxDefaultPosition, wxSize(400, 200), | |
83 | wxNB_MULTILINE); | |
84 | ||
85 | for( unsigned int i = 0; i < 10; i++ ) | |
86 | { | |
87 | m_notebook->AddPage(new wxPanel(m_notebook), "Panel", false, 0); | |
88 | } | |
89 | ||
90 | CPPUNIT_ASSERT( m_notebook->GetRowCount() != 1 ); | |
91 | #endif | |
92 | } | |
93 | ||
94 | #endif //wxUSE_NOTEBOOK |