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