#include "wx/sizer.h"
#endif // WX_PRECOMP
-inline std::ostream& operator<<(std::ostream& o, const wxSize& s)
-{
- return o << s.x << 'x' << s.y;
-}
+#include "asserthelper.h"
// ----------------------------------------------------------------------------
// test class
CPPUNIT_TEST_SUITE( BoxSizerTestCase );
CPPUNIT_TEST( Size1 );
CPPUNIT_TEST( Size3 );
+ CPPUNIT_TEST( CalcMin );
CPPUNIT_TEST_SUITE_END();
void Size1();
void Size3();
+ void CalcMin();
wxWindow *m_win;
wxSizer *m_sizer;
// register in the unnamed registry so that these tests are run by default
CPPUNIT_TEST_SUITE_REGISTRATION( BoxSizerTestCase );
-// also include in it's own registry so that these tests can be run alone
+// also include in its own registry so that these tests can be run alone
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( BoxSizerTestCase, "BoxSizerTestCase" );
// ----------------------------------------------------------------------------
child[1] = new wxWindow(m_win, wxID_ANY);
child[2] = new wxWindow(m_win, wxID_ANY);
- int j;
for ( unsigned i = 0; i < WXSIZEOF(layoutTestData); i++ )
{
LayoutTestData ltd = layoutTestData[i];
}
m_sizer->Clear();
+
+ unsigned j;
for ( j = 0; j < WXSIZEOF(child); j++ )
ltd.AddToSizer(m_sizer, child[j], j);
WX_ASSERT_EQUAL_MESSAGE
(
(
- "test %lu, permutation #%d: wrong size for child #%d "
+ "test %lu, permutation #%lu: wrong size for child #%d "
"for total size %d",
static_cast<unsigned long>(i),
static_cast<unsigned long>(p),
}
}
}
+
+void BoxSizerTestCase::CalcMin()
+{
+ static const unsigned NUM_TEST_ITEM = 3;
+
+ static const struct CalcMinTestData
+ {
+ // proportions of the elements, if one of them is -1 it means to not
+ // use this window at all in this test
+ int prop[NUM_TEST_ITEM];
+
+ // minimal sizes of the elements in the sizer direction
+ int minsize[NUM_TEST_ITEM];
+
+ // the expected minimal sizer size
+ int total;
+ } calcMinTestData[] =
+ {
+ { { 1, 1, -1 }, { 30, 50, 0 }, 100 },
+ { { 1, 1, 0 }, { 30, 50, 20 }, 120 },
+ { { 10, 10, -1 }, { 30, 50, 0 }, 100 },
+ { { 1, 2, 2 }, { 50, 50, 80 }, 250 },
+ { { 1, 2, 2 }, { 100, 50, 80 }, 500 },
+ };
+
+ unsigned n;
+ wxWindow *child[NUM_TEST_ITEM];
+ for ( n = 0; n < NUM_TEST_ITEM; n++ )
+ child[n] = new wxWindow(m_win, wxID_ANY);
+
+ for ( unsigned i = 0; i < WXSIZEOF(calcMinTestData); i++ )
+ {
+ m_sizer->Clear();
+
+ const CalcMinTestData& cmtd = calcMinTestData[i];
+ for ( n = 0; n < NUM_TEST_ITEM; n++ )
+ {
+ if ( cmtd.prop[n] != -1 )
+ {
+ child[n]->SetInitialSize(wxSize(cmtd.minsize[n], -1));
+ m_sizer->Add(child[n], wxSizerFlags(cmtd.prop[n]));
+ }
+ }
+
+ WX_ASSERT_EQUAL_MESSAGE
+ (
+ ("In test #%u", i),
+ cmtd.total, m_sizer->CalcMin().x
+ );
+ }
+}