forked from qt-creator/qt-creator
AutoTest: Improve test output handling
Instead of just providing the hidden search, provide a more obvious present filter functionality for the text output similar to what is done in other output windows. This still has the find functionality present as well. Task-number: QTCREATORBUG-28706 Change-Id: I8f8b1494d86c90cbb9ea6bfad3f0e74caf3de2c9 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -15,15 +15,13 @@
|
|||||||
#include "testsettings.h"
|
#include "testsettings.h"
|
||||||
#include "testtreemodel.h"
|
#include "testtreemodel.h"
|
||||||
|
|
||||||
#include <aggregation/aggregate.h>
|
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/find/basetextfind.h>
|
|
||||||
#include <coreplugin/find/itemviewfind.h>
|
#include <coreplugin/find/itemviewfind.h>
|
||||||
#include <coreplugin/icontext.h>
|
#include <coreplugin/icontext.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/outputwindow.h>
|
||||||
|
|
||||||
#include <projectexplorer/buildmanager.h>
|
#include <projectexplorer/buildmanager.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
@@ -115,16 +113,22 @@ TestResultsPane::TestResultsPane(QObject *parent) :
|
|||||||
|
|
||||||
outputLayout->addWidget(ItemViewFind::createSearchableWrapper(m_treeView));
|
outputLayout->addWidget(ItemViewFind::createSearchableWrapper(m_treeView));
|
||||||
|
|
||||||
m_textOutput = new QPlainTextEdit;
|
m_textOutput = new Core::OutputWindow(Core::Context("AutoTest.TextOutput"),
|
||||||
m_textOutput->setPalette(pal);
|
"AutoTest.TextOutput.Filter");
|
||||||
m_textOutput->setFont(TextEditor::TextEditorSettings::fontSettings().font());
|
|
||||||
|
m_textOutput->setBaseFont(TextEditor::TextEditorSettings::fontSettings().font());
|
||||||
m_textOutput->setWordWrapMode(QTextOption::WordWrap);
|
m_textOutput->setWordWrapMode(QTextOption::WordWrap);
|
||||||
m_textOutput->setReadOnly(true);
|
m_textOutput->setReadOnly(true);
|
||||||
m_outputWidget->addWidget(m_textOutput);
|
m_outputWidget->addWidget(m_textOutput);
|
||||||
|
|
||||||
auto agg = new Aggregation::Aggregate;
|
setupFilterUi("AutoTest.TextOutput.Filter");
|
||||||
agg->add(m_textOutput);
|
setupContext("AutoTest.TextOutput", m_textOutput);
|
||||||
agg->add(new BaseTextFind(m_textOutput));
|
setFilteringEnabled(false);
|
||||||
|
setZoomButtonsEnabled(false);
|
||||||
|
connect(this, &IOutputPane::zoomInRequested, m_textOutput, &Core::OutputWindow::zoomIn);
|
||||||
|
connect(this, &IOutputPane::zoomOutRequested, m_textOutput, &Core::OutputWindow::zoomOut);
|
||||||
|
connect(this, &IOutputPane::resetZoomRequested, m_textOutput, &Core::OutputWindow::resetZoom);
|
||||||
|
connect(this, &IOutputPane::fontChanged, m_textOutput, &OutputWindow::setBaseFont);
|
||||||
|
|
||||||
createToolButtons();
|
createToolButtons();
|
||||||
|
|
||||||
@@ -235,33 +239,6 @@ void TestResultsPane::addTestResult(const TestResult &result)
|
|||||||
navigateStateChanged();
|
navigateStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void checkAndFineTuneColors(QTextCharFormat *format)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(format, return);
|
|
||||||
const QColor bgColor = format->background().color();
|
|
||||||
QColor fgColor = format->foreground().color();
|
|
||||||
|
|
||||||
if (StyleHelper::isReadableOn(bgColor, fgColor))
|
|
||||||
return;
|
|
||||||
|
|
||||||
int h, s, v;
|
|
||||||
fgColor.getHsv(&h, &s, &v);
|
|
||||||
// adjust the color value to ensure better readability
|
|
||||||
if (StyleHelper::luminance(bgColor) < .5)
|
|
||||||
v = v + 64;
|
|
||||||
else
|
|
||||||
v = v - 64;
|
|
||||||
|
|
||||||
fgColor.setHsv(h, s, v);
|
|
||||||
if (!StyleHelper::isReadableOn(bgColor, fgColor)) {
|
|
||||||
s = (s + 128) % 255; // adjust the saturation to ensure better readability
|
|
||||||
fgColor.setHsv(h, s, v);
|
|
||||||
if (!StyleHelper::isReadableOn(bgColor, fgColor))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
format->setForeground(fgColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestResultsPane::addOutputLine(const QByteArray &outputLine, OutputChannel channel)
|
void TestResultsPane::addOutputLine(const QByteArray &outputLine, OutputChannel channel)
|
||||||
{
|
{
|
||||||
@@ -271,20 +248,9 @@ void TestResultsPane::addOutputLine(const QByteArray &outputLine, OutputChannel
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FormattedText formattedText
|
m_textOutput->appendMessage(QString::fromUtf8(outputLine) + '\n',
|
||||||
= FormattedText{QString::fromUtf8(outputLine), m_defaultFormat};
|
channel == OutputChannel::StdOut ? OutputFormat::StdOutFormat
|
||||||
const QList<FormattedText> formatted = channel == OutputChannel::StdOut
|
: OutputFormat::StdErrFormat);
|
||||||
? m_stdOutHandler.parseText(formattedText)
|
|
||||||
: m_stdErrHandler.parseText(formattedText);
|
|
||||||
|
|
||||||
QTextCursor cursor = m_textOutput->textCursor();
|
|
||||||
cursor.beginEditBlock();
|
|
||||||
for (auto formattedText : formatted) {
|
|
||||||
checkAndFineTuneColors(&formattedText.format);
|
|
||||||
cursor.insertText(formattedText.text, formattedText.format);
|
|
||||||
}
|
|
||||||
cursor.insertText("\n");
|
|
||||||
cursor.endEditBlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *TestResultsPane::outputWidget(QWidget *parent)
|
QWidget *TestResultsPane::outputWidget(QWidget *parent)
|
||||||
@@ -299,8 +265,11 @@ QWidget *TestResultsPane::outputWidget(QWidget *parent)
|
|||||||
|
|
||||||
QList<QWidget *> TestResultsPane::toolBarWidgets() const
|
QList<QWidget *> TestResultsPane::toolBarWidgets() const
|
||||||
{
|
{
|
||||||
return {m_expandCollapse, m_runAll, m_runSelected, m_runFailed, m_runFile, m_stopTestRun,
|
QList<QWidget *> result = {m_expandCollapse, m_runAll, m_runSelected, m_runFailed,
|
||||||
m_outputToggleButton, m_filterButton};
|
m_runFile, m_stopTestRun, m_outputToggleButton, m_filterButton};
|
||||||
|
for (QWidget *widget : IOutputPane::toolBarWidgets())
|
||||||
|
result.append(widget);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TestResultsPane::displayName() const
|
QString TestResultsPane::displayName() const
|
||||||
@@ -325,14 +294,6 @@ 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();
|
||||||
m_defaultFormat.setBackground(creatorTheme()->palette().color(
|
|
||||||
m_textOutput->backgroundRole()));
|
|
||||||
m_defaultFormat.setForeground(creatorTheme()->palette().color(
|
|
||||||
m_textOutput->foregroundRole()));
|
|
||||||
|
|
||||||
// in case they had been forgotten to reset
|
|
||||||
m_stdErrHandler.endFormatScope();
|
|
||||||
m_stdOutHandler.endFormatScope();
|
|
||||||
clearMarks();
|
clearMarks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,6 +406,12 @@ void TestResultsPane::goToPrev()
|
|||||||
onItemActivated(nextCurrentIndex);
|
onItemActivated(nextCurrentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestResultsPane::updateFilter()
|
||||||
|
{
|
||||||
|
m_textOutput->updateFilterProperties(filterText(), filterCaseSensitivity(), filterUsesRegexp(),
|
||||||
|
filterIsInverted());
|
||||||
|
}
|
||||||
|
|
||||||
void TestResultsPane::onItemActivated(const QModelIndex &index)
|
void TestResultsPane::onItemActivated(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
@@ -711,6 +678,8 @@ void TestResultsPane::toggleOutputStyle()
|
|||||||
m_outputWidget->setCurrentIndex(displayText ? 1 : 0);
|
m_outputWidget->setCurrentIndex(displayText ? 1 : 0);
|
||||||
m_outputToggleButton->setIcon(displayText ? Icons::VISUAL_DISPLAY.icon()
|
m_outputToggleButton->setIcon(displayText ? Icons::VISUAL_DISPLAY.icon()
|
||||||
: Icons::TEXT_DISPLAY.icon());
|
: Icons::TEXT_DISPLAY.icon());
|
||||||
|
setFilteringEnabled(displayText);
|
||||||
|
setZoomButtonsEnabled(displayText);
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper for onCopyWholeTriggered() and onSaveWholeTriggered()
|
// helper for onCopyWholeTriggered() and onSaveWholeTriggered()
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include <coreplugin/ioutputpane.h>
|
#include <coreplugin/ioutputpane.h>
|
||||||
|
|
||||||
#include <utils/ansiescapecodehandler.h>
|
|
||||||
#include <utils/itemviews.h>
|
#include <utils/itemviews.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@@ -24,6 +23,7 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class IContext;
|
class IContext;
|
||||||
|
class OutputWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
@@ -71,6 +71,7 @@ public:
|
|||||||
bool canPrevious() const override;
|
bool canPrevious() const override;
|
||||||
void goToNext() override;
|
void goToNext() override;
|
||||||
void goToPrev() override;
|
void goToPrev() override;
|
||||||
|
void updateFilter() override;
|
||||||
|
|
||||||
void addTestResult(const TestResult &result);
|
void addTestResult(const TestResult &result);
|
||||||
void addOutputLine(const QByteArray &outputLine, OutputChannel channel);
|
void addOutputLine(const QByteArray &outputLine, OutputChannel channel);
|
||||||
@@ -118,15 +119,12 @@ private:
|
|||||||
QToolButton *m_stopTestRun;
|
QToolButton *m_stopTestRun;
|
||||||
QToolButton *m_filterButton;
|
QToolButton *m_filterButton;
|
||||||
QToolButton *m_outputToggleButton;
|
QToolButton *m_outputToggleButton;
|
||||||
QPlainTextEdit *m_textOutput;
|
Core::OutputWindow *m_textOutput;
|
||||||
QMenu *m_filterMenu;
|
QMenu *m_filterMenu;
|
||||||
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;
|
QVector<TestEditorMark *> m_marks;
|
||||||
QTextCharFormat m_defaultFormat;
|
|
||||||
Utils::AnsiEscapeCodeHandler m_stdErrHandler;
|
|
||||||
Utils::AnsiEscapeCodeHandler m_stdOutHandler;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user