]>
git.saurik.com Git - wxWidgets.git/blob - tests/controls/virtlistctrltest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/virtlistctrltest.cpp
3 // Purpose: wxListCtrl unit tests for virtual mode
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2010 Vadim Zeitlin <vadim@wxwidgets.org>
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
26 #include "wx/listctrl.h"
28 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 class VirtListCtrlTestCase
: public CppUnit::TestCase
35 VirtListCtrlTestCase() { }
38 virtual void tearDown();
41 CPPUNIT_TEST_SUITE( VirtListCtrlTestCase
);
42 CPPUNIT_TEST( UpdateSelection
);
43 CPPUNIT_TEST_SUITE_END();
45 void UpdateSelection();
49 wxDECLARE_NO_COPY_CLASS(VirtListCtrlTestCase
);
52 // register in the unnamed registry so that these tests are run by default
53 CPPUNIT_TEST_SUITE_REGISTRATION( VirtListCtrlTestCase
);
55 // also include in it's own registry so that these tests can be run alone
56 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( VirtListCtrlTestCase
, "VirtListCtrlTestCase" );
58 // ----------------------------------------------------------------------------
59 // test initialization
60 // ----------------------------------------------------------------------------
62 void VirtListCtrlTestCase::setUp()
64 m_list
= new wxListCtrl(wxTheApp
->GetTopWindow(), wxID_ANY
,
65 wxPoint(0, 0), wxSize(400, 200),
66 wxLC_REPORT
| wxLC_VIRTUAL
);
69 void VirtListCtrlTestCase::tearDown()
75 void VirtListCtrlTestCase::UpdateSelection()
77 m_list
->SetItemCount(10);
78 CPPUNIT_ASSERT_EQUAL( 0, m_list
->GetSelectedItemCount() );
80 m_list
->SetItemState(7, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
81 CPPUNIT_ASSERT_EQUAL( 1, m_list
->GetSelectedItemCount() );
83 m_list
->SetItemState(0, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
84 CPPUNIT_ASSERT_EQUAL( 2, m_list
->GetSelectedItemCount() );
86 // The item 7 is now invalid and so shouldn't be counted as selected any
88 m_list
->SetItemCount(5);
89 CPPUNIT_ASSERT_EQUAL( 1, m_list
->GetSelectedItemCount() );
92 #endif // wxUSE_LISTCTRL