X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5af86f4df50e22985c852afdcad1c7979d036b1b..bb03d283bef07de18d0dd584eb047d2f7e1b3856:/tests/window/setsize.cpp?ds=inline diff --git a/tests/window/setsize.cpp b/tests/window/setsize.cpp index 122cb0749a..b720b79335 100644 --- a/tests/window/setsize.cpp +++ b/tests/window/setsize.cpp @@ -22,10 +22,7 @@ #include "wx/window.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 @@ -43,10 +40,25 @@ private: CPPUNIT_TEST_SUITE( SetSizeTestCase ); CPPUNIT_TEST( SetSize ); CPPUNIT_TEST( SetSizeLessThanMinSize ); + CPPUNIT_TEST( BestSize ); CPPUNIT_TEST_SUITE_END(); void SetSize(); void SetSizeLessThanMinSize(); + void BestSize(); + + // Helper class overriding DoGetBestSize() for testing purposes. + class MyWindow : public wxWindow + { + public: + MyWindow(wxWindow* parent) + : wxWindow(parent, wxID_ANY) + { + } + + protected: + virtual wxSize DoGetBestSize() const { return wxSize(50, 250); } + }; wxWindow *m_win; @@ -56,7 +68,7 @@ private: // register in the unnamed registry so that these tests are run by default CPPUNIT_TEST_SUITE_REGISTRATION( SetSizeTestCase ); -// 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( SetSizeTestCase, "SetSizeTestCase" ); // ---------------------------------------------------------------------------- @@ -65,7 +77,7 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SetSizeTestCase, "SetSizeTestCase" ); void SetSizeTestCase::setUp() { - m_win = new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY); + m_win = new MyWindow(wxTheApp->GetTopWindow()); } void SetSizeTestCase::tearDown() @@ -94,3 +106,13 @@ void SetSizeTestCase::SetSizeLessThanMinSize() CPPUNIT_ASSERT_EQUAL( size, m_win->GetSize() ); } +void SetSizeTestCase::BestSize() +{ + CPPUNIT_ASSERT_EQUAL( wxSize(50, 250), m_win->GetBestSize() ); + + m_win->SetMinSize(wxSize(100, 100)); + CPPUNIT_ASSERT_EQUAL( wxSize(100, 250), m_win->GetBestSize() ); + + m_win->SetMaxSize(wxSize(200, 200)); + CPPUNIT_ASSERT_EQUAL( wxSize(100, 200), m_win->GetBestSize() ); +}