]> git.saurik.com Git - wxWidgets.git/blame - tests/toplevel/toplevel.cpp
Add CombineURIs implementation for wxWebFileProtocolHandler. Update the IE backend...
[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
38 virtual void setUp();
39 virtual void tearDown();
40
41private:
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
1b54c33f 55//CPPUNIT_TEST_SUITE_REGISTRATION( TopLevelWindowTestCase );
dbc7ceb9 56
e3778b4d 57// also include in its own registry so that these tests can be run alone
1b54c33f 58CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TopLevelWindowTestCase, "fixme" );
dbc7ceb9
KO
59
60// ----------------------------------------------------------------------------
61// test initialization
62// ----------------------------------------------------------------------------
63
64void TopLevelWindowTestCase::setUp()
65{
66}
67
68void TopLevelWindowTestCase::tearDown()
69{
70}
71
72// ----------------------------------------------------------------------------
73// tests themselves
74// ----------------------------------------------------------------------------
75
76void TopLevelWindowTestCase::DialogShowTest()
77{
78 wxDialog* dialog = new wxDialog(NULL, -1, "Dialog Test");
79 TopLevelWindowShowTest(dialog);
80 dialog->Destroy();
81}
82
83void TopLevelWindowTestCase::FrameShowTest()
84{
85 wxFrame* frame = new wxFrame(NULL, -1, "Frame test");
86 TopLevelWindowShowTest(frame);
87 frame->Destroy();
88}
89
90void 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.
1b54c33f 98#if defined(__WXMSW__) || defined(__WXMAC__)
dbc7ceb9
KO
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}