]>
git.saurik.com Git - wxWidgets.git/blob - tests/sizers/boxsizer.cpp
e4dbbec1df7618dc6e53a20f7ff2a933d1b053ac
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/sizers/boxsizer.cpp
3 // Purpose: Unit tests for wxBoxSizer
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2010 Vadim Zeitlin <vadim@wxwidgets.org>
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
25 inline std::ostream
& operator<<(std::ostream
& o
, const wxSize
& s
)
27 return o
<< s
.x
<< 'x' << s
.y
;
30 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
34 class BoxSizerTestCase
: public CppUnit::TestCase
37 BoxSizerTestCase() { }
40 virtual void tearDown();
43 CPPUNIT_TEST_SUITE( BoxSizerTestCase
);
44 CPPUNIT_TEST( Size1
);
45 CPPUNIT_TEST_SUITE_END();
52 DECLARE_NO_COPY_CLASS(BoxSizerTestCase
)
55 // register in the unnamed registry so that these tests are run by default
56 CPPUNIT_TEST_SUITE_REGISTRATION( BoxSizerTestCase
);
58 // also include in it's own registry so that these tests can be run alone
59 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( BoxSizerTestCase
, "BoxSizerTestCase" );
61 // ----------------------------------------------------------------------------
62 // test initialization
63 // ----------------------------------------------------------------------------
65 void BoxSizerTestCase::setUp()
67 m_win
= new wxWindow(wxTheApp
->GetTopWindow(), wxID_ANY
);
68 m_win
->SetClientSize(127, 35);
70 m_sizer
= new wxBoxSizer(wxHORIZONTAL
);
71 m_win
->SetSizer(m_sizer
);
74 void BoxSizerTestCase::tearDown()
82 // ----------------------------------------------------------------------------
84 // ----------------------------------------------------------------------------
86 void BoxSizerTestCase::Size1()
88 const wxSize sizeTotal
= m_win
->GetClientSize();
89 const wxSize sizeChild
= sizeTotal
/ 2;
92 child
= new wxWindow(m_win
, wxID_ANY
, wxDefaultPosition
, sizeChild
);
95 CPPUNIT_ASSERT_EQUAL( sizeChild
, child
->GetSize() );
98 m_sizer
->Add(child
, wxSizerFlags(1));
100 CPPUNIT_ASSERT_EQUAL( wxSize(sizeTotal
.x
, sizeChild
.y
), child
->GetSize() );
103 m_sizer
->Add(child
, wxSizerFlags(1).Expand());
105 CPPUNIT_ASSERT_EQUAL( sizeTotal
, child
->GetSize() );