forked from qt-creator/qt-creator
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:
@@ -49,7 +49,8 @@ SOURCES += \
|
|||||||
quick/quicktestvisitors.cpp \
|
quick/quicktestvisitors.cpp \
|
||||||
quick/quicktestframework.cpp \
|
quick/quicktestframework.cpp \
|
||||||
quick/quicktest_utils.cpp \
|
quick/quicktest_utils.cpp \
|
||||||
testframeworkmanager.cpp
|
testframeworkmanager.cpp \
|
||||||
|
testeditormark.cpp
|
||||||
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
@@ -105,7 +106,8 @@ HEADERS += \
|
|||||||
quick/quicktestframework.h \
|
quick/quicktestframework.h \
|
||||||
testframeworkmanager.h \
|
testframeworkmanager.h \
|
||||||
testrunconfiguration.h \
|
testrunconfiguration.h \
|
||||||
itestsettingspage.h
|
itestsettingspage.h \
|
||||||
|
testeditormark.h
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
autotest.qrc
|
autotest.qrc
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ QtcPlugin {
|
|||||||
"testcodeparser.h",
|
"testcodeparser.h",
|
||||||
"testconfiguration.cpp",
|
"testconfiguration.cpp",
|
||||||
"testconfiguration.h",
|
"testconfiguration.h",
|
||||||
|
"testeditormark.cpp",
|
||||||
|
"testeditormark.h",
|
||||||
"testnavigationwidget.cpp",
|
"testnavigationwidget.cpp",
|
||||||
"testnavigationwidget.h",
|
"testnavigationwidget.h",
|
||||||
"testresult.cpp",
|
"testresult.cpp",
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ const char AUTOTEST_SETTINGS_TR[] = QT_TRANSLATE_NOOP("AutoTest", "Testing
|
|||||||
const char FRAMEWORK_PREFIX[] = "AutoTest.Framework.";
|
const char FRAMEWORK_PREFIX[] = "AutoTest.Framework.";
|
||||||
const char SETTINGSPAGE_PREFIX[] = "A.AutoTest.";
|
const char SETTINGSPAGE_PREFIX[] = "A.AutoTest.";
|
||||||
const char SETTINGSGROUP[] = "Autotest";
|
const char SETTINGSGROUP[] = "Autotest";
|
||||||
|
const char TASK_MARK_ID[] = "Autotest.TaskMark";
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|||||||
45
src/plugins/autotest/testeditormark.cpp
Normal file
45
src/plugins/autotest/testeditormark.cpp
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2018 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "testeditormark.h"
|
||||||
|
#include "testresultspane.h"
|
||||||
|
|
||||||
|
namespace Autotest {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
TestEditorMark::TestEditorMark(QPersistentModelIndex item, const Utils::FileName &file, int line)
|
||||||
|
: TextEditor::TextMark(file, line, Core::Id(Constants::TASK_MARK_ID)),
|
||||||
|
m_item(item)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEditorMark::clicked()
|
||||||
|
{
|
||||||
|
auto instance = TestResultsPane::instance();
|
||||||
|
instance->showTestResult(m_item);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Autotest
|
||||||
48
src/plugins/autotest/testeditormark.h
Normal file
48
src/plugins/autotest/testeditormark.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2018 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <texteditor/textmark.h>
|
||||||
|
|
||||||
|
#include <QPersistentModelIndex>
|
||||||
|
|
||||||
|
namespace Autotest {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class TestEditorMark : public TextEditor::TextMark
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TestEditorMark(QPersistentModelIndex item, const Utils::FileName &file, int line);
|
||||||
|
|
||||||
|
bool isClickable() const override { return true; }
|
||||||
|
void clicked() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPersistentModelIndex m_item;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Autotest
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "testsettings.h"
|
#include "testsettings.h"
|
||||||
#include "testtreemodel.h"
|
#include "testtreemodel.h"
|
||||||
#include "testcodeparser.h"
|
#include "testcodeparser.h"
|
||||||
|
#include "testeditormark.h"
|
||||||
|
|
||||||
#include <aggregation/aggregate.h>
|
#include <aggregation/aggregate.h>
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
@@ -273,6 +274,7 @@ void TestResultsPane::clearContents()
|
|||||||
connect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged,
|
connect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged,
|
||||||
this, &TestResultsPane::onScrollBarRangeChanged, Qt::UniqueConnection);
|
this, &TestResultsPane::onScrollBarRangeChanged, Qt::UniqueConnection);
|
||||||
m_textOutput->clear();
|
m_textOutput->clear();
|
||||||
|
clearMarks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestResultsPane::visibilityChanged(bool /*visible*/)
|
void TestResultsPane::visibilityChanged(bool /*visible*/)
|
||||||
@@ -508,6 +510,7 @@ void TestResultsPane::onTestRunFinished()
|
|||||||
this, &TestResultsPane::onScrollBarRangeChanged);
|
this, &TestResultsPane::onScrollBarRangeChanged);
|
||||||
if (!m_treeView->isVisible())
|
if (!m_treeView->isVisible())
|
||||||
popup(Core::IOutputPane::NoModeSwitch);
|
popup(Core::IOutputPane::NoModeSwitch);
|
||||||
|
createMarks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestResultsPane::onScrollBarRangeChanged(int, int max)
|
void TestResultsPane::onScrollBarRangeChanged(int, int max)
|
||||||
@@ -629,5 +632,43 @@ QString TestResultsPane::getWholeOutput(const QModelIndex &parent)
|
|||||||
return output;
|
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 Internal
|
||||||
} // namespace Autotest
|
} // namespace Autotest
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ namespace Internal {
|
|||||||
class TestResultModel;
|
class TestResultModel;
|
||||||
class TestResultFilterModel;
|
class TestResultFilterModel;
|
||||||
class TestResult;
|
class TestResult;
|
||||||
|
class TestEditorMark;
|
||||||
|
|
||||||
class ResultsTreeView : public Utils::TreeView
|
class ResultsTreeView : public Utils::TreeView
|
||||||
{
|
{
|
||||||
@@ -92,6 +93,7 @@ public:
|
|||||||
|
|
||||||
void addTestResult(const TestResultPtr &result);
|
void addTestResult(const TestResultPtr &result);
|
||||||
void addOutput(const QByteArray &output);
|
void addOutput(const QByteArray &output);
|
||||||
|
void showTestResult(const QModelIndex &index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit TestResultsPane(QObject *parent = 0);
|
explicit TestResultsPane(QObject *parent = 0);
|
||||||
@@ -117,6 +119,9 @@ private:
|
|||||||
void toggleOutputStyle();
|
void toggleOutputStyle();
|
||||||
QString getWholeOutput(const QModelIndex &parent = QModelIndex());
|
QString getWholeOutput(const QModelIndex &parent = QModelIndex());
|
||||||
|
|
||||||
|
void createMarks(const QModelIndex& parent = QModelIndex());
|
||||||
|
void clearMarks();
|
||||||
|
|
||||||
QStackedWidget *m_outputWidget;
|
QStackedWidget *m_outputWidget;
|
||||||
QFrame *m_summaryWidget;
|
QFrame *m_summaryWidget;
|
||||||
QLabel *m_summaryLabel;
|
QLabel *m_summaryLabel;
|
||||||
@@ -135,6 +140,7 @@ private:
|
|||||||
bool m_autoScroll = false;
|
bool m_autoScroll = false;
|
||||||
bool m_atEnd = false;
|
bool m_atEnd = false;
|
||||||
bool m_testRunning = false;
|
bool m_testRunning = false;
|
||||||
|
QVector<TestEditorMark *> m_marks;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user