]>
git.saurik.com Git - wxWidgets.git/blob - tests/controls/checklistboxtest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/checklistlistbox.cpp
3 // Purpose: wxCheckListBox unit test
4 // Author: Steven Lamerton
6 // Copyright: (c) 2010 Steven Lamerton
7 ///////////////////////////////////////////////////////////////////////////////
11 #if wxUSE_CHECKLISTBOX
19 #include "wx/checklst.h"
22 #include "itemcontainertest.h"
23 #include "testableframe.h"
25 class CheckListBoxTestCase
: public ItemContainerTestCase
, public CppUnit::TestCase
28 CheckListBoxTestCase() { }
31 virtual void tearDown();
34 virtual wxItemContainer
*GetContainer() const { return m_check
; }
35 virtual wxWindow
*GetContainerWindow() const { return m_check
; }
37 CPPUNIT_TEST_SUITE( CheckListBoxTestCase
);
38 wxITEM_CONTAINER_TESTS();
39 CPPUNIT_TEST( Check
);
40 CPPUNIT_TEST_SUITE_END();
44 wxCheckListBox
* m_check
;
46 DECLARE_NO_COPY_CLASS(CheckListBoxTestCase
)
49 // register in the unnamed registry so that these tests are run by default
50 CPPUNIT_TEST_SUITE_REGISTRATION( CheckListBoxTestCase
);
52 // also include in its own registry so that these tests can be run alone
53 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( CheckListBoxTestCase
, "CheckListBoxTestCase" );
55 void CheckListBoxTestCase::setUp()
57 m_check
= new wxCheckListBox(wxTheApp
->GetTopWindow(), wxID_ANY
);
60 void CheckListBoxTestCase::tearDown()
65 void CheckListBoxTestCase::Check()
67 EventCounter
toggled(m_check
, wxEVT_CHECKLISTBOX
);
69 wxArrayInt checkedItems
;
70 wxArrayString testitems
;
71 testitems
.Add("item 0");
72 testitems
.Add("item 1");
73 testitems
.Add("item 2");
74 testitems
.Add("item 3");
76 m_check
->Append(testitems
);
80 m_check
->Check(1, false);
82 //We should not get any events when changing this from code
83 CPPUNIT_ASSERT_EQUAL(0, toggled
.GetCount());
84 CPPUNIT_ASSERT_EQUAL(true, m_check
->IsChecked(0));
85 CPPUNIT_ASSERT_EQUAL(false, m_check
->IsChecked(1));
87 CPPUNIT_ASSERT_EQUAL(1, m_check
->GetCheckedItems(checkedItems
));
88 CPPUNIT_ASSERT_EQUAL(0, checkedItems
[0]);
90 //Make sure a double check of an items doesn't deselect it
93 CPPUNIT_ASSERT_EQUAL(true, m_check
->IsChecked(0));
96 #endif // wxUSE_CHECKLISTBOX