Menu

[r5]: / UnitTestCPP / unittestspage.cpp  Maximize  Restore  History

Download this file

106 lines (88 with data), 3.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : unittestspage.cpp
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// 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.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#include "workspace.h"
#include "globals.h"
#include "unittestspage.h"
#include "imanager.h"
#include <wx/msgdlg.h>
UnitTestsPage::UnitTestsPage(wxWindow* parent, TestSummary* summary, IManager *mgr )
: UnitTestsBasePage( parent, wxID_ANY, wxDefaultPosition, wxSize(1, 1), 0 )
, m_mgr(mgr)
{
#ifdef __WXDEBUG__
summary->PrintSelf();
#endif
m_progressPassed->SetMaxRange((size_t)summary->totalTests);
m_progressFailed->SetMaxRange((size_t)summary->totalTests);
m_progressFailed->SetFillCol(wxT("RED"));
m_progressPassed->SetFillCol(wxT("PALE GREEN"));
wxString msg;
msg << summary->totalTests;
m_staticTextTotalTests->SetLabel(msg);
msg.clear();
msg << summary->errorCount;
m_staticTextFailTestsNum->SetLabel(msg);
msg.clear();
msg << summary->totalTests - summary->errorCount;
m_staticTextSuccessTestsNum->SetLabel(msg);
m_listCtrlErrors->InsertColumn(0, wxT("File"));
m_listCtrlErrors->InsertColumn(1, wxT("Line"));
m_listCtrlErrors->InsertColumn(2, wxT("Description"));
for (size_t i=0; i<summary->errorLines.GetCount(); i++) {
ErrorLineInfo info = summary->errorLines.Item(i);
long row = AppendListCtrlRow(m_listCtrlErrors);
SetColumnText(m_listCtrlErrors, row, 0, info.file);
SetColumnText(m_listCtrlErrors, row, 1, info.line);
SetColumnText(m_listCtrlErrors, row, 2, info.description);
}
m_listCtrlErrors->SetColumnWidth(0, 200);
m_listCtrlErrors->SetColumnWidth(1, 100);
m_listCtrlErrors->SetColumnWidth(2, wxLIST_AUTOSIZE);
}
void UnitTestsPage::UpdateFailedBar(size_t amount, const wxString& msg)
{
m_progressFailed->Update(amount, msg);
}
void UnitTestsPage::UpdatePassedBar(size_t amount, const wxString& msg)
{
m_progressPassed->Update(amount, msg);
}
void UnitTestsPage::OnItemActivated(wxListEvent& e)
{
wxString file = GetColumnText(m_listCtrlErrors, e.m_itemIndex, 0);
wxString line = GetColumnText(m_listCtrlErrors, e.m_itemIndex, 1);
long l;
line.ToLong(&l);
// convert the file to absolute path
wxString err_msg, cwd;
wxString proj = m_mgr->GetWorkspace()->GetActiveProjectName();
ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(proj, err_msg);
if(p) {
cwd = p->GetFileName().GetPath();
}
wxFileName fn(file);
fn.MakeAbsolute(cwd);
m_mgr->OpenFile(fn.GetFullPath(), proj, l-1);
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.