00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #ifdef __GNUG__
00014 #pragma implementation "CRButtonClickEvent.h"
00015 #endif
00016
00017 #include "CRButtonClickEvent.h"
00018
00019 #include <wxGuiTest/CRWindowHierarchyHandler.h>
00020 #include <wxGuiTest/CRCppEmitter.h>
00021
00022 using namespace wxTst;
00023
00024
00025 CRButtonClickEvent::CRButtonClickEvent (wxEvent *event) :
00026 CRCapturedEvent (event)
00027 {
00028
00029 }
00030
00031
00032 CRButtonClickEvent::~CRButtonClickEvent ()
00033 {
00034
00035 }
00036
00037
00038 void CRButtonClickEvent::Process (CRCapturedEvent** WXUNUSED(pendingEvt))
00039 {
00040 wxWindow *wdwEvtObject = wxDynamicCast (m_event->GetEventObject (), wxWindow);
00041 wxASSERT (wdwEvtObject != NULL);
00042
00043 CRWindowHierarchyHandler *hierarchy = CRWindowHierarchyHandler::GetInstance();
00044 wxASSERT (hierarchy != NULL);
00045 m_buttonName = wdwEvtObject->GetName ();
00046 m_containerName = hierarchy->FindContainerName (wdwEvtObject);
00047 wxASSERT (!m_containerName.IsEmpty ());
00048 }
00049
00050
00051 void CRButtonClickEvent::EmitCpp ()
00052 {
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 CRCppEmitter *emitter = CRCppEmitter::GetInstance ();
00074
00075 wxString containerVarName = emitter->AddContainerLookupCode (
00076 m_containerName, wxString::Format (_T("button '%s'"), m_buttonName.c_str ()));
00077
00078 wxString buttonWdwVarName = emitter->MakeVarName (m_buttonName, _T("Wdw"));
00079
00080 wxString str;
00081 str << _T("wxWindow *") << buttonWdwVarName << _T(" = ") << containerVarName <<
00082 _T("->FindWindow (");
00083 str << _T("_T(\"") << m_buttonName << _T("\"));");
00084 emitter->AddCode (str);
00085
00086 str.Clear ();
00087 str << _T("CPPUNIT_ASSERT_MESSAGE (\"Window for button '") << m_buttonName <<
00088 _T("' not found\", ") << buttonWdwVarName << _T(" != NULL);");
00089 emitter->AddCode (str);
00090
00091 str.Clear ();
00092 str << _T("wxTst::EventSimulationHelper::ClickButton (") <<
00093 buttonWdwVarName << _T("->GetId (), ") << buttonWdwVarName << _T(");");
00094 emitter->AddCode (str);
00095
00096 str.Clear ();
00097 str << _T("wxTst::WxGuiTestHelper::FlushEventQueue ();\n");
00098 emitter->AddCode (str);
00099 }
00100