]>
git.saurik.com Git - wxWidgets.git/blob - tests/controls/headerctrltest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/headerctrltest.cpp
3 // Purpose: wxHeaderCtrl unit test
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
20 #ifdef __WXMSW__ // no generic version of this control yet
24 #include "wx/headerctrl.h"
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 class HeaderCtrlTestCase
: public CppUnit::TestCase
34 HeaderCtrlTestCase() { }
37 virtual void tearDown();
40 CPPUNIT_TEST_SUITE( HeaderCtrlTestCase
);
41 CPPUNIT_TEST( AddDelete
);
42 CPPUNIT_TEST( BestSize
);
43 CPPUNIT_TEST_SUITE_END();
48 wxHeaderCtrlSimple
*m_header
;
50 DECLARE_NO_COPY_CLASS(HeaderCtrlTestCase
)
53 // register in the unnamed registry so that these tests are run by default
54 CPPUNIT_TEST_SUITE_REGISTRATION( HeaderCtrlTestCase
);
56 // also include in it's own registry so that these tests can be run alone
57 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( HeaderCtrlTestCase
, "HeaderCtrlTestCase" );
59 // ----------------------------------------------------------------------------
60 // test initialization
61 // ----------------------------------------------------------------------------
63 void HeaderCtrlTestCase::setUp()
65 m_header
= new wxHeaderCtrlSimple(wxTheApp
->GetTopWindow());
68 void HeaderCtrlTestCase::tearDown()
74 // ----------------------------------------------------------------------------
75 // the tests themselves
76 // ----------------------------------------------------------------------------
78 void HeaderCtrlTestCase::AddDelete()
80 CPPUNIT_ASSERT_EQUAL( 0, m_header
->GetColumnCount() );
82 m_header
->AppendColumn(wxHeaderColumnSimple("Column 1"));
83 CPPUNIT_ASSERT_EQUAL( 1, m_header
->GetColumnCount() );
85 m_header
->AppendColumn(wxHeaderColumnSimple("Column 2"));
86 CPPUNIT_ASSERT_EQUAL( 2, m_header
->GetColumnCount() );
88 m_header
->InsertColumn(wxHeaderColumnSimple("Column 0"), 0);
89 CPPUNIT_ASSERT_EQUAL( 3, m_header
->GetColumnCount() );
91 m_header
->DeleteColumn(2);
92 CPPUNIT_ASSERT_EQUAL( 2, m_header
->GetColumnCount() );
95 void HeaderCtrlTestCase::BestSize()
97 const wxSize sizeEmpty
= m_header
->GetBestSize();
98 CPPUNIT_ASSERT( sizeEmpty
.x
> 0 );
99 CPPUNIT_ASSERT( sizeEmpty
.y
> 0 );
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
);