]> git.saurik.com Git - wxWidgets.git/blob - tests/toplevel/toplevel.cpp
Italian translations update from Stefano <l.stickell@@yahoo.it>.
[wxWidgets.git] / tests / toplevel / toplevel.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/toplevel/toplevel.cpp
3 // Purpose: Tests for wxTopLevelWindow
4 // Author: Kevin Ollivier
5 // Created: 2008-05-25
6 // RCS-ID: $Id$
7 // Copyright: (c) 2009 Kevin Ollivier <kevino@theolliviers.com>
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/dialog.h"
22 #include "wx/frame.h"
23 #include "wx/textctrl.h"
24 #include "wx/toplevel.h"
25 #endif // WX_PRECOMP
26
27 #include "wx/evtloop.h"
28
29 // ----------------------------------------------------------------------------
30 // test class
31 // ----------------------------------------------------------------------------
32
33 class TopLevelWindowTestCase : public CppUnit::TestCase
34 {
35 public:
36 TopLevelWindowTestCase() { }
37
38 virtual void setUp();
39 virtual void tearDown();
40
41 private:
42 CPPUNIT_TEST_SUITE( TopLevelWindowTestCase );
43 CPPUNIT_TEST( DialogShowTest );
44 CPPUNIT_TEST( FrameShowTest );
45 CPPUNIT_TEST_SUITE_END();
46
47 void DialogShowTest();
48 void FrameShowTest();
49 void TopLevelWindowShowTest(wxTopLevelWindow* tlw);
50
51 DECLARE_NO_COPY_CLASS(TopLevelWindowTestCase)
52 };
53
54 // register in the unnamed registry so that these tests are run by default
55 //CPPUNIT_TEST_SUITE_REGISTRATION( TopLevelWindowTestCase );
56
57 // also include in its own registry so that these tests can be run alone
58 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TopLevelWindowTestCase, "fixme" );
59
60 // ----------------------------------------------------------------------------
61 // test initialization
62 // ----------------------------------------------------------------------------
63
64 void TopLevelWindowTestCase::setUp()
65 {
66 }
67
68 void TopLevelWindowTestCase::tearDown()
69 {
70 }
71
72 // ----------------------------------------------------------------------------
73 // tests themselves
74 // ----------------------------------------------------------------------------
75
76 void TopLevelWindowTestCase::DialogShowTest()
77 {
78 wxDialog* dialog = new wxDialog(NULL, -1, "Dialog Test");
79 TopLevelWindowShowTest(dialog);
80 dialog->Destroy();
81 }
82
83 void TopLevelWindowTestCase::FrameShowTest()
84 {
85 wxFrame* frame = new wxFrame(NULL, -1, "Frame test");
86 TopLevelWindowShowTest(frame);
87 frame->Destroy();
88 }
89
90 void TopLevelWindowTestCase::TopLevelWindowShowTest(wxTopLevelWindow* tlw)
91 {
92 CPPUNIT_ASSERT(!tlw->IsShown());
93
94 wxTextCtrl* textCtrl = new wxTextCtrl(tlw, -1, "test");
95 textCtrl->SetFocus();
96
97 // only run this test on platforms where ShowWithoutActivating is implemented.
98 #if defined(__WXMSW__) || defined(__WXMAC__)
99 tlw->ShowWithoutActivating();
100 CPPUNIT_ASSERT(tlw->IsShown());
101 CPPUNIT_ASSERT(!tlw->IsActive());
102
103 tlw->Hide();
104 CPPUNIT_ASSERT(!tlw->IsShown());
105 CPPUNIT_ASSERT(!tlw->IsActive());
106 #endif
107
108 tlw->Show(true);
109 CPPUNIT_ASSERT(tlw->IsActive());
110 CPPUNIT_ASSERT(tlw->IsShown());
111
112 tlw->Hide();
113 CPPUNIT_ASSERT(!tlw->IsShown());
114 CPPUNIT_ASSERT(tlw->IsActive());
115 }