don't take the min size into account when setting the window size explicitly in wxGTK...
[wxWidgets.git] / tests / window / setsize.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/window/setsize.cpp
3 // Purpose: Tests for SetSize() and related wxWindow methods
4 // Author: Vadim Zeitlin
5 // Created: 2008-05-25
6 // RCS-ID: $Id$
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 ///////////////////////////////////////////////////////////////////////////////
9
10 // ----------------------------------------------------------------------------
11 // headers
12 // ----------------------------------------------------------------------------
13
14 #include "testprec.h"
15
16 #ifdef __BORLANDC__
17 #pragma hdrstop
18 #endif
19
20 #ifndef WX_PRECOMP
21 #include "wx/app.h"
22 #include "wx/window.h"
23 #endif // WX_PRECOMP
24
25 inline std::ostream& operator<<(std::ostream& o, const wxSize& s)
26 {
27 return o << s.x << 'x' << s.y;
28 }
29
30 // ----------------------------------------------------------------------------
31 // test class
32 // ----------------------------------------------------------------------------
33
34 class SetSizeTestCase : public CppUnit::TestCase
35 {
36 public:
37 SetSizeTestCase() { }
38
39 virtual void setUp();
40 virtual void tearDown();
41
42 private:
43 CPPUNIT_TEST_SUITE( SetSizeTestCase );
44 CPPUNIT_TEST( SetSize );
45 CPPUNIT_TEST( SetSizeLessThanMinSize );
46 CPPUNIT_TEST_SUITE_END();
47
48 void SetSize();
49 void SetSizeLessThanMinSize();
50
51 wxWindow *m_win;
52
53 DECLARE_NO_COPY_CLASS(SetSizeTestCase)
54 };
55
56 // register in the unnamed registry so that these tests are run by default
57 CPPUNIT_TEST_SUITE_REGISTRATION( SetSizeTestCase );
58
59 // also include in it's own registry so that these tests can be run alone
60 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SetSizeTestCase, "SetSizeTestCase" );
61
62 // ----------------------------------------------------------------------------
63 // test initialization
64 // ----------------------------------------------------------------------------
65
66 void SetSizeTestCase::setUp()
67 {
68 m_win = new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY);
69 }
70
71 void SetSizeTestCase::tearDown()
72 {
73 delete m_win;
74 m_win = NULL;
75 }
76
77 // ----------------------------------------------------------------------------
78 // tests themselves
79 // ----------------------------------------------------------------------------
80
81 void SetSizeTestCase::SetSize()
82 {
83 const wxSize size(127, 35);
84 m_win->SetSize(size);
85 CPPUNIT_ASSERT_EQUAL( size, m_win->GetSize() );
86 }
87
88 void SetSizeTestCase::SetSizeLessThanMinSize()
89 {
90 m_win->SetMinSize(wxSize(100, 100));
91
92 const wxSize size(200, 50);
93 m_win->SetSize(size);
94 CPPUNIT_ASSERT_EQUAL( size, m_win->GetSize() );
95 }
96