forked from qt-creator/qt-creator
AutoTest: Provide way to access the original test output
When running tests the original output is processed and not presented to the user at all. For crashing tests this could mean that output was not able to get processed completely (e.g. when having XML as output and relying on well-formed code) Unhandled output could also lead to incorrect results. This patch adds another view to the results pane which contains the complete output of the last test run. Change-Id: I923496e9c440de4ea68bee55415777ea5c2379c2 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -33,16 +33,15 @@
|
||||
#include "testtreemodel.h"
|
||||
#include "testcodeparser.h"
|
||||
|
||||
#include <aggregation/aggregate.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/find/basetextfind.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
|
||||
#include <texteditor/texteditor.h>
|
||||
|
||||
#include <utils/theme/theme.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
@@ -54,6 +53,7 @@
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QScrollBar>
|
||||
#include <QStackedWidget>
|
||||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
@@ -79,11 +79,13 @@ TestResultsPane::TestResultsPane(QObject *parent) :
|
||||
Core::IOutputPane(parent),
|
||||
m_context(new Core::IContext(this))
|
||||
{
|
||||
m_outputWidget = new QWidget;
|
||||
m_outputWidget = new QStackedWidget;
|
||||
QWidget *visualOutputWidget = new QWidget;
|
||||
m_outputWidget->addWidget(visualOutputWidget);
|
||||
QVBoxLayout *outputLayout = new QVBoxLayout;
|
||||
outputLayout->setMargin(0);
|
||||
outputLayout->setSpacing(0);
|
||||
m_outputWidget->setLayout(outputLayout);
|
||||
visualOutputWidget->setLayout(outputLayout);
|
||||
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Window,
|
||||
@@ -103,7 +105,7 @@ TestResultsPane::TestResultsPane(QObject *parent) :
|
||||
|
||||
outputLayout->addWidget(m_summaryWidget);
|
||||
|
||||
m_treeView = new ResultsTreeView(m_outputWidget);
|
||||
m_treeView = new ResultsTreeView(visualOutputWidget);
|
||||
m_treeView->setHeaderHidden(true);
|
||||
m_treeView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
m_treeView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
@@ -119,6 +121,19 @@ TestResultsPane::TestResultsPane(QObject *parent) :
|
||||
|
||||
outputLayout->addWidget(Core::ItemViewFind::createSearchableWrapper(m_treeView));
|
||||
|
||||
m_textOutput = new QPlainTextEdit;
|
||||
m_textOutput->setPalette(pal);
|
||||
QFont font("monospace");
|
||||
font.setStyleHint(QFont::TypeWriter);
|
||||
m_textOutput->setFont(font);
|
||||
m_textOutput->setWordWrapMode(QTextOption::WordWrap);
|
||||
m_textOutput->setReadOnly(true);
|
||||
m_outputWidget->addWidget(m_textOutput);
|
||||
|
||||
auto agg = new Aggregation::Aggregate;
|
||||
agg->add(m_textOutput);
|
||||
agg->add(new Core::BaseTextFind(m_textOutput));
|
||||
|
||||
createToolButtons();
|
||||
|
||||
connect(m_treeView, &Utils::TreeView::activated, this, &TestResultsPane::onItemActivated);
|
||||
@@ -188,6 +203,11 @@ void TestResultsPane::createToolButtons()
|
||||
initializeFilterMenu();
|
||||
connect(m_filterMenu, &QMenu::triggered, this, &TestResultsPane::filterMenuTriggered);
|
||||
m_filterButton->setMenu(m_filterMenu);
|
||||
m_outputToggleButton = new QToolButton(m_treeView);
|
||||
m_outputToggleButton->setIcon(Icons::TEXT_DISPLAY.icon());
|
||||
m_outputToggleButton->setToolTip(tr("Switch Between Visual and Text Display"));
|
||||
m_outputToggleButton->setEnabled(true);
|
||||
connect(m_outputToggleButton, &QToolButton::clicked, this, &TestResultsPane::toggleOutputStyle);
|
||||
}
|
||||
|
||||
static TestResultsPane *s_instance = nullptr;
|
||||
@@ -202,6 +222,8 @@ TestResultsPane *TestResultsPane::instance()
|
||||
TestResultsPane::~TestResultsPane()
|
||||
{
|
||||
delete m_treeView;
|
||||
if (!m_outputWidget->parent())
|
||||
delete m_outputWidget;
|
||||
s_instance = nullptr;
|
||||
}
|
||||
|
||||
@@ -217,6 +239,11 @@ void TestResultsPane::addTestResult(const TestResultPtr &result)
|
||||
navigateStateChanged();
|
||||
}
|
||||
|
||||
void TestResultsPane::addOutput(const QByteArray &output)
|
||||
{
|
||||
m_textOutput->appendPlainText(QString::fromLatin1(output));
|
||||
}
|
||||
|
||||
QWidget *TestResultsPane::outputWidget(QWidget *parent)
|
||||
{
|
||||
if (m_outputWidget) {
|
||||
@@ -229,7 +256,8 @@ QWidget *TestResultsPane::outputWidget(QWidget *parent)
|
||||
|
||||
QList<QWidget *> TestResultsPane::toolBarWidgets() const
|
||||
{
|
||||
return {m_expandCollapse, m_runAll, m_runSelected, m_stopTestRun, m_filterButton};
|
||||
return {m_expandCollapse, m_runAll, m_runSelected, m_stopTestRun, m_outputToggleButton,
|
||||
m_filterButton};
|
||||
}
|
||||
|
||||
QString TestResultsPane::displayName() const
|
||||
@@ -251,6 +279,7 @@ void TestResultsPane::clearContents()
|
||||
m_autoScroll = AutotestPlugin::instance()->settings()->autoScroll;
|
||||
connect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged,
|
||||
this, &TestResultsPane::onScrollBarRangeChanged, Qt::UniqueConnection);
|
||||
m_textOutput->clear();
|
||||
}
|
||||
|
||||
void TestResultsPane::visibilityChanged(bool visible)
|
||||
@@ -574,6 +603,14 @@ void TestResultsPane::onSaveWholeTriggered()
|
||||
}
|
||||
}
|
||||
|
||||
void TestResultsPane::toggleOutputStyle()
|
||||
{
|
||||
const bool displayText = m_outputWidget->currentIndex() == 0;
|
||||
m_outputWidget->setCurrentIndex(displayText ? 1 : 0);
|
||||
m_outputToggleButton->setIcon(displayText ? Icons::VISUAL_DISPLAY.icon()
|
||||
: Icons::TEXT_DISPLAY.icon());
|
||||
}
|
||||
|
||||
// helper for onCopyWholeTriggered() and onSaveWholeTriggered()
|
||||
QString TestResultsPane::getWholeOutput(const QModelIndex &parent)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user