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

📄 runtestsdlg.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 3 页
字号:
        bool err = FALSE;        unsigned int i;        int n = paths.Count();        for (i = 0; i < n; i++)        {            // TODO: check that it's the right kind of file            if (-1 == checkList->FindString(paths[i]))            {                checkList->Append(paths[i]);                checkList->Check(checkList->Number()-1, TRUE);            }            else                err = TRUE;        }        if (err)            wxMessageBox(_("One or more of the files was already present"),                wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK, this);    }}void ecRunTestsExecutablesDialog::OnAddFromFolder(wxCommandEvent& event){    wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);    if (!checkList)        return;    // In the MFC tool, a modified version of the folder dialog was used but    // we can't do that in general in wxWindows; so instead we ask the questions    // before we show the folder dialog.    // We won't bother allowing the user to change the extension: on Windows it's .exe,    // on Unix it's anything.//#ifdef __WXMSW__//    wxString filespec(wxT("*.exe"));//#else    wxString filespec(wxT("*"));//#endif    wxString msg;    msg.Printf(_("Would you like to add from subfolders, or just the folder you specify?\nChoose Yes to add from subfolders."));    int ans = wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_QUESTION|wxYES_NO|wxCANCEL, this);    if (ans == wxCANCEL)        return;    bool recurse = (ans == wxYES);    wxDirDialog dialog(this, _("Choose a folder to add tests from"), wxGetCwd());    if (dialog.ShowModal() == wxID_OK)    {        wxString folder(dialog.GetPath());        if (!wxDirExists(folder))        {            wxMessageBox(_("Sorry, this folder does not exist."), wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK, this);            return;        }        wxBusyCursor busy;        AddFromFolder(folder, recurse, filespec);    }}void ecRunTestsExecutablesDialog::AddFromFolder(const wxString& folder, bool recurse, const wxString& wildcard){    wxString filename;    wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);    {        wxDir dir;        if (!dir.Open(folder))            return;                        bool success = dir.GetFirst(& filename, wildcard, wxDIR_FILES);        while (success)        {            wxString path = folder + wxString(wxFILE_SEP_PATH) + filename;                        if (-1 == checkList->FindString(path))            {                checkList->Append(path);                checkList->Check(checkList->Number()-1, TRUE);            }                               success = dir.GetNext(& filename);        }    }        // Recurse down the subfolders    if (recurse)    {        wxArrayString subfolders;        {            wxDir dir2;            if (!dir2.Open(folder))                return;                        bool success = dir2.GetFirst(& filename, wxT("*"), wxDIR_DIRS);            while (success)            {                wxString path = folder + wxString(wxFILE_SEP_PATH) + filename;                subfolders.Add(path);                                            success = dir2.GetNext(& filename);            }        }        unsigned int i;        for (i = 0; i < subfolders.Count(); i ++)        {            AddFromFolder(subfolders[i], recurse, wildcard);        }    }}void ecRunTestsExecutablesDialog::OnRemove(wxCommandEvent& event){    wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);    if (!checkList)        return;    bool cont = FALSE;    do    {        // Delete the selections one at a time since        // the indexes change when you delete one        wxArrayInt ar;        if (checkList->GetSelections(ar) > 0)        {            checkList->Delete(ar[0]);            cont = TRUE;        }        else            cont = FALSE;    } while (cont);}void ecRunTestsExecutablesDialog::OnUpdateCheckAll(wxUpdateUIEvent& event){    wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);    if (!checkList)        return;    // If there were no unchecked items, we can disable the check all button    event.Enable( checkList->Number() != SelectedTestCount() );}void ecRunTestsExecutablesDialog::OnUpdateUncheckAll(wxUpdateUIEvent& event){    event.Enable( SelectedTestCount() > 0 );}int ecRunTestsExecutablesDialog::SelectedTestCount(){    wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);    if (!checkList)        return 0;    int selCount = 0;    int i;    int n = checkList->Number();    for (i = 0; i < n; i++)    {        if (checkList->IsChecked(i))        {            selCount ++;        }    }    return selCount;}wxString ecRunTestsExecutablesDialog::SelectedTest(int nIndex){    wxString str;    wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);    if (!checkList)        return str;    int i;    for (i=0; i < checkList->Number(); i++)    {        if (checkList->IsChecked(i))        {            if(0==nIndex--)            {                str = checkList->GetString(i);                break;            }        }    }    return str;}/* Output dialog */IMPLEMENT_CLASS(ecRunTestsOutputDialog, wxPanel)ecRunTestsOutputDialog::ecRunTestsOutputDialog(wxWindow* parent):    wxPanel(parent, ecID_RUN_TESTS_OUTPUT){    CreateControls(this);        SetHelpText(_("The output dialog displays the run output."));}void ecRunTestsOutputDialog::CreateControls( wxPanel *parent){    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );    wxTextCtrl *item1 = new wxTextCtrl( parent, ecID_RUN_TESTS_OUTPUT_TEXT, "", wxDefaultPosition, wxSize(80,40), wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxCLIP_CHILDREN );    item0->Add( item1, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );    // Add context-sensitive help    FindWindow(ecID_RUN_TESTS_OUTPUT_TEXT)->SetHelpText(_("Displays the output of test execution."));    parent->SetAutoLayout( TRUE );    parent->SetSizer( item0 );}void ecRunTestsOutputDialog::AddText(const wxString& msg){    wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow(ecID_RUN_TESTS_OUTPUT_TEXT);    wxASSERT (textCtrl != NULL);    textCtrl->SetInsertionPointEnd();    textCtrl->AppendText(msg);    }void ecRunTestsOutputDialog::AddLogMsg(const wxString& msg){    wxString msg2(msg);    if ((msg == wxEmptyString) || (msg.Last() != wxT('\n')))        msg2 += wxT("\n");    AddText(msg2);}/* Summary dialog */IMPLEMENT_CLASS(ecRunTestsSummaryDialog, wxPanel)BEGIN_EVENT_TABLE(ecRunTestsSummaryDialog, wxPanel)    EVT_LIST_COL_CLICK(ecID_RUN_TESTS_SUMMARY_LIST, ecRunTestsSummaryDialog::OnColClick)END_EVENT_TABLE()wxListCtrl* ecRunTestsSummaryDialog::m_listCtrl = NULL;ecRunTestsSummaryDialog::ecRunTestsSummaryDialog(wxWindow* parent):    wxPanel(parent, ecID_RUN_TESTS_SUMMARY){    CreateControls(this);        SetHelpText(_("The summary dialog shows a summary of the results of each run."));}void ecRunTestsSummaryDialog::CreateControls( wxPanel *parent){    m_listCtrl = new wxListCtrl(parent, ecID_RUN_TESTS_SUMMARY_LIST, wxDefaultPosition, wxSize(100, 100), wxSUNKEN_BORDER|wxLC_REPORT);    m_listCtrl->InsertColumn(0, "Time", wxLIST_FORMAT_LEFT, 60);    m_listCtrl->InsertColumn(1, "Host", wxLIST_FORMAT_LEFT, 60);    m_listCtrl->InsertColumn(2, "Platform", wxLIST_FORMAT_LEFT, 60);    m_listCtrl->InsertColumn(3, "Executable", wxLIST_FORMAT_LEFT, 60);    m_listCtrl->InsertColumn(4, "Status", wxLIST_FORMAT_LEFT, 60);    m_listCtrl->InsertColumn(5, "Size", wxLIST_FORMAT_LEFT, 60);    m_listCtrl->InsertColumn(6, "Download", wxLIST_FORMAT_LEFT, 60);    m_listCtrl->InsertColumn(7, "Elapsed", wxLIST_FORMAT_LEFT, 60);    m_listCtrl->InsertColumn(8, "Execution", wxLIST_FORMAT_LEFT, 60);    wxSizer *item0 = new wxBoxSizer( wxVERTICAL );    wxWindow *item1 = parent->FindWindow( ecID_RUN_TESTS_SUMMARY_LIST );    wxASSERT( item1 );    item0->Add( item1, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );    parent->SetAutoLayout( TRUE );    parent->SetSizer( item0 );    // Add context-sensitive help    FindWindow(ecID_RUN_TESTS_SUMMARY_LIST)->SetHelpText(_("Displays a summary of test execution."));}void ecRunTestsSummaryDialog::AddResult (CeCosTest *pTest){    const wxString strResult(pTest->ResultString(FALSE));    int nLength=strResult.Length();    wxString arstr[8];    wxString strTime,strDate;    int i;    // 1999-05-28 10:29:28 nan:0 TX39-jmr3904-sim tx39-jmr3904sim-libc10-signal2.exe Fail 0k/1108k D=0.0/0.0 Total=9.3 E=0.6/300.0     wxStringTokenizer tok(strResult, wxT(" "));    strDate = tok.GetNextToken();    strTime = tok.GetNextToken();    strDate += wxT(" ");    strDate += strTime;    for (i = 0; i < 8; i++)        arstr[i] = tok.GetNextToken();    // Remove characters before '=' in time fields    for ( i = 5 ; i < 8 ; i ++ )    {        wxString str = arstr[i].AfterFirst(wxT('-')) ;        arstr[i] = str.IsEmpty() ? arstr[i] : str;    }    int nItem = m_listCtrl->GetItemCount() ;    int nIndex = m_listCtrl->InsertItem (nItem, strDate);    m_listCtrl->SetItemData(nItem,nItem);// to support sorting    for (i = 0; i < 8; i++)    {        m_listCtrl->SetItem(nIndex, i+1, arstr[i]);    }  #if 0    // OLD CODE    int i;    // TRACE(_T("%s\n"),strResult);    // 1999-05-28 10:29:28 nan:0 TX39-jmr3904-sim tx39-jmr3904sim-libc10-signal2.exe Fail 0k/1108k D=0.0/0.0 Total=9.3 E=0.6/300.0     _stscanf(strResult,_T("%s %s %s %s %s %s %s %s %s %s"),        strDate.GetBuffer(1+nLength),        strTime.GetBuffer(1+nLength),        arstr[0].GetBuffer(1+nLength),        arstr[1].GetBuffer(1+nLength),        arstr[2].GetBuffer(1+nLength),        arstr[3].GetBuffer(1+nLength),        arstr[4].GetBuffer(1+nLength),        arstr[5].GetBuffer(1+nLength),        arstr[6].GetBuffer(1+nLength),        arstr[7].GetBuffer(1+nLength));    // Remove before '=' in time fields    for(i=5;i<8;i++){        TCHAR *pch=_tcschr(arstr[i],_TCHAR('='));        if(pch){            arstr[i]=pch+1;        }    }        strDate.ReleaseBuffer();    strTime.ReleaseBuffer();    strDate+=_TCHAR(' ');    strDate+=strTime;    int nItem=m_List.GetItemCount();    m_List.InsertItem(nItem,strDate);    m_List.SetItemData(nItem,nItem);// to support sorting    for(i=0;i<8;i++){        m_List.SetItemText(nItem,1+i,arstr[i]);        arstr[i].ReleaseBuffer();    }#endif}// Sort function.// The function is passed the client data of the two items,// plus another general client data value which in this case// we use for the column index.int CALLBACK ecRunTestsSummaryDialog::SummarySortFunc(long data1, long data2, long col){    wxString str1 = wxListCtrlGetItemTextColumn(* m_listCtrl, data1, col);    wxString str2 = wxListCtrlGetItemTextColumn(* m_listCtrl, data2, col);    int ret = str1.CmpNoCase(str2);    return ret;}void ecRunTestsSummaryDialog::OnColClick(wxListEvent& event){    m_listCtrl->SortItems((wxListCtrlCompare) SummarySortFunc,(long) event.m_col);    // The item data contains the index in the list control, so this needs    // to be reset after sorting.    int i;    for (i = m_listCtrl->GetItemCount()-1;i>=0;--i)    {        m_listCtrl->SetItemData(i,i);    }}

⌨️ 快捷键说明

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