]> git.saurik.com Git - wxWidgets.git/blob - tests/window/clientsize.cpp
Initialize wxXmlResourceHandler members in its ctor.
[wxWidgets.git] / tests / window / clientsize.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/clientsize.cpp
3 // Purpose: Client vs. window size handling unit test
4 // Author: Vaclav Slavik
5 // Created: 2008-02-12
6 // RCS-ID: $Id$
7 // Copyright: (c) 2008 Vaclav Slavik <vslavik@fastmail.fm>
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 // ----------------------------------------------------------------------------
26 // test class
27 // ----------------------------------------------------------------------------
28
29 class ClientSizeTestCase : public CppUnit::TestCase
30 {
31 public:
32 ClientSizeTestCase() { }
33
34 virtual void setUp();
35 virtual void tearDown();
36
37 private:
38 CPPUNIT_TEST_SUITE( ClientSizeTestCase );
39 CPPUNIT_TEST( ClientToWindow );
40 CPPUNIT_TEST( ClientSizeNotNegative );
41 CPPUNIT_TEST( WindowToClient );
42 CPPUNIT_TEST_SUITE_END();
43
44 void ClientToWindow();
45 void ClientSizeNotNegative();
46 void WindowToClient();
47
48 wxWindow *m_win;
49
50 DECLARE_NO_COPY_CLASS(ClientSizeTestCase)
51 };
52
53 // register in the unnamed registry so that these tests are run by default
54 CPPUNIT_TEST_SUITE_REGISTRATION( ClientSizeTestCase );
55
56 // also include in its own registry so that these tests can be run alone
57 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ClientSizeTestCase, "ClientSizeTestCase" );
58
59 // ----------------------------------------------------------------------------
60 // test initialization
61 // ----------------------------------------------------------------------------
62
63 void ClientSizeTestCase::setUp()
64 {
65 m_win = wxTheApp->GetTopWindow();
66 }
67
68 void ClientSizeTestCase::tearDown()
69 {
70 m_win = NULL;
71 }
72
73 // ----------------------------------------------------------------------------
74 // tests themselves
75 // ----------------------------------------------------------------------------
76
77 void ClientSizeTestCase::ClientToWindow()
78 {
79 CPPUNIT_ASSERT(m_win->GetSize() ==
80 m_win->ClientToWindowSize(m_win->GetClientSize()));
81 }
82
83 void ClientSizeTestCase::ClientSizeNotNegative()
84 {
85 wxWindow* w = new wxWindow(wxTheApp->GetTopWindow(), -1,
86 wxDefaultPosition, wxDefaultSize,
87 wxBORDER_THEME);
88 w->SetSize(wxSize(1,1));
89 const wxSize szw = w->GetClientSize();
90 CPPUNIT_ASSERT(szw.GetWidth() >= 0);
91 CPPUNIT_ASSERT(szw.GetHeight() >= 0);
92 w->Destroy();
93 }
94
95 void ClientSizeTestCase::WindowToClient()
96 {
97 CPPUNIT_ASSERT(m_win->GetClientSize() ==
98 m_win->WindowToClientSize(m_win->GetSize()));
99 }