Add a unit test checking selection updating in virtual wxListCtrl.
Verify that the selection is updated correctly after the number of items in the control is decreased. See #12378. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66141 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -192,6 +192,7 @@ TEST_GUI_OBJECTS = \
|
||||
test_gui_toolbooktest.o \
|
||||
test_gui_treebooktest.o \
|
||||
test_gui_treectrltest.o \
|
||||
test_gui_virtlistctrltest.o \
|
||||
test_gui_windowtest.o \
|
||||
test_gui_clone.o \
|
||||
test_gui_propagation.o \
|
||||
@@ -797,6 +798,9 @@ test_gui_treebooktest.o: $(srcdir)/controls/treebooktest.cpp $(TEST_GUI_ODEP)
|
||||
test_gui_treectrltest.o: $(srcdir)/controls/treectrltest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/treectrltest.cpp
|
||||
|
||||
test_gui_virtlistctrltest.o: $(srcdir)/controls/virtlistctrltest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/virtlistctrltest.cpp
|
||||
|
||||
test_gui_windowtest.o: $(srcdir)/controls/windowtest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/windowtest.cpp
|
||||
|
||||
|
92
tests/controls/virtlistctrltest.cpp
Normal file
92
tests/controls/virtlistctrltest.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/virtlistctrltest.cpp
|
||||
// Purpose: wxListCtrl unit tests for virtual mode
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2010-11-13
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2010 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_LISTCTRL
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/listctrl.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class VirtListCtrlTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
VirtListCtrlTestCase() { }
|
||||
|
||||
virtual void setUp();
|
||||
virtual void tearDown();
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( VirtListCtrlTestCase );
|
||||
CPPUNIT_TEST( UpdateSelection );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void UpdateSelection();
|
||||
|
||||
wxListCtrl *m_list;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(VirtListCtrlTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( VirtListCtrlTestCase );
|
||||
|
||||
// also include in it's own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( VirtListCtrlTestCase, "VirtListCtrlTestCase" );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test initialization
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void VirtListCtrlTestCase::setUp()
|
||||
{
|
||||
m_list = new wxListCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxPoint(0, 0), wxSize(400, 200),
|
||||
wxLC_REPORT | wxLC_VIRTUAL);
|
||||
}
|
||||
|
||||
void VirtListCtrlTestCase::tearDown()
|
||||
{
|
||||
delete m_list;
|
||||
m_list = NULL;
|
||||
}
|
||||
|
||||
void VirtListCtrlTestCase::UpdateSelection()
|
||||
{
|
||||
m_list->SetItemCount(10);
|
||||
CPPUNIT_ASSERT_EQUAL( 0, m_list->GetSelectedItemCount() );
|
||||
|
||||
m_list->SetItemState(7, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
|
||||
CPPUNIT_ASSERT_EQUAL( 1, m_list->GetSelectedItemCount() );
|
||||
|
||||
m_list->SetItemState(0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
|
||||
CPPUNIT_ASSERT_EQUAL( 2, m_list->GetSelectedItemCount() );
|
||||
|
||||
// The item 7 is now invalid and so shouldn't be counted as selected any
|
||||
// more.
|
||||
m_list->SetItemCount(5);
|
||||
CPPUNIT_ASSERT_EQUAL( 1, m_list->GetSelectedItemCount() );
|
||||
}
|
||||
|
||||
#endif // wxUSE_LISTCTRL
|
@@ -177,6 +177,7 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_toolbooktest.obj \
|
||||
$(OBJS)\test_gui_treebooktest.obj \
|
||||
$(OBJS)\test_gui_treectrltest.obj \
|
||||
$(OBJS)\test_gui_virtlistctrltest.obj \
|
||||
$(OBJS)\test_gui_windowtest.obj \
|
||||
$(OBJS)\test_gui_clone.obj \
|
||||
$(OBJS)\test_gui_propagation.obj \
|
||||
@@ -843,6 +844,9 @@ $(OBJS)\test_gui_treebooktest.obj: .\controls\treebooktest.cpp
|
||||
$(OBJS)\test_gui_treectrltest.obj: .\controls\treectrltest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\treectrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_virtlistctrltest.obj: .\controls\virtlistctrltest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\virtlistctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_windowtest.obj: .\controls\windowtest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\windowtest.cpp
|
||||
|
||||
|
@@ -170,6 +170,7 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_toolbooktest.o \
|
||||
$(OBJS)\test_gui_treebooktest.o \
|
||||
$(OBJS)\test_gui_treectrltest.o \
|
||||
$(OBJS)\test_gui_virtlistctrltest.o \
|
||||
$(OBJS)\test_gui_windowtest.o \
|
||||
$(OBJS)\test_gui_clone.o \
|
||||
$(OBJS)\test_gui_propagation.o \
|
||||
@@ -824,6 +825,9 @@ $(OBJS)\test_gui_treebooktest.o: ./controls/treebooktest.cpp
|
||||
$(OBJS)\test_gui_treectrltest.o: ./controls/treectrltest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_virtlistctrltest.o: ./controls/virtlistctrltest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_windowtest.o: ./controls/windowtest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
|
@@ -172,6 +172,7 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_toolbooktest.obj \
|
||||
$(OBJS)\test_gui_treebooktest.obj \
|
||||
$(OBJS)\test_gui_treectrltest.obj \
|
||||
$(OBJS)\test_gui_virtlistctrltest.obj \
|
||||
$(OBJS)\test_gui_windowtest.obj \
|
||||
$(OBJS)\test_gui_clone.obj \
|
||||
$(OBJS)\test_gui_propagation.obj \
|
||||
@@ -969,6 +970,9 @@ $(OBJS)\test_gui_treebooktest.obj: .\controls\treebooktest.cpp
|
||||
$(OBJS)\test_gui_treectrltest.obj: .\controls\treectrltest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\treectrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_virtlistctrltest.obj: .\controls\virtlistctrltest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\virtlistctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_windowtest.obj: .\controls\windowtest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\windowtest.cpp
|
||||
|
||||
|
@@ -412,6 +412,7 @@ TEST_GUI_OBJECTS = &
|
||||
$(OBJS)\test_gui_toolbooktest.obj &
|
||||
$(OBJS)\test_gui_treebooktest.obj &
|
||||
$(OBJS)\test_gui_treectrltest.obj &
|
||||
$(OBJS)\test_gui_virtlistctrltest.obj &
|
||||
$(OBJS)\test_gui_windowtest.obj &
|
||||
$(OBJS)\test_gui_clone.obj &
|
||||
$(OBJS)\test_gui_propagation.obj &
|
||||
@@ -882,6 +883,9 @@ $(OBJS)\test_gui_treebooktest.obj : .AUTODEPEND .\controls\treebooktest.cpp
|
||||
$(OBJS)\test_gui_treectrltest.obj : .AUTODEPEND .\controls\treectrltest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_virtlistctrltest.obj : .AUTODEPEND .\controls\virtlistctrltest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_windowtest.obj : .AUTODEPEND .\controls\windowtest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
|
@@ -173,6 +173,7 @@
|
||||
controls/toolbooktest.cpp
|
||||
controls/treebooktest.cpp
|
||||
controls/treectrltest.cpp
|
||||
controls/virtlistctrltest.cpp
|
||||
controls/windowtest.cpp
|
||||
events/clone.cpp
|
||||
events/propagation.cpp
|
||||
|
@@ -501,6 +501,10 @@ SOURCE=.\controls\treectrltest.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\controls\virtlistctrltest.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\controls\windowtest.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@@ -808,6 +808,9 @@
|
||||
<File
|
||||
RelativePath=".\controls\treectrltest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\virtlistctrltest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\windowtest.cpp">
|
||||
</File>
|
||||
|
@@ -1151,6 +1151,10 @@
|
||||
RelativePath=".\controls\treectrltest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\virtlistctrltest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\windowtest.cpp"
|
||||
>
|
||||
|
@@ -1123,6 +1123,10 @@
|
||||
RelativePath=".\controls\treectrltest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\virtlistctrltest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\windowtest.cpp"
|
||||
>
|
||||
|
Reference in New Issue
Block a user