232fdc630c
Add a lot of tests for many wx GUI classes. Add tests using the new wxUIActionSimulator class but disable them under OS X as too many of them currently fail there. Refactor the test suite to make organizing the existing tests and adding the new ones easier. Improve documentation using the information gathered while testing the classes. Also update the documentation of the testing system itself. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65386 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
80 lines
1.9 KiB
C++
80 lines
1.9 KiB
C++
///////////////////////////////////////////////////////////////////////////////
|
|
// Name: testableframe.cpp
|
|
// Purpose: An improved wxFrame for unit-testing
|
|
// Author: Steven Lamerton
|
|
// RCS-ID: $Id:$
|
|
// Copyright: (c) 2010 Steven Lamerton
|
|
// Licence: wxWidgets licence
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
#include "testprec.h"
|
|
|
|
#ifdef __BORLANDC__
|
|
#pragma hdrstop
|
|
#endif
|
|
|
|
#include "wx/app.h"
|
|
#include "testableframe.h"
|
|
|
|
wxTestableFrame::wxTestableFrame() : wxFrame(NULL, wxID_ANY, "Test Frame")
|
|
{
|
|
}
|
|
|
|
void wxTestableFrame::OnEvent(wxEvent& evt)
|
|
{
|
|
m_count[evt.GetEventType()]++;
|
|
|
|
if(! evt.IsCommandEvent() )
|
|
evt.Skip();
|
|
}
|
|
|
|
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 total;
|
|
}
|
|
else
|
|
{
|
|
long count = m_count[type];
|
|
m_count[type] = 0;
|
|
return count;
|
|
}
|
|
}
|
|
|
|
EventCounter::EventCounter(wxWindow* win, wxEventType type) : m_type(type),
|
|
m_win(win)
|
|
|
|
{
|
|
m_frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
|
wxTestableFrame);
|
|
|
|
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_frame = NULL;
|
|
m_win = NULL;
|
|
}
|