X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/232fdc630c42eb165f7659981043e794be03b3b7..0d1903dbda864780eec30efdc4e91776bdbfd21b:/tests/testableframe.cpp?ds=sidebyside diff --git a/tests/testableframe.cpp b/tests/testableframe.cpp index efa7396f26..b260adaa45 100644 --- a/tests/testableframe.cpp +++ b/tests/testableframe.cpp @@ -2,9 +2,8 @@ // Name: testableframe.cpp // Purpose: An improved wxFrame for unit-testing // Author: Steven Lamerton -// RCS-ID: $Id:$ // Copyright: (c) 2010 Steven Lamerton -// Licence: wxWidgets licence +// Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx/wx.h". @@ -31,48 +30,31 @@ void wxTestableFrame::OnEvent(wxEvent& evt) int wxTestableFrame::GetEventCount(wxEventType type) { - if (type == wxEVT_ANY) - { - //Get the total event count - long total = 0; - - for(wxLongToLongHashMap::iterator iter = m_count.begin(); - iter != m_count.end(); - iter++) - { - total += iter->second; - iter->second = 0; - } + return m_count[type]; +} - return total; - } - else - { - long count = m_count[type]; - m_count[type] = 0; - return count; - } +void wxTestableFrame::ClearEventCount(wxEventType type) +{ + m_count[type] = 0; } EventCounter::EventCounter(wxWindow* win, wxEventType type) : m_type(type), m_win(win) { - m_frame = wxStaticCast(wxTheApp->GetTopWindow(), - wxTestableFrame); + m_frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame); - m_win->Connect(m_type, - wxEventHandler(wxTestableFrame::OnEvent), - NULL, - m_frame); + m_win->Connect(m_type, wxEventHandler(wxTestableFrame::OnEvent), + NULL, m_frame); } EventCounter::~EventCounter() { - m_win->Disconnect(m_type, - wxEventHandler(wxTestableFrame::OnEvent), - NULL, - m_frame); + m_win->Disconnect(m_type, wxEventHandler(wxTestableFrame::OnEvent), + NULL, m_frame); + + //This stops spurious counts from previous tests + Clear(); m_frame = NULL; m_win = NULL;