2008-12-03 16:53:10 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: tests/controls/headerctrltest.cpp
|
|
|
|
// Purpose: wxHeaderCtrl 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
|
|
|
|
|
2008-12-03 16:56:49 -05:00
|
|
|
#ifdef __WXMSW__ // no generic version of this control yet
|
|
|
|
|
2008-12-03 16:53:10 -05:00
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/app.h"
|
|
|
|
#include "wx/headerctrl.h"
|
|
|
|
#endif // WX_PRECOMP
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// test class
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class HeaderCtrlTestCase : public CppUnit::TestCase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
HeaderCtrlTestCase() { }
|
|
|
|
|
|
|
|
virtual void setUp();
|
|
|
|
virtual void tearDown();
|
|
|
|
|
|
|
|
private:
|
|
|
|
CPPUNIT_TEST_SUITE( HeaderCtrlTestCase );
|
|
|
|
CPPUNIT_TEST( AddDelete );
|
|
|
|
CPPUNIT_TEST( BestSize );
|
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
|
|
|
|
void AddDelete();
|
|
|
|
void BestSize();
|
|
|
|
|
2008-12-07 09:47:55 -05:00
|
|
|
wxHeaderCtrlSimple *m_header;
|
2008-12-03 16:53:10 -05:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(HeaderCtrlTestCase)
|
|
|
|
};
|
|
|
|
|
|
|
|
// register in the unnamed registry so that these tests are run by default
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( HeaderCtrlTestCase );
|
|
|
|
|
|
|
|
// also include in it's own registry so that these tests can be run alone
|
|
|
|
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( HeaderCtrlTestCase, "HeaderCtrlTestCase" );
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// test initialization
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void HeaderCtrlTestCase::setUp()
|
|
|
|
{
|
2008-12-07 09:47:55 -05:00
|
|
|
m_header = new wxHeaderCtrlSimple(wxTheApp->GetTopWindow());
|
2008-12-03 16:53:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void HeaderCtrlTestCase::tearDown()
|
|
|
|
{
|
|
|
|
delete m_header;
|
|
|
|
m_header = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// the tests themselves
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void HeaderCtrlTestCase::AddDelete()
|
|
|
|
{
|
|
|
|
CPPUNIT_ASSERT_EQUAL( 0, m_header->GetColumnCount() );
|
|
|
|
|
2008-12-07 10:58:59 -05:00
|
|
|
m_header->AppendColumn(wxHeaderColumnSimple("Column 1"));
|
2008-12-03 16:53:10 -05:00
|
|
|
CPPUNIT_ASSERT_EQUAL( 1, m_header->GetColumnCount() );
|
|
|
|
|
2008-12-07 10:58:59 -05:00
|
|
|
m_header->AppendColumn(wxHeaderColumnSimple("Column 2"));
|
2008-12-03 16:53:10 -05:00
|
|
|
CPPUNIT_ASSERT_EQUAL( 2, m_header->GetColumnCount() );
|
|
|
|
|
2008-12-07 10:58:59 -05:00
|
|
|
m_header->InsertColumn(wxHeaderColumnSimple("Column 0"), 0);
|
2008-12-03 16:53:10 -05:00
|
|
|
CPPUNIT_ASSERT_EQUAL( 3, m_header->GetColumnCount() );
|
|
|
|
|
|
|
|
m_header->DeleteColumn(2);
|
|
|
|
CPPUNIT_ASSERT_EQUAL( 2, m_header->GetColumnCount() );
|
|
|
|
}
|
|
|
|
|
|
|
|
void HeaderCtrlTestCase::BestSize()
|
|
|
|
{
|
|
|
|
const wxSize sizeEmpty = m_header->GetBestSize();
|
|
|
|
CPPUNIT_ASSERT( sizeEmpty.x > 0 );
|
|
|
|
CPPUNIT_ASSERT( sizeEmpty.y > 0 );
|
|
|
|
|
2008-12-07 10:58:59 -05:00
|
|
|
m_header->AppendColumn(wxHeaderColumnSimple("Foo"));
|
|
|
|
m_header->AppendColumn(wxHeaderColumnSimple("Bar"));
|
2008-12-03 16:53:10 -05:00
|
|
|
const wxSize size = m_header->GetBestSize();
|
|
|
|
CPPUNIT_ASSERT_EQUAL( sizeEmpty.y, size.y );
|
|
|
|
}
|
|
|
|
|
2008-12-03 16:56:49 -05:00
|
|
|
#endif // __WXMSW__
|