]>
git.saurik.com Git - wxWidgets.git/blob - tests/toplevel/toplevel.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/toplevel/toplevel.cpp
3 // Purpose: Tests for wxTopLevelWindow
4 // Author: Kevin Ollivier
6 // RCS-ID: $Id: toplevel.cpp 53741 2008-05-25 03:08:31Z VZ $
7 // Copyright: (c) 2009 Kevin Ollivier <kevino@theolliviers.com>
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
22 #include "wx/window.h"
25 #include "wx/evtloop.h"
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 class TopLevelWindowTestCase
: public CppUnit::TestCase
34 TopLevelWindowTestCase() { }
37 virtual void tearDown();
40 CPPUNIT_TEST_SUITE( TopLevelWindowTestCase
);
41 CPPUNIT_TEST( DialogShowTest
);
42 CPPUNIT_TEST( FrameShowTest
);
43 CPPUNIT_TEST_SUITE_END();
45 void DialogShowTest();
47 void TopLevelWindowShowTest(wxTopLevelWindow
* tlw
);
49 DECLARE_NO_COPY_CLASS(TopLevelWindowTestCase
)
52 // register in the unnamed registry so that these tests are run by default
53 CPPUNIT_TEST_SUITE_REGISTRATION( TopLevelWindowTestCase
);
55 // also include in it's own registry so that these tests can be run alone
56 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TopLevelWindowTestCase
, "TopLevelWindowTestCase" );
58 // ----------------------------------------------------------------------------
59 // test initialization
60 // ----------------------------------------------------------------------------
62 void TopLevelWindowTestCase::setUp()
66 void TopLevelWindowTestCase::tearDown()
70 // ----------------------------------------------------------------------------
72 // ----------------------------------------------------------------------------
74 void TopLevelWindowTestCase::DialogShowTest()
76 wxDialog
* dialog
= new wxDialog(NULL
, -1, "Dialog Test");
77 TopLevelWindowShowTest(dialog
);
81 void TopLevelWindowTestCase::FrameShowTest()
83 wxFrame
* frame
= new wxFrame(NULL
, -1, "Frame test");
84 TopLevelWindowShowTest(frame
);
88 void TopLevelWindowTestCase::TopLevelWindowShowTest(wxTopLevelWindow
* tlw
)
90 CPPUNIT_ASSERT(!tlw
->IsShown());
92 wxTextCtrl
* textCtrl
= new wxTextCtrl(tlw
, -1, "test");
95 // only run this test on platforms where ShowWithoutActivating is implemented.
96 #ifdef __WXMSW__ || defined(__WXMAC__)
97 tlw
->ShowWithoutActivating();
98 CPPUNIT_ASSERT(tlw
->IsShown());
99 CPPUNIT_ASSERT(!tlw
->IsActive());
102 CPPUNIT_ASSERT(!tlw
->IsShown());
103 CPPUNIT_ASSERT(!tlw
->IsActive());
107 CPPUNIT_ASSERT(tlw
->IsActive());
108 CPPUNIT_ASSERT(tlw
->IsShown());
111 CPPUNIT_ASSERT(!tlw
->IsShown());
112 CPPUNIT_ASSERT(tlw
->IsActive());