]>
Commit | Line | Data |
---|---|---|
dbc7ceb9 KO |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: tests/toplevel/toplevel.cpp | |
3 | // Purpose: Tests for wxTopLevelWindow | |
4 | // Author: Kevin Ollivier | |
5 | // Created: 2008-05-25 | |
dbc7ceb9 KO |
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 | |
1b54c33f DS |
20 | #include "wx/dialog.h" |
21 | #include "wx/frame.h" | |
22 | #include "wx/textctrl.h" | |
23 | #include "wx/toplevel.h" | |
dbc7ceb9 KO |
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 | ||
dbc7ceb9 KO |
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 | |
1b54c33f | 51 | //CPPUNIT_TEST_SUITE_REGISTRATION( TopLevelWindowTestCase ); |
dbc7ceb9 | 52 | |
e3778b4d | 53 | // also include in its own registry so that these tests can be run alone |
1b54c33f | 54 | CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TopLevelWindowTestCase, "fixme" ); |
dbc7ceb9 | 55 | |
dbc7ceb9 KO |
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()); | |
7cd60fb9 | 77 | |
dbc7ceb9 KO |
78 | wxTextCtrl* textCtrl = new wxTextCtrl(tlw, -1, "test"); |
79 | textCtrl->SetFocus(); | |
7cd60fb9 | 80 | |
dbc7ceb9 | 81 | // only run this test on platforms where ShowWithoutActivating is implemented. |
1b54c33f | 82 | #if defined(__WXMSW__) || defined(__WXMAC__) |
dbc7ceb9 KO |
83 | tlw->ShowWithoutActivating(); |
84 | CPPUNIT_ASSERT(tlw->IsShown()); | |
85 | CPPUNIT_ASSERT(!tlw->IsActive()); | |
7cd60fb9 | 86 | |
dbc7ceb9 KO |
87 | tlw->Hide(); |
88 | CPPUNIT_ASSERT(!tlw->IsShown()); | |
89 | CPPUNIT_ASSERT(!tlw->IsActive()); | |
90 | #endif | |
7cd60fb9 | 91 | |
dbc7ceb9 KO |
92 | tlw->Show(true); |
93 | CPPUNIT_ASSERT(tlw->IsActive()); | |
94 | CPPUNIT_ASSERT(tlw->IsShown()); | |
7cd60fb9 | 95 | |
dbc7ceb9 KO |
96 | tlw->Hide(); |
97 | CPPUNIT_ASSERT(!tlw->IsShown()); | |
98 | CPPUNIT_ASSERT(tlw->IsActive()); | |
99 | } |