⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 runtestsdlg.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    int iTest;    int nResources=wxGetApp().GetSettings().GetRunTestsSettings().m_bRemote ? wxMax(1,CTestResource::GetMatchCount (m_ep)):1;    if(nResources>CeCosTest::InstanceCount){        if (m_nNextToSubmit >= m_executables->SelectedTestCount()){            m_runStatus = ecStopped;            wxButton* runButton = (wxButton*) FindWindow(ecID_RUN_TESTS_RUN);            runButton->SetLabel(_("&Run"));            m_output->AddLogMsg(_("Run complete"));            delete m_pResource;            m_pResource=0;            return;        }        ecRunTestsInfo *pInfo=new ecRunTestsInfo;        pInfo->pTest=new CeCosTest(m_ep, m_executables->SelectedTest(m_nNextToSubmit++));        pInfo->pSheet=this;        if(wxGetApp().GetSettings().GetRunTestsSettings().m_bRemote){            CeCosThreadUtils::RunThread(RunRemoteFunc,pInfo, (CeCosThreadUtils::CallbackProc*) RunCallback,_T("RunRemoteFunc"));        } else {            bool bRun=false;            switch((ResetType)wxGetApp().GetSettings().GetRunTestsSettings().m_nReset){            case RESET_NONE:                bRun=true;                break;            case RESET_X10:                {                    // Resetting can take a while, so spawn a thread                    bRun=false;                    ecResetThread* thread = new ecResetThread(pInfo);                    if (thread->Create() != wxTHREAD_NO_ERROR)                    {                        // Thread will be deleted automatically when it has finished running                        thread->Run();                    }                    else                        delete thread;                    break;                }            case RESET_MANUAL:                {                    bRun=(wxOK == wxMessageBox(_("Press OK when target is reset - cancel to abort run"),_("Reset board"), wxOK|wxCANCEL));                    if(!bRun)                    {                        m_nNextToSubmit = m_executables->SelectedTestCount();                        RunCallback(pInfo);                    }                    break;                }            }            if(bRun){                if (1 < m_nNextToSubmit)                      m_output->AddLogMsg(_("Run continuing"));                CeCosThreadUtils::RunThread(RunLocalFunc, pInfo, (CeCosThreadUtils::CallbackProc*) RunCallback,_T("RunLocalFunc"));            }        }    }}// thread execution starts herevoid *ecResetThread::Entry(){    wxString str;    String str1;    bool bOk=false;    CResetAttributes::ResetResult n=m_info->pSheet->m_pResource->Reset(str1);    str = str1;    if(CResetAttributes::RESET_OK!=n){        str += wxT(">>> Could not reset target\n");    }    str += wxT('\n');    m_info->pSheet->OutputToBuffer(str);    if(bOk){        // we're already in a thread, so we can call the function directly        m_info->pTest->RunLocal();    }    ecRunTestsDialog::RunCallback(m_info);    return NULL;}// called when the thread exits - whether it terminates normally or is// stopped with Delete() (but not when it is Kill()ed!)void ecResetThread::OnExit(){}void CALLBACK ecRunTestsDialog::RunLocalFunc(void *pParam){  ((ecRunTestsInfo *)pParam)->pTest->RunLocal();}void CALLBACK ecRunTestsDialog::RunRemoteFunc(void *pParam){  ((ecRunTestsInfo *)pParam)->pTest->RunRemote(NULL);}void ecRunTestsDialog::RunCallback(void *pParam){    ecRunTestsInfo *pInfo=(ecRunTestsInfo *)pParam;    ecRunTestsDialog *pSheet=pInfo->pSheet;    if (m_runTestsDialog) // Will be NULL if dialog has been closed & deleted    {        CeCosTest *pTest=pInfo->pTest;        pInfo->pSheet->m_CS.Enter();        pSheet->m_summary->AddResult(pTest);        delete pTest;        // OnIdle will check this variable and reset the status and button label        pSheet->m_testsAreComplete = TRUE;        pInfo->pSheet->m_CS.Leave();    }    delete pInfo;}void ecRunTestsDialog::OnIdle(wxIdleEvent& event){    FlushBuffer();    if (m_testsAreComplete)    {        m_testsAreComplete = FALSE;        SubmitTests();    }    event.Skip();}void CALLBACK ecRunTestsDialog::TestOutputCallback(void *pParam,LPCTSTR psz){    ecRunTestsDialog* pWnd = (ecRunTestsDialog*)pParam;    if (ecRunTestsDialog::m_runTestsDialog)    {        // FIXME: test output should not contain CR characters on non-Windows        // platforms so need to find the root of this problem#ifndef __WXMSW__        wxString output(psz);        output.Replace(wxT("\r"), wxEmptyString); // remove CR characters        pWnd->OutputToBuffer(output);#else        // FIXME ends        pWnd->OutputToBuffer(psz);#endif    }}// Write to the output buffer for OnIdle to pick upvoid ecRunTestsDialog::OutputToBuffer(const wxString& str){    wxCriticalSection ct;    ct.Enter();    if (m_outputBufferPresent)        m_outputBuffer += str;    else        m_outputBuffer = str;    m_outputBufferPresent = TRUE;    ct.Leave();}// Write any remaining textvoid ecRunTestsDialog::FlushBuffer(){    if (m_outputBufferPresent)    {        m_output->AddText(m_outputBuffer);        m_outputBuffer = wxEmptyString;        m_outputBufferPresent = FALSE;    }}#if 0void ecRunTestsDialog::OnHelp(wxCommandEvent& event){    int sel = m_notebook->GetSelection();    wxASSERT_MSG( (sel != -1), wxT("A notebook tab should always be selected."));    wxWindow* page = (wxWindow*) m_notebook->GetPage(sel);    wxString helpTopic;    if (page == m_displayOptions)    {        helpTopic = wxT("Display options dialog");    }    if (!helpTopic.IsEmpty())    {        wxGetApp().GetHelpController().KeywordSearch(helpTopic);    }}#endif// This sets the text for the selected page, but doesn't help// when trying to click on a tab: we would expect the appropriate help// for that tab. We would need to look at the tabs to do this, from within OnContextHelp -// probably not worth it.void ecRunTestsDialog::OnPageChange(wxNotebookEvent& event){    event.Skip();#if 0    int sel = m_notebook->GetSelection();    if (sel < 0)        return;    wxWindow* page = m_notebook->GetPage(sel);    if (page)    {        wxString helpText;        if (page == m_displayOptions)            helpText = _("The display options dialog allows you to change display-related options.");        else if (page == m_viewerOptions)            helpText = _("The viewer options dialog allows you to configure viewers.");        else if (page == m_pathOptions)            helpText = _("The path options dialog allows you to change tool paths.");        else if (page == m_conflictResolutionOptions)            helpText = _("The conflict resolution options dialog allows you to change options related to conflict resolution.");        m_notebook->SetHelpText(helpText);    }#endif}bool ecRunTestsDialog::TransferDataToWindow(){    // In this case there is no data to be transferred    m_executables->TransferDataToWindow();    m_output->TransferDataToWindow();    m_summary->TransferDataToWindow();    return TRUE;}bool ecRunTestsDialog::TransferDataFromWindow(){    // In this case there is no data to be transferred    m_executables->TransferDataFromWindow();    m_output->TransferDataFromWindow();    m_summary->TransferDataFromWindow();    return TRUE;}void ecRunTestsDialog::OnSize(wxSizeEvent& event){    event.Skip();    wxRefreshControls(this);}// Add the test to the dialogvoid ecRunTestsDialog::Populate(const wxString& test, bool select){    wxCheckListBox* checkListBox = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);    wxASSERT( checkListBox );    checkListBox->Append(test);    if (select)        checkListBox->Check(checkListBox->Number() - 1, TRUE);}/* Executables dialog */IMPLEMENT_CLASS(ecRunTestsExecutablesDialog, wxPanel)BEGIN_EVENT_TABLE(ecRunTestsExecutablesDialog, wxPanel)    EVT_BUTTON(ecID_RUN_TESTS_CHECK_ALL, ecRunTestsExecutablesDialog::OnCheckAll)    EVT_BUTTON(ecID_RUN_TESTS_UNCHECK_ALL, ecRunTestsExecutablesDialog::OnUncheckAll)    EVT_BUTTON(ecID_RUN_TESTS_ADD, ecRunTestsExecutablesDialog::OnAdd)    EVT_BUTTON(ecID_RUN_TESTS_ADD_FOLDER, ecRunTestsExecutablesDialog::OnAddFromFolder)    EVT_BUTTON(ecID_RUN_TESTS_REMOVE, ecRunTestsExecutablesDialog::OnRemove)    EVT_UPDATE_UI(ecID_RUN_TESTS_CHECK_ALL, ecRunTestsExecutablesDialog::OnUpdateCheckAll)    EVT_UPDATE_UI(ecID_RUN_TESTS_UNCHECK_ALL, ecRunTestsExecutablesDialog::OnUpdateUncheckAll)END_EVENT_TABLE()ecRunTestsExecutablesDialog::ecRunTestsExecutablesDialog(wxWindow* parent):    wxPanel(parent, ecID_RUN_TESTS_EXECUTABLES){    CreateControls(this);        SetHelpText(_("The executables dialog allows you to select tests to be run."));}void ecRunTestsExecutablesDialog::CreateControls( wxPanel *parent){    // Create the foreign control    wxCheckListBox* listBox = new wxCheckListBox(parent, ecID_RUN_TESTS_TEST_LIST, wxDefaultPosition, wxSize(100, 100),        0, NULL, wxSUNKEN_BORDER|wxLB_EXTENDED);    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );    wxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );    wxButton *item2 = new wxButton( parent, ecID_RUN_TESTS_CHECK_ALL, "C&heck All", wxDefaultPosition, wxDefaultSize, 0 );    item1->Add( item2, 0, wxALIGN_CENTRE|wxALL, 5 );    item1->Add( 2, 2, 1, wxALIGN_CENTRE|wxALL, 0 );    wxButton *item3 = new wxButton( parent, ecID_RUN_TESTS_UNCHECK_ALL, "&Uncheck All", wxDefaultPosition, wxDefaultSize, 0 );    item1->Add( item3, 0, wxALIGN_CENTRE|wxALL, 5 );    item1->Add( 2, 2, 1, wxALIGN_CENTRE|wxALL, 0 );    wxButton *item4 = new wxButton( parent, ecID_RUN_TESTS_ADD, "&Add...", wxDefaultPosition, wxDefaultSize, 0 );    item1->Add( item4, 0, wxALIGN_CENTRE|wxALL, 5 );    item1->Add( 2, 2, 1, wxALIGN_CENTRE|wxALL, 0 );    wxButton *item5 = new wxButton( parent, ecID_RUN_TESTS_ADD_FOLDER, "Add from &Folder...", wxDefaultPosition, wxDefaultSize, 0 );    item1->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 );    item1->Add( 2, 2, 1, wxALIGN_CENTRE|wxALL, 0 );    wxButton *item6 = new wxButton( parent, ecID_RUN_TESTS_REMOVE, "&Remove", wxDefaultPosition, wxDefaultSize, 0 );    item1->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );    item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );    wxWindow *item7 = parent->FindWindow( ecID_RUN_TESTS_TEST_LIST );    wxASSERT( item7 );    item0->Add( item7, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );    // Add context-sensitive help    FindWindow(ecID_RUN_TESTS_TEST_LIST)->SetHelpText(_("Displays the set of tests that can be executed. Each test can be selected for execution by checking the adjacent box."));    FindWindow(ecID_RUN_TESTS_CHECK_ALL)->SetHelpText(_("Selects all tests for execution."));    FindWindow(ecID_RUN_TESTS_UNCHECK_ALL)->SetHelpText(_("Clears the selection of tests."));    FindWindow(ecID_RUN_TESTS_ADD)->SetHelpText(_("Adds a test to the set that can be executed."));    FindWindow(ecID_RUN_TESTS_ADD_FOLDER)->SetHelpText(_("Adds one or more tests to the set that can be executed, from a folder."));    FindWindow(ecID_RUN_TESTS_REMOVE)->SetHelpText(_("Removes a test from the set that can executed."));    parent->SetAutoLayout( TRUE );    parent->SetSizer( item0 );}void ecRunTestsExecutablesDialog::OnCheckAll(wxCommandEvent& event){    wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);    if (!checkList)        return;    int i;    int n = checkList->Number();    for (i = 0; i < n; i++)        checkList->Check(i, TRUE);}void ecRunTestsExecutablesDialog::OnUncheckAll(wxCommandEvent& event){    wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);    if (!checkList)        return;    int i;    int n = checkList->Number();    for (i = 0; i < n; i++)        checkList->Check(i, FALSE);}void ecRunTestsExecutablesDialog::OnAdd(wxCommandEvent& event){    wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);    if (!checkList)        return;//#ifdef __WXMSW__//    wxString wildcard(wxT("Executables (*.exe)|*.exe"));//#else    wxString wildcard(wxT("Executables (*)|*"));//#endif    wxFileDialog dialog(this, _("Choose one or more executables to add"), wxGetCwd(), wxEmptyString,        wildcard, wxMULTIPLE|wxOPEN);    if (dialog.ShowModal() == wxID_OK)    {        wxArrayString paths;        dialog.GetPaths(paths);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -