]> git.saurik.com Git - wxWidgets.git/blob - tests/controls/frametest.cpp
Fixed dropdown height of wxChoice and wxComboBox controls.
[wxWidgets.git] / tests / controls / frametest.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/frametest.cpp
3 // Purpose: wxFrame unit test
4 // Author: Steven Lamerton
5 // Created: 2010-07-10
6 // RCS-ID: $Id$
7 // Copyright: (c) 2010 Steven Lamerton
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #include "testprec.h"
11
12 #ifdef __BORLANDC__
13 #pragma hdrstop
14 #endif
15
16 #ifndef WX_PRECOMP
17 #include "wx/app.h"
18 #include "wx/frame.h"
19 #endif // WX_PRECOMP
20
21 #include "testableframe.h"
22
23 class FrameTestCase : public CppUnit::TestCase
24 {
25 public:
26 FrameTestCase() { }
27
28 void setUp();
29 void tearDown();
30
31 private:
32 CPPUNIT_TEST_SUITE( FrameTestCase );
33 CPPUNIT_TEST( Iconize );
34 CPPUNIT_TEST( Close );
35 CPPUNIT_TEST_SUITE_END();
36
37 void Iconize();
38 void Close();
39
40 wxFrame *m_frame;
41
42 DECLARE_NO_COPY_CLASS(FrameTestCase)
43 };
44
45 // register in the unnamed registry so that these tests are run by default
46 CPPUNIT_TEST_SUITE_REGISTRATION( FrameTestCase );
47
48 // also include in its own registry so that these tests can be run alone
49 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FrameTestCase, "FrameTestCase" );
50
51 void FrameTestCase::setUp()
52 {
53 m_frame = new wxFrame(NULL, wxID_ANY, "test frame");
54 m_frame->Show();
55 }
56
57 void FrameTestCase::tearDown()
58 {
59 wxDELETE(m_frame);
60 }
61
62 void FrameTestCase::Iconize()
63 {
64 #ifdef __WXMSW__
65 wxTestableFrame* testframe = wxStaticCast(wxTheApp->GetTopWindow(),
66 wxTestableFrame);
67
68 EventCounter count(m_frame, wxEVT_ICONIZE);
69
70 m_frame->Iconize();
71 m_frame->Iconize(false);
72
73 CPPUNIT_ASSERT_EQUAL(2, testframe->GetEventCount());
74 #endif
75 }
76
77 void FrameTestCase::Close()
78 {
79 wxTestableFrame* testframe = wxStaticCast(wxTheApp->GetTopWindow(),
80 wxTestableFrame);
81
82 EventCounter count(m_frame, wxEVT_CLOSE_WINDOW);
83
84 m_frame->Close();
85
86 CPPUNIT_ASSERT_EQUAL(1, testframe->GetEventCount());
87 }