toolbooktest.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: tests/controls/toolbooktest.cpp
  3. // Purpose: wxToolbook 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_TOOLBOOK
  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/toolbook.h"
  18. #include "wx/toolbar.h"
  19. #include "bookctrlbasetest.h"
  20. class ToolbookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase
  21. {
  22. public:
  23. ToolbookTestCase() { }
  24. virtual void setUp();
  25. virtual void tearDown();
  26. private:
  27. virtual wxBookCtrlBase *GetBase() const { return m_toolbook; }
  28. virtual wxEventType GetChangedEvent() const
  29. { return wxEVT_TOOLBOOK_PAGE_CHANGED; }
  30. virtual wxEventType GetChangingEvent() const
  31. { return wxEVT_TOOLBOOK_PAGE_CHANGING; }
  32. virtual void Realize() { m_toolbook->GetToolBar()->Realize(); }
  33. CPPUNIT_TEST_SUITE( ToolbookTestCase );
  34. wxBOOK_CTRL_BASE_TESTS();
  35. CPPUNIT_TEST( ToolBar );
  36. CPPUNIT_TEST_SUITE_END();
  37. void ToolBar();
  38. wxToolbook *m_toolbook;
  39. DECLARE_NO_COPY_CLASS(ToolbookTestCase)
  40. };
  41. // register in the unnamed registry so that these tests are run by default
  42. CPPUNIT_TEST_SUITE_REGISTRATION( ToolbookTestCase );
  43. // also include in its own registry so that these tests can be run alone
  44. CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ToolbookTestCase, "ToolbookTestCase" );
  45. void ToolbookTestCase::setUp()
  46. {
  47. m_toolbook = new wxToolbook(wxTheApp->GetTopWindow(), wxID_ANY, wxDefaultPosition, wxSize(400, 200));
  48. AddPanels();
  49. }
  50. void ToolbookTestCase::tearDown()
  51. {
  52. wxDELETE(m_toolbook);
  53. }
  54. void ToolbookTestCase::ToolBar()
  55. {
  56. wxToolBar* toolbar = static_cast<wxToolBar*>(m_toolbook->GetToolBar());
  57. CPPUNIT_ASSERT(toolbar);
  58. CPPUNIT_ASSERT_EQUAL(3, toolbar->GetToolsCount());
  59. }
  60. #endif //wxUSE_TOOLBOOK