]> git.saurik.com Git - wxWidgets.git/blob - tests/controls/headerctrltest.cpp
in STL build wxVector elements need to be assignable as well as copy constructible
[wxWidgets.git] / tests / controls / headerctrltest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/headerctrltest.cpp
3 // Purpose: wxHeaderCtrl 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 #ifdef __WXMSW__ // no generic version of this control yet
21
22 #ifndef WX_PRECOMP
23 #include "wx/app.h"
24 #include "wx/headerctrl.h"
25 #endif // WX_PRECOMP
26
27 // ----------------------------------------------------------------------------
28 // test class
29 // ----------------------------------------------------------------------------
30
31 class HeaderCtrlTestCase : public CppUnit::TestCase
32 {
33 public:
34 HeaderCtrlTestCase() { }
35
36 virtual void setUp();
37 virtual void tearDown();
38
39 private:
40 CPPUNIT_TEST_SUITE( HeaderCtrlTestCase );
41 CPPUNIT_TEST( AddDelete );
42 CPPUNIT_TEST( BestSize );
43 CPPUNIT_TEST_SUITE_END();
44
45 void AddDelete();
46 void BestSize();
47
48 wxHeaderCtrlSimple *m_header;
49
50 DECLARE_NO_COPY_CLASS(HeaderCtrlTestCase)
51 };
52
53 // register in the unnamed registry so that these tests are run by default
54 CPPUNIT_TEST_SUITE_REGISTRATION( HeaderCtrlTestCase );
55
56 // also include in it's own registry so that these tests can be run alone
57 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( HeaderCtrlTestCase, "HeaderCtrlTestCase" );
58
59 // ----------------------------------------------------------------------------
60 // test initialization
61 // ----------------------------------------------------------------------------
62
63 void HeaderCtrlTestCase::setUp()
64 {
65 m_header = new wxHeaderCtrlSimple(wxTheApp->GetTopWindow());
66 }
67
68 void HeaderCtrlTestCase::tearDown()
69 {
70 delete m_header;
71 m_header = NULL;
72 }
73
74 // ----------------------------------------------------------------------------
75 // the tests themselves
76 // ----------------------------------------------------------------------------
77
78 void HeaderCtrlTestCase::AddDelete()
79 {
80 CPPUNIT_ASSERT_EQUAL( 0, m_header->GetColumnCount() );
81
82 m_header->AppendColumn(wxHeaderColumnSimple("Column 1"));
83 CPPUNIT_ASSERT_EQUAL( 1, m_header->GetColumnCount() );
84
85 m_header->AppendColumn(wxHeaderColumnSimple("Column 2"));
86 CPPUNIT_ASSERT_EQUAL( 2, m_header->GetColumnCount() );
87
88 m_header->InsertColumn(wxHeaderColumnSimple("Column 0"), 0);
89 CPPUNIT_ASSERT_EQUAL( 3, m_header->GetColumnCount() );
90
91 m_header->DeleteColumn(2);
92 CPPUNIT_ASSERT_EQUAL( 2, m_header->GetColumnCount() );
93 }
94
95 void HeaderCtrlTestCase::BestSize()
96 {
97 const wxSize sizeEmpty = m_header->GetBestSize();
98 CPPUNIT_ASSERT( sizeEmpty.x > 0 );
99 CPPUNIT_ASSERT( sizeEmpty.y > 0 );
100
101 m_header->AppendColumn(wxHeaderColumnSimple("Foo"));
102 m_header->AppendColumn(wxHeaderColumnSimple("Bar"));
103 const wxSize size = m_header->GetBestSize();
104 CPPUNIT_ASSERT_EQUAL( sizeEmpty.y, size.y );
105 }
106
107 #endif // __WXMSW__