]>
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 CPPUNIT_TEST_SUITE( TopLevelWindowTestCase
);
40 CPPUNIT_TEST( DialogShowTest
);
41 CPPUNIT_TEST( FrameShowTest
);
42 CPPUNIT_TEST_SUITE_END();
44 void DialogShowTest();
46 void TopLevelWindowShowTest(wxTopLevelWindow
* tlw
);
48 DECLARE_NO_COPY_CLASS(TopLevelWindowTestCase
)
51 // register in the unnamed registry so that these tests are run by default
52 //CPPUNIT_TEST_SUITE_REGISTRATION( TopLevelWindowTestCase );
54 // also include in its own registry so that these tests can be run alone
55 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TopLevelWindowTestCase
, "fixme" );
57 // ----------------------------------------------------------------------------
59 // ----------------------------------------------------------------------------
61 void TopLevelWindowTestCase::DialogShowTest()
63 wxDialog
* dialog
= new wxDialog(NULL
, -1, "Dialog Test");
64 TopLevelWindowShowTest(dialog
);
68 void TopLevelWindowTestCase::FrameShowTest()
70 wxFrame
* frame
= new wxFrame(NULL
, -1, "Frame test");
71 TopLevelWindowShowTest(frame
);
75 void TopLevelWindowTestCase::TopLevelWindowShowTest(wxTopLevelWindow
* tlw
)
77 CPPUNIT_ASSERT(!tlw
->IsShown());
79 wxTextCtrl
* textCtrl
= new wxTextCtrl(tlw
, -1, "test");
82 // only run this test on platforms where ShowWithoutActivating is implemented.
83 #if defined(__WXMSW__) || defined(__WXMAC__)
84 tlw
->ShowWithoutActivating();
85 CPPUNIT_ASSERT(tlw
->IsShown());
86 CPPUNIT_ASSERT(!tlw
->IsActive());
89 CPPUNIT_ASSERT(!tlw
->IsShown());
90 CPPUNIT_ASSERT(!tlw
->IsActive());
94 CPPUNIT_ASSERT(tlw
->IsActive());
95 CPPUNIT_ASSERT(tlw
->IsShown());
98 CPPUNIT_ASSERT(!tlw
->IsShown());
99 CPPUNIT_ASSERT(tlw
->IsActive());