📄 runtestsdlg.cpp
字号:
//####COPYRIGHTBEGIN####//// ----------------------------------------------------------------------------// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.//// This program is part of the eCos host tools.//// This program is free software; you can redistribute it and/or modify it// under the terms of the GNU General Public License as published by the Free// Software Foundation; either version 2 of the License, or (at your option)// any later version.//// This program is distributed in the hope that it will be useful, but WITHOUT// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for// more details.//// You should have received a copy of the GNU General Public License along with// this program; if not, write to the Free Software Foundation, Inc.,// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.//// ----------------------------------------------------------------------------////####COPYRIGHTEND####// runtestsdlg.cpp :////===========================================================================//#####DESCRIPTIONBEGIN####//// Author(s): julians// Contact(s): julians// Date: 2000/09/29// Version: $Id: runtestsdlg.cpp,v 1.14 2001/06/29 13:48:22 julians Exp $// Purpose:// Description: Implementation file for ecRunTestsDialog// Requires:// Provides:// See also:// Known bugs:// Usage:////####DESCRIPTIONEND####////===========================================================================#ifdef __GNUG__ #pragma implementation "runtestsdlg.cpp"#endif#include "ecpch.h"#ifdef __BORLANDC__ #pragma hdrstop#endif#include "wx/notebook.h"#include "wx/cshelp.h"#include "wx/checklst.h"#include "wx/listctrl.h"#include "wx/tokenzr.h"#include "TestResource.h"#include "runtestsdlg.h"#include "configtool.h"#include "settingsdlg.h"#include "eCosThreadUtils.h"#include "eCosTrace.h"void ecRunTestsTimer::Notify(){ static bool s_inNotify = FALSE; if (s_inNotify) return; s_inNotify = TRUE; // On Windows, simply having the timer going will ping the message queue // and cause idle processing to happen. // On Unix, this doesn't happen so we have to do the processing explicitly.#ifdef __WXMSW__ // Nothing to do#else if ( ecRunTestsDialog::m_runTestsDialog ) { wxIdleEvent event; ecRunTestsDialog::m_runTestsDialog->OnIdle(event); }#endif s_inNotify = FALSE;}/* * Run Tests dialog */IMPLEMENT_CLASS(ecRunTestsDialog, wxDialog)BEGIN_EVENT_TABLE(ecRunTestsDialog, wxDialog) EVT_BUTTON(wxID_OK, ecRunTestsDialog::OnOK) EVT_BUTTON(ecID_RUN_TESTS_RUN, ecRunTestsDialog::OnRun) EVT_BUTTON(ecID_RUN_TESTS_PROPERTIES, ecRunTestsDialog::OnProperties) //EVT_BUTTON(wxID_HELP, ecRunTestsDialog::OnHelp) EVT_NOTEBOOK_PAGE_CHANGED(-1, ecRunTestsDialog::OnPageChange) EVT_SIZE(ecRunTestsDialog::OnSize) EVT_IDLE(ecRunTestsDialog::OnIdle) EVT_CLOSE(ecRunTestsDialog::OnCloseWindow)END_EVENT_TABLE()#define PROPERTY_DIALOG_WIDTH 600#define PROPERTY_DIALOG_HEIGHT 550ecRunTestsDialog* ecRunTestsDialog::m_runTestsDialog = NULL;// For 400x400 settings dialog, size your panels to about 375x325 in dialog editor// (209 x 162 dialog units)ecRunTestsDialog::ecRunTestsDialog(wxWindow* parent): wxDialog(), m_runStatus(ecStopped), m_nNextToSubmit(-1), m_pResource(NULL), m_testsAreComplete(FALSE){ m_runTestsDialog = this; SetExtraStyle(wxDIALOG_EX_CONTEXTHELP); wxDialog::Create(parent, ecID_RUN_TESTS_DIALOG, _("Run Tests"), wxPoint(0, 0), wxSize(PROPERTY_DIALOG_WIDTH, PROPERTY_DIALOG_HEIGHT), wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER); // Under MSW, we don't seem to be able to react to a click on the dialog background (no // event is generated). SetHelpText(_("Run tests from this dialog.")); wxScreenDC dc; wxSize ppi = dc.GetPPI(); //double scaleFactor = ((double) charH) / 13.0; double scaleFactor = ((double) ppi.y) / 96.0; // Fudge the scale factor to make the dialog slightly smaller, // otherwise it's a bit big. (We're assuming that most displays // are 96 or 120 ppi). if (ppi.y == 120) scaleFactor = 1.14; int dialogWidth = (int)(PROPERTY_DIALOG_WIDTH * scaleFactor); int dialogHeight = (int)(PROPERTY_DIALOG_HEIGHT * scaleFactor); SetSize(dialogWidth, dialogHeight); m_notebook = new wxNotebook(this, ecID_RUN_TESTS_NOTEBOOK, wxPoint(2, 2), wxSize(PROPERTY_DIALOG_WIDTH - 4, PROPERTY_DIALOG_HEIGHT - 4)); m_executables = new ecRunTestsExecutablesDialog(m_notebook); m_notebook->AddPage(m_executables, wxT("Executables")); m_executables->TransferDataToWindow(); m_output = new ecRunTestsOutputDialog(m_notebook); m_notebook->AddPage(m_output, wxT("Output")); m_output->TransferDataToWindow(); m_summary = new ecRunTestsSummaryDialog(m_notebook); m_notebook->AddPage(m_summary, wxT("Summary")); m_summary->TransferDataToWindow(); wxSizer *item0 = new wxBoxSizer( wxVERTICAL ); item0->Add( m_notebook, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 ); wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL ); wxButton *runButton = new wxButton( this, ecID_RUN_TESTS_RUN, "&Run", wxDefaultPosition, wxDefaultSize, 0 ); item1->Add( runButton, 0, wxALIGN_CENTRE|wxALL, 5 ); wxButton *okButton = new wxButton( this, wxID_OK, "&Close", wxDefaultPosition, wxDefaultSize, 0 ); item1->Add( okButton, 0, wxALIGN_CENTRE|wxALL, 5 ); wxButton *propertiesButton = new wxButton( this, ecID_RUN_TESTS_PROPERTIES, "&Properties...", wxDefaultPosition, wxDefaultSize, 0 ); item1->Add( propertiesButton, 0, wxALIGN_CENTRE|wxALL, 5 );/* wxButton *helpButton = new wxButton( this, wxID_HELP, "&Help", wxDefaultPosition, wxDefaultSize, 0 ); item1->Add( helpButton, 0, wxALIGN_CENTRE|wxALL, 5 );*/#ifdef __WXGTK__ // Context-sensitive help button (question mark) wxButton *contextButton = new wxContextHelpButton( this ); item1->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );#endif // Necessary to add a spacer or the button highlight interferes with the notebook under wxGTK item0->Add( 4, 4, 0, wxALIGN_CENTRE|wxALL, 0 ); item0->Add( item1, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 0 ); this->SetAutoLayout( TRUE ); this->SetSizer( item0 ); okButton->SetDefault(); okButton->SetFocus(); Layout(); m_executables->Layout(); m_output->Layout(); m_summary->Layout(); okButton->SetHelpText(_("Closes the dialog.")); runButton->SetHelpText(_("Runs one or more tests selected in the Executables window.")); propertiesButton->SetHelpText(_("Shows timeout and connection properties.")); //helpButton->SetHelpText(_("Invokes help for the selected dialog.")); Centre(wxBOTH); // TODO: Is this necessary?#if 0 m_prop.Add(_T("Active timeout"), wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeout); m_prop.Add(_T("Download timeout"), wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeout); m_prop.Add(_T("Active timeout type"), wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType); m_prop.Add(_T("Download timeout type"), wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType); m_prop.Add(_T("Remote"), wxGetApp().GetSettings().GetRunTestsSettings().m_bRemote); m_prop.Add(_T("Serial"), wxGetApp().GetSettings().GetRunTestsSettings().m_bSerial); m_prop.Add(_T("Port"), wxGetApp().GetSettings().GetRunTestsSettings().m_strPort); m_prop.Add(_T("Baud"), wxGetApp().GetSettings().GetRunTestsSettings().m_nBaud); m_prop.Add(_T("Local TCPIP Host"), wxGetApp().GetSettings().GetRunTestsSettings().m_strLocalTCPIPHost); m_prop.Add(_T("Local TCPIP Port"), wxGetApp().GetSettings().GetRunTestsSettings().m_nLocalTCPIPPort); m_prop.Add(_T("Reset Type"), wxGetApp().GetSettings().GetRunTestsSettings().m_nReset); m_prop.Add(_T("Reset String"), wxGetApp().GetSettings().GetRunTestsSettings().m_strReset); m_prop.Add(_T("Resource Host"), wxGetApp().GetSettings().GetRunTestsSettings().m_strResourceHost); m_prop.Add(_T("Resource Port"), wxGetApp().GetSettings().GetRunTestsSettings().m_nResourcePort); m_prop.Add(_T("Remote Host"), wxGetApp().GetSettings().GetRunTestsSettings().m_strRemoteHost); m_prop.Add(_T("Remote Port"), wxGetApp().GetSettings().GetRunTestsSettings().m_nRemotePort); // TODO //m_prop.Add(_T("Recurse"), executionpage.m_bRecurse); m_prop.Add(_T("Farmed"), wxGetApp().GetSettings().GetRunTestsSettings().m_bFarmed); // TODO // m_prop.Add(_T("Extension"),executionpage.m_strExtension);#endif#ifdef _DEBUG CeCosTrace::EnableTracing(CeCosTrace::TRACE_LEVEL_TRACE);#endif CeCosTrace::SetInteractive(TRUE); CeCosTrace::SetOutput(TestOutputCallback, this); CeCosTrace::SetError (TestOutputCallback, this); m_timer.Start(200);}ecRunTestsDialog::~ecRunTestsDialog(){ m_timer.Stop(); CeCosTrace::SetInteractive(FALSE); m_runTestsDialog = NULL; if (m_pResource) { delete m_pResource; }}void ecRunTestsDialog::OnOK(wxCommandEvent& event){ if (ecRunning == m_runStatus) { wxMessageBox(_("Tests are running. Please press Stop before quitting this dialog."), wxGetApp().GetSettings().GetAppName(), wxICON_INFORMATION|wxOK, this); return; } wxDialog::OnOK(event);}void ecRunTestsDialog::OnCloseWindow(wxCloseEvent& event){ if (ecRunning == m_runStatus) { wxMessageBox(_("Tests are running. Please press Stop before quitting this dialog."), wxGetApp().GetSettings().GetAppName(), wxICON_INFORMATION|wxOK, this); event.Veto(); return; } this->EndModal(wxID_CANCEL); this->Destroy();}void ecRunTestsDialog::OnProperties(wxCommandEvent& event){ ecSettingsDialog dialog(this); dialog.SetSelection(3); dialog.ShowModal();}void ecRunTestsDialog::OnRun(wxCommandEvent& event){ if (ecRunning == m_runStatus) { m_output->AddLogMsg(_("Run cancelled")); m_runStatus = ecStopping; m_CS.Enter(); m_nNextToSubmit=0x7fffffff; m_CS.Leave(); CeCosTest::CancelAllInstances(); } else { if ( 0 == m_executables->SelectedTestCount()) { wxMessageBox(_("No tests have been selected for execution."), wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK, this); return ; } else { m_ep = CeCosTest::ExecutionParameters( CeCosTest::ExecutionParameters::RUN, wxGetApp().GetSettings().GetRunTestsSettings().m_strTarget, TIMEOUT_NONE==wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType?0x7fffffff:TIMEOUT_AUTOMATIC==wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeoutType?900000:1000*wxGetApp().GetSettings().GetRunTestsSettings().m_nTimeout, TIMEOUT_NONE==wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType?0x7fffffff:TIMEOUT_AUTOMATIC==wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeoutType?0:1000*wxGetApp().GetSettings().GetRunTestsSettings().m_nDownloadTimeout); if ( wxGetApp().GetSettings().GetRunTestsSettings().m_bRemote ) { CTestResource::SetResourceServer(CeCosSocket::HostPort(wxGetApp().GetSettings().GetRunTestsSettings().m_strResourceHost, wxGetApp().GetSettings().GetRunTestsSettings().m_nResourcePort)); if (!CTestResource::Load()) { wxMessageBox(_("Could not connect to resource server."), wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK, this); return; } } else { wxString strPort; if (wxGetApp().GetSettings().GetRunTestsSettings().m_bSerial) strPort = wxGetApp().GetSettings().GetRunTestsSettings().m_strPort; else strPort = (const wxChar*) CeCosSocket::HostPort(wxGetApp().GetSettings().GetRunTestsSettings().m_strLocalTCPIPHost,wxGetApp().GetSettings().GetRunTestsSettings().m_nLocalTCPIPPort); if(0==strPort.Length()){ m_pResource=new CTestResource(_T(""),m_ep.PlatformName()); } else { // Translate from e.g. COM2 to /dev/ttyS1 on Unix. // Let's assume the Windows notation is the 'standard'. strPort = TranslatePort(strPort); int nBaud = wxGetApp().GetSettings().GetRunTestsSettings().m_bSerial ? wxGetApp().GetSettings().GetRunTestsSettings().m_nBaud:0; if (RESET_X10 != wxGetApp().GetSettings().GetRunTestsSettings().m_nReset) { m_pResource=new CTestResource(_T(""),m_ep.PlatformName(), strPort, nBaud); } else { m_pResource=new CTestResource(_T(""),m_ep.PlatformName(), strPort, nBaud, wxGetApp().GetSettings().GetRunTestsSettings().m_strReset); } } } m_runStatus = ecRunning; m_testsAreComplete = FALSE; wxButton* runButton = (wxButton*) FindWindow(ecID_RUN_TESTS_RUN); runButton->SetLabel(_("&Stop")); m_nNextToSubmit=0; m_output->AddLogMsg(_("Run started")); SubmitTests(); } }}wxString ecRunTestsDialog::TranslatePort(const wxString& port) const{#ifdef __WXGTK__ wxString name(port.Left(3)); if (name.CmpNoCase(wxT("COM")) == 0) { wxString strNum(port.Mid(3)); if (strNum.IsEmpty()) return port; int num = atoi(strNum); wxString newPort; newPort.Printf(wxT("/dev/ttyS%d"), num-1); return newPort; } else#endif return port;}void ecRunTestsDialog::SubmitTests(){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -