]> git.saurik.com Git - wxWidgets.git/blame - tests/controls/choicetest.cpp
Not not pass debug messages on from wxLogWindow.
[wxWidgets.git] / tests / controls / choicetest.cpp
CommitLineData
232fdc63
VZ
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
25class ChoiceTestCase : public ItemContainerTestCase, public CppUnit::TestCase
26{
27public:
28 ChoiceTestCase() { }
29
30 virtual void setUp();
31 virtual void tearDown();
32
33private:
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
50CPPUNIT_TEST_SUITE_REGISTRATION( ChoiceTestCase );
51
e3778b4d 52// also include in its own registry so that these tests can be run alone
232fdc63
VZ
53CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ChoiceTestCase, "ChoiceTestCase" );
54
55void ChoiceTestCase::setUp()
56{
57 m_choice = new wxChoice(wxTheApp->GetTopWindow(), wxID_ANY);
58}
59
60void ChoiceTestCase::tearDown()
61{
62 wxDELETE(m_choice);
63}
64
65void ChoiceTestCase::Sort()
66{
a6856aa8 67#if !defined(__WXOSX__)
232fdc63
VZ
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