]> git.saurik.com Git - wxWidgets.git/blame - tests/window/clientsize.cpp
Consistently handle DST start time in wxDateTime::Set().
[wxWidgets.git] / tests / window / clientsize.cpp
CommitLineData
301d7a0d
VS
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
301d7a0d
VS
6// Copyright: (c) 2008 Vaclav Slavik <vslavik@fastmail.fm>
7///////////////////////////////////////////////////////////////////////////////
8
9// ----------------------------------------------------------------------------
10// headers
11// ----------------------------------------------------------------------------
12
13#include "testprec.h"
14
15#ifdef __BORLANDC__
16 #pragma hdrstop
17#endif
18
19#ifndef WX_PRECOMP
20 #include "wx/app.h"
21 #include "wx/window.h"
22#endif // WX_PRECOMP
23
24// ----------------------------------------------------------------------------
25// test class
26// ----------------------------------------------------------------------------
27
28class ClientSizeTestCase : public CppUnit::TestCase
29{
30public:
31 ClientSizeTestCase() { }
32
33 virtual void setUp();
34 virtual void tearDown();
35
36private:
37 CPPUNIT_TEST_SUITE( ClientSizeTestCase );
38 CPPUNIT_TEST( ClientToWindow );
352a7d6c 39 CPPUNIT_TEST( ClientSizeNotNegative );
301d7a0d
VS
40 CPPUNIT_TEST( WindowToClient );
41 CPPUNIT_TEST_SUITE_END();
42
43 void ClientToWindow();
352a7d6c 44 void ClientSizeNotNegative();
301d7a0d
VS
45 void WindowToClient();
46
47 wxWindow *m_win;
48
49 DECLARE_NO_COPY_CLASS(ClientSizeTestCase)
50};
51
52// register in the unnamed registry so that these tests are run by default
53CPPUNIT_TEST_SUITE_REGISTRATION( ClientSizeTestCase );
54
e3778b4d 55// also include in its own registry so that these tests can be run alone
301d7a0d
VS
56CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ClientSizeTestCase, "ClientSizeTestCase" );
57
58// ----------------------------------------------------------------------------
59// test initialization
60// ----------------------------------------------------------------------------
61
62void ClientSizeTestCase::setUp()
63{
64 m_win = wxTheApp->GetTopWindow();
65}
66
67void ClientSizeTestCase::tearDown()
68{
69 m_win = NULL;
70}
71
72// ----------------------------------------------------------------------------
73// tests themselves
74// ----------------------------------------------------------------------------
75
76void ClientSizeTestCase::ClientToWindow()
77{
78 CPPUNIT_ASSERT(m_win->GetSize() ==
79 m_win->ClientToWindowSize(m_win->GetClientSize()));
80}
81
352a7d6c
VZ
82void ClientSizeTestCase::ClientSizeNotNegative()
83{
84 wxWindow* w = new wxWindow(wxTheApp->GetTopWindow(), -1,
85 wxDefaultPosition, wxDefaultSize,
86 wxBORDER_THEME);
87 w->SetSize(wxSize(1,1));
88 const wxSize szw = w->GetClientSize();
89 CPPUNIT_ASSERT(szw.GetWidth() >= 0);
90 CPPUNIT_ASSERT(szw.GetHeight() >= 0);
91 w->Destroy();
92}
93
301d7a0d
VS
94void ClientSizeTestCase::WindowToClient()
95{
96 CPPUNIT_ASSERT(m_win->GetClientSize() ==
97 m_win->WindowToClientSize(m_win->GetSize()));
98}