]> git.saurik.com Git - wxWidgets.git/commitdiff
Add some basic tests for wxDataViewCtrl selection handling.
authorVáclav Slavík <vslavik@fastmail.fm>
Wed, 10 Aug 2011 15:24:25 +0000 (15:24 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Wed, 10 Aug 2011 15:24:25 +0000 (15:24 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68623 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/Makefile.in
tests/controls/dataviewctrltest.cpp [new file with mode: 0644]
tests/makefile.bcc
tests/makefile.gcc
tests/makefile.vc
tests/makefile.wat
tests/test.bkl
tests/test_test_gui.dsp
tests/test_vc7_test_gui.vcproj
tests/test_vc8_test_gui.vcproj
tests/test_vc9_test_gui.vcproj

index 61c235eaee5f67e078a03a6a2e354889a1c46123..26ae782b0042e80d7833aae4078f5ea43ca72a9d 100644 (file)
@@ -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
 
diff --git a/tests/controls/dataviewctrltest.cpp b/tests/controls/dataviewctrltest.cpp
new file mode 100644 (file)
index 0000000..60d1a38
--- /dev/null
@@ -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
index 3f816730c28f8ec542e88157ccf43477bcab31a4..812e939faed4acde2be1b98feaf2918cfcb9baf9 100644 (file)
@@ -151,7 +151,8 @@ TEST_GUI_OBJECTS =  \
        $(OBJS)\test_gui_choicebooktest.obj \\r
        $(OBJS)\test_gui_choicetest.obj \\r
        $(OBJS)\test_gui_comboboxtest.obj \\r
-       $(OBJS)\test_gui_datepickerctrltest.obj \
+       $(OBJS)\test_gui_dataviewctrltest.obj \\r
+       $(OBJS)\test_gui_datepickerctrltest.obj \\r
        $(OBJS)\test_gui_frametest.obj \\r
        $(OBJS)\test_gui_gaugetest.obj \\r
        $(OBJS)\test_gui_gridtest.obj \\r
@@ -780,9 +781,12 @@ $(OBJS)\test_gui_choicetest.obj: .\controls\choicetest.cpp
 $(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp\r
        $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp\r
 \r
-$(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\r
+       $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\dataviewctrltest.cpp\r
+\r
+$(OBJS)\test_gui_datepickerctrltest.obj: .\controls\datepickerctrltest.cpp\r
+       $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\datepickerctrltest.cpp\r
+\r
 $(OBJS)\test_gui_frametest.obj: .\controls\frametest.cpp\r
        $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\frametest.cpp\r
 \r
index 652df038cad17accb674f756836cbf4e8ad81135..49ea23cddd701afdf31e8c3841828eed157b27d2 100644 (file)
@@ -144,7 +144,8 @@ TEST_GUI_OBJECTS =  \
        $(OBJS)\test_gui_choicebooktest.o \\r
        $(OBJS)\test_gui_choicetest.o \\r
        $(OBJS)\test_gui_comboboxtest.o \\r
-       $(OBJS)\test_gui_datepickerctrltest.o \
+       $(OBJS)\test_gui_dataviewctrltest.o \\r
+       $(OBJS)\test_gui_datepickerctrltest.o \\r
        $(OBJS)\test_gui_frametest.o \\r
        $(OBJS)\test_gui_gaugetest.o \\r
        $(OBJS)\test_gui_gridtest.o \\r
@@ -761,9 +762,12 @@ $(OBJS)\test_gui_choicetest.o: ./controls/choicetest.cpp
 $(OBJS)\test_gui_comboboxtest.o: ./controls/comboboxtest.cpp\r
        $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<\r
 \r
-$(OBJS)\test_gui_datepickerctrltest.o: ./controls/datepickerctrltest.cpp
-       $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
-
+$(OBJS)\test_gui_dataviewctrltest.o: ./controls/dataviewctrltest.cpp\r
+       $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<\r
+\r
+$(OBJS)\test_gui_datepickerctrltest.o: ./controls/datepickerctrltest.cpp\r
+       $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<\r
+\r
 $(OBJS)\test_gui_frametest.o: ./controls/frametest.cpp\r
        $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<\r
 \r
index a509e659eed4e66c1b4de9b7ef80b1cc3ad91bd6..91f473492413cc9e9092e17d282fa458acab90f3 100644 (file)
@@ -146,7 +146,8 @@ TEST_GUI_OBJECTS =  \
        $(OBJS)\test_gui_choicebooktest.obj \\r
        $(OBJS)\test_gui_choicetest.obj \\r
        $(OBJS)\test_gui_comboboxtest.obj \\r
-       $(OBJS)\test_gui_datepickerctrltest.obj \
+       $(OBJS)\test_gui_dataviewctrltest.obj \\r
+       $(OBJS)\test_gui_datepickerctrltest.obj \\r
        $(OBJS)\test_gui_frametest.obj \\r
        $(OBJS)\test_gui_gaugetest.obj \\r
        $(OBJS)\test_gui_gridtest.obj \\r
@@ -906,9 +907,12 @@ $(OBJS)\test_gui_choicetest.obj: .\controls\choicetest.cpp
 $(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp\r
        $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp\r
 \r
-$(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\r
+       $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\dataviewctrltest.cpp\r
+\r
+$(OBJS)\test_gui_datepickerctrltest.obj: .\controls\datepickerctrltest.cpp\r
+       $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\datepickerctrltest.cpp\r
+\r
 $(OBJS)\test_gui_frametest.obj: .\controls\frametest.cpp\r
        $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\frametest.cpp\r
 \r
index 12fca8172ad8d4383b0b520f81cfe90981420b3b..e566570d79160f672dcd37091a806e48f4072982 100644 (file)
@@ -390,7 +390,8 @@ TEST_GUI_OBJECTS =  &
        $(OBJS)\test_gui_choicebooktest.obj &\r
        $(OBJS)\test_gui_choicetest.obj &\r
        $(OBJS)\test_gui_comboboxtest.obj &\r
-       $(OBJS)\test_gui_datepickerctrltest.obj &
+       $(OBJS)\test_gui_dataviewctrltest.obj &\r
+       $(OBJS)\test_gui_datepickerctrltest.obj &\r
        $(OBJS)\test_gui_frametest.obj &\r
        $(OBJS)\test_gui_gaugetest.obj &\r
        $(OBJS)\test_gui_gridtest.obj &\r
@@ -820,9 +821,12 @@ $(OBJS)\test_gui_choicetest.obj :  .AUTODEPEND .\controls\choicetest.cpp
 $(OBJS)\test_gui_comboboxtest.obj :  .AUTODEPEND .\controls\comboboxtest.cpp\r
        $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<\r
 \r
-$(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\r
+       $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<\r
+\r
+$(OBJS)\test_gui_datepickerctrltest.obj :  .AUTODEPEND .\controls\datepickerctrltest.cpp\r
+       $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<\r
+\r
 $(OBJS)\test_gui_frametest.obj :  .AUTODEPEND .\controls\frametest.cpp\r
        $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<\r
 \r
index 6530babbb109c7313253b901f7675695ec9b255d..344abee419725f8eb38e4e38f8e4b3a4c6d5ec52 100644 (file)
             controls/choicebooktest.cpp
             controls/choicetest.cpp
             controls/comboboxtest.cpp
+            controls/dataviewctrltest.cpp
             controls/datepickerctrltest.cpp
             controls/frametest.cpp
             controls/gaugetest.cpp
index 4ebfd627270773ac05d22eebf0b1ac04dcd5a2fc..cd06b3663e8c1d813b6e89445184ab556c1a2902 100644 (file)
@@ -307,10 +307,14 @@ SOURCE=.\config\config.cpp
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\controls\datepickerctrltest.cpp
-# End Source File
-# Begin Source File
-
+SOURCE=.\controls\dataviewctrltest.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\controls\datepickerctrltest.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\dummy.cpp\r
 # ADD BASE CPP /Yc"testprec.h"\r
 # ADD CPP /Yc"testprec.h"\r
index 344e7b10594117254548dfc5d5ede661f44b4e5a..7bffd2876b174d93c35fdace52d3eca6c66bf54a 100644 (file)
                                RelativePath=".\config\config.cpp">\r
                        </File>\r
                        <File\r
-                               RelativePath=".\controls\datepickerctrltest.cpp">
-                       </File>
-                       <File
+                               RelativePath=".\controls\dataviewctrltest.cpp">\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\controls\datepickerctrltest.cpp">\r
+                       </File>\r
+                       <File\r
                                RelativePath=".\dummy.cpp">\r
                                <FileConfiguration\r
                                        Name="Debug|Win32">\r
index 978c1aa7332da76ce4316b028f3e83f1131e56f9..bdcc44289baedc15efbfcfaf42bc328ec9b5383d 100644 (file)
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\controls\datepickerctrltest.cpp"
-                               >
-                       </File>
-                       <File
+                               RelativePath=".\controls\dataviewctrltest.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\controls\datepickerctrltest.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath=".\dummy.cpp"\r
                                >\r
                                <FileConfiguration\r
index dc18d968728c5c572fad463b44ad53f1fbd8d68e..9648dbf89fa08daa637b8eb13b8e84f64c15b1d8 100644 (file)
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\controls\datepickerctrltest.cpp"
-                               >
-                       </File>
-                       <File
+                               RelativePath=".\controls\dataviewctrltest.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\controls\datepickerctrltest.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath=".\dummy.cpp"\r
                                >\r
                                <FileConfiguration\r