]> git.saurik.com Git - wxWidgets.git/blame - tests/testableframe.cpp
Don't exclude tests from wxMSW-Setup.exe.
[wxWidgets.git] / tests / testableframe.cpp
CommitLineData
232fdc63
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: testableframe.cpp
3// Purpose: An improved wxFrame for unit-testing
4// Author: Steven Lamerton
4ceca854 5// RCS-ID: $Id$
232fdc63 6// Copyright: (c) 2010 Steven Lamerton
3fdcd5d5 7// Licence: wxWindows licence
232fdc63
VZ
8///////////////////////////////////////////////////////////////////////////////
9
10// For compilers that support precompilation, includes "wx/wx.h".
11#include "testprec.h"
12
13#ifdef __BORLANDC__
14 #pragma hdrstop
15#endif
16
17#include "wx/app.h"
18#include "testableframe.h"
19
20wxTestableFrame::wxTestableFrame() : wxFrame(NULL, wxID_ANY, "Test Frame")
21{
22}
23
24void wxTestableFrame::OnEvent(wxEvent& evt)
25{
26 m_count[evt.GetEventType()]++;
27
28 if(! evt.IsCommandEvent() )
29 evt.Skip();
30}
31
32int wxTestableFrame::GetEventCount(wxEventType type)
33{
744d91d4 34 return m_count[type];
232fdc63
VZ
35}
36
4ceca854
SL
37void wxTestableFrame::ClearEventCount(wxEventType type)
38{
39 m_count[type] = 0;
40}
41
232fdc63
VZ
42EventCounter::EventCounter(wxWindow* win, wxEventType type) : m_type(type),
43 m_win(win)
44
45{
744d91d4 46 m_frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame);
232fdc63 47
744d91d4
SL
48 m_win->Connect(m_type, wxEventHandler(wxTestableFrame::OnEvent),
49 NULL, m_frame);
232fdc63
VZ
50}
51
52EventCounter::~EventCounter()
53{
744d91d4
SL
54 m_win->Disconnect(m_type, wxEventHandler(wxTestableFrame::OnEvent),
55 NULL, m_frame);
232fdc63 56
4ceca854 57 //This stops spurious counts from previous tests
744d91d4 58 Clear();
4ceca854 59
232fdc63
VZ
60 m_frame = NULL;
61 m_win = NULL;
62}