choicebooktest.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: tests/controls/choicebooktest.cpp
  3. // Purpose: wxChoicebook 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_CHOICEBOOK
  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/choicebk.h"
  18. #include "bookctrlbasetest.h"
  19. class ChoicebookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase
  20. {
  21. public:
  22. ChoicebookTestCase() { }
  23. virtual void setUp();
  24. virtual void tearDown();
  25. private:
  26. virtual wxBookCtrlBase *GetBase() const { return m_choicebook; }
  27. virtual wxEventType GetChangedEvent() const
  28. { return wxEVT_CHOICEBOOK_PAGE_CHANGED; }
  29. virtual wxEventType GetChangingEvent() const
  30. { return wxEVT_CHOICEBOOK_PAGE_CHANGING; }
  31. CPPUNIT_TEST_SUITE( ChoicebookTestCase );
  32. wxBOOK_CTRL_BASE_TESTS();
  33. CPPUNIT_TEST( Choice );
  34. CPPUNIT_TEST_SUITE_END();
  35. void Choice();
  36. wxChoicebook *m_choicebook;
  37. DECLARE_NO_COPY_CLASS(ChoicebookTestCase)
  38. };
  39. // register in the unnamed registry so that these tests are run by default
  40. CPPUNIT_TEST_SUITE_REGISTRATION( ChoicebookTestCase );
  41. // also include in its own registry so that these tests can be run alone
  42. CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ChoicebookTestCase, "ChoicebookTestCase" );
  43. void ChoicebookTestCase::setUp()
  44. {
  45. m_choicebook = new wxChoicebook(wxTheApp->GetTopWindow(), wxID_ANY);
  46. AddPanels();
  47. }
  48. void ChoicebookTestCase::tearDown()
  49. {
  50. wxDELETE(m_choicebook);
  51. }
  52. void ChoicebookTestCase::Choice()
  53. {
  54. wxChoice* choice = m_choicebook->GetChoiceCtrl();
  55. CPPUNIT_ASSERT(choice);
  56. CPPUNIT_ASSERT_EQUAL(3, choice->GetCount());
  57. CPPUNIT_ASSERT_EQUAL("Panel 1", choice->GetString(0));
  58. }
  59. #endif //wxUSE_CHOICEBOOK