searchctrltest.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: tests/controls/searchctrltest.cpp
  3. // Purpose: wxSearchCtrl unit test
  4. // Author: Vadim Zeitlin
  5. // Created: 2013-01-20
  6. // Copyright: (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
  7. ///////////////////////////////////////////////////////////////////////////////
  8. #include "testprec.h"
  9. #if wxUSE_SEARCHCTRL
  10. #ifdef __BORLANDC__
  11. #pragma hdrstop
  12. #endif
  13. #ifndef WX_PRECOMP
  14. #include "wx/app.h"
  15. #endif // WX_PRECOMP
  16. #include "wx/srchctrl.h"
  17. class SearchCtrlTestCase : public CppUnit::TestCase
  18. {
  19. public:
  20. SearchCtrlTestCase() { }
  21. virtual void setUp();
  22. virtual void tearDown();
  23. private:
  24. CPPUNIT_TEST_SUITE( SearchCtrlTestCase );
  25. CPPUNIT_TEST( Focus );
  26. CPPUNIT_TEST_SUITE_END();
  27. void Focus();
  28. wxSearchCtrl* m_search;
  29. DECLARE_NO_COPY_CLASS(SearchCtrlTestCase)
  30. };
  31. // register in the unnamed registry so that these tests are run by default
  32. CPPUNIT_TEST_SUITE_REGISTRATION( SearchCtrlTestCase );
  33. // also include in its own registry so that these tests can be run alone
  34. CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SearchCtrlTestCase, "SearchCtrlTestCase" );
  35. void SearchCtrlTestCase::setUp()
  36. {
  37. m_search = new wxSearchCtrl(wxTheApp->GetTopWindow(), wxID_ANY);
  38. }
  39. void SearchCtrlTestCase::tearDown()
  40. {
  41. delete m_search;
  42. m_search = NULL;
  43. }
  44. void SearchCtrlTestCase::Focus()
  45. {
  46. // TODO OS X test only passes when run solo ...
  47. #ifndef __WXOSX__
  48. m_search->SetFocus();
  49. CPPUNIT_ASSERT( m_search->HasFocus() );
  50. #endif
  51. }
  52. #endif // wxUSE_SEARCHCTRL