]> git.saurik.com Git - wxWidgets.git/blob - tests/controls/choicetest.cpp
Remove "release" suffix from wx-config links used in RPMs.
[wxWidgets.git] / tests / controls / choicetest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/choice.cpp
3 // Purpose: wxChoice unit test
4 // Author: Steven Lamerton
5 // Created: 2010-06-29
6 // RCS-ID: $Id$
7 // Copyright: (c) 2010 Steven Lamerton
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #include "testprec.h"
11
12 #if wxUSE_CHOICE
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #ifndef WX_PRECOMP
19 #include "wx/app.h"
20 #include "wx/choice.h"
21 #endif // WX_PRECOMP
22
23 #include "itemcontainertest.h"
24
25 class ChoiceTestCase : public ItemContainerTestCase, public CppUnit::TestCase
26 {
27 public:
28 ChoiceTestCase() { }
29
30 virtual void setUp();
31 virtual void tearDown();
32
33 private:
34 virtual wxItemContainer *GetContainer() const { return m_choice; }
35 virtual wxWindow *GetContainerWindow() const { return m_choice; }
36
37 CPPUNIT_TEST_SUITE( ChoiceTestCase );
38 wxITEM_CONTAINER_TESTS();
39 CPPUNIT_TEST( Sort );
40 CPPUNIT_TEST_SUITE_END();
41
42 void Sort();
43
44 wxChoice* m_choice;
45
46 DECLARE_NO_COPY_CLASS(ChoiceTestCase)
47 };
48
49 // register in the unnamed registry so that these tests are run by default
50 CPPUNIT_TEST_SUITE_REGISTRATION( ChoiceTestCase );
51
52 // also include in it's own registry so that these tests can be run alone
53 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ChoiceTestCase, "ChoiceTestCase" );
54
55 void ChoiceTestCase::setUp()
56 {
57 m_choice = new wxChoice(wxTheApp->GetTopWindow(), wxID_ANY);
58 }
59
60 void ChoiceTestCase::tearDown()
61 {
62 wxDELETE(m_choice);
63 }
64
65 void ChoiceTestCase::Sort()
66 {
67 #if !defined(__WXOSX__)
68 wxDELETE(m_choice);
69 m_choice = new wxChoice(wxTheApp->GetTopWindow(), wxID_ANY,
70 wxDefaultPosition, wxDefaultSize, 0, 0,
71 wxCB_SORT);
72
73 wxArrayString testitems;
74 testitems.Add("aaa");
75 testitems.Add("Aaa");
76 testitems.Add("aba");
77 testitems.Add("aaab");
78 testitems.Add("aab");
79 testitems.Add("AAA");
80
81 m_choice->Append(testitems);
82
83 CPPUNIT_ASSERT_EQUAL("AAA", m_choice->GetString(0));
84 CPPUNIT_ASSERT_EQUAL("Aaa", m_choice->GetString(1));
85 CPPUNIT_ASSERT_EQUAL("aaa", m_choice->GetString(2));
86 CPPUNIT_ASSERT_EQUAL("aaab", m_choice->GetString(3));
87 CPPUNIT_ASSERT_EQUAL("aab", m_choice->GetString(4));
88 CPPUNIT_ASSERT_EQUAL("aba", m_choice->GetString(5));
89
90 m_choice->Append("a");
91
92 CPPUNIT_ASSERT_EQUAL("a", m_choice->GetString(0));
93 #endif
94 }
95
96 #endif //wxUSE_CHOICE