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