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);
|
||||
enableAllResultTypes(true);
|
||||
if (!testSettings().omitInternalMsg())
|
||||
toggleTestResultType(ResultType::MessageInternal);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
QModelIndex index = m_sourceModel->index(sourceRow, 0, sourceParent);
|
||||
|
@@ -14,8 +14,7 @@
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
namespace Autotest::Internal {
|
||||
|
||||
class TestResultItem : public Utils::TypedTreeItem<TestResultItem, TestResultItem>
|
||||
{
|
||||
@@ -101,6 +100,9 @@ public:
|
||||
bool hasResults();
|
||||
TestResult testResult(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:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
@@ -110,5 +112,4 @@ private:
|
||||
QSet<ResultType> m_enabled;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
} // namespace Autotest::Internal
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/outputwindow.h>
|
||||
#include <coreplugin/session.h>
|
||||
|
||||
#include <projectexplorer/buildmanager.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
@@ -30,6 +31,7 @@
|
||||
#include <texteditor/texteditor.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/proxyaction.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -51,8 +53,7 @@
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
namespace Autotest::Internal {
|
||||
|
||||
ResultsTreeView::ResultsTreeView(QWidget *parent)
|
||||
: TreeView(parent)
|
||||
@@ -158,6 +159,10 @@ TestResultsPane::TestResultsPane(QObject *parent) :
|
||||
connect(TestRunner::instance(), &TestRunner::hadDisabledTests,
|
||||
m_model, &TestResultModel::raiseDisabledTests);
|
||||
visualOutputWidget->installEventFilter(this);
|
||||
connect(SessionManager::instance(), &SessionManager::sessionLoaded,
|
||||
this, &TestResultsPane::onSessionLoaded);
|
||||
connect(SessionManager::instance(), &SessionManager::aboutToSaveSession,
|
||||
this, &TestResultsPane::onAboutToSaveSession);
|
||||
}
|
||||
|
||||
void TestResultsPane::createToolButtons()
|
||||
@@ -438,11 +443,6 @@ void TestResultsPane::onItemActivated(const QModelIndex &index)
|
||||
|
||||
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;
|
||||
textAndType.insert(ResultType::Pass, Tr::tr("Pass"));
|
||||
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::MessageWarn, Tr::tr("Warning 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) {
|
||||
const ResultType &result = it.key();
|
||||
QAction *action = new QAction(m_filterMenu);
|
||||
action->setText(it.value());
|
||||
action->setCheckable(true);
|
||||
action->setChecked(result != ResultType::MessageInternal || !omitIntern);
|
||||
action->setChecked(enabled.contains(result));
|
||||
action->setData(int(result));
|
||||
m_filterMenu->addAction(action);
|
||||
}
|
||||
@@ -734,6 +735,34 @@ void TestResultsPane::clearMarks()
|
||||
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)
|
||||
{
|
||||
QModelIndex mapped = m_filterModel->mapFromSource(index);
|
||||
@@ -743,5 +772,4 @@ void TestResultsPane::showTestResult(const QModelIndex &index)
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
} // namespace Autotest::Internal
|
||||
|
@@ -100,6 +100,9 @@ private:
|
||||
void createMarks(const QModelIndex &parent = QModelIndex());
|
||||
void clearMarks();
|
||||
|
||||
void onSessionLoaded();
|
||||
void onAboutToSaveSession();
|
||||
|
||||
QStackedWidget *m_outputWidget;
|
||||
QFrame *m_summaryWidget;
|
||||
QLabel *m_summaryLabel;
|
||||
|
Reference in New Issue
Block a user