]>
git.saurik.com Git - wxWidgets.git/blob - tests/window/clientsize.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/clientsize.cpp
3 // Purpose: Client vs. window size handling unit test
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2008 Vaclav Slavik <vslavik@fastmail.fm>
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
22 #include "wx/window.h"
25 // ----------------------------------------------------------------------------
27 // ----------------------------------------------------------------------------
29 class ClientSizeTestCase
: public CppUnit::TestCase
32 ClientSizeTestCase() { }
35 virtual void tearDown();
38 CPPUNIT_TEST_SUITE( ClientSizeTestCase
);
39 CPPUNIT_TEST( ClientToWindow
);
40 CPPUNIT_TEST( ClientSizeNotNegative
);
41 CPPUNIT_TEST( WindowToClient
);
42 CPPUNIT_TEST_SUITE_END();
44 void ClientToWindow();
45 void ClientSizeNotNegative();
46 void WindowToClient();
50 DECLARE_NO_COPY_CLASS(ClientSizeTestCase
)
53 // register in the unnamed registry so that these tests are run by default
54 CPPUNIT_TEST_SUITE_REGISTRATION( ClientSizeTestCase
);
56 // also include in its own registry so that these tests can be run alone
57 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ClientSizeTestCase
, "ClientSizeTestCase" );
59 // ----------------------------------------------------------------------------
60 // test initialization
61 // ----------------------------------------------------------------------------
63 void ClientSizeTestCase::setUp()
65 m_win
= wxTheApp
->GetTopWindow();
68 void ClientSizeTestCase::tearDown()
73 // ----------------------------------------------------------------------------
75 // ----------------------------------------------------------------------------
77 void ClientSizeTestCase::ClientToWindow()
79 CPPUNIT_ASSERT(m_win
->GetSize() ==
80 m_win
->ClientToWindowSize(m_win
->GetClientSize()));
83 void ClientSizeTestCase::ClientSizeNotNegative()
85 wxWindow
* w
= new wxWindow(wxTheApp
->GetTopWindow(), -1,
86 wxDefaultPosition
, wxDefaultSize
,
88 w
->SetSize(wxSize(1,1));
89 const wxSize szw
= w
->GetClientSize();
90 CPPUNIT_ASSERT(szw
.GetWidth() >= 0);
91 CPPUNIT_ASSERT(szw
.GetHeight() >= 0);
95 void ClientSizeTestCase::WindowToClient()
97 CPPUNIT_ASSERT(m_win
->GetClientSize() ==
98 m_win
->WindowToClientSize(m_win
->GetSize()));