]>
git.saurik.com Git - wxWidgets.git/blob - tests/window/setsize.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/window/setsize.cpp
3 // Purpose: Tests for SetSize() and related wxWindow methods
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
7 ///////////////////////////////////////////////////////////////////////////////
9 // ----------------------------------------------------------------------------
11 // ----------------------------------------------------------------------------
21 #include "wx/window.h"
24 #include "asserthelper.h"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 class SetSizeTestCase
: public CppUnit::TestCase
36 virtual void tearDown();
39 CPPUNIT_TEST_SUITE( SetSizeTestCase
);
40 CPPUNIT_TEST( SetSize
);
41 CPPUNIT_TEST( SetSizeLessThanMinSize
);
42 CPPUNIT_TEST( BestSize
);
43 CPPUNIT_TEST_SUITE_END();
46 void SetSizeLessThanMinSize();
49 // Helper class overriding DoGetBestSize() for testing purposes.
50 class MyWindow
: public wxWindow
53 MyWindow(wxWindow
* parent
)
54 : wxWindow(parent
, wxID_ANY
)
59 virtual wxSize
DoGetBestSize() const { return wxSize(50, 250); }
64 DECLARE_NO_COPY_CLASS(SetSizeTestCase
)
67 // register in the unnamed registry so that these tests are run by default
68 CPPUNIT_TEST_SUITE_REGISTRATION( SetSizeTestCase
);
70 // also include in its own registry so that these tests can be run alone
71 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SetSizeTestCase
, "SetSizeTestCase" );
73 // ----------------------------------------------------------------------------
74 // test initialization
75 // ----------------------------------------------------------------------------
77 void SetSizeTestCase::setUp()
79 m_win
= new MyWindow(wxTheApp
->GetTopWindow());
82 void SetSizeTestCase::tearDown()
88 // ----------------------------------------------------------------------------
90 // ----------------------------------------------------------------------------
92 void SetSizeTestCase::SetSize()
94 const wxSize
size(127, 35);
96 CPPUNIT_ASSERT_EQUAL( size
, m_win
->GetSize() );
99 void SetSizeTestCase::SetSizeLessThanMinSize()
101 m_win
->SetMinSize(wxSize(100, 100));
103 const wxSize
size(200, 50);
104 m_win
->SetSize(size
);
105 CPPUNIT_ASSERT_EQUAL( size
, m_win
->GetSize() );
108 void SetSizeTestCase::BestSize()
110 CPPUNIT_ASSERT_EQUAL( wxSize(50, 250), m_win
->GetBestSize() );
112 m_win
->SetMinSize(wxSize(100, 100));
113 CPPUNIT_ASSERT_EQUAL( wxSize(100, 250), m_win
->GetBestSize() );
115 m_win
->SetMaxSize(wxSize(200, 200));
116 CPPUNIT_ASSERT_EQUAL( wxSize(100, 200), m_win
->GetBestSize() );