]> git.saurik.com Git - wxWidgets.git/blame_incremental - tests/testableframe.cpp
Convert wxFSW_EVENT_{WARNING,ERROR} to string correctly.
[wxWidgets.git] / tests / testableframe.cpp
... / ...
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: testableframe.cpp
3// Purpose: An improved wxFrame for unit-testing
4// Author: Steven Lamerton
5// RCS-ID: $Id$
6// Copyright: (c) 2010 Steven Lamerton
7// Licence: wxWindows licence
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{
34 return m_count[type];
35}
36
37void wxTestableFrame::ClearEventCount(wxEventType type)
38{
39 m_count[type] = 0;
40}
41
42EventCounter::EventCounter(wxWindow* win, wxEventType type) : m_type(type),
43 m_win(win)
44
45{
46 m_frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame);
47
48 m_win->Connect(m_type, wxEventHandler(wxTestableFrame::OnEvent),
49 NULL, m_frame);
50}
51
52EventCounter::~EventCounter()
53{
54 m_win->Disconnect(m_type, wxEventHandler(wxTestableFrame::OnEvent),
55 NULL, m_frame);
56
57 //This stops spurious counts from previous tests
58 Clear();
59
60 m_frame = NULL;
61 m_win = NULL;
62}