add unit test for wxTextEntry methods of wxComboBox
[wxWidgets.git] / tests / controls / comboboxtest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/comboboxtest.cpp
3 // Purpose: wxComboBox unit test
4 // Author: Vadim Zeitlin
5 // Created: 2007-09-25
6 // RCS-ID: $Id$
7 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
8 ///////////////////////////////////////////////////////////////////////////////
9
10 // ----------------------------------------------------------------------------
11 // headers
12 // ----------------------------------------------------------------------------
13
14 #include "testprec.h"
15
16 #ifdef __BORLANDC__
17 #pragma hdrstop
18 #endif
19
20 #ifndef WX_PRECOMP
21 #include "wx/app.h"
22 #include "wx/combobox.h"
23 #endif // WX_PRECOMP
24
25 #include "textentrytest.h"
26
27 // ----------------------------------------------------------------------------
28 // test class
29 // ----------------------------------------------------------------------------
30
31 class ComboBoxTestCase : public TextEntryTestCase
32 {
33 public:
34 ComboBoxTestCase() { }
35
36 virtual void setUp();
37 virtual void tearDown();
38
39 private:
40 virtual wxTextEntry *GetTestEntry() const { return m_combo; }
41 virtual wxWindow *GetTestWindow() const { return m_combo; }
42
43 virtual void CheckStringSelection(const char * WXUNUSED(sel))
44 {
45 // do nothing here, as explained in TextEntryTestCase comment, our
46 // GetStringSelection() is the wxChoice, not wxTextEntry, one and there
47 // is no way to return the selection contents directly
48 }
49
50 CPPUNIT_TEST_SUITE( ComboBoxTestCase );
51 wxTEXT_ENTRY_TESTS();
52 CPPUNIT_TEST_SUITE_END();
53
54 wxComboBox *m_combo;
55
56 DECLARE_NO_COPY_CLASS(ComboBoxTestCase)
57 };
58
59 // register in the unnamed registry so that these tests are run by default
60 CPPUNIT_TEST_SUITE_REGISTRATION( ComboBoxTestCase );
61
62 // also include in it's own registry so that these tests can be run alone
63 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ComboBoxTestCase, "ComboBoxTestCase" );
64
65 // ----------------------------------------------------------------------------
66 // test initialization
67 // ----------------------------------------------------------------------------
68
69 void ComboBoxTestCase::setUp()
70 {
71 m_combo = new wxComboBox(wxTheApp->GetTopWindow(), wxID_ANY);
72 }
73
74 void ComboBoxTestCase::tearDown()
75 {
76 delete m_combo;
77 m_combo = NULL;
78 }
79
80 // ----------------------------------------------------------------------------
81 // tests themselves
82 // ----------------------------------------------------------------------------
83