1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/checklistlistbox.cpp
3 // Purpose: wxCheckListBox unit test
4 // Author: Steven Lamerton
7 // Copyright: (c) 2010 Steven Lamerton
8 ///////////////////////////////////////////////////////////////////////////////
12 #if wxUSE_CHECKLISTBOX
20 #include "wx/checklst.h"
23 #include "itemcontainertest.h"
24 #include "testableframe.h"
26 class CheckListBoxTestCase
: public ItemContainerTestCase
, public CppUnit::TestCase
29 CheckListBoxTestCase() { }
32 virtual void tearDown();
35 virtual wxItemContainer
*GetContainer() const { return m_check
; }
36 virtual wxWindow
*GetContainerWindow() const { return m_check
; }
38 CPPUNIT_TEST_SUITE( CheckListBoxTestCase
);
39 wxITEM_CONTAINER_TESTS();
40 CPPUNIT_TEST( Check
);
41 CPPUNIT_TEST_SUITE_END();
45 wxCheckListBox
* m_check
;
47 DECLARE_NO_COPY_CLASS(CheckListBoxTestCase
)
50 // register in the unnamed registry so that these tests are run by default
51 CPPUNIT_TEST_SUITE_REGISTRATION( CheckListBoxTestCase
);
53 // also include in its own registry so that these tests can be run alone
54 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( CheckListBoxTestCase
, "CheckListBoxTestCase" );
56 void CheckListBoxTestCase::setUp()
58 m_check
= new wxCheckListBox(wxTheApp
->GetTopWindow(), wxID_ANY
);
61 void CheckListBoxTestCase::tearDown()
66 void CheckListBoxTestCase::Check()
68 EventCounter
toggled(m_check
, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
);
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 //Make sure a double check of an items doesn't deselect it
90 CPPUNIT_ASSERT_EQUAL(true, m_check
->IsChecked(0));
93 #endif // wxUSE_CHECKLISTBOX