Get rid of CppUnit boilerplate in wxGridSizer unit test
No real changes, just simplify and use CHECK() instead of CPPUNIT_ASSERT_EQUAL() (which is the same as REQUIRE()).
This commit is contained in:
@@ -25,23 +25,11 @@
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class GridSizerTestCase : public CppUnit::TestCase
|
||||
class GridSizerTestCase
|
||||
{
|
||||
public:
|
||||
GridSizerTestCase() { }
|
||||
|
||||
virtual void setUp() wxOVERRIDE;
|
||||
virtual void tearDown() wxOVERRIDE;
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( GridSizerTestCase );
|
||||
CPPUNIT_TEST( Expand );
|
||||
CPPUNIT_TEST( IncompatibleFlags );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Expand();
|
||||
void IncompatibleFlags();
|
||||
|
||||
protected:
|
||||
GridSizerTestCase();
|
||||
~GridSizerTestCase();
|
||||
// Clear the current sizer contents and add the specified windows to it,
|
||||
// using the same flags for all of them.
|
||||
void SetChildren(const wxVector<wxWindow*>& children,
|
||||
@@ -53,17 +41,11 @@ private:
|
||||
wxDECLARE_NO_COPY_CLASS(GridSizerTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( GridSizerTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( GridSizerTestCase, "GridSizerTestCase" );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test initialization
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void GridSizerTestCase::setUp()
|
||||
GridSizerTestCase::GridSizerTestCase()
|
||||
{
|
||||
m_win = new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_win->SetClientSize(127, 35);
|
||||
@@ -72,7 +54,7 @@ void GridSizerTestCase::setUp()
|
||||
m_win->SetSizer(m_sizer);
|
||||
}
|
||||
|
||||
void GridSizerTestCase::tearDown()
|
||||
GridSizerTestCase::~GridSizerTestCase()
|
||||
{
|
||||
delete m_win;
|
||||
m_win = NULL;
|
||||
@@ -102,7 +84,9 @@ void GridSizerTestCase::SetChildren(const wxVector<wxWindow*>& children,
|
||||
// tests themselves
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void GridSizerTestCase::Expand()
|
||||
TEST_CASE_METHOD(GridSizerTestCase,
|
||||
"wxGridSizer::Expand",
|
||||
"[grid-sizer][sizer]")
|
||||
{
|
||||
const wxSize sizeTotal = m_win->GetClientSize();
|
||||
const wxSize sizeChild(sizeTotal.x / 4, sizeTotal.y / 4);
|
||||
@@ -121,42 +105,38 @@ void GridSizerTestCase::Expand()
|
||||
|
||||
// Without Expand() windows have their initial size.
|
||||
SetChildren(children, wxSizerFlags());
|
||||
CPPUNIT_ASSERT_EQUAL( sizeChild, children[0]->GetSize() );
|
||||
CPPUNIT_ASSERT_EQUAL( sizeChild, children[1]->GetSize() );
|
||||
CPPUNIT_ASSERT_EQUAL( sizeChild, children[2]->GetSize() );
|
||||
CPPUNIT_ASSERT_EQUAL( sizeChild, children[3]->GetSize() );
|
||||
CHECK( children[0]->GetSize() == sizeChild );
|
||||
CHECK( children[1]->GetSize() == sizeChild );
|
||||
CHECK( children[2]->GetSize() == sizeChild );
|
||||
CHECK( children[3]->GetSize() == sizeChild );
|
||||
|
||||
// With just expand, they expand to fill the entire column and the row
|
||||
// containing them (which may or not expand on its own).
|
||||
SetChildren(children, wxSizerFlags().Expand());
|
||||
CPPUNIT_ASSERT_EQUAL( sizeChild, children[0]->GetSize() );
|
||||
CPPUNIT_ASSERT_EQUAL( wxSize(sizeRest.x, sizeChild.y),
|
||||
children[1]->GetSize() );
|
||||
CPPUNIT_ASSERT_EQUAL( wxSize(sizeChild.x, sizeRest.y),
|
||||
children[2]->GetSize() );
|
||||
CPPUNIT_ASSERT_EQUAL( sizeRest, children[3]->GetSize() );
|
||||
CHECK( children[0]->GetSize() == sizeChild );
|
||||
CHECK( children[1]->GetSize() == wxSize(sizeRest.x, sizeChild.y) );
|
||||
CHECK( children[2]->GetSize() == wxSize(sizeChild.x, sizeRest.y) );
|
||||
CHECK( children[3]->GetSize() == sizeRest );
|
||||
|
||||
// With expand and another alignment flag, they should expand only in the
|
||||
// direction in which the alignment is not given.
|
||||
SetChildren(children, wxSizerFlags().Expand().CentreVertical());
|
||||
CPPUNIT_ASSERT_EQUAL( sizeChild, children[0]->GetSize() );
|
||||
CPPUNIT_ASSERT_EQUAL( wxSize(sizeRest.x, sizeChild.y),
|
||||
children[1]->GetSize() );
|
||||
CPPUNIT_ASSERT_EQUAL( sizeChild, children[2]->GetSize() );
|
||||
CPPUNIT_ASSERT_EQUAL( wxSize(sizeRest.x, sizeChild.y),
|
||||
children[3]->GetSize() );
|
||||
CHECK( children[0]->GetSize() == sizeChild );
|
||||
CHECK( children[1]->GetSize() == wxSize(sizeRest.x, sizeChild.y) );
|
||||
CHECK( children[2]->GetSize() == sizeChild );
|
||||
CHECK( children[3]->GetSize() == wxSize(sizeRest.x, sizeChild.y) );
|
||||
|
||||
// Same as above but mirrored.
|
||||
SetChildren(children, wxSizerFlags().Expand().CentreHorizontal());
|
||||
CPPUNIT_ASSERT_EQUAL( sizeChild, children[0]->GetSize() );
|
||||
CPPUNIT_ASSERT_EQUAL( sizeChild, children[1]->GetSize() );
|
||||
CPPUNIT_ASSERT_EQUAL( wxSize(sizeChild.x, sizeRest.y),
|
||||
children[2]->GetSize() );
|
||||
CPPUNIT_ASSERT_EQUAL( wxSize(sizeChild.x, sizeRest.y),
|
||||
children[3]->GetSize() );
|
||||
CHECK( children[0]->GetSize() == sizeChild );
|
||||
CHECK( children[1]->GetSize() == sizeChild );
|
||||
CHECK( children[2]->GetSize() == wxSize(sizeChild.x, sizeRest.y) );
|
||||
CHECK( children[3]->GetSize() == wxSize(sizeChild.x, sizeRest.y) );
|
||||
}
|
||||
|
||||
void GridSizerTestCase::IncompatibleFlags()
|
||||
TEST_CASE_METHOD(GridSizerTestCase,
|
||||
"wxGridSizer::IncompatibleFlags",
|
||||
"[grid-sizer][sizer]")
|
||||
{
|
||||
WX_ASSERT_FAILS_WITH_ASSERT_MESSAGE
|
||||
(
|
||||
|
Reference in New Issue
Block a user