]> git.saurik.com Git - wxWidgets.git/blame - tests/window/setsize.cpp
Merge wxUIActionSimulator fixes from SOC2010_GUI_TEST branch.
[wxWidgets.git] / tests / window / setsize.cpp
CommitLineData
5af86f4d
VZ
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
25inline 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
34class SetSizeTestCase : public CppUnit::TestCase
35{
36public:
37 SetSizeTestCase() { }
38
39 virtual void setUp();
40 virtual void tearDown();
41
42private:
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
57CPPUNIT_TEST_SUITE_REGISTRATION( SetSizeTestCase );
58
59// also include in it's own registry so that these tests can be run alone
60CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SetSizeTestCase, "SetSizeTestCase" );
61
62// ----------------------------------------------------------------------------
63// test initialization
64// ----------------------------------------------------------------------------
65
66void SetSizeTestCase::setUp()
67{
68 m_win = new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY);
69}
70
71void SetSizeTestCase::tearDown()
72{
73 delete m_win;
74 m_win = NULL;
75}
76
77// ----------------------------------------------------------------------------
78// tests themselves
79// ----------------------------------------------------------------------------
80
81void SetSizeTestCase::SetSize()
82{
83 const wxSize size(127, 35);
84 m_win->SetSize(size);
85 CPPUNIT_ASSERT_EQUAL( size, m_win->GetSize() );
86}
87
88void 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