]> git.saurik.com Git - wxWidgets.git/blob - tests/window/clientsize.cpp
add unit test for wxTextCtrl::GetInsertionPoint()
[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( WindowToClient );
41 CPPUNIT_TEST_SUITE_END();
42
43 void ClientToWindow();
44 void WindowToClient();
45
46 wxWindow *m_win;
47
48 DECLARE_NO_COPY_CLASS(ClientSizeTestCase)
49 };
50
51 // register in the unnamed registry so that these tests are run by default
52 CPPUNIT_TEST_SUITE_REGISTRATION( ClientSizeTestCase );
53
54 // also include in it's own registry so that these tests can be run alone
55 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ClientSizeTestCase, "ClientSizeTestCase" );
56
57 // ----------------------------------------------------------------------------
58 // test initialization
59 // ----------------------------------------------------------------------------
60
61 void ClientSizeTestCase::setUp()
62 {
63 m_win = wxTheApp->GetTopWindow();
64 }
65
66 void ClientSizeTestCase::tearDown()
67 {
68 m_win = NULL;
69 }
70
71 // ----------------------------------------------------------------------------
72 // tests themselves
73 // ----------------------------------------------------------------------------
74
75 void ClientSizeTestCase::ClientToWindow()
76 {
77 CPPUNIT_ASSERT(m_win->GetSize() ==
78 m_win->ClientToWindowSize(m_win->GetClientSize()));
79 }
80
81 void ClientSizeTestCase::WindowToClient()
82 {
83 CPPUNIT_ASSERT(m_win->GetClientSize() ==
84 m_win->WindowToClientSize(m_win->GetSize()));
85 }