2010-08-22 22:16:05 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: testableframe.h
|
|
|
|
// Purpose: An improved wxFrame for unit-testing
|
|
|
|
// Author: Steven Lamerton
|
2010-09-23 16:55:29 +00:00
|
|
|
// RCS-ID: $Id$
|
2010-08-22 22:16:05 +00:00
|
|
|
// Copyright: (c) 2010 Steven Lamerton
|
2011-04-04 09:21:52 +00:00
|
|
|
// Licence: wxWindows licence
|
2010-08-22 22:16:05 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "wx/frame.h"
|
|
|
|
#include "wx/hashmap.h"
|
|
|
|
#include "wx/event.h"
|
|
|
|
|
|
|
|
class wxTestableFrame : public wxFrame
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxTestableFrame();
|
|
|
|
|
|
|
|
void OnEvent(wxEvent& evt);
|
|
|
|
|
2012-03-11 14:32:24 +00:00
|
|
|
private:
|
|
|
|
friend class EventCounter;
|
2010-08-22 22:16:05 +00:00
|
|
|
|
2012-03-11 14:32:24 +00:00
|
|
|
int GetEventCount(wxEventType type);
|
2010-09-23 16:55:29 +00:00
|
|
|
void ClearEventCount(wxEventType type);
|
|
|
|
|
2010-08-22 22:16:05 +00:00
|
|
|
wxLongToLongHashMap m_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
class EventCounter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
EventCounter(wxWindow* win, wxEventType type);
|
|
|
|
~EventCounter();
|
|
|
|
|
2012-03-11 14:32:24 +00:00
|
|
|
int GetCount() { return m_frame->GetEventCount(m_type); }
|
|
|
|
void Clear() { m_frame->ClearEventCount(m_type); }
|
|
|
|
|
2010-08-22 22:16:05 +00:00
|
|
|
private:
|
|
|
|
wxEventType m_type;
|
|
|
|
wxTestableFrame* m_frame;
|
|
|
|
wxWindow* m_win;
|
|
|
|
};
|