]>
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
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
22 #include "wx/window.h"
25 #include "asserthelper.h"
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 class SetSizeTestCase
: public CppUnit::TestCase
37 virtual void tearDown();
40 CPPUNIT_TEST_SUITE( SetSizeTestCase
);
41 CPPUNIT_TEST( SetSize
);
42 CPPUNIT_TEST( SetSizeLessThanMinSize
);
43 CPPUNIT_TEST( BestSize
);
44 CPPUNIT_TEST_SUITE_END();
47 void SetSizeLessThanMinSize();
50 // Helper class overriding DoGetBestSize() for testing purposes.
51 class MyWindow
: public wxWindow
54 MyWindow(wxWindow
* parent
)
55 : wxWindow(parent
, wxID_ANY
)
60 virtual wxSize
DoGetBestSize() const { return wxSize(50, 250); }
65 DECLARE_NO_COPY_CLASS(SetSizeTestCase
)
68 // register in the unnamed registry so that these tests are run by default
69 CPPUNIT_TEST_SUITE_REGISTRATION( SetSizeTestCase
);
71 // also include in its own registry so that these tests can be run alone
72 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SetSizeTestCase
, "SetSizeTestCase" );
74 // ----------------------------------------------------------------------------
75 // test initialization
76 // ----------------------------------------------------------------------------
78 void SetSizeTestCase::setUp()
80 m_win
= new MyWindow(wxTheApp
->GetTopWindow());
83 void SetSizeTestCase::tearDown()
89 // ----------------------------------------------------------------------------
91 // ----------------------------------------------------------------------------
93 void SetSizeTestCase::SetSize()
95 const wxSize
size(127, 35);
97 CPPUNIT_ASSERT_EQUAL( size
, m_win
->GetSize() );
100 void SetSizeTestCase::SetSizeLessThanMinSize()
102 m_win
->SetMinSize(wxSize(100, 100));
104 const wxSize
size(200, 50);
105 m_win
->SetSize(size
);
106 CPPUNIT_ASSERT_EQUAL( size
, m_win
->GetSize() );
109 void SetSizeTestCase::BestSize()
111 CPPUNIT_ASSERT_EQUAL( wxSize(50, 250), m_win
->GetBestSize() );
113 m_win
->SetMinSize(wxSize(100, 100));
114 CPPUNIT_ASSERT_EQUAL( wxSize(100, 250), m_win
->GetBestSize() );
116 m_win
->SetMaxSize(wxSize(200, 200));
117 CPPUNIT_ASSERT_EQUAL( wxSize(100, 200), m_win
->GetBestSize() );