00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #ifdef __GNUG__
00014 #pragma implementation "CRTreeSelectionChangingEvent.h"
00015 #endif
00016
00017 #include "CRTreeSelectionChangingEvent.h"
00018
00019 #include <wxGuiTest/CRWindowHierarchyHandler.h>
00020 #include <wxGuiTest/CRCppEmitter.h>
00021
00022 using namespace wxTst;
00023
00024
00025 CRTreeSelectionChangingEvent::CRTreeSelectionChangingEvent (wxEvent *event) :
00026 CRAbstractTreeEvent (event)
00027 {
00028
00029 }
00030
00031
00032 CRTreeSelectionChangingEvent::~CRTreeSelectionChangingEvent ()
00033 {
00034
00035 }
00036
00037
00038 void CRTreeSelectionChangingEvent::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_treeCtrlName = wdwEvtObject->GetName ();
00046 m_containerName = hierarchy->FindContainerName (wdwEvtObject);
00047 wxASSERT (!m_containerName.IsEmpty ());
00048
00049 this->BuildTreeItemSiblingIdxHierarchyList ();
00050 }
00051
00052
00053 void CRTreeSelectionChangingEvent::EmitCpp ()
00054 {
00055
00056
00057
00058
00059
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 CRCppEmitter *emitter = CRCppEmitter::GetInstance ();
00085
00086 wxString containerVarName = emitter->AddContainerLookupCode (
00087 m_containerName, wxString::Format (_T("tree control '%s'"),
00088 m_treeCtrlName.c_str ()));
00089
00090 wxString treeCtrlWdwVarName = emitter->MakeVarName (m_treeCtrlName,
00091 _T("Wdw"));
00092
00093 wxString str;
00094 str << _T("wxWindow *") << treeCtrlWdwVarName << _T(" = ") <<
00095 containerVarName << _T("->FindWindow (");
00096 str << _T("_T(\"") << m_treeCtrlName << _T("\"));");
00097 emitter->AddCode (str);
00098
00099 str.Clear ();
00100 str << _T("CPPUNIT_ASSERT_MESSAGE (\"Window for tree control '") <<
00101 m_treeCtrlName << _T("' not found\", ") << treeCtrlWdwVarName <<
00102 _T(" != NULL);");
00103 emitter->AddCode (str);
00104
00105 wxString treeCtrlVarName = emitter->MakeVarName (m_treeCtrlName);
00106
00107 str.Clear ();
00108 str << _T("wxTreeCtrl *") << treeCtrlVarName << _T(" = wxDynamicCast (") <<
00109 treeCtrlWdwVarName << _T(", wxTreeCtrl);");
00110 emitter->AddCode (str);
00111
00112 str.Clear ();
00113 str << _T("CPPUNIT_ASSERT_MESSAGE (\"Converting window for tree control '") <<
00114 m_treeCtrlName << _T("' failed\", ") << treeCtrlVarName <<
00115 _T(" != NULL);");
00116 emitter->AddCode (str);
00117
00118 wxString rootIdVarName = _T("rootId");
00119
00120 str.Clear ();
00121 str << _T("wxTreeItemId ") << rootIdVarName << _T(" = ") << treeCtrlVarName <<
00122 _T("->GetRootItem ();");
00123 emitter->AddCode (str);
00124
00125 str.Clear ();
00126 str << _T("CPPUNIT_ASSERT_MESSAGE (\"Tree control root item is invalid\", ")
00127 << rootIdVarName << _T(".IsOk ());");
00128 emitter->AddCode (str);
00129
00130 wxString parentItemIdVarName = rootIdVarName;
00131
00132 unsigned int cnt;
00133 UnsignedIntList::const_iterator it;
00134 for (it = m_treeItemSiblingIdxHierarchyList.begin (), cnt = 1;
00135 it != m_treeItemSiblingIdxHierarchyList.end (); it++, cnt++) {
00136
00137 wxString curTreeItemIdVarName = emitter->MakeVarName (
00138 wxString::Format (_T("treeItemId%d"), cnt));
00139
00140 str.Clear ();
00141 str << _T("wxTreeItemId ") << curTreeItemIdVarName
00142 << _T(" = wxTst::EventSimulationHelper::GetNthTreeChild (")
00143 << treeCtrlVarName << _T(", ") << (*it) << _T(", ")
00144 << parentItemIdVarName << _T(");");
00145 emitter->AddCode (str);
00146
00147 str.Clear ();
00148 str << _T("CPPUNIT_ASSERT_MESSAGE (\"Tree control item is invalid\", ") <<
00149 curTreeItemIdVarName << _T(".IsOk ());");
00150 emitter->AddCode (str);
00151
00152 parentItemIdVarName = curTreeItemIdVarName;
00153 }
00154
00155 str.Clear ();
00156 str << _T("wxTst::EventSimulationHelper::SelectTreeItem (") <<
00157 parentItemIdVarName << _T(", ") << treeCtrlVarName << _T(");");
00158 emitter->AddCode (str);
00159
00160 str.Clear ();
00161 str << _T("wxTst::WxGuiTestHelper::FlushEventQueue ();\n");
00162 emitter->AddCode (str);
00163 }
00164
00165
00166