notebooktest.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. #include "testprec.h"
  9. #if wxUSE_NOTEBOOK
  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/notebook.h"
  18. #include "bookctrlbasetest.h"
  19. class NotebookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase
  20. {
  21. public:
  22. NotebookTestCase() { }
  23. virtual void setUp();
  24. virtual void tearDown();
  25. private:
  26. virtual wxBookCtrlBase *GetBase() const { return m_notebook; }
  27. virtual wxEventType GetChangedEvent() const
  28. { return wxEVT_NOTEBOOK_PAGE_CHANGED; }
  29. virtual wxEventType GetChangingEvent() const
  30. { return wxEVT_NOTEBOOK_PAGE_CHANGING; }
  31. CPPUNIT_TEST_SUITE( NotebookTestCase );
  32. wxBOOK_CTRL_BASE_TESTS();
  33. CPPUNIT_TEST( Image );
  34. CPPUNIT_TEST( RowCount );
  35. CPPUNIT_TEST_SUITE_END();
  36. void RowCount();
  37. wxNotebook *m_notebook;
  38. DECLARE_NO_COPY_CLASS(NotebookTestCase)
  39. };
  40. // register in the unnamed registry so that these tests are run by default
  41. CPPUNIT_TEST_SUITE_REGISTRATION( NotebookTestCase );
  42. // also include in its own registry so that these tests can be run alone
  43. CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( NotebookTestCase, "NotebookTestCase" );
  44. void NotebookTestCase::setUp()
  45. {
  46. m_notebook = new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY,
  47. wxDefaultPosition, wxSize(400, 200));
  48. AddPanels();
  49. }
  50. void NotebookTestCase::tearDown()
  51. {
  52. wxDELETE(m_notebook);
  53. }
  54. void NotebookTestCase::RowCount()
  55. {
  56. CPPUNIT_ASSERT_EQUAL(1, m_notebook->GetRowCount());
  57. #ifdef __WXMSW__
  58. wxDELETE(m_notebook);
  59. m_notebook = new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY,
  60. wxDefaultPosition, wxSize(400, 200),
  61. wxNB_MULTILINE);
  62. for( unsigned int i = 0; i < 10; i++ )
  63. {
  64. m_notebook->AddPage(new wxPanel(m_notebook), "Panel", false, 0);
  65. }
  66. CPPUNIT_ASSERT( m_notebook->GetRowCount() != 1 );
  67. #endif
  68. }
  69. #endif //wxUSE_NOTEBOOK