📄 runtestssheet.cpp
字号:
{ ((Info *)pParam)->pTest->RunRemote(NULL);}void CRunTestsSheet::SubmitTests(){ int nResources=m_bRemote?max(1,CTestResource::GetMatchCount (m_ep)):1; if(nResources>CeCosTest::InstanceCount){ if(m_nNextToSubmit>=executionpage.SelectedTestCount()){ return; } Info *pInfo=new Info; pInfo->pTest=new CeCosTest(m_ep, executionpage.SelectedTest(m_nNextToSubmit++)); pInfo->pSheet=this; m_nTestsToComplete++; if(m_bRemote){ CeCosThreadUtils::RunThread(RunRemoteFunc,pInfo,RunCallback,_T("RunRemoteFunc")); } else { bool bRun=false; if(CeCosTest::IsSim(m_ep.Target())){ bRun=true; } else { switch((ResetType)m_nReset){ case RESET_NONE: bRun=true; break; case RESET_X10: // Resetting can take a while, so spawn a thread bRun=false; { DWORD dwID; CloseHandle(CreateThread(0,0,X10ThreadFunc, pInfo, 0, &dwID)); } break; case RESET_MANUAL: bRun=(IDOK==MessageBox(_T("Press OK when target is reset - cancel to abort run"),NULL,MB_OKCANCEL)); if(!bRun){ m_nNextToSubmit=executionpage.SelectedTestCount(); RunCallback(pInfo); } break; } } if(bRun){ CeCosThreadUtils::RunThread(RunLocalFunc,pInfo,RunCallback,_T("RunLocalFunc")); } } }}void CRunTestsSheet::RunCallback(void *pParam){ Info *pInfo=(Info *)pParam; CRunTestsSheet *pSheet=pInfo->pSheet; if(::IsWindow(pSheet->m_hWnd)){ //FIXME CeCosTest *pTest=pInfo->pTest; EnterCriticalSection(&pSheet->m_CS); pSheet->summarypage.AddResult(pTest); delete pTest; pSheet->m_nTestsToComplete--; pSheet->SubmitTests(); if(0==pSheet->m_nTestsToComplete){ // It would be nice to do this in the handler for WM_RUNCOMPLETE, but we must be in the CS delete pSheet->m_pResource; pSheet->m_pResource=0; pSheet->PostMessage(WM_RUNCOMPLETE,0,0); } LeaveCriticalSection(&pSheet->m_CS); } delete pInfo;}LRESULT CRunTestsSheet::OnTestsComplete(WPARAM wParam, LPARAM lParam){ UNUSED_ALWAYS(wParam); UNUSED_ALWAYS(lParam); m_Status=Stopped; SetDlgItemText(IDOK,_T("&Run")); outputpage.AddLogMsg(_T("Run complete")); return 0;}void CALLBACK CRunTestsSheet::TestOutputCallback(void *pParam,LPCTSTR psz){ CRunTestsSheet*pWnd=(CRunTestsSheet*)pParam; if(::IsWindow(pWnd->m_hWnd)){ //FIXME LPTSTR pszCopy=new TCHAR[1+_tcslen(psz)]; _tcscpy(pszCopy,psz); pWnd->PostMessage(WM_TESTOUTPUT,(WPARAM)pszCopy,0); }}LRESULT CRunTestsSheet::OnTestOutput(WPARAM wParam, LPARAM lParam){ UNUSED_ALWAYS(lParam); LPTSTR psz=(LPTSTR)wParam; outputpage.AddText(psz); delete [] psz; return 0;}void CRunTestsSheet::OnProperties(){ CPropertiesDialog dlg(m_bHideTarget,m_bHideRemoteControls); dlg.m_strTarget=m_strTarget; dlg.m_nTimeout=m_nTimeout; dlg.m_nDownloadTimeout=m_nDownloadTimeout; dlg.m_nTimeoutType=m_nTimeoutType; dlg.m_nDownloadTimeoutType=m_nDownloadTimeoutType; dlg.m_bRemote=m_bRemote; dlg.m_bSerial=m_bSerial; dlg.m_strPort=m_strPort; dlg.m_nBaud=m_nBaud; dlg.m_strLocalTCPIPHost=m_strLocalTCPIPHost; dlg.m_nLocalTCPIPPort=m_nLocalTCPIPPort; dlg.m_nReset=m_nReset; dlg.m_strReset=m_strReset; dlg.m_strResourceHost=m_strResourceHost; dlg.m_nResourcePort=m_nResourcePort; dlg.m_strRemoteHost=m_strRemoteHost; dlg.m_nRemotePort=m_nRemotePort; dlg.m_strPort=m_strPort; dlg.m_bFarmed=m_bFarmed; if(IDOK==dlg.DoModal()){ m_strTarget=dlg.m_strTarget; m_nTimeout=dlg.m_nTimeout; m_nDownloadTimeout=dlg.m_nDownloadTimeout; m_nTimeoutType=dlg.m_nTimeoutType; m_nDownloadTimeoutType=dlg.m_nDownloadTimeoutType; m_bRemote=dlg.m_bRemote; m_bSerial=dlg.m_bSerial; m_strPort=dlg.m_strPort; m_nBaud=dlg.m_nBaud; m_strLocalTCPIPHost=dlg.m_strLocalTCPIPHost; m_nLocalTCPIPPort=dlg.m_nLocalTCPIPPort; m_nReset=dlg.m_nReset; m_strReset=dlg.m_strReset; m_strResourceHost=dlg.m_strResourceHost; m_nResourcePort=dlg.m_nResourcePort; m_strRemoteHost=dlg.m_strRemoteHost; m_nRemotePort=dlg.m_nRemotePort; m_bFarmed=dlg.m_bFarmed; if(m_pInitFunc){ m_pInitFunc(&m_prop,true); } }}void CRunTestsSheet::OnClose(){ if(m_pInitFunc){ WINDOWPLACEMENT wndpl; wndpl.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(&wndpl); if(!IsWindowVisible()){ wndpl.showCmd=SW_HIDE; } m_strPlacement.Format(_T("%d %d %d %d %d"), wndpl.rcNormalPosition.left, wndpl.rcNormalPosition.top, wndpl.rcNormalPosition.right, wndpl.rcNormalPosition.bottom, wndpl.showCmd); m_pInitFunc(&m_prop,true); } if(m_bModal){ EndDialog(IDOK); } else { DestroyWindow(); }}void CRunTestsSheet::OnSysCommand(UINT nID, LPARAM lParam) { if(SC_CLOSE==nID){ OnClose(); } else { CeCosPropertySheet::OnSysCommand(nID, lParam); }}void CRunTestsSheet::OnSize(UINT nType, int cx, int cy) { // WS_OVERLAPPEDWINDOW would preclude caption bar help button ModifyStyle(0,WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME ,0); CeCosPropertySheet::OnSize(nType, cx, cy); if(SIZE_MINIMIZED!=nType){ CRect rect; GetWindowRect(rect); TRACE(_T("OnSize(%d) left=%d top=%d right=%d bottom=%d ar=%d\n"),nType,rect.left,rect.top,rect.right,rect.bottom,m_bAllowResizing); m_rcOffset.left =rect.left-m_rcPrev.left; m_rcOffset.right =rect.right-m_rcPrev.right; m_rcOffset.top =rect.top-m_rcPrev.top; m_rcOffset.bottom=rect.bottom-m_rcPrev.bottom; m_rcPrev=rect; if(m_bAllowResizing){ cx=max(m_cxMin,cx); cy=max(m_cyMin,cy); MoveWindow(GetTabControl(),Stretch); CRect rc[sizeof(arIds)/sizeof(arIds[0])]; CRect rcSheet; GetWindowRect(rcSheet); for(int i=0;i<sizeof(arIds)/sizeof(arIds[0]);i++){ CWnd *pWnd=GetDlgItem(arIds[i]); if(pWnd){ pWnd->GetWindowRect(rc[i]); ScreenToClient(rc[i]); MoveWindow(pWnd,BottomRight,FALSE); } } for(i=0;i<sizeof(arIds)/sizeof(arIds[0]);i++){ CWnd *pWnd=GetDlgItem(arIds[i]); if(pWnd){ pWnd->Invalidate(); InvalidateRect(rc[i]); } else { TRACE(_T("Failed to find window id=%x\n"),arIds[i]); } } for(i=0;i<GetPageCount();i++){ MoveWindow(GetPage(i),Stretch); } } }}void CRunTestsSheet::MoveWindow(CWnd *pWnd, AffinityType Affinity,bool bRepaint){ if(m_bAllowResizing&&pWnd){ TRACE(_T("MoveWindow left=%d top=%d right=%d bottom=%d\n"),m_rcOffset.left,m_rcOffset.top,m_rcOffset.right,m_rcOffset.bottom); CRect rect; pWnd->GetWindowRect(rect); pWnd->GetParent()->ScreenToClient(rect); TRACE(_T(" left=%d top=%d right=%d bottom=%d"),rect.left,rect.top,rect.right,rect.bottom); int nHeight=rect.Height(); int nWidth=rect.Width(); switch(Affinity){ case BottomRight: rect.right +=m_rcOffset.Width(); rect.bottom+=m_rcOffset.Height(); rect.top =rect.bottom-nHeight; rect.left=rect.right -nWidth; break; case TopRight: rect.right +=m_rcOffset.Width(); rect.left=rect.right -nWidth; break; case BottomLeft: rect.top +=m_rcOffset.Height(); rect.right=rect.left+nWidth; break; case TopLeft: break; case Stretch: rect.right +=m_rcOffset.Width(); rect.bottom+=m_rcOffset.Height(); break; } TRACE(_T(" -> left=%d top=%d right=%d bottom=%d\n"),rect.left,rect.top,rect.right,rect.bottom); pWnd->MoveWindow(rect,bRepaint); }}void CRunTestsSheet::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { lpMMI->ptMinTrackSize.x = m_cxMin; lpMMI->ptMinTrackSize.y = 175; CeCosPropertySheet::OnGetMinMaxInfo(lpMMI);}LRESULT CRunTestsSheet::OnKickIdle(WPARAM, LPARAM){ // We could use WM_KICKIDLE to drive CMDUI messages, but in fact we just // use an OnKickIdle handler directly (here and in the pages) to control // button greying. bool bEnableRunStop=false; bool bEnableProperties=false; switch(m_Status){ case Running: bEnableRunStop=true; break; case Stopping: bEnableProperties=true; break; case Stopped: bEnableRunStop=executionpage.SomeTestsSelected(); bEnableProperties=true; break; } GetDlgItem(IDOK)->EnableWindow(bEnableRunStop); GetDlgItem(ID_APPLY_NOW)->EnableWindow(bEnableProperties); SendMessageToDescendants(WM_KICKIDLE, 0, 0, FALSE, FALSE); return 0;}BOOL CRunTestsSheet::PreTranslateMessage(MSG* pMsg) { if(WM_KEYDOWN==pMsg->message && VK_ESCAPE==pMsg->wParam){ return TRUE;// escape character handled } return CeCosPropertySheet::PreTranslateMessage(pMsg);}void CRunTestsSheet::SetTarget(LPCTSTR pszTarget){ m_strTarget=pszTarget; m_bHideTarget=true;}void CRunTestsSheet::HideRemoteControls(){ m_bHideRemoteControls=true;}void CRunTestsSheet::Populate(LPCTSTR pszFile,bool bSelect/*=true*/){ executionpage.m_arstrPreLoad.SetAt(pszFile,bSelect?this:0);}int CRunTestsSheet::DoModal() { m_bModal=true; return CeCosPropertySheet::DoModal();}void CRunTestsSheet::PostNcDestroy() { if(!m_bModal){ delete this; } else { CeCosPropertySheet::PostNcDestroy(); }}void CRunTestsSheet::OnTimer(UINT nIDEvent) { SendMessage(WM_KICKIDLE,0,0); CeCosPropertySheet::OnTimer(nIDEvent);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -