void CRButtonClickEvent::EmitCpp () { // Expected emitting (XRC): /* wxWindow *evtSimHlpTestPanel = wxWindow::FindWindowByName ("EvtSimHlpTestPanel"); CPPUNIT_ASSERT_MESSAGE ("Container window for button 'Button' not found", evtSimHlpTestPanel != NULL); wxWindow *buttonWdw = evtSimHlpTestPanel->FindWindow (XRCID("Button")); CPPUNIT_ASSERT_MESSAGE ("Window for button 'Button' not found", buttonWdw != NULL); swTst::WxGuiTestEventSimulationHelper::ClickButton (buttonWdw->GetId (), buttonWdw); swTst::WxGuiTestHelper::FlushEventQueue (); */ // Or non-XRC: /* ... wxWindow *buttonWdw = evtSimHlpTestPanel->FindWindow ("Button"); ... */ CRCppEmitter *emitter = CRCppEmitter::GetInstance (); wxString containerVarName = emitter->AddContainerLookupCode ( m_containerName, wxString::Format ("button '%s'", m_buttonName.c_str ())); wxString buttonWdwVarName = emitter->MakeVarName (m_buttonName, "Wdw"); wxString str; str << "wxWindow *" << buttonWdwVarName << " = " << containerVarName << "->FindWindow ("; if (m_isXRC) { str << "XRCID(\"" << m_buttonName << "\"));"; } else { str << "\"" << m_buttonName << "\");"; } emitter->AddCode (str); str.Clear (); str << "CPPUNIT_ASSERT_MESSAGE (\"Window for button '" << m_buttonName << "' not found\", " << buttonWdwVarName << " != NULL);"; emitter->AddCode (str); str.Clear (); str << "swTst::WxGuiTestEventSimulationHelper::ClickButton (" << buttonWdwVarName << "->GetId (), " << buttonWdwVarName << ");"; emitter->AddCode (str); str.Clear (); str << "swTst::WxGuiTestHelper::FlushEventQueue ();\n"; emitter->AddCode (str); }
void CRSpinCtrlUpdateEvent::EmitCpp () { // Expected emitting (XRC): /* wxWindow *evtSimHlpTestPanel = wxWindow::FindWindowByName ( "EvtSimHlpTestPanel"); CPPUNIT_ASSERT_MESSAGE ("Container window for spin control 'Spinctrl' \ not found", evtSimHlpTestPanel != NULL); wxWindow *spinctrlWdw = evtSimHlpTestPanel->FindWindow (XRCID( "Spinctrl")); CPPUNIT_ASSERT_MESSAGE ("Window for spin control 'Spinctrl' not found", spinctrlWdw != NULL); SpinCtrl *spinctrl = wxDynamicCast (spinctrlWdw, SpinCtrl); CPPUNIT_ASSERT_MESSAGE ("Converting window for spin control 'Spinctrl' \ failed", spinctrl != NULL); wxTst::EventSimulationHelper::SetSpinctrlValueWithoutEvent ( spinctrl, 0.6); wxTst::WxGuiTestHelper::FlushEventQueue (); */ // Or non-XRC: /* ... wxWindow *spinctrlWdw = evtSimHlpTestPanel->FindWindow ("Spinctrl"); ... */ CRCppEmitter *emitter = CRCppEmitter::GetInstance (); wxString containerVarName = emitter->AddContainerLookupCode ( m_containerName, wxString::Format (_T("spin control '%s'"), m_spinCtrlName.c_str ())); wxString spinCtrlWdwVarName = emitter->MakeVarName(m_spinCtrlName, _T("Wdw")); wxString str; str << _T("wxWindow *") << spinCtrlWdwVarName << _T(" = ") << containerVarName << _T("->FindWindow ("); str << _T("_T(\"") << m_spinCtrlName << _T("\"));"); emitter->AddCode (str); str.Clear (); str << _T("CPPUNIT_ASSERT_MESSAGE (\"Window for spin control '") << m_spinCtrlName << _T("' not found\", ") << spinCtrlWdwVarName << _T(" != NULL);"); emitter->AddCode (str); wxString spinCtrlVarName = emitter->MakeVarName (m_spinCtrlName); str.Clear (); str << _T("wxSpinCtrl *") << spinCtrlVarName << _T(" = wxDynamicCast (") << spinCtrlWdwVarName << _T(", wxSpinCtrl);"); emitter->AddCode (str); str.Clear (); str << _T("CPPUNIT_ASSERT_MESSAGE (\"Converting window for spin control '") << m_spinCtrlName << _T("' failed\", ") << spinCtrlVarName << _T(" != NULL);"); emitter->AddCode (str); str.Clear (); str << _T("wxTst::EventSimulationHelper::SetSpinCtrlValue (") << spinCtrlVarName << _T(", ") << m_spinCtrlValue << _T(");"); emitter->AddCode (str); str.Clear (); str << _T("wxTst::WxGuiTestHelper::FlushEventQueue ();\n"); emitter->AddCode (str); }
void CRTreeItemRightClickEvent::EmitCpp () { // Expected emitting (XRC): /* wxWindow *evtSimHlpTestPanel = wxWindow::FindWindowByName ( "EvtSimHlpTestPanel"); CPPUNIT_ASSERT_MESSAGE ("Container window for tree control 'TreeCtrl' not \ found", evtSimHlpTestPanel != NULL); wxWindow *treeCtrlWdw = evtSimHlpTestPanel->FindWindow (XRCID("TreeCtrl")); CPPUNIT_ASSERT_MESSAGE ("Window for tree control 'TreeCtrl' not found", treeCtrlWdw != NULL); wxTreeCtrl *treeCtrl = wxDynamicCast (treeCtrlWdw, wxTreeCtrl); CPPUNIT_ASSERT_MESSAGE ("Converting window for tree control 'TreeCtrl' \ failed", treeCtrl != NULL); wxTreeItemId rootId = treeCtrl->GetRootItem (); CPPUNIT_ASSERT_MESSAGE ("Tree control root item is invalid", rootId.IsOk ( )); treeCtrl->Expand (rootId); wxTreeItemId treeItemId1 = sw::TreeCtrl::GetNthChild (treeCtrl, 2, rootId); CPPUNIT_ASSERT_MESSAGE ("Tree control item is invalid", treeItemId1.IsOk ( )); wxTst::EventSimulationHelper::RightClickTreeItem (treeItemId1, treeCtrl); wxTst::WxGuiTestHelper::FlushEventQueue (); */ // Or non-XRC: /* ... wxWindow *treeCtrlWdw = evtSimHlpTestPanel->FindWindow ("TreeCtrl"); ... */ CRCppEmitter *emitter = CRCppEmitter::GetInstance (); wxString containerVarName = emitter->AddContainerLookupCode ( m_containerName, wxString::Format (_T("tree control '%s'"), m_treeCtrlName.c_str ())); wxString treeCtrlWdwVarName = emitter->MakeVarName (m_treeCtrlName, _T("Wdw")); wxString str; str << _T("wxWindow *") << treeCtrlWdwVarName << _T(" = ") << containerVarName << _T("->FindWindow ("); str << _T("_T(\"") << m_treeCtrlName << _T("\"));"); emitter->AddCode (str); str.Clear (); str << _T("CPPUNIT_ASSERT_MESSAGE (\"Window for tree control '") << m_treeCtrlName << _T("' not found\", ") << treeCtrlWdwVarName << _T(" != NULL);"); emitter->AddCode (str); wxString treeCtrlVarName = emitter->MakeVarName (m_treeCtrlName); str.Clear (); str << _T("wxTreeCtrl *") << treeCtrlVarName << _T(" = wxDynamicCast (") << treeCtrlWdwVarName << _T(", wxTreeCtrl);"); emitter->AddCode (str); str.Clear (); str << _T("CPPUNIT_ASSERT_MESSAGE (\"Converting window for tree control '") << m_treeCtrlName << _T("' failed\", ") << treeCtrlVarName << _T(" != NULL);"); emitter->AddCode (str); wxString rootIdVarName = _T("rootId"); str.Clear (); str << _T("wxTreeItemId ") << rootIdVarName << _T(" = ") << treeCtrlVarName << _T("->GetRootItem ();"); emitter->AddCode (str); str.Clear (); str << _T("CPPUNIT_ASSERT_MESSAGE (\"Tree control root item is invalid\", ") << rootIdVarName << _T(".IsOk ());"); emitter->AddCode (str); wxString parentItemIdVarName = rootIdVarName; unsigned int cnt; UnsignedIntList::const_iterator it; for (it = m_treeItemSiblingIdxHierarchyList.begin (), cnt = 1; it != m_treeItemSiblingIdxHierarchyList.end (); it++, cnt++) { // Right click event simulation requires the visibility of the tree // item due to bounding box calculations: str.Clear (); str << treeCtrlVarName << _T("->Expand (") << parentItemIdVarName << _T(");"); emitter->AddCode (str); wxString curTreeItemIdVarName = emitter->MakeVarName ( wxString::Format (_T("treeItemId%d"), cnt)); str.Clear (); str << _T("wxTreeItemId ") << curTreeItemIdVarName << _T(" = sw::TreeCtrl::GetNthChild (") << treeCtrlVarName << _T(", ") << (*it) << _T(", ") << parentItemIdVarName << _T(");"); emitter->AddCode (str); str.Clear (); str << _T("CPPUNIT_ASSERT_MESSAGE (\"Tree control item is invalid\", ") << curTreeItemIdVarName << _T(".IsOk ());"); emitter->AddCode (str); parentItemIdVarName = curTreeItemIdVarName; } str.Clear (); str << _T("wxTst::EventSimulationHelper::RightClickTreeItem (") << parentItemIdVarName << _T(", ") << treeCtrlVarName << _T(");"); emitter->AddCode (str); str.Clear (); str << _T("wxTst::WxGuiTestHelper::FlushEventQueue ();\n"); emitter->AddCode (str); }
void CRCheckBoxClickEvent::EmitCpp () { // Expected emitting (XRC): /* wxWindow *evtSimHlpTestPanel = wxWindow::FindWindowByName ( "EvtSimHlpTestPanel"); CPPUNIT_ASSERT_MESSAGE ("Container window for check box 'Checkbox' not \ found", evtSimHlpTestPanel != NULL); wxWindow *checkboxWdw = evtSimHlpTestPanel->FindWindow (XRCID("Checkbox")); CPPUNIT_ASSERT_MESSAGE ("Window for check box 'Checkbox' not found", checkboxWdw != NULL); wxCheckBox *checkbox = wxDynamicCast (checkboxWdw, wxCheckBox); CPPUNIT_ASSERT_MESSAGE ("Converting window for check box 'Checkbox' \ failed", checkbox != NULL); swTst::WxGuiTestEventSimulationHelper::SetCheckboxState (checkbox, true); swTst::WxGuiTestHelper::FlushEventQueue (); */ // Or non-XRC: /* ... wxWindow *checkboxWdw = evtSimHlpTestPanel->FindWindow ("Checkbox"); ... */ CRCppEmitter *emitter = CRCppEmitter::GetInstance (); wxString containerVarName = emitter->AddContainerLookupCode ( m_containerName, wxString::Format ("check box '%s'", m_checkBoxName.c_str ())); wxString checkBoxWdwVarName = emitter->MakeVarName (m_checkBoxName, "Wdw"); wxString str; str << "wxWindow *" << checkBoxWdwVarName << " = " << containerVarName << "->FindWindow ("; if (m_isXRC) { str << "XRCID(\"" << m_checkBoxName << "\"));"; } else { str << "\"" << m_checkBoxName << "\");"; } emitter->AddCode (str); str.Clear (); str << "CPPUNIT_ASSERT_MESSAGE (\"Window for check box '" << m_checkBoxName << "' not found\", " << checkBoxWdwVarName << " != NULL);"; emitter->AddCode (str); wxString checkBoxVarName = emitter->MakeVarName (m_checkBoxName); str.Clear (); str << "wxCheckBox *" << checkBoxVarName << " = wxDynamicCast (" << checkBoxWdwVarName << ", wxCheckBox);"; emitter->AddCode (str); str.Clear (); str << "CPPUNIT_ASSERT_MESSAGE (\"Converting window for check box '" << m_checkBoxName << "' failed\", " << checkBoxVarName << " != NULL);"; emitter->AddCode (str); wxString isCheckedBoolStr = m_isChecked ? "true" : "false"; str.Clear (); str << "swTst::WxGuiTestEventSimulationHelper::SetCheckboxState (" << checkBoxVarName << ", " << isCheckedBoolStr << ");"; emitter->AddCode (str); str.Clear (); str << "swTst::WxGuiTestHelper::FlushEventQueue ();\n"; emitter->AddCode (str); }
void CRChoiceSelectionEvent::EmitCpp () { // Expected emitting (XRC): /* wxWindow *evtSimHlpTestPanel = wxWindow::FindWindowByName ( "EvtSimHlpTestPanel"); CPPUNIT_ASSERT_MESSAGE ("Container window for choice 'Choice' not found", evtSimHlpTestPanel != NULL); wxWindow *choiceWdw = evtSimHlpTestPanel->FindWindow (XRCID("Choice")); CPPUNIT_ASSERT_MESSAGE ("Window for choice 'Choice' not found", choiceWdw != NULL); wxChoice *choice = wxDynamicCast (choiceWdw, wxChoice); CPPUNIT_ASSERT_MESSAGE ("Converting window for choice 'Choice' failed", choice != NULL); const wxString choiceSelectionText (_("Item2")); int choiceSelection = choice->FindString (choiceSelectionText); wxTst::EventSimulationHelper::SelectChoiceItem (choice, choiceSelection); wxTst::WxGuiTestHelper::FlushEventQueue (); */ // Or non-XRC: /* ... wxWindow *choiceWdw = evtSimHlpTestPanel->FindWindow ("Choice"); ... */ CRCppEmitter *emitter = CRCppEmitter::GetInstance (); wxString containerVarName = emitter->AddContainerLookupCode ( m_containerName, wxString::Format (_T("choice '%s'"), m_choiceName.c_str ())); wxString choiceWdwVarName = emitter->MakeVarName (m_choiceName, _T("Wdw")); wxString str; str << _T("wxWindow *") << choiceWdwVarName << _T(" = ") << containerVarName << _T("->FindWindow ("); str << _T("_T(\"") << m_choiceName << _T("\"));"); emitter->AddCode (str); str.Clear (); str << _T("CPPUNIT_ASSERT_MESSAGE (\"Window for choice '") << m_choiceName << _T("' not found\", ") << choiceWdwVarName << _T(" != NULL);"); emitter->AddCode (str); wxString choiceVarName = emitter->MakeVarName (m_choiceName); str.Clear (); str << _T("wxChoice *") << choiceVarName << _T(" = wxDynamicCast (") << choiceWdwVarName << _T(", wxChoice);"); emitter->AddCode (str); str.Clear (); str << _T("CPPUNIT_ASSERT_MESSAGE (\"Converting window for choice '") << m_choiceName << _T("' failed\", ") << choiceVarName << _T(" != NULL);"); emitter->AddCode (str); wxString choiceSelTextVarName = emitter->MakeVarName (choiceVarName, _T("SelectionText")); str.Clear (); str << _T("const wxString ") << choiceSelTextVarName << _T(" (_(\"") << m_choiceValue << _T("\"));"); emitter->AddCode (str); wxString choiceSelVarName = emitter->MakeVarName (choiceVarName, _T("Selection")); str.Clear (); str << _T("int ") << choiceSelVarName << _T(" = ") << choiceVarName << _T("->FindString (") << choiceSelTextVarName << _T(");"); emitter->AddCode (str); str.Clear (); str << _T("wxTst::EventSimulationHelper::SelectChoiceItem (") << choiceVarName << _T(", ") << choiceSelVarName << _T(");"); emitter->AddCode (str); str.Clear (); str << _T("wxTst::WxGuiTestHelper::FlushEventQueue ();\n"); emitter->AddCode (str); }