listbooktest.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: tests/controls/listbooktest.cpp
  3. // Purpose: wxListbook unit test
  4. // Author: Steven Lamerton
  5. // Created: 2010-07-02
  6. // Copyright: (c) 2010 Steven Lamerton
  7. ///////////////////////////////////////////////////////////////////////////////
  8. #include "testprec.h"
  9. #if wxUSE_LISTBOOK
  10. #ifdef __BORLANDC__
  11. #pragma hdrstop
  12. #endif
  13. #ifndef WX_PRECOMP
  14. #include "wx/app.h"
  15. #include "wx/panel.h"
  16. #endif // WX_PRECOMP
  17. #include "wx/listbook.h"
  18. #include "wx/listctrl.h"
  19. #include "bookctrlbasetest.h"
  20. class ListbookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase
  21. {
  22. public:
  23. ListbookTestCase() { }
  24. virtual void setUp();
  25. virtual void tearDown();
  26. private:
  27. virtual wxBookCtrlBase *GetBase() const { return m_listbook; }
  28. virtual wxEventType GetChangedEvent() const
  29. { return wxEVT_LISTBOOK_PAGE_CHANGED; }
  30. virtual wxEventType GetChangingEvent() const
  31. { return wxEVT_LISTBOOK_PAGE_CHANGING; }
  32. CPPUNIT_TEST_SUITE( ListbookTestCase );
  33. wxBOOK_CTRL_BASE_TESTS();
  34. CPPUNIT_TEST( ListView );
  35. CPPUNIT_TEST_SUITE_END();
  36. void ListView();
  37. wxListbook *m_listbook;
  38. DECLARE_NO_COPY_CLASS(ListbookTestCase)
  39. };
  40. // register in the unnamed registry so that these tests are run by default
  41. CPPUNIT_TEST_SUITE_REGISTRATION( ListbookTestCase );
  42. // also include in its own registry so that these tests can be run alone
  43. CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ListbookTestCase, "ListbookTestCase" );
  44. void ListbookTestCase::setUp()
  45. {
  46. m_listbook = new wxListbook(wxTheApp->GetTopWindow(), wxID_ANY,
  47. wxDefaultPosition, wxSize(400, 300));
  48. AddPanels();
  49. }
  50. void ListbookTestCase::tearDown()
  51. {
  52. wxDELETE(m_listbook);
  53. }
  54. void ListbookTestCase::ListView()
  55. {
  56. wxListView* listview = m_listbook->GetListView();
  57. CPPUNIT_ASSERT(listview);
  58. CPPUNIT_ASSERT_EQUAL(3, listview->GetItemCount());
  59. CPPUNIT_ASSERT_EQUAL("Panel 1", listview->GetItemText(0));
  60. }
  61. #endif //wxUSE_LISTBOOK