]> git.saurik.com Git - wxWidgets.git/blame - tests/toplevel/toplevel.cpp
No real changes, just spelling fixes to comments. Closes #15030.
[wxWidgets.git] / tests / toplevel / toplevel.cpp
CommitLineData
dbc7ceb9
KO
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/toplevel/toplevel.cpp
3// Purpose: Tests for wxTopLevelWindow
4// Author: Kevin Ollivier
5// Created: 2008-05-25
b5b208a1 6// RCS-ID: $Id$
dbc7ceb9
KO
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
1b54c33f
DS
21 #include "wx/dialog.h"
22 #include "wx/frame.h"
23 #include "wx/textctrl.h"
24 #include "wx/toplevel.h"
dbc7ceb9
KO
25#endif // WX_PRECOMP
26
27#include "wx/evtloop.h"
28
29// ----------------------------------------------------------------------------
30// test class
31// ----------------------------------------------------------------------------
32
33class TopLevelWindowTestCase : public CppUnit::TestCase
34{
35public:
36 TopLevelWindowTestCase() { }
37
dbc7ceb9
KO
38private:
39 CPPUNIT_TEST_SUITE( TopLevelWindowTestCase );
40 CPPUNIT_TEST( DialogShowTest );
41 CPPUNIT_TEST( FrameShowTest );
42 CPPUNIT_TEST_SUITE_END();
43
44 void DialogShowTest();
45 void FrameShowTest();
46 void TopLevelWindowShowTest(wxTopLevelWindow* tlw);
47
48 DECLARE_NO_COPY_CLASS(TopLevelWindowTestCase)
49};
50
51// register in the unnamed registry so that these tests are run by default
1b54c33f 52//CPPUNIT_TEST_SUITE_REGISTRATION( TopLevelWindowTestCase );
dbc7ceb9 53
e3778b4d 54// also include in its own registry so that these tests can be run alone
1b54c33f 55CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TopLevelWindowTestCase, "fixme" );
dbc7ceb9 56
dbc7ceb9
KO
57// ----------------------------------------------------------------------------
58// tests themselves
59// ----------------------------------------------------------------------------
60
61void TopLevelWindowTestCase::DialogShowTest()
62{
63 wxDialog* dialog = new wxDialog(NULL, -1, "Dialog Test");
64 TopLevelWindowShowTest(dialog);
65 dialog->Destroy();
66}
67
68void TopLevelWindowTestCase::FrameShowTest()
69{
70 wxFrame* frame = new wxFrame(NULL, -1, "Frame test");
71 TopLevelWindowShowTest(frame);
72 frame->Destroy();
73}
74
75void TopLevelWindowTestCase::TopLevelWindowShowTest(wxTopLevelWindow* tlw)
76{
77 CPPUNIT_ASSERT(!tlw->IsShown());
7cd60fb9 78
dbc7ceb9
KO
79 wxTextCtrl* textCtrl = new wxTextCtrl(tlw, -1, "test");
80 textCtrl->SetFocus();
7cd60fb9 81
dbc7ceb9 82// only run this test on platforms where ShowWithoutActivating is implemented.
1b54c33f 83#if defined(__WXMSW__) || defined(__WXMAC__)
dbc7ceb9
KO
84 tlw->ShowWithoutActivating();
85 CPPUNIT_ASSERT(tlw->IsShown());
86 CPPUNIT_ASSERT(!tlw->IsActive());
7cd60fb9 87
dbc7ceb9
KO
88 tlw->Hide();
89 CPPUNIT_ASSERT(!tlw->IsShown());
90 CPPUNIT_ASSERT(!tlw->IsActive());
91#endif
7cd60fb9 92
dbc7ceb9
KO
93 tlw->Show(true);
94 CPPUNIT_ASSERT(tlw->IsActive());
95 CPPUNIT_ASSERT(tlw->IsShown());
7cd60fb9 96
dbc7ceb9
KO
97 tlw->Hide();
98 CPPUNIT_ASSERT(!tlw->IsShown());
99 CPPUNIT_ASSERT(tlw->IsActive());
100}