]>
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 // Copyright: (c) 2009 Kevin Ollivier <kevino@theolliviers.com>
7 ///////////////////////////////////////////////////////////////////////////////
9 // ----------------------------------------------------------------------------
11 // ----------------------------------------------------------------------------
20 #include "wx/dialog.h"
22 #include "wx/textctrl.h"
23 #include "wx/toplevel.h"
26 #include "wx/evtloop.h"
28 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 class TopLevelWindowTestCase
: public CppUnit::TestCase
35 TopLevelWindowTestCase() { }
38 CPPUNIT_TEST_SUITE( TopLevelWindowTestCase
);
39 CPPUNIT_TEST( DialogShowTest
);
40 CPPUNIT_TEST( FrameShowTest
);
41 CPPUNIT_TEST_SUITE_END();
43 void DialogShowTest();
45 void TopLevelWindowShowTest(wxTopLevelWindow
* tlw
);
47 DECLARE_NO_COPY_CLASS(TopLevelWindowTestCase
)
50 // register in the unnamed registry so that these tests are run by default
51 //CPPUNIT_TEST_SUITE_REGISTRATION( TopLevelWindowTestCase );
53 // also include in its own registry so that these tests can be run alone
54 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TopLevelWindowTestCase
, "fixme" );
56 // ----------------------------------------------------------------------------
58 // ----------------------------------------------------------------------------
60 void TopLevelWindowTestCase::DialogShowTest()
62 wxDialog
* dialog
= new wxDialog(NULL
, -1, "Dialog Test");
63 TopLevelWindowShowTest(dialog
);
67 void TopLevelWindowTestCase::FrameShowTest()
69 wxFrame
* frame
= new wxFrame(NULL
, -1, "Frame test");
70 TopLevelWindowShowTest(frame
);
74 void TopLevelWindowTestCase::TopLevelWindowShowTest(wxTopLevelWindow
* tlw
)
76 CPPUNIT_ASSERT(!tlw
->IsShown());
78 wxTextCtrl
* textCtrl
= new wxTextCtrl(tlw
, -1, "test");
81 // only run this test on platforms where ShowWithoutActivating is implemented.
82 #if defined(__WXMSW__) || defined(__WXMAC__)
83 tlw
->ShowWithoutActivating();
84 CPPUNIT_ASSERT(tlw
->IsShown());
85 CPPUNIT_ASSERT(!tlw
->IsActive());
88 CPPUNIT_ASSERT(!tlw
->IsShown());
89 CPPUNIT_ASSERT(!tlw
->IsActive());
93 CPPUNIT_ASSERT(tlw
->IsActive());
94 CPPUNIT_ASSERT(tlw
->IsShown());
97 CPPUNIT_ASSERT(!tlw
->IsShown());
98 CPPUNIT_ASSERT(tlw
->IsActive());