]> git.saurik.com Git - wxWidgets.git/blame - tests/controls/treectrltest.cpp
bringing back utf32 encoding for wchar, fixes #10666
[wxWidgets.git] / tests / controls / treectrltest.cpp
CommitLineData
fa97ee24
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/controls/treectrltest.cpp
3// Purpose: wxTreeCtrl unit test
4// Author: Vadim Zeitlin
5// Created: 2008-11-26
6// RCS-ID: $Id$
7// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8///////////////////////////////////////////////////////////////////////////////
9
10// ----------------------------------------------------------------------------
11// headers
12// ----------------------------------------------------------------------------
13
14#include "testprec.h"
15
16#ifdef __BORLANDC__
17 #pragma hdrstop
18#endif
19
20#ifndef WX_PRECOMP
21 #include "wx/app.h"
22#endif // WX_PRECOMP
23
24#include "wx/treectrl.h"
25
26// ----------------------------------------------------------------------------
27// test class
28// ----------------------------------------------------------------------------
29
30class TreeCtrlTestCase : public CppUnit::TestCase
31{
32public:
33 TreeCtrlTestCase() { }
34
35 virtual void setUp();
36 virtual void tearDown();
37
38private:
39 CPPUNIT_TEST_SUITE( TreeCtrlTestCase );
40 CPPUNIT_TEST( HasChildren );
41 CPPUNIT_TEST( PseudoTest_SetHiddenRoot );
42 CPPUNIT_TEST( HasChildren );
43 CPPUNIT_TEST_SUITE_END();
44
45 void HasChildren();
46 void PseudoTest_SetHiddenRoot() { ms_hiddenRoot = true; }
47
48 static bool ms_hiddenRoot;
49
50 wxTreeCtrl *m_tree;
51
52 DECLARE_NO_COPY_CLASS(TreeCtrlTestCase)
53};
54
55// register in the unnamed registry so that these tests are run by default
56CPPUNIT_TEST_SUITE_REGISTRATION( TreeCtrlTestCase );
57
58// also include in it's own registry so that these tests can be run alone
59CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TreeCtrlTestCase, "TreeCtrlTestCase" );
60
61// ----------------------------------------------------------------------------
62// test initialization
63// ----------------------------------------------------------------------------
64
65bool TreeCtrlTestCase::ms_hiddenRoot = false;
66
67void TreeCtrlTestCase::setUp()
68{
69 m_tree = new wxTreeCtrl(wxTheApp->GetTopWindow());
70 if ( ms_hiddenRoot )
71 m_tree->ToggleWindowStyle(wxTR_HIDE_ROOT); // actually set it
72}
73
74void TreeCtrlTestCase::tearDown()
75{
76 delete m_tree;
77 m_tree = NULL;
78}
79
80// ----------------------------------------------------------------------------
81// the tests themselves
82// ----------------------------------------------------------------------------
83
84void TreeCtrlTestCase::HasChildren()
85{
86 const wxTreeItemId root = m_tree->AddRoot("root");
87 const wxTreeItemId child1 = m_tree->AppendItem(root, "child1");
88 const wxTreeItemId child2 = m_tree->AppendItem(root, "child2");
89 const wxTreeItemId grandchild = m_tree->AppendItem(child1, "grandchild");
90
91 CPPUNIT_ASSERT( m_tree->HasChildren(root) );
92 CPPUNIT_ASSERT( m_tree->HasChildren(child1) );
93 CPPUNIT_ASSERT( !m_tree->HasChildren(child2) );
94 CPPUNIT_ASSERT( !m_tree->HasChildren(grandchild) );
95}
96