]>
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
7 // Copyright: (c) 2009 Kevin Ollivier <kevino@theolliviers.com>
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
21 #include "wx/dialog.h"
23 #include "wx/textctrl.h"
24 #include "wx/toplevel.h"
27 #include "wx/evtloop.h"
29 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
33 class TopLevelWindowTestCase
: public CppUnit::TestCase
36 TopLevelWindowTestCase() { }
39 virtual void tearDown();
42 CPPUNIT_TEST_SUITE( TopLevelWindowTestCase
);
43 CPPUNIT_TEST( DialogShowTest
);
44 CPPUNIT_TEST( FrameShowTest
);
45 CPPUNIT_TEST_SUITE_END();
47 void DialogShowTest();
49 void TopLevelWindowShowTest(wxTopLevelWindow
* tlw
);
51 DECLARE_NO_COPY_CLASS(TopLevelWindowTestCase
)
54 // register in the unnamed registry so that these tests are run by default
55 //CPPUNIT_TEST_SUITE_REGISTRATION( TopLevelWindowTestCase );
57 // also include in its own registry so that these tests can be run alone
58 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TopLevelWindowTestCase
, "fixme" );
60 // ----------------------------------------------------------------------------
61 // test initialization
62 // ----------------------------------------------------------------------------
64 void TopLevelWindowTestCase::setUp()
68 void TopLevelWindowTestCase::tearDown()
72 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
76 void TopLevelWindowTestCase::DialogShowTest()
78 wxDialog
* dialog
= new wxDialog(NULL
, -1, "Dialog Test");
79 TopLevelWindowShowTest(dialog
);
83 void TopLevelWindowTestCase::FrameShowTest()
85 wxFrame
* frame
= new wxFrame(NULL
, -1, "Frame test");
86 TopLevelWindowShowTest(frame
);
90 void TopLevelWindowTestCase::TopLevelWindowShowTest(wxTopLevelWindow
* tlw
)
92 CPPUNIT_ASSERT(!tlw
->IsShown());
94 wxTextCtrl
* textCtrl
= new wxTextCtrl(tlw
, -1, "test");
97 // only run this test on platforms where ShowWithoutActivating is implemented.
98 #if defined(__WXMSW__) || defined(__WXMAC__)
99 tlw
->ShowWithoutActivating();
100 CPPUNIT_ASSERT(tlw
->IsShown());
101 CPPUNIT_ASSERT(!tlw
->IsActive());
104 CPPUNIT_ASSERT(!tlw
->IsShown());
105 CPPUNIT_ASSERT(!tlw
->IsActive());
109 CPPUNIT_ASSERT(tlw
->IsActive());
110 CPPUNIT_ASSERT(tlw
->IsShown());
113 CPPUNIT_ASSERT(!tlw
->IsShown());
114 CPPUNIT_ASSERT(tlw
->IsActive());