Skip to content
Newer
Older
100644 63 lines (48 sloc) 1.49 KB
232fdc6 @vadz Merge the new GUI tests from SOC2010_GUI_TEST branch.
vadz authored Aug 22, 2010
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: testableframe.cpp
3 // Purpose: An improved wxFrame for unit-testing
4 // Author: Steven Lamerton
4ceca85 @sjlamerton Add ClearEventCount to wxTestableFrame. This means we can clear an ev…
sjlamerton authored Sep 23, 2010
5 // RCS-ID: $Id$
232fdc6 @vadz Merge the new GUI tests from SOC2010_GUI_TEST branch.
vadz authored Aug 22, 2010
6 // Copyright: (c) 2010 Steven Lamerton
3fdcd5d @discnl Changed licence references to "wxWindows licence".
discnl authored Apr 4, 2011
7 // Licence: wxWindows licence
232fdc6 @vadz Merge the new GUI tests from SOC2010_GUI_TEST branch.
vadz authored Aug 22, 2010
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
20 wxTestableFrame::wxTestableFrame() : wxFrame(NULL, wxID_ANY, "Test Frame")
21 {
22 }
23
24 void wxTestableFrame::OnEvent(wxEvent& evt)
25 {
26 m_count[evt.GetEventType()]++;
27
28 if(! evt.IsCommandEvent() )
29 evt.Skip();
30 }
31
32 int wxTestableFrame::GetEventCount(wxEventType type)
33 {
744d91d @sjlamerton Move getting the unit test event count from wxTestableFrame to the Ev…
sjlamerton authored Mar 11, 2012
34 return m_count[type];
232fdc6 @vadz Merge the new GUI tests from SOC2010_GUI_TEST branch.
vadz authored Aug 22, 2010
35 }
36
4ceca85 @sjlamerton Add ClearEventCount to wxTestableFrame. This means we can clear an ev…
sjlamerton authored Sep 23, 2010
37 void wxTestableFrame::ClearEventCount(wxEventType type)
38 {
39 m_count[type] = 0;
40 }
41
232fdc6 @vadz Merge the new GUI tests from SOC2010_GUI_TEST branch.
vadz authored Aug 22, 2010
42 EventCounter::EventCounter(wxWindow* win, wxEventType type) : m_type(type),
43 m_win(win)
44
45 {
744d91d @sjlamerton Move getting the unit test event count from wxTestableFrame to the Ev…
sjlamerton authored Mar 11, 2012
46 m_frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame);
232fdc6 @vadz Merge the new GUI tests from SOC2010_GUI_TEST branch.
vadz authored Aug 22, 2010
47
744d91d @sjlamerton Move getting the unit test event count from wxTestableFrame to the Ev…
sjlamerton authored Mar 11, 2012
48 m_win->Connect(m_type, wxEventHandler(wxTestableFrame::OnEvent),
49 NULL, m_frame);
232fdc6 @vadz Merge the new GUI tests from SOC2010_GUI_TEST branch.
vadz authored Aug 22, 2010
50 }
51
52 EventCounter::~EventCounter()
53 {
744d91d @sjlamerton Move getting the unit test event count from wxTestableFrame to the Ev…
sjlamerton authored Mar 11, 2012
54 m_win->Disconnect(m_type, wxEventHandler(wxTestableFrame::OnEvent),
55 NULL, m_frame);
232fdc6 @vadz Merge the new GUI tests from SOC2010_GUI_TEST branch.
vadz authored Aug 22, 2010
56
4ceca85 @sjlamerton Add ClearEventCount to wxTestableFrame. This means we can clear an ev…
sjlamerton authored Sep 23, 2010
57 //This stops spurious counts from previous tests
744d91d @sjlamerton Move getting the unit test event count from wxTestableFrame to the Ev…
sjlamerton authored Mar 11, 2012
58 Clear();
4ceca85 @sjlamerton Add ClearEventCount to wxTestableFrame. This means we can clear an ev…
sjlamerton authored Sep 23, 2010
59
232fdc6 @vadz Merge the new GUI tests from SOC2010_GUI_TEST branch.
vadz authored Aug 22, 2010
60 m_frame = NULL;
61 m_win = NULL;
62 }
Something went wrong with that request. Please try again.