]> git.saurik.com Git - wxWidgets.git/blob - tests/testableframe.h
Use wxCOMPtr throughout wxWebViewIE to simplify the code and reduce the chance of...
[wxWidgets.git] / tests / testableframe.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: testableframe.h
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 #include "wx/frame.h"
11 #include "wx/hashmap.h"
12 #include "wx/event.h"
13
14 class wxTestableFrame : public wxFrame
15 {
16 public:
17 wxTestableFrame();
18
19 void OnEvent(wxEvent& evt);
20
21 private:
22 friend class EventCounter;
23
24 int GetEventCount(wxEventType type);
25 void ClearEventCount(wxEventType type);
26
27 wxLongToLongHashMap m_count;
28 };
29
30 class EventCounter
31 {
32 public:
33 EventCounter(wxWindow* win, wxEventType type);
34 ~EventCounter();
35
36 int GetCount() { return m_frame->GetEventCount(m_type); }
37 void Clear() { m_frame->ClearEventCount(m_type); }
38
39 private:
40 wxEventType m_type;
41 wxTestableFrame* m_frame;
42 wxWindow* m_win;
43 };