frametest.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: tests/controls/frametest.cpp
  3. // Purpose: wxFrame unit test
  4. // Author: Steven Lamerton
  5. // Created: 2010-07-10
  6. // Copyright: (c) 2010 Steven Lamerton
  7. ///////////////////////////////////////////////////////////////////////////////
  8. #include "testprec.h"
  9. #ifdef __BORLANDC__
  10. #pragma hdrstop
  11. #endif
  12. #ifndef WX_PRECOMP
  13. #include "wx/app.h"
  14. #include "wx/frame.h"
  15. #endif // WX_PRECOMP
  16. #include "testableframe.h"
  17. class FrameTestCase : public CppUnit::TestCase
  18. {
  19. public:
  20. FrameTestCase() { }
  21. void setUp();
  22. void tearDown();
  23. private:
  24. CPPUNIT_TEST_SUITE( FrameTestCase );
  25. CPPUNIT_TEST( Iconize );
  26. CPPUNIT_TEST( Close );
  27. CPPUNIT_TEST_SUITE_END();
  28. void Iconize();
  29. void Close();
  30. wxFrame *m_frame;
  31. DECLARE_NO_COPY_CLASS(FrameTestCase)
  32. };
  33. // register in the unnamed registry so that these tests are run by default
  34. CPPUNIT_TEST_SUITE_REGISTRATION( FrameTestCase );
  35. // also include in its own registry so that these tests can be run alone
  36. CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FrameTestCase, "FrameTestCase" );
  37. void FrameTestCase::setUp()
  38. {
  39. m_frame = new wxFrame(NULL, wxID_ANY, "test frame");
  40. m_frame->Show();
  41. }
  42. void FrameTestCase::tearDown()
  43. {
  44. m_frame->Destroy();
  45. }
  46. void FrameTestCase::Iconize()
  47. {
  48. #ifdef __WXMSW__
  49. EventCounter iconize(m_frame, wxEVT_ICONIZE);
  50. m_frame->Iconize();
  51. m_frame->Iconize(false);
  52. CPPUNIT_ASSERT_EQUAL(2, iconize.GetCount());
  53. #endif
  54. }
  55. void FrameTestCase::Close()
  56. {
  57. EventCounter close(m_frame, wxEVT_CLOSE_WINDOW);
  58. m_frame->Close();
  59. CPPUNIT_ASSERT_EQUAL(1, close.GetCount());
  60. }