]>
Commit | Line | Data |
---|---|---|
232fdc63 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: tests/controls/listbooktest.cpp | |
3 | // Purpose: wxListbook 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_LISTBOOK | |
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/listbook.h" | |
23 | #include "wx/listctrl.h" | |
24 | #include "bookctrlbasetest.h" | |
25 | ||
26 | class ListbookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase | |
27 | { | |
28 | public: | |
29 | ListbookTestCase() { } | |
30 | ||
31 | virtual void setUp(); | |
32 | virtual void tearDown(); | |
33 | ||
34 | private: | |
35 | virtual wxBookCtrlBase *GetBase() const { return m_listbook; } | |
36 | ||
37 | virtual wxEventType GetChangedEvent() const | |
ce7fe42e | 38 | { return wxEVT_LISTBOOK_PAGE_CHANGED; } |
232fdc63 VZ |
39 | |
40 | virtual wxEventType GetChangingEvent() const | |
ce7fe42e | 41 | { return wxEVT_LISTBOOK_PAGE_CHANGING; } |
232fdc63 VZ |
42 | |
43 | CPPUNIT_TEST_SUITE( ListbookTestCase ); | |
44 | wxBOOK_CTRL_BASE_TESTS(); | |
45 | CPPUNIT_TEST( ListView ); | |
46 | CPPUNIT_TEST_SUITE_END(); | |
47 | ||
48 | void ListView(); | |
49 | ||
50 | wxListbook *m_listbook; | |
51 | ||
52 | DECLARE_NO_COPY_CLASS(ListbookTestCase) | |
53 | }; | |
54 | ||
55 | // register in the unnamed registry so that these tests are run by default | |
56 | CPPUNIT_TEST_SUITE_REGISTRATION( ListbookTestCase ); | |
57 | ||
e3778b4d | 58 | // also include in its own registry so that these tests can be run alone |
232fdc63 VZ |
59 | CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ListbookTestCase, "ListbookTestCase" ); |
60 | ||
61 | void ListbookTestCase::setUp() | |
62 | { | |
63 | m_listbook = new wxListbook(wxTheApp->GetTopWindow(), wxID_ANY, | |
64 | wxDefaultPosition, wxSize(400, 300)); | |
65 | AddPanels(); | |
66 | } | |
67 | ||
68 | void ListbookTestCase::tearDown() | |
69 | { | |
70 | wxDELETE(m_listbook); | |
71 | } | |
72 | ||
73 | void ListbookTestCase::ListView() | |
74 | { | |
75 | wxListView* listview = m_listbook->GetListView(); | |
76 | ||
77 | CPPUNIT_ASSERT(listview); | |
78 | CPPUNIT_ASSERT_EQUAL(3, listview->GetItemCount()); | |
79 | CPPUNIT_ASSERT_EQUAL("Panel 1", listview->GetItemText(0)); | |
80 | } | |
81 | ||
82 | #endif //wxUSE_LISTBOOK |