00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #ifdef __GNUG__
00014 #pragma implementation "CRRadioBoxSelectionEvent.h"
00015 #endif
00016
00017 #include "CRRadioBoxSelectionEvent.h"
00018
00019 #include <wxGuiTest/CRWindowHierarchyHandler.h>
00020 #include <wxGuiTest/CRCppEmitter.h>
00021
00022 using namespace wxTst;
00023
00024
00025 CRRadioBoxSelectionEvent::CRRadioBoxSelectionEvent (wxEvent *event) :
00026 CRCapturedEvent (event)
00027 {
00028
00029 }
00030
00031
00032 CRRadioBoxSelectionEvent::~CRRadioBoxSelectionEvent ()
00033 {
00034
00035 }
00036
00037
00038 void CRRadioBoxSelectionEvent::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
00046 m_radioBoxName = wdwEvtObject->GetName ();
00047 m_containerName = hierarchy->FindContainerName (wdwEvtObject);
00048 wxASSERT (!m_containerName.IsEmpty ());
00049
00050 wxASSERT (m_event->IsCommandEvent ());
00051 wxCommandEvent *cmdEvt = wxDynamicCast (m_event, wxCommandEvent);
00052 wxASSERT (cmdEvt != NULL);
00053 wxRadioBox *radioBox = wxDynamicCast (wdwEvtObject, wxRadioBox);
00054 wxASSERT (radioBox != NULL);
00055 m_radioBoxValue = radioBox->GetStringSelection ();
00056 }
00057
00058
00059 void CRRadioBoxSelectionEvent::EmitCpp ()
00060 {
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 CRCppEmitter *emitter = CRCppEmitter::GetInstance ();
00087
00088 wxString containerVarName = emitter->AddContainerLookupCode (
00089 m_containerName, wxString::Format (_T("radio box '%s'"),
00090 m_radioBoxName.c_str ()));
00091
00092 wxString radioBoxWdwVarName = emitter->MakeVarName (m_radioBoxName,
00093 _T("Wdw"));
00094
00095 wxString str;
00096 str << _T("wxWindow *") << radioBoxWdwVarName << _T(" = ") <<
00097 containerVarName << _T("->FindWindow (");
00098 str << _T("_T(\"") << m_radioBoxName << _T("\"));");
00099 emitter->AddCode (str);
00100
00101 str.Clear ();
00102 str << _T("CPPUNIT_ASSERT_MESSAGE (\"Window for radio box '") <<
00103 m_radioBoxName << _T("' not found\", ") << radioBoxWdwVarName <<
00104 _T(" != NULL);");
00105 emitter->AddCode (str);
00106
00107 wxString radioBoxVarName = emitter->MakeVarName (m_radioBoxName);
00108
00109 str.Clear ();
00110 str << _T("wxRadioBox *") << radioBoxVarName << _T(" = wxDynamicCast (") <<
00111 radioBoxWdwVarName << _T(", wxRadioBox);");
00112 emitter->AddCode (str);
00113
00114 str.Clear ();
00115 str << _T("CPPUNIT_ASSERT_MESSAGE (\"Converting window for radio box '") <<
00116 m_radioBoxName << _T("' failed\", ") << radioBoxVarName <<
00117 _T(" != NULL);");
00118 emitter->AddCode (str);
00119
00120 wxString radioBoxSelTextVarName = emitter->MakeVarName (radioBoxVarName,
00121 _T("SelectionText"));
00122
00123 str.Clear ();
00124 str << _T("const wxString ") << radioBoxSelTextVarName << _T(" (_(\"") <<
00125 m_radioBoxValue << _T("\"));");
00126 emitter->AddCode (str);
00127
00128 wxString radioBoxSelVarName = emitter->MakeVarName (radioBoxVarName,
00129 _T("Selection"));
00130
00131 str.Clear ();
00132 str << _T("int ") << radioBoxSelVarName << _T(" = ") << radioBoxVarName <<
00133 _T("->FindString (") << radioBoxSelTextVarName << _T(");");
00134 emitter->AddCode (str);
00135
00136 str.Clear ();
00137 str << _T("wxTst::EventSimulationHelper::SelectRadioBoxItem (") <<
00138 radioBoxVarName << _T(", ") << radioBoxSelVarName << _T(");");
00139 emitter->AddCode (str);
00140
00141 str.Clear ();
00142 str << _T("wxTst::WxGuiTestHelper::FlushEventQueue ();\n");
00143 emitter->AddCode (str);
00144 }
00145