]>
git.saurik.com Git - wxWidgets.git/blob - tests/controls/comboboxtest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/comboboxtest.cpp
3 // Purpose: wxComboBox unit test
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
22 #include "wx/combobox.h"
25 #include "textentrytest.h"
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 class ComboBoxTestCase
: public TextEntryTestCase
34 ComboBoxTestCase() { }
37 virtual void tearDown();
40 virtual wxTextEntry
*GetTestEntry() const { return m_combo
; }
41 virtual wxWindow
*GetTestWindow() const { return m_combo
; }
43 virtual void CheckStringSelection(const char * WXUNUSED(sel
))
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
50 CPPUNIT_TEST_SUITE( ComboBoxTestCase
);
54 CPPUNIT_TEST_SUITE_END();
60 DECLARE_NO_COPY_CLASS(ComboBoxTestCase
)
63 // register in the unnamed registry so that these tests are run by default
64 CPPUNIT_TEST_SUITE_REGISTRATION( ComboBoxTestCase
);
66 // also include in it's own registry so that these tests can be run alone
67 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ComboBoxTestCase
, "ComboBoxTestCase" );
69 // ----------------------------------------------------------------------------
70 // test initialization
71 // ----------------------------------------------------------------------------
73 void ComboBoxTestCase::setUp()
75 m_combo
= new wxComboBox(wxTheApp
->GetTopWindow(), wxID_ANY
);
78 void ComboBoxTestCase::tearDown()
84 // ----------------------------------------------------------------------------
86 // ----------------------------------------------------------------------------
88 void ComboBoxTestCase::Size()
90 // under MSW changing combobox size is a non-trivial operation because of
91 // confusion between the size of the control with and without dropdown, so
92 // check that it does work as expected
94 const int heightOrig
= m_combo
->GetSize().y
;
96 // check that the height doesn't change if we don't touch it
97 m_combo
->SetSize(100, -1);
98 CPPUNIT_ASSERT_EQUAL( heightOrig
, m_combo
->GetSize().y
);
100 // check that setting both big and small (but not too small, there is a
101 // limit on how small the control can become under MSW) heights works
102 m_combo
->SetSize(-1, 50);
103 CPPUNIT_ASSERT_EQUAL( 50, m_combo
->GetSize().y
);
105 m_combo
->SetSize(-1, 10);
106 CPPUNIT_ASSERT_EQUAL( 10, m_combo
->GetSize().y
);
108 // and also that restoring it works (this used to be broken before 2.9.1)
109 m_combo
->SetSize(-1, heightOrig
);
110 CPPUNIT_ASSERT_EQUAL( heightOrig
, m_combo
->GetSize().y
);