]>
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
6 // Copyright: (c) 2008 Vaclav Slavik <vslavik@fastmail.fm>
7 ///////////////////////////////////////////////////////////////////////////////
9 // ----------------------------------------------------------------------------
11 // ----------------------------------------------------------------------------
21 #include "wx/window.h"
24 // ----------------------------------------------------------------------------
26 // ----------------------------------------------------------------------------
28 class ClientSizeTestCase
: public CppUnit::TestCase
31 ClientSizeTestCase() { }
34 virtual void tearDown();
37 CPPUNIT_TEST_SUITE( ClientSizeTestCase
);
38 CPPUNIT_TEST( ClientToWindow
);
39 CPPUNIT_TEST( ClientSizeNotNegative
);
40 CPPUNIT_TEST( WindowToClient
);
41 CPPUNIT_TEST_SUITE_END();
43 void ClientToWindow();
44 void ClientSizeNotNegative();
45 void WindowToClient();
49 DECLARE_NO_COPY_CLASS(ClientSizeTestCase
)
52 // register in the unnamed registry so that these tests are run by default
53 CPPUNIT_TEST_SUITE_REGISTRATION( ClientSizeTestCase
);
55 // also include in its own registry so that these tests can be run alone
56 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ClientSizeTestCase
, "ClientSizeTestCase" );
58 // ----------------------------------------------------------------------------
59 // test initialization
60 // ----------------------------------------------------------------------------
62 void ClientSizeTestCase::setUp()
64 m_win
= wxTheApp
->GetTopWindow();
67 void ClientSizeTestCase::tearDown()
72 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
76 void ClientSizeTestCase::ClientToWindow()
78 CPPUNIT_ASSERT(m_win
->GetSize() ==
79 m_win
->ClientToWindowSize(m_win
->GetClientSize()));
82 void ClientSizeTestCase::ClientSizeNotNegative()
84 wxWindow
* w
= new wxWindow(wxTheApp
->GetTopWindow(), -1,
85 wxDefaultPosition
, wxDefaultSize
,
87 w
->SetSize(wxSize(1,1));
88 const wxSize szw
= w
->GetClientSize();
89 CPPUNIT_ASSERT(szw
.GetWidth() >= 0);
90 CPPUNIT_ASSERT(szw
.GetHeight() >= 0);
94 void ClientSizeTestCase::WindowToClient()
96 CPPUNIT_ASSERT(m_win
->GetClientSize() ==
97 m_win
->WindowToClientSize(m_win
->GetSize()));