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