{
wxCHECK_MSG( item.IsOk(), false, wxT("invalid tree item") );
+ if ( IS_VIRTUAL_ROOT(item) )
+ {
+ wxTreeItemIdValue cookie;
+ return GetFirstChild(item, cookie).IsOk();
+ }
+
wxTreeViewItem tvItem(item, TVIF_CHILDREN);
DoGetItem(&tvItem);
test_gui_listctrltest.o \
test_gui_textctrltest.o \
test_gui_textentrytest.o \
+ test_gui_treectrltest.o \
test_gui_propagation.o \
test_gui_rawbmp.o \
test_gui_htmlwindow.o \
test_gui_textentrytest.o: $(srcdir)/controls/textentrytest.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/textentrytest.cpp
+test_gui_treectrltest.o: $(srcdir)/controls/treectrltest.cpp $(TEST_GUI_ODEP)
+ $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/treectrltest.cpp
+
test_gui_propagation.o: $(srcdir)/events/propagation.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/events/propagation.cpp
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: tests/controls/treectrltest.cpp
+// Purpose: wxTreeCtrl unit test
+// Author: Vadim Zeitlin
+// Created: 2008-11-26
+// RCS-ID: $Id$
+// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
+///////////////////////////////////////////////////////////////////////////////
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#include "testprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/app.h"
+#endif // WX_PRECOMP
+
+#include "wx/treectrl.h"
+
+// ----------------------------------------------------------------------------
+// test class
+// ----------------------------------------------------------------------------
+
+class TreeCtrlTestCase : public CppUnit::TestCase
+{
+public:
+ TreeCtrlTestCase() { }
+
+ virtual void setUp();
+ virtual void tearDown();
+
+private:
+ CPPUNIT_TEST_SUITE( TreeCtrlTestCase );
+ CPPUNIT_TEST( HasChildren );
+ CPPUNIT_TEST( PseudoTest_SetHiddenRoot );
+ CPPUNIT_TEST( HasChildren );
+ CPPUNIT_TEST_SUITE_END();
+
+ void HasChildren();
+ void PseudoTest_SetHiddenRoot() { ms_hiddenRoot = true; }
+
+ static bool ms_hiddenRoot;
+
+ wxTreeCtrl *m_tree;
+
+ DECLARE_NO_COPY_CLASS(TreeCtrlTestCase)
+};
+
+// register in the unnamed registry so that these tests are run by default
+CPPUNIT_TEST_SUITE_REGISTRATION( TreeCtrlTestCase );
+
+// also include in it's own registry so that these tests can be run alone
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TreeCtrlTestCase, "TreeCtrlTestCase" );
+
+// ----------------------------------------------------------------------------
+// test initialization
+// ----------------------------------------------------------------------------
+
+bool TreeCtrlTestCase::ms_hiddenRoot = false;
+
+void TreeCtrlTestCase::setUp()
+{
+ m_tree = new wxTreeCtrl(wxTheApp->GetTopWindow());
+ if ( ms_hiddenRoot )
+ m_tree->ToggleWindowStyle(wxTR_HIDE_ROOT); // actually set it
+}
+
+void TreeCtrlTestCase::tearDown()
+{
+ delete m_tree;
+ m_tree = NULL;
+}
+
+// ----------------------------------------------------------------------------
+// the tests themselves
+// ----------------------------------------------------------------------------
+
+void TreeCtrlTestCase::HasChildren()
+{
+ const wxTreeItemId root = m_tree->AddRoot("root");
+ const wxTreeItemId child1 = m_tree->AppendItem(root, "child1");
+ const wxTreeItemId child2 = m_tree->AppendItem(root, "child2");
+ const wxTreeItemId grandchild = m_tree->AppendItem(child1, "grandchild");
+
+ CPPUNIT_ASSERT( m_tree->HasChildren(root) );
+ CPPUNIT_ASSERT( m_tree->HasChildren(child1) );
+ CPPUNIT_ASSERT( !m_tree->HasChildren(child2) );
+ CPPUNIT_ASSERT( !m_tree->HasChildren(grandchild) );
+}
+
$(OBJS)\test_gui_listctrltest.obj \
$(OBJS)\test_gui_textctrltest.obj \
$(OBJS)\test_gui_textentrytest.obj \
+ $(OBJS)\test_gui_treectrltest.obj \
$(OBJS)\test_gui_propagation.obj \
$(OBJS)\test_gui_rawbmp.obj \
$(OBJS)\test_gui_htmlwindow.obj \
$(OBJS)\test_gui_textentrytest.obj: .\controls\textentrytest.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\textentrytest.cpp
+$(OBJS)\test_gui_treectrltest.obj: .\controls\treectrltest.cpp
+ $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\treectrltest.cpp
+
$(OBJS)\test_gui_propagation.obj: .\events\propagation.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\events\propagation.cpp
$(OBJS)\test_gui_listctrltest.o \
$(OBJS)\test_gui_textctrltest.o \
$(OBJS)\test_gui_textentrytest.o \
+ $(OBJS)\test_gui_treectrltest.o \
$(OBJS)\test_gui_propagation.o \
$(OBJS)\test_gui_rawbmp.o \
$(OBJS)\test_gui_htmlwindow.o \
$(OBJS)\test_gui_textentrytest.o: ./controls/textentrytest.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\test_gui_treectrltest.o: ./controls/treectrltest.cpp
+ $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\test_gui_propagation.o: ./events/propagation.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_gui_listctrltest.obj \
$(OBJS)\test_gui_textctrltest.obj \
$(OBJS)\test_gui_textentrytest.obj \
+ $(OBJS)\test_gui_treectrltest.obj \
$(OBJS)\test_gui_propagation.obj \
$(OBJS)\test_gui_rawbmp.obj \
$(OBJS)\test_gui_htmlwindow.obj \
$(OBJS)\test_gui_textentrytest.obj: .\controls\textentrytest.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\textentrytest.cpp
+$(OBJS)\test_gui_treectrltest.obj: .\controls\treectrltest.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\treectrltest.cpp
+
$(OBJS)\test_gui_propagation.obj: .\events\propagation.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\events\propagation.cpp
$(OBJS)\test_gui_listctrltest.obj &
$(OBJS)\test_gui_textctrltest.obj &
$(OBJS)\test_gui_textentrytest.obj &
+ $(OBJS)\test_gui_treectrltest.obj &
$(OBJS)\test_gui_propagation.obj &
$(OBJS)\test_gui_rawbmp.obj &
$(OBJS)\test_gui_htmlwindow.obj &
$(OBJS)\test_gui_textentrytest.obj : .AUTODEPEND .\controls\textentrytest.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
+$(OBJS)\test_gui_treectrltest.obj : .AUTODEPEND .\controls\treectrltest.cpp
+ $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
+
$(OBJS)\test_gui_propagation.obj : .AUTODEPEND .\events\propagation.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
controls/listctrltest.cpp
controls/textctrltest.cpp
controls/textentrytest.cpp
+ controls/treectrltest.cpp
events/propagation.cpp
image/rawbmp.cpp
html/htmlwindow.cpp
\r
SOURCE=.\controls\textentrytest.cpp\r
# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\controls\treectrltest.cpp\r
+# End Source File\r
# End Group\r
# End Target\r
# End Project\r
<File\r
RelativePath=".\controls\textentrytest.cpp">\r
</File>\r
+ <File\r
+ RelativePath=".\controls\treectrltest.cpp">\r
+ </File>\r
</Filter>\r
<Filter\r
Name="Resource Files"\r
RelativePath=".\controls\textentrytest.cpp"\r
>\r
</File>\r
+ <File\r
+ RelativePath=".\controls\treectrltest.cpp"\r
+ >\r
+ </File>\r
</Filter>\r
<Filter\r
Name="Resource Files"\r
RelativePath=".\controls\textentrytest.cpp"\r
>\r
</File>\r
+ <File\r
+ RelativePath=".\controls\treectrltest.cpp"\r
+ >\r
+ </File>\r
</Filter>\r
<Filter\r
Name="Resource Files"\r