]>
git.saurik.com Git - wxWidgets.git/blob - tests/controls/choicetest.cpp
dd82ff123daac11242d7308a67979d5677035e66
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/choice.cpp
3 // Purpose: wxChoice unit test
4 // Author: Steven Lamerton
7 // Copyright: (c) 2010 Steven Lamerton
8 ///////////////////////////////////////////////////////////////////////////////
20 #include "wx/choice.h"
23 #include "itemcontainertest.h"
25 class ChoiceTestCase
: public ItemContainerTestCase
, public CppUnit::TestCase
31 virtual void tearDown();
34 virtual wxItemContainer
*GetContainer() const { return m_choice
; }
35 virtual wxWindow
*GetContainerWindow() const { return m_choice
; }
37 CPPUNIT_TEST_SUITE( ChoiceTestCase
);
38 wxITEM_CONTAINER_TESTS();
40 CPPUNIT_TEST_SUITE_END();
46 DECLARE_NO_COPY_CLASS(ChoiceTestCase
)
49 // register in the unnamed registry so that these tests are run by default
50 CPPUNIT_TEST_SUITE_REGISTRATION( ChoiceTestCase
);
52 // also include in its own registry so that these tests can be run alone
53 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ChoiceTestCase
, "ChoiceTestCase" );
55 void ChoiceTestCase::setUp()
57 m_choice
= new wxChoice(wxTheApp
->GetTopWindow(), wxID_ANY
);
60 void ChoiceTestCase::tearDown()
65 void ChoiceTestCase::Sort()
67 #if !defined(__WXOSX__)
69 m_choice
= new wxChoice(wxTheApp
->GetTopWindow(), wxID_ANY
,
70 wxDefaultPosition
, wxDefaultSize
, 0, 0,
73 wxArrayString testitems
;
77 testitems
.Add("aaab");
81 m_choice
->Append(testitems
);
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));
90 m_choice
->Append("a");
92 CPPUNIT_ASSERT_EQUAL("a", m_choice
->GetString(0));