Add some basic tests for wxDataViewCtrl selection handling.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68623 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
57ab45460d
commit
cbef7338c1
@ -46,7 +46,7 @@ wx_top_builddir = @wx_top_builddir@
|
||||
|
||||
DESTDIR =
|
||||
WX_RELEASE = 2.9
|
||||
WX_VERSION = $(WX_RELEASE).2
|
||||
WX_VERSION = $(WX_RELEASE).3
|
||||
LIBDIRNAME = $(wx_top_builddir)/lib
|
||||
TEST_CXXFLAGS = $(__test_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
|
||||
$(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
|
||||
@ -166,6 +166,7 @@ TEST_GUI_OBJECTS = \
|
||||
test_gui_choicebooktest.o \
|
||||
test_gui_choicetest.o \
|
||||
test_gui_comboboxtest.o \
|
||||
test_gui_dataviewctrltest.o \
|
||||
test_gui_datepickerctrltest.o \
|
||||
test_gui_frametest.o \
|
||||
test_gui_gaugetest.o \
|
||||
@ -732,6 +733,9 @@ test_gui_choicetest.o: $(srcdir)/controls/choicetest.cpp $(TEST_GUI_ODEP)
|
||||
test_gui_comboboxtest.o: $(srcdir)/controls/comboboxtest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/comboboxtest.cpp
|
||||
|
||||
test_gui_dataviewctrltest.o: $(srcdir)/controls/dataviewctrltest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/dataviewctrltest.cpp
|
||||
|
||||
test_gui_datepickerctrltest.o: $(srcdir)/controls/datepickerctrltest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/datepickerctrltest.cpp
|
||||
|
||||
|
140
tests/controls/dataviewctrltest.cpp
Normal file
140
tests/controls/dataviewctrltest.cpp
Normal file
@ -0,0 +1,140 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/treectrltest.cpp
|
||||
// Purpose: wxDataViewCtrl unit test
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2011-08-08
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2011 Vaclav Slavik <vslavik@gmail.com>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_DATAVIEWCTRL
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "wx/app.h"
|
||||
#include "wx/dataview.h"
|
||||
|
||||
#include "testableframe.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class DataViewCtrlTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
DataViewCtrlTestCase() { }
|
||||
|
||||
virtual void setUp();
|
||||
virtual void tearDown();
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( DataViewCtrlTestCase );
|
||||
CPPUNIT_TEST( DeleteSelected );
|
||||
CPPUNIT_TEST( DeleteNotSelected );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void DeleteSelected();
|
||||
void DeleteNotSelected();
|
||||
|
||||
// the dataview control itself
|
||||
wxDataViewTreeCtrl *m_dvc;
|
||||
|
||||
// and some of its items
|
||||
wxDataViewItem m_root,
|
||||
m_child1,
|
||||
m_child2,
|
||||
m_grandchild;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(DataViewCtrlTestCase)
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( DataViewCtrlTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DataViewCtrlTestCase, "DataViewCtrlTestCase" );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test initialization
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void DataViewCtrlTestCase::setUp()
|
||||
{
|
||||
m_dvc = new wxDataViewTreeCtrl(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxSize(400, 200),
|
||||
wxDV_MULTIPLE);
|
||||
|
||||
m_root = m_dvc->AppendContainer(wxDataViewItem(), "The root");
|
||||
m_child1 = m_dvc->AppendContainer(m_root, "child1");
|
||||
m_grandchild = m_dvc->AppendItem(m_child1, "grandchild");
|
||||
m_child2 = m_dvc->AppendItem(m_root, "child2");
|
||||
|
||||
m_dvc->SetSize(400, 200);
|
||||
m_dvc->ExpandAncestors(m_root);
|
||||
m_dvc->Refresh();
|
||||
m_dvc->Update();
|
||||
}
|
||||
|
||||
void DataViewCtrlTestCase::tearDown()
|
||||
{
|
||||
delete m_dvc;
|
||||
m_dvc = NULL;
|
||||
|
||||
m_root =
|
||||
m_child1 =
|
||||
m_child2 =
|
||||
m_grandchild = wxDataViewItem();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the tests themselves
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void DataViewCtrlTestCase::DeleteSelected()
|
||||
{
|
||||
wxDataViewItemArray sel;
|
||||
sel.push_back(m_child1);
|
||||
sel.push_back(m_grandchild);
|
||||
sel.push_back(m_child2);
|
||||
m_dvc->SetSelections(sel);
|
||||
|
||||
// delete a selected item
|
||||
m_dvc->DeleteItem(m_child1);
|
||||
|
||||
m_dvc->GetSelections(sel);
|
||||
|
||||
// m_child1 and its children should be removed from the selection now
|
||||
CPPUNIT_ASSERT( sel.size() == 1 );
|
||||
CPPUNIT_ASSERT( sel[0] == m_child2 );
|
||||
}
|
||||
|
||||
void DataViewCtrlTestCase::DeleteNotSelected()
|
||||
{
|
||||
wxDataViewItemArray sel;
|
||||
sel.push_back(m_child1);
|
||||
sel.push_back(m_grandchild);
|
||||
m_dvc->SetSelections(sel);
|
||||
|
||||
// delete unselected item
|
||||
m_dvc->DeleteItem(m_child2);
|
||||
|
||||
m_dvc->GetSelections(sel);
|
||||
|
||||
// m_child1 and its children should be removed from the selection now
|
||||
CPPUNIT_ASSERT( sel.size() == 2 );
|
||||
CPPUNIT_ASSERT( sel[0] == m_child1 );
|
||||
CPPUNIT_ASSERT( sel[1] == m_grandchild );
|
||||
}
|
||||
|
||||
#endif //wxUSE_TREECTRL
|
@ -151,7 +151,8 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_choicebooktest.obj \
|
||||
$(OBJS)\test_gui_choicetest.obj \
|
||||
$(OBJS)\test_gui_comboboxtest.obj \
|
||||
$(OBJS)\test_gui_datepickerctrltest.obj \
|
||||
$(OBJS)\test_gui_dataviewctrltest.obj \
|
||||
$(OBJS)\test_gui_datepickerctrltest.obj \
|
||||
$(OBJS)\test_gui_frametest.obj \
|
||||
$(OBJS)\test_gui_gaugetest.obj \
|
||||
$(OBJS)\test_gui_gridtest.obj \
|
||||
@ -780,9 +781,12 @@ $(OBJS)\test_gui_choicetest.obj: .\controls\choicetest.cpp
|
||||
$(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp
|
||||
|
||||
$(OBJS)\test_gui_datepickerctrltest.obj: .\controls\datepickerctrltest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\datepickerctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_dataviewctrltest.obj: .\controls\dataviewctrltest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\dataviewctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_datepickerctrltest.obj: .\controls\datepickerctrltest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\datepickerctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_frametest.obj: .\controls\frametest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\frametest.cpp
|
||||
|
||||
|
@ -144,7 +144,8 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_choicebooktest.o \
|
||||
$(OBJS)\test_gui_choicetest.o \
|
||||
$(OBJS)\test_gui_comboboxtest.o \
|
||||
$(OBJS)\test_gui_datepickerctrltest.o \
|
||||
$(OBJS)\test_gui_dataviewctrltest.o \
|
||||
$(OBJS)\test_gui_datepickerctrltest.o \
|
||||
$(OBJS)\test_gui_frametest.o \
|
||||
$(OBJS)\test_gui_gaugetest.o \
|
||||
$(OBJS)\test_gui_gridtest.o \
|
||||
@ -761,9 +762,12 @@ $(OBJS)\test_gui_choicetest.o: ./controls/choicetest.cpp
|
||||
$(OBJS)\test_gui_comboboxtest.o: ./controls/comboboxtest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_datepickerctrltest.o: ./controls/datepickerctrltest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_dataviewctrltest.o: ./controls/dataviewctrltest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_datepickerctrltest.o: ./controls/datepickerctrltest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_frametest.o: ./controls/frametest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
|
@ -146,7 +146,8 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_choicebooktest.obj \
|
||||
$(OBJS)\test_gui_choicetest.obj \
|
||||
$(OBJS)\test_gui_comboboxtest.obj \
|
||||
$(OBJS)\test_gui_datepickerctrltest.obj \
|
||||
$(OBJS)\test_gui_dataviewctrltest.obj \
|
||||
$(OBJS)\test_gui_datepickerctrltest.obj \
|
||||
$(OBJS)\test_gui_frametest.obj \
|
||||
$(OBJS)\test_gui_gaugetest.obj \
|
||||
$(OBJS)\test_gui_gridtest.obj \
|
||||
@ -906,9 +907,12 @@ $(OBJS)\test_gui_choicetest.obj: .\controls\choicetest.cpp
|
||||
$(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp
|
||||
|
||||
$(OBJS)\test_gui_datepickerctrltest.obj: .\controls\datepickerctrltest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\datepickerctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_dataviewctrltest.obj: .\controls\dataviewctrltest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\dataviewctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_datepickerctrltest.obj: .\controls\datepickerctrltest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\datepickerctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_frametest.obj: .\controls\frametest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\frametest.cpp
|
||||
|
||||
|
@ -390,7 +390,8 @@ TEST_GUI_OBJECTS = &
|
||||
$(OBJS)\test_gui_choicebooktest.obj &
|
||||
$(OBJS)\test_gui_choicetest.obj &
|
||||
$(OBJS)\test_gui_comboboxtest.obj &
|
||||
$(OBJS)\test_gui_datepickerctrltest.obj &
|
||||
$(OBJS)\test_gui_dataviewctrltest.obj &
|
||||
$(OBJS)\test_gui_datepickerctrltest.obj &
|
||||
$(OBJS)\test_gui_frametest.obj &
|
||||
$(OBJS)\test_gui_gaugetest.obj &
|
||||
$(OBJS)\test_gui_gridtest.obj &
|
||||
@ -820,9 +821,12 @@ $(OBJS)\test_gui_choicetest.obj : .AUTODEPEND .\controls\choicetest.cpp
|
||||
$(OBJS)\test_gui_comboboxtest.obj : .AUTODEPEND .\controls\comboboxtest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_datepickerctrltest.obj : .AUTODEPEND .\controls\datepickerctrltest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_dataviewctrltest.obj : .AUTODEPEND .\controls\dataviewctrltest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_datepickerctrltest.obj : .AUTODEPEND .\controls\datepickerctrltest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_frametest.obj : .AUTODEPEND .\controls\frametest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
|
@ -147,6 +147,7 @@
|
||||
controls/choicebooktest.cpp
|
||||
controls/choicetest.cpp
|
||||
controls/comboboxtest.cpp
|
||||
controls/dataviewctrltest.cpp
|
||||
controls/datepickerctrltest.cpp
|
||||
controls/frametest.cpp
|
||||
controls/gaugetest.cpp
|
||||
|
@ -307,10 +307,14 @@ SOURCE=.\config\config.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\controls\datepickerctrltest.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\controls\dataviewctrltest.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\controls\datepickerctrltest.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dummy.cpp
|
||||
# ADD BASE CPP /Yc"testprec.h"
|
||||
# ADD CPP /Yc"testprec.h"
|
||||
|
@ -620,9 +620,12 @@
|
||||
RelativePath=".\config\config.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\datepickerctrltest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\dataviewctrltest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\datepickerctrltest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\dummy.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
|
@ -900,10 +900,14 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\datepickerctrltest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\dataviewctrltest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\datepickerctrltest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\dummy.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
|
@ -872,10 +872,14 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\datepickerctrltest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\dataviewctrltest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\controls\datepickerctrltest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\dummy.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
|
Loading…
Reference in New Issue
Block a user