]>
git.saurik.com Git - wxWidgets.git/blob - tests/controls/choicetest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/choice.cpp
3 // Purpose: wxChoice unit test
4 // Author: Steven Lamerton
6 // Copyright: (c) 2010 Steven Lamerton
7 ///////////////////////////////////////////////////////////////////////////////
19 #include "wx/choice.h"
22 #include "itemcontainertest.h"
24 class ChoiceTestCase
: public ItemContainerTestCase
, public CppUnit::TestCase
30 virtual void tearDown();
33 virtual wxItemContainer
*GetContainer() const { return m_choice
; }
34 virtual wxWindow
*GetContainerWindow() const { return m_choice
; }
36 CPPUNIT_TEST_SUITE( ChoiceTestCase
);
37 wxITEM_CONTAINER_TESTS();
39 CPPUNIT_TEST_SUITE_END();
45 DECLARE_NO_COPY_CLASS(ChoiceTestCase
)
48 // register in the unnamed registry so that these tests are run by default
49 CPPUNIT_TEST_SUITE_REGISTRATION( ChoiceTestCase
);
51 // also include in its own registry so that these tests can be run alone
52 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ChoiceTestCase
, "ChoiceTestCase" );
54 void ChoiceTestCase::setUp()
56 m_choice
= new wxChoice(wxTheApp
->GetTopWindow(), wxID_ANY
);
59 void ChoiceTestCase::tearDown()
64 void ChoiceTestCase::Sort()
66 #if !defined(__WXOSX__)
68 m_choice
= new wxChoice(wxTheApp
->GetTopWindow(), wxID_ANY
,
69 wxDefaultPosition
, wxDefaultSize
, 0, 0,
72 wxArrayString testitems
;
76 testitems
.Add("aaab");
80 m_choice
->Append(testitems
);
82 CPPUNIT_ASSERT_EQUAL("AAA", m_choice
->GetString(0));
83 CPPUNIT_ASSERT_EQUAL("Aaa", m_choice
->GetString(1));
84 CPPUNIT_ASSERT_EQUAL("aaa", m_choice
->GetString(2));
85 CPPUNIT_ASSERT_EQUAL("aaab", m_choice
->GetString(3));
86 CPPUNIT_ASSERT_EQUAL("aab", m_choice
->GetString(4));
87 CPPUNIT_ASSERT_EQUAL("aba", m_choice
->GetString(5));
89 m_choice
->Append("a");
91 CPPUNIT_ASSERT_EQUAL("a", m_choice
->GetString(0));