]>
git.saurik.com Git - wxWidgets.git/blob - tests/testableframe.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: testableframe.cpp
3 // Purpose: An improved wxFrame for unit-testing
4 // Author: Steven Lamerton
5 // Copyright: (c) 2010 Steven Lamerton
6 // Licence: wxWindows licence
7 ///////////////////////////////////////////////////////////////////////////////
9 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "testableframe.h"
19 wxTestableFrame::wxTestableFrame() : wxFrame(NULL
, wxID_ANY
, "Test Frame")
23 void wxTestableFrame::OnEvent(wxEvent
& evt
)
25 m_count
[evt
.GetEventType()]++;
27 if(! evt
.IsCommandEvent() )
31 int wxTestableFrame::GetEventCount(wxEventType type
)
36 void wxTestableFrame::ClearEventCount(wxEventType type
)
41 EventCounter::EventCounter(wxWindow
* win
, wxEventType type
) : m_type(type
),
45 m_frame
= wxStaticCast(wxTheApp
->GetTopWindow(), wxTestableFrame
);
47 m_win
->Connect(m_type
, wxEventHandler(wxTestableFrame::OnEvent
),
51 EventCounter::~EventCounter()
53 m_win
->Disconnect(m_type
, wxEventHandler(wxTestableFrame::OnEvent
),
56 //This stops spurious counts from previous tests