forked from qt-creator/qt-creator
AutoTest: Add sessions settings
Store the settings for showing durations and the current active result filters. Change-Id: I5d7a8e5ccea3da89593d940b3bf87928a7209625 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -464,6 +464,8 @@ TestResultFilterModel::TestResultFilterModel(TestResultModel *sourceModel, QObje
|
|||||||
{
|
{
|
||||||
setSourceModel(sourceModel);
|
setSourceModel(sourceModel);
|
||||||
enableAllResultTypes(true);
|
enableAllResultTypes(true);
|
||||||
|
if (!testSettings().omitInternalMsg())
|
||||||
|
toggleTestResultType(ResultType::MessageInternal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestResultFilterModel::enableAllResultTypes(bool enabled)
|
void TestResultFilterModel::enableAllResultTypes(bool enabled)
|
||||||
@@ -527,6 +529,24 @@ TestResultItem *TestResultFilterModel::itemForIndex(const QModelIndex &index) co
|
|||||||
return index.isValid() ? m_sourceModel->itemForIndex(mapToSource(index)) : nullptr;
|
return index.isValid() ? m_sourceModel->itemForIndex(mapToSource(index)) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QVariantList TestResultFilterModel::enabledFiltersAsSetting() const
|
||||||
|
{
|
||||||
|
return Utils::transform(Utils::toList(m_enabled),
|
||||||
|
[](ResultType rt) { return QVariant::fromValue(int(rt)); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestResultFilterModel::setEnabledFiltersFromSetting(const QVariantList &enabled)
|
||||||
|
{
|
||||||
|
m_enabled.clear();
|
||||||
|
if (!enabled.isEmpty()) {
|
||||||
|
for (const QVariant &variant : enabled)
|
||||||
|
m_enabled << ResultType(variant.value<int>());
|
||||||
|
}
|
||||||
|
// when misused: ensure non-discardable filters are enabled
|
||||||
|
m_enabled << ResultType::MessageFatal << ResultType::MessageSystem << ResultType::MessageError;
|
||||||
|
invalidateFilter();
|
||||||
|
}
|
||||||
|
|
||||||
bool TestResultFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
bool TestResultFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||||
{
|
{
|
||||||
QModelIndex index = m_sourceModel->index(sourceRow, 0, sourceParent);
|
QModelIndex index = m_sourceModel->index(sourceRow, 0, sourceParent);
|
||||||
|
@@ -14,8 +14,7 @@
|
|||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class TestResultItem : public Utils::TypedTreeItem<TestResultItem, TestResultItem>
|
class TestResultItem : public Utils::TypedTreeItem<TestResultItem, TestResultItem>
|
||||||
{
|
{
|
||||||
@@ -101,6 +100,9 @@ public:
|
|||||||
bool hasResults();
|
bool hasResults();
|
||||||
TestResult testResult(const QModelIndex &index) const;
|
TestResult testResult(const QModelIndex &index) const;
|
||||||
TestResultItem *itemForIndex(const QModelIndex &index) const;
|
TestResultItem *itemForIndex(const QModelIndex &index) const;
|
||||||
|
const QSet<ResultType> enabledFilters() const { return m_enabled; }
|
||||||
|
const QVariantList enabledFiltersAsSetting() const;
|
||||||
|
void setEnabledFiltersFromSetting(const QVariantList &enabled);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||||
@@ -110,5 +112,4 @@ private:
|
|||||||
QSet<ResultType> m_enabled;
|
QSet<ResultType> m_enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Autotest::Internal
|
||||||
} // namespace Autotest
|
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include <coreplugin/icontext.h>
|
#include <coreplugin/icontext.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/outputwindow.h>
|
#include <coreplugin/outputwindow.h>
|
||||||
|
#include <coreplugin/session.h>
|
||||||
|
|
||||||
#include <projectexplorer/buildmanager.h>
|
#include <projectexplorer/buildmanager.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
@@ -30,6 +31,7 @@
|
|||||||
#include <texteditor/texteditor.h>
|
#include <texteditor/texteditor.h>
|
||||||
#include <texteditor/texteditorsettings.h>
|
#include <texteditor/texteditorsettings.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/proxyaction.h>
|
#include <utils/proxyaction.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -51,8 +53,7 @@
|
|||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
ResultsTreeView::ResultsTreeView(QWidget *parent)
|
ResultsTreeView::ResultsTreeView(QWidget *parent)
|
||||||
: TreeView(parent)
|
: TreeView(parent)
|
||||||
@@ -158,6 +159,10 @@ TestResultsPane::TestResultsPane(QObject *parent) :
|
|||||||
connect(TestRunner::instance(), &TestRunner::hadDisabledTests,
|
connect(TestRunner::instance(), &TestRunner::hadDisabledTests,
|
||||||
m_model, &TestResultModel::raiseDisabledTests);
|
m_model, &TestResultModel::raiseDisabledTests);
|
||||||
visualOutputWidget->installEventFilter(this);
|
visualOutputWidget->installEventFilter(this);
|
||||||
|
connect(SessionManager::instance(), &SessionManager::sessionLoaded,
|
||||||
|
this, &TestResultsPane::onSessionLoaded);
|
||||||
|
connect(SessionManager::instance(), &SessionManager::aboutToSaveSession,
|
||||||
|
this, &TestResultsPane::onAboutToSaveSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestResultsPane::createToolButtons()
|
void TestResultsPane::createToolButtons()
|
||||||
@@ -438,11 +443,6 @@ void TestResultsPane::onItemActivated(const QModelIndex &index)
|
|||||||
|
|
||||||
void TestResultsPane::initializeFilterMenu()
|
void TestResultsPane::initializeFilterMenu()
|
||||||
{
|
{
|
||||||
const bool omitIntern = testSettings().omitInternalMsg();
|
|
||||||
// FilterModel has all messages enabled by default
|
|
||||||
if (omitIntern)
|
|
||||||
m_filterModel->toggleTestResultType(ResultType::MessageInternal);
|
|
||||||
|
|
||||||
QMap<ResultType, QString> textAndType;
|
QMap<ResultType, QString> textAndType;
|
||||||
textAndType.insert(ResultType::Pass, Tr::tr("Pass"));
|
textAndType.insert(ResultType::Pass, Tr::tr("Pass"));
|
||||||
textAndType.insert(ResultType::Fail, Tr::tr("Fail"));
|
textAndType.insert(ResultType::Fail, Tr::tr("Fail"));
|
||||||
@@ -453,12 +453,13 @@ void TestResultsPane::initializeFilterMenu()
|
|||||||
textAndType.insert(ResultType::MessageDebug, Tr::tr("Debug Messages"));
|
textAndType.insert(ResultType::MessageDebug, Tr::tr("Debug Messages"));
|
||||||
textAndType.insert(ResultType::MessageWarn, Tr::tr("Warning Messages"));
|
textAndType.insert(ResultType::MessageWarn, Tr::tr("Warning Messages"));
|
||||||
textAndType.insert(ResultType::MessageInternal, Tr::tr("Internal Messages"));
|
textAndType.insert(ResultType::MessageInternal, Tr::tr("Internal Messages"));
|
||||||
|
const QSet<ResultType> enabled = m_filterModel->enabledFilters();
|
||||||
for (auto it = textAndType.cbegin(); it != textAndType.cend(); ++it) {
|
for (auto it = textAndType.cbegin(); it != textAndType.cend(); ++it) {
|
||||||
const ResultType &result = it.key();
|
const ResultType &result = it.key();
|
||||||
QAction *action = new QAction(m_filterMenu);
|
QAction *action = new QAction(m_filterMenu);
|
||||||
action->setText(it.value());
|
action->setText(it.value());
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
action->setChecked(result != ResultType::MessageInternal || !omitIntern);
|
action->setChecked(enabled.contains(result));
|
||||||
action->setData(int(result));
|
action->setData(int(result));
|
||||||
m_filterMenu->addAction(action);
|
m_filterMenu->addAction(action);
|
||||||
}
|
}
|
||||||
@@ -734,6 +735,34 @@ void TestResultsPane::clearMarks()
|
|||||||
m_marks.clear();
|
m_marks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static constexpr char SV_SHOW_DURATIONS[] = "AutoTest.ShowDurations";
|
||||||
|
static constexpr char SV_MESSAGE_FILTER[] = "AutoTest.MessageFilter";
|
||||||
|
|
||||||
|
void TestResultsPane::onSessionLoaded()
|
||||||
|
{
|
||||||
|
const bool showDurations = SessionManager::sessionValue(SV_SHOW_DURATIONS, true).toBool();
|
||||||
|
m_showDurationButton->setChecked(showDurations);
|
||||||
|
const QVariantList enabledFilters = SessionManager::sessionValue(SV_MESSAGE_FILTER).toList();
|
||||||
|
|
||||||
|
if (enabledFilters.isEmpty()) {
|
||||||
|
m_filterModel->enableAllResultTypes(true);
|
||||||
|
if (testSettings().omitInternalMsg())
|
||||||
|
m_filterModel->toggleTestResultType(ResultType::MessageInternal);
|
||||||
|
} else {
|
||||||
|
m_filterModel->setEnabledFiltersFromSetting(enabledFilters);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_filterMenu->clear();
|
||||||
|
initializeFilterMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TestResultsPane::onAboutToSaveSession()
|
||||||
|
{
|
||||||
|
SessionManager::setSessionValue(SV_SHOW_DURATIONS, m_showDurationButton->isChecked());
|
||||||
|
SessionManager::setSessionValue(SV_MESSAGE_FILTER, m_filterModel->enabledFiltersAsSetting());
|
||||||
|
}
|
||||||
|
|
||||||
void TestResultsPane::showTestResult(const QModelIndex &index)
|
void TestResultsPane::showTestResult(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
QModelIndex mapped = m_filterModel->mapFromSource(index);
|
QModelIndex mapped = m_filterModel->mapFromSource(index);
|
||||||
@@ -743,5 +772,4 @@ void TestResultsPane::showTestResult(const QModelIndex &index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Autotest::Internal
|
||||||
} // namespace Autotest
|
|
||||||
|
@@ -100,6 +100,9 @@ private:
|
|||||||
void createMarks(const QModelIndex &parent = QModelIndex());
|
void createMarks(const QModelIndex &parent = QModelIndex());
|
||||||
void clearMarks();
|
void clearMarks();
|
||||||
|
|
||||||
|
void onSessionLoaded();
|
||||||
|
void onAboutToSaveSession();
|
||||||
|
|
||||||
QStackedWidget *m_outputWidget;
|
QStackedWidget *m_outputWidget;
|
||||||
QFrame *m_summaryWidget;
|
QFrame *m_summaryWidget;
|
||||||
QLabel *m_summaryLabel;
|
QLabel *m_summaryLabel;
|
||||||
|
Reference in New Issue
Block a user