Autotest: Add editor's mark for test's failed assertion

Tooltip shows failure details. Click navigates to test results pane.

Task-number: QTCREATORBUG-20328
Change-Id: I47ffaef1f035dfc5b244644a099e1c7d8db6715b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Sergey Morozov
2018-05-03 23:29:18 +03:00
parent c4530d64b8
commit 743a37dda2
7 changed files with 147 additions and 2 deletions

View File

@@ -32,6 +32,7 @@
#include "testsettings.h"
#include "testtreemodel.h"
#include "testcodeparser.h"
#include "testeditormark.h"
#include <aggregation/aggregate.h>
#include <coreplugin/actionmanager/actionmanager.h>
@@ -273,6 +274,7 @@ void TestResultsPane::clearContents()
connect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged,
this, &TestResultsPane::onScrollBarRangeChanged, Qt::UniqueConnection);
m_textOutput->clear();
clearMarks();
}
void TestResultsPane::visibilityChanged(bool /*visible*/)
@@ -508,6 +510,7 @@ void TestResultsPane::onTestRunFinished()
this, &TestResultsPane::onScrollBarRangeChanged);
if (!m_treeView->isVisible())
popup(Core::IOutputPane::NoModeSwitch);
createMarks();
}
void TestResultsPane::onScrollBarRangeChanged(int, int max)
@@ -629,5 +632,43 @@ QString TestResultsPane::getWholeOutput(const QModelIndex &parent)
return output;
}
void TestResultsPane::createMarks(const QModelIndex &parent)
{
for (int row = 0, count = m_model->rowCount(parent); row < count; ++row) {
const QModelIndex index = m_model->index(row, 0, parent);
const TestResult *result = m_model->testResult(index);
QTC_ASSERT(result, continue);
if (m_model->hasChildren(index))
createMarks(index);
const QVector<Result::Type> interested{Result::Fail, Result::UnexpectedPass};
if (interested.contains(result->result())) {
const Utils::FileName fileName = Utils::FileName::fromString(result->fileName());
TestEditorMark *mark = new TestEditorMark(index, fileName, result->line());
mark->setIcon(index.data(Qt::DecorationRole).value<QIcon>());
mark->setColor(Utils::Theme::OutputPanes_TestFailTextColor);
mark->setPriority(TextEditor::TextMark::NormalPriority);
mark->setToolTip(result->description());
m_marks << mark;
}
}
}
void TestResultsPane::clearMarks()
{
qDeleteAll(m_marks);
m_marks.clear();
}
void TestResultsPane::showTestResult(const QModelIndex &index)
{
QModelIndex mapped = m_filterModel->mapFromSource(index);
if (mapped.isValid()) {
popup(Core::IOutputPane::NoModeSwitch);
m_treeView->setCurrentIndex(mapped);
}
}
} // namespace Internal
} // namespace Autotest