forked from qt-creator/qt-creator
AutoTests: Aspectify parts of main settings
Change-Id: I407b5102e1f2a6647f6fdca01a61dfa422c5d3ee Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -96,7 +96,7 @@ public:
|
||||
void onRunUnderCursorTriggered(TestRunMode mode);
|
||||
|
||||
TestSettings m_settings;
|
||||
TestSettingsPage m_testSettingPage{&m_settings};
|
||||
TestSettingsPage m_testSettingPage;
|
||||
|
||||
TestCodeParser m_testCodeParser;
|
||||
TestTreeModel m_testTreeModel{&m_testCodeParser};
|
||||
@@ -178,11 +178,6 @@ AutotestPluginPrivate::~AutotestPluginPrivate()
|
||||
delete m_resultsPane;
|
||||
}
|
||||
|
||||
TestSettings *AutotestPlugin::settings()
|
||||
{
|
||||
return &dd->m_settings;
|
||||
}
|
||||
|
||||
TestProjectSettings *AutotestPlugin::projectSettings(ProjectExplorer::Project *project)
|
||||
{
|
||||
auto &settings = s_projectSettings[project];
|
||||
|
@@ -18,7 +18,6 @@ namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
class TestProjectSettings;
|
||||
struct TestSettings;
|
||||
|
||||
struct ChoicePair
|
||||
{
|
||||
@@ -43,7 +42,6 @@ public:
|
||||
void extensionsInitialized() override;
|
||||
ShutdownFlag aboutToShutdown() override;
|
||||
|
||||
static TestSettings *settings();
|
||||
static TestProjectSettings *projectSettings(ProjectExplorer::Project *project);
|
||||
static TestFrameworks activeTestFrameworks();
|
||||
static void updateMenuItemsEnabledState();
|
||||
|
@@ -6,7 +6,6 @@
|
||||
#include "boosttestoutputreader.h"
|
||||
#include "boosttestsettings.h"
|
||||
|
||||
#include "../autotestplugin.h"
|
||||
#include "../itestframework.h"
|
||||
#include "../testsettings.h"
|
||||
|
||||
@@ -106,7 +105,7 @@ QStringList BoostTestConfiguration::argumentsForTestRunner(QStringList *omitted)
|
||||
for (const QString &test : testCases())
|
||||
arguments << "-t" << test;
|
||||
|
||||
if (AutotestPlugin::settings()->processArgs) {
|
||||
if (TestSettings::instance()->processArgs()) {
|
||||
arguments << filterInterfering(runnable().command.arguments().split(
|
||||
' ', Qt::SkipEmptyParts), omitted);
|
||||
}
|
||||
|
@@ -6,7 +6,6 @@
|
||||
#include "catchoutputreader.h"
|
||||
#include "catchtestsettings.h"
|
||||
|
||||
#include "../autotestplugin.h"
|
||||
#include "../itestframework.h"
|
||||
#include "../testsettings.h"
|
||||
|
||||
@@ -80,7 +79,7 @@ QStringList CatchConfiguration::argumentsForTestRunner(QStringList *omitted) con
|
||||
arguments << "\"" + testCases().join("\", \"") + "\"";
|
||||
arguments << "--reporter" << "xml";
|
||||
|
||||
if (AutotestPlugin::settings()->processArgs) {
|
||||
if (TestSettings::instance()->processArgs()) {
|
||||
arguments << filterInterfering(runnable().command.arguments().split(
|
||||
' ', Qt::SkipEmptyParts), omitted);
|
||||
}
|
||||
|
@@ -88,7 +88,7 @@ QList<ITestConfiguration *> CTestTreeItem::testConfigurationsFor(const QStringLi
|
||||
return {};
|
||||
|
||||
const ProjectExplorer::BuildSystem *buildSystem = target->buildSystem();
|
||||
QStringList options{"--timeout", QString::number(AutotestPlugin::settings()->timeout / 1000)};
|
||||
QStringList options{"--timeout", QString::number(TestSettings::instance()->timeout() / 1000)};
|
||||
auto ctestSettings = static_cast<CTestSettings *>(testBase()->testSettings());
|
||||
options << ctestSettings->activeSettingsAsOptions();
|
||||
CommandLine command = buildSystem->commandLineForTests(selected, options);
|
||||
|
@@ -6,7 +6,6 @@
|
||||
#include "gtestoutputreader.h"
|
||||
#include "gtestsettings.h"
|
||||
|
||||
#include "../autotestplugin.h"
|
||||
#include "../itestframework.h"
|
||||
#include "../testsettings.h"
|
||||
|
||||
@@ -55,7 +54,7 @@ QStringList filterInterfering(const QStringList &provided, QStringList *omitted)
|
||||
QStringList GTestConfiguration::argumentsForTestRunner(QStringList *omitted) const
|
||||
{
|
||||
QStringList arguments;
|
||||
if (AutotestPlugin::settings()->processArgs) {
|
||||
if (TestSettings::instance()->processArgs()) {
|
||||
arguments << filterInterfering(runnable().command.arguments().split(
|
||||
' ', Qt::SkipEmptyParts), omitted);
|
||||
}
|
||||
|
@@ -2,8 +2,9 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "qttest_utils.h"
|
||||
|
||||
#include "qttesttreeitem.h"
|
||||
#include "../autotestplugin.h"
|
||||
#include "../itestframework.h"
|
||||
#include "../testsettings.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
@@ -136,7 +137,7 @@ Environment prepareBasicEnvironment(const Environment &env)
|
||||
result.set("QT_FORCE_STDERR_LOGGING", "1");
|
||||
result.set("QT_LOGGING_TO_CONSOLE", "1");
|
||||
}
|
||||
const int timeout = AutotestPlugin::settings()->timeout;
|
||||
const int timeout = TestSettings::instance()->timeout();
|
||||
if (timeout > 5 * 60 * 1000) // Qt5.5 introduced hard limit, Qt5.6.1 added env var to raise this
|
||||
result.set("QTEST_FUNCTION_TIMEOUT", QString::number(timeout));
|
||||
return result;
|
||||
|
@@ -7,7 +7,6 @@
|
||||
#include "qttestsettings.h"
|
||||
#include "qttest_utils.h"
|
||||
|
||||
#include "../autotestplugin.h"
|
||||
#include "../itestframework.h"
|
||||
#include "../testsettings.h"
|
||||
|
||||
@@ -40,7 +39,7 @@ TestOutputReader *QtTestConfiguration::createOutputReader(Process *app) const
|
||||
QStringList QtTestConfiguration::argumentsForTestRunner(QStringList *omitted) const
|
||||
{
|
||||
QStringList arguments;
|
||||
if (AutotestPlugin::settings()->processArgs) {
|
||||
if (TestSettings::instance()->processArgs()) {
|
||||
arguments.append(QTestUtils::filterInterfering(
|
||||
runnable().command.arguments().split(' ', Qt::SkipEmptyParts),
|
||||
omitted, false));
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "quicktestconfiguration.h"
|
||||
|
||||
#include "../autotestplugin.h"
|
||||
#include "../itestframework.h"
|
||||
#include "../qtest/qttestoutputreader.h"
|
||||
#include "../qtest/qttestsettings.h"
|
||||
@@ -33,7 +32,7 @@ TestOutputReader *QuickTestConfiguration::createOutputReader(Process *app) const
|
||||
QStringList QuickTestConfiguration::argumentsForTestRunner(QStringList *omitted) const
|
||||
{
|
||||
QStringList arguments;
|
||||
if (AutotestPlugin::settings()->processArgs) {
|
||||
if (TestSettings::instance()->processArgs()) {
|
||||
arguments.append(QTestUtils::filterInterfering
|
||||
(runnable().command.arguments().split(' ', Qt::SkipEmptyParts),
|
||||
omitted, true));
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "testframeworkmanager.h"
|
||||
|
||||
#include "autotestplugin.h"
|
||||
#include "testsettings.h"
|
||||
|
||||
#include <utils/aspects.h>
|
||||
@@ -98,7 +97,7 @@ ITestTool *TestFrameworkManager::testToolForBuildSystemId(Id buildSystemId)
|
||||
|
||||
void TestFrameworkManager::synchronizeSettings(QSettings *s)
|
||||
{
|
||||
Internal::AutotestPlugin::settings()->fromSettings(s);
|
||||
Internal::TestSettings::instance()->fromSettings(s);
|
||||
for (ITestFramework *framework : std::as_const(m_registeredFrameworks)) {
|
||||
if (ITestSettings *fSettings = framework->testSettings())
|
||||
fSettings->readSettings(s);
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "testresultdelegate.h"
|
||||
|
||||
#include "autotestplugin.h"
|
||||
#include "testresultmodel.h"
|
||||
#include "testsettings.h"
|
||||
|
||||
@@ -162,10 +161,10 @@ void TestResultDelegate::clearCache()
|
||||
|
||||
void TestResultDelegate::limitTextOutput(QString &output) const
|
||||
{
|
||||
int maxLineCount = Internal::AutotestPlugin::settings()->resultDescriptionMaxSize;
|
||||
int maxLineCount = Internal::TestSettings::instance()->resultDescriptionMaxSize();
|
||||
bool limited = false;
|
||||
|
||||
if (Internal::AutotestPlugin::settings()->limitResultDescription && maxLineCount > 0) {
|
||||
if (Internal::TestSettings::instance()->limitResultDescription() && maxLineCount > 0) {
|
||||
int index = -1;
|
||||
int lastChar = output.size() - 1;
|
||||
|
||||
@@ -183,7 +182,7 @@ void TestResultDelegate::limitTextOutput(QString &output) const
|
||||
}
|
||||
}
|
||||
|
||||
if (AutotestPlugin::settings()->limitResultOutput && output.length() > outputLimit) {
|
||||
if (TestSettings::instance()->limitResultOutput() && output.length() > outputLimit) {
|
||||
output = output.left(outputLimit);
|
||||
limited = true;
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@
|
||||
#include "testresultmodel.h"
|
||||
|
||||
#include "autotesticons.h"
|
||||
#include "autotestplugin.h"
|
||||
#include "testrunner.h"
|
||||
#include "testsettings.h"
|
||||
#include "testtreeitem.h"
|
||||
@@ -274,7 +273,7 @@ void TestResultModel::addTestResult(const TestResult &testResult, bool autoExpan
|
||||
|
||||
TestResultItem *newItem = new TestResultItem(testResult);
|
||||
TestResultItem *root = nullptr;
|
||||
if (AutotestPlugin::settings()->displayApplication) {
|
||||
if (TestSettings::instance()->displayApplication()) {
|
||||
const QString application = testResult.id();
|
||||
if (!application.isEmpty()) {
|
||||
root = rootItem()->findFirstLevelChild([&application](TestResultItem *child) {
|
||||
|
@@ -291,7 +291,7 @@ void TestResultsPane::clearContents()
|
||||
setIconBadgeNumber(0);
|
||||
navigateStateChanged();
|
||||
m_summaryWidget->setVisible(false);
|
||||
m_autoScroll = AutotestPlugin::settings()->autoScroll;
|
||||
m_autoScroll = TestSettings::instance()->autoScroll();
|
||||
connect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged,
|
||||
this, &TestResultsPane::onScrollBarRangeChanged, Qt::UniqueConnection);
|
||||
m_textOutput->clear();
|
||||
@@ -437,7 +437,7 @@ void TestResultsPane::onRunSelectedTriggered()
|
||||
|
||||
void TestResultsPane::initializeFilterMenu()
|
||||
{
|
||||
const bool omitIntern = AutotestPlugin::settings()->omitInternalMssg;
|
||||
const bool omitIntern = TestSettings::instance()->omitInternalMsg();
|
||||
// FilterModel has all messages enabled by default
|
||||
if (omitIntern)
|
||||
m_filterModel->toggleTestResultType(ResultType::MessageInternal);
|
||||
@@ -553,8 +553,8 @@ void TestResultsPane::onTestRunFinished()
|
||||
m_model->removeCurrentTestMessage();
|
||||
disconnect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged,
|
||||
this, &TestResultsPane::onScrollBarRangeChanged);
|
||||
if (AutotestPlugin::settings()->popupOnFinish
|
||||
&& (!AutotestPlugin::settings()->popupOnFail || hasFailedTests(m_model))) {
|
||||
if (TestSettings::instance()->popupOnFinish()
|
||||
&& (!TestSettings::instance()->popupOnFail() || hasFailedTests(m_model))) {
|
||||
popup(IOutputPane::NoModeSwitch);
|
||||
}
|
||||
createMarks();
|
||||
|
@@ -258,7 +258,7 @@ static RunConfiguration *getRunConfiguration(const QString &buildTargetKey)
|
||||
|
||||
int TestRunner::precheckTestConfigurations()
|
||||
{
|
||||
const bool omitWarnings = AutotestPlugin::settings()->omitRunConfigWarn;
|
||||
const bool omitWarnings = TestSettings::instance()->omitRunConfigWarn();
|
||||
int testCaseCount = 0;
|
||||
for (ITestConfiguration *itc : std::as_const(m_selectedTests)) {
|
||||
if (itc->testBase()->type() == ITestBase::Tool) {
|
||||
@@ -402,7 +402,7 @@ void TestRunner::runTestsHelper()
|
||||
}
|
||||
process.setEnvironment(environment);
|
||||
|
||||
m_cancelTimer.setInterval(AutotestPlugin::settings()->timeout);
|
||||
m_cancelTimer.setInterval(TestSettings::instance()->timeout());
|
||||
m_cancelTimer.start();
|
||||
|
||||
qCInfo(runnerLog) << "Command:" << process.commandLine().executable();
|
||||
@@ -465,7 +465,7 @@ void TestRunner::runTestsHelper()
|
||||
cancelCurrent(UserCanceled);
|
||||
});
|
||||
|
||||
if (AutotestPlugin::settings()->popupOnStart)
|
||||
if (TestSettings::instance()->popupOnStart())
|
||||
AutotestPlugin::popupResultsPane();
|
||||
|
||||
m_taskTree->start();
|
||||
@@ -588,7 +588,7 @@ void TestRunner::debugTests()
|
||||
connect(runControl, &RunControl::stopped, this, &TestRunner::onFinished);
|
||||
m_finishDebugConnect = connect(runControl, &RunControl::finished, this, &TestRunner::onFinished);
|
||||
ProjectExplorerPlugin::startRunControl(runControl);
|
||||
if (useOutputProcessor && AutotestPlugin::settings()->popupOnStart)
|
||||
if (useOutputProcessor && TestSettings::instance()->popupOnStart())
|
||||
AutotestPlugin::popupResultsPane();
|
||||
}
|
||||
|
||||
@@ -669,10 +669,10 @@ static RunAfterBuildMode runAfterBuild()
|
||||
return RunAfterBuildMode::None;
|
||||
|
||||
if (!project->namedSettings(Constants::SK_USE_GLOBAL).isValid())
|
||||
return AutotestPlugin::settings()->runAfterBuild;
|
||||
return TestSettings::instance()->runAfterBuildMode();
|
||||
|
||||
TestProjectSettings *projectSettings = AutotestPlugin::projectSettings(project);
|
||||
return projectSettings->useGlobalSettings() ? AutotestPlugin::settings()->runAfterBuild
|
||||
return projectSettings->useGlobalSettings() ? TestSettings::instance()->runAfterBuildMode()
|
||||
: projectSettings->runAfterBuild();
|
||||
}
|
||||
|
||||
|
@@ -4,53 +4,123 @@
|
||||
#include "testsettings.h"
|
||||
|
||||
#include "autotestconstants.h"
|
||||
#include "autotesttr.h"
|
||||
#include "testframeworkmanager.h"
|
||||
|
||||
#include <utils/id.h>
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
namespace Autotest::Internal {
|
||||
|
||||
static const char timeoutKey[] = "Timeout";
|
||||
static const char omitInternalKey[] = "OmitInternal";
|
||||
static const char omitRunConfigWarnKey[] = "OmitRCWarnings";
|
||||
static const char limitResultOutputKey[] = "LimitResultOutput";
|
||||
static const char limitResultDescriptionKey[] = "LimitResultDescription";
|
||||
static const char resultDescriptionMaxSizeKey[] = "ResultDescriptionMaxSize";
|
||||
static const char autoScrollKey[] = "AutoScrollResults";
|
||||
static const char processArgsKey[] = "ProcessArgs";
|
||||
static const char displayApplicationKey[] = "DisplayApp";
|
||||
static const char popupOnStartKey[] = "PopupOnStart";
|
||||
static const char popupOnFinishKey[] = "PopupOnFinish";
|
||||
static const char popupOnFailKey[] = "PopupOnFail";
|
||||
static const char runAfterBuildKey[] = "RunAfterBuild";
|
||||
static const char groupSuffix[] = ".group";
|
||||
|
||||
constexpr int defaultTimeout = 60000;
|
||||
|
||||
TestSettings::TestSettings()
|
||||
: timeout(defaultTimeout)
|
||||
static TestSettings *s_instance;
|
||||
|
||||
TestSettings *TestSettings::instance()
|
||||
{
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
TestSettings::TestSettings()
|
||||
{
|
||||
s_instance = this;
|
||||
|
||||
setSettingsGroup(Constants::SETTINGSGROUP);
|
||||
|
||||
registerAspect(&timeout);
|
||||
timeout.setSettingsKey("Timeout");
|
||||
timeout.setDefaultValue(defaultTimeout);
|
||||
timeout.setRange(5000, 36'000'000); // 36 Mio ms = 36'000 s = 10 h
|
||||
timeout.setSuffix(Tr::tr(" s")); // we show seconds, but store milliseconds
|
||||
timeout.setDisplayScaleFactor(1000);
|
||||
timeout.setToolTip(Tr::tr("Timeout used when executing test cases. This will apply "
|
||||
"for each test case on its own, not the whole project."));
|
||||
|
||||
registerAspect(&omitInternalMsg);
|
||||
omitInternalMsg.setSettingsKey("OmitInternal");
|
||||
omitInternalMsg.setDefaultValue(true);
|
||||
omitInternalMsg.setLabelText(Tr::tr("Omit internal messages"));
|
||||
omitInternalMsg.setToolTip(Tr::tr("Hides internal messages by default. "
|
||||
"You can still enable them by using the test results filter."));
|
||||
|
||||
registerAspect(&omitRunConfigWarn);
|
||||
omitRunConfigWarn.setSettingsKey("OmitRCWarnings");
|
||||
omitRunConfigWarn.setLabelText(Tr::tr("Omit run configuration warnings"));
|
||||
omitRunConfigWarn.setToolTip(Tr::tr("Hides warnings related to a deduced run configuration."));
|
||||
|
||||
registerAspect(&limitResultOutput);
|
||||
limitResultOutput.setSettingsKey("LimitResultOutput");
|
||||
limitResultOutput.setDefaultValue(true);
|
||||
limitResultOutput.setLabelText(Tr::tr("Limit result output"));
|
||||
limitResultOutput.setToolTip(Tr::tr("Limits result output to 100000 characters."));
|
||||
|
||||
registerAspect(&limitResultDescription);
|
||||
limitResultDescription.setSettingsKey("LimitResultDescription");
|
||||
limitResultDescription.setLabelText(Tr::tr("Limit result description:"));
|
||||
limitResultDescription.setToolTip(
|
||||
Tr::tr("Limit number of lines shown in test result tooltip and description."));
|
||||
|
||||
registerAspect(&resultDescriptionMaxSize);
|
||||
resultDescriptionMaxSize.setSettingsKey("ResultDescriptionMaxSize");
|
||||
resultDescriptionMaxSize.setDefaultValue(10);
|
||||
resultDescriptionMaxSize.setRange(1, 100000);
|
||||
resultDescriptionMaxSize.setEnabler(&limitResultDescription);
|
||||
|
||||
registerAspect(&autoScroll);
|
||||
autoScroll.setSettingsKey("AutoScrollResults");
|
||||
autoScroll.setDefaultValue(true);
|
||||
autoScroll.setLabelText(Tr::tr("Automatically scroll results"));
|
||||
autoScroll.setToolTip(Tr::tr("Automatically scrolls down when new items are added "
|
||||
"and scrollbar is at bottom."));
|
||||
|
||||
registerAspect(&processArgs);
|
||||
processArgs.setSettingsKey("ProcessArgs");
|
||||
processArgs.setLabelText(Tr::tr("Process arguments"));
|
||||
processArgs.setToolTip(
|
||||
Tr::tr("Allow passing arguments specified on the respective run configuration.\n"
|
||||
"Warning: this is an experimental feature and might lead to failing to "
|
||||
"execute the test executable."));
|
||||
|
||||
registerAspect(&displayApplication);
|
||||
displayApplication.setSettingsKey("DisplayApp");
|
||||
displayApplication.setLabelText(Tr::tr("Group results by application"));
|
||||
|
||||
registerAspect(&popupOnStart);
|
||||
popupOnStart.setSettingsKey("PopupOnStart");
|
||||
popupOnStart.setLabelText(Tr::tr("Open results when tests start"));
|
||||
popupOnStart.setToolTip(
|
||||
Tr::tr("Displays test results automatically when tests are started."));
|
||||
|
||||
registerAspect(&popupOnFinish);
|
||||
popupOnFinish.setSettingsKey("PopupOnFinish");
|
||||
popupOnFinish.setDefaultValue(true);
|
||||
popupOnFinish.setLabelText(Tr::tr("Open results when tests finish"));
|
||||
popupOnFinish.setToolTip(
|
||||
Tr::tr("Displays test results automatically when tests are finished."));
|
||||
|
||||
registerAspect(&popupOnFail);
|
||||
popupOnFail.setSettingsKey("PopupOnFail");
|
||||
popupOnFail.setLabelText(Tr::tr("Only for unsuccessful test runs"));
|
||||
popupOnFail.setEnabler(&popupOnFinish);
|
||||
popupOnFail.setToolTip(Tr::tr("Displays test results only if the test run contains "
|
||||
"failed, fatal or unexpectedly passed tests."));
|
||||
|
||||
registerAspect(&runAfterBuild);
|
||||
runAfterBuild.setSettingsKey("RunAfterBuild");
|
||||
runAfterBuild.setDisplayStyle(Utils::SelectionAspect::DisplayStyle::ComboBox);
|
||||
runAfterBuild.setToolTip(Tr::tr("Runs chosen tests automatically if a build succeeded."));
|
||||
runAfterBuild.addOption(Tr::tr("None"));
|
||||
runAfterBuild.addOption(Tr::tr("All"));
|
||||
runAfterBuild.addOption(Tr::tr("Selected"));
|
||||
}
|
||||
|
||||
void TestSettings::toSettings(QSettings *s) const
|
||||
{
|
||||
AspectContainer::writeSettings(s);
|
||||
|
||||
s->beginGroup(Constants::SETTINGSGROUP);
|
||||
s->setValue(timeoutKey, timeout);
|
||||
s->setValue(omitInternalKey, omitInternalMssg);
|
||||
s->setValue(omitRunConfigWarnKey, omitRunConfigWarn);
|
||||
s->setValue(limitResultOutputKey, limitResultOutput);
|
||||
s->setValue(limitResultDescriptionKey, limitResultDescription);
|
||||
s->setValue(resultDescriptionMaxSizeKey, resultDescriptionMaxSize);
|
||||
s->setValue(autoScrollKey, autoScroll);
|
||||
s->setValue(processArgsKey, processArgs);
|
||||
s->setValue(displayApplicationKey, displayApplication);
|
||||
s->setValue(popupOnStartKey, popupOnStart);
|
||||
s->setValue(popupOnFinishKey, popupOnFinish);
|
||||
s->setValue(popupOnFailKey, popupOnFail);
|
||||
s->setValue(runAfterBuildKey, int(runAfterBuild));
|
||||
|
||||
// store frameworks and their current active and grouping state
|
||||
for (auto it = frameworks.cbegin(); it != frameworks.cend(); ++it) {
|
||||
const Utils::Id &id = it.key();
|
||||
@@ -65,21 +135,10 @@ void TestSettings::toSettings(QSettings *s) const
|
||||
|
||||
void TestSettings::fromSettings(QSettings *s)
|
||||
{
|
||||
AspectContainer::readSettings(s);
|
||||
|
||||
s->beginGroup(Constants::SETTINGSGROUP);
|
||||
timeout = s->value(timeoutKey, defaultTimeout).toInt();
|
||||
omitInternalMssg = s->value(omitInternalKey, true).toBool();
|
||||
omitRunConfigWarn = s->value(omitRunConfigWarnKey, false).toBool();
|
||||
limitResultOutput = s->value(limitResultOutputKey, true).toBool();
|
||||
limitResultDescription = s->value(limitResultDescriptionKey, false).toBool();
|
||||
resultDescriptionMaxSize = s->value(resultDescriptionMaxSizeKey, 10).toInt();
|
||||
autoScroll = s->value(autoScrollKey, true).toBool();
|
||||
processArgs = s->value(processArgsKey, false).toBool();
|
||||
displayApplication = s->value(displayApplicationKey, false).toBool();
|
||||
popupOnStart = s->value(popupOnStartKey, true).toBool();
|
||||
popupOnFinish = s->value(popupOnFinishKey, true).toBool();
|
||||
popupOnFail = s->value(popupOnFailKey, false).toBool();
|
||||
runAfterBuild = RunAfterBuildMode(s->value(runAfterBuildKey,
|
||||
int(RunAfterBuildMode::None)).toInt());
|
||||
|
||||
// try to get settings for registered frameworks
|
||||
const TestFrameworks ®istered = TestFrameworkManager::registeredFrameworks();
|
||||
frameworks.clear();
|
||||
@@ -102,5 +161,9 @@ void TestSettings::fromSettings(QSettings *s)
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
RunAfterBuildMode TestSettings::runAfterBuildMode() const
|
||||
{
|
||||
return static_cast<RunAfterBuildMode>(runAfterBuild.value());
|
||||
}
|
||||
|
||||
} // namespace Autotest::Internal
|
||||
|
@@ -3,18 +3,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QHash>
|
||||
#include <utils/aspects.h>
|
||||
|
||||
namespace Utils {
|
||||
class Id;
|
||||
}
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
namespace Autotest::Internal {
|
||||
|
||||
enum class RunAfterBuildMode
|
||||
{
|
||||
@@ -23,29 +14,39 @@ enum class RunAfterBuildMode
|
||||
Selected
|
||||
};
|
||||
|
||||
struct TestSettings
|
||||
class NonAspectSettings
|
||||
{
|
||||
TestSettings();
|
||||
void toSettings(QSettings *s) const;
|
||||
void fromSettings(QSettings *s);
|
||||
|
||||
int timeout;
|
||||
bool omitInternalMssg = true;
|
||||
bool omitRunConfigWarn = false;
|
||||
bool limitResultOutput = true;
|
||||
bool limitResultDescription = false;
|
||||
int resultDescriptionMaxSize = 10;
|
||||
bool autoScroll = true;
|
||||
bool processArgs = false;
|
||||
bool displayApplication = false;
|
||||
bool popupOnStart = true;
|
||||
bool popupOnFinish = true;
|
||||
bool popupOnFail = false;
|
||||
RunAfterBuildMode runAfterBuild = RunAfterBuildMode::None;
|
||||
public:
|
||||
QHash<Utils::Id, bool> frameworks;
|
||||
QHash<Utils::Id, bool> frameworksGrouping;
|
||||
QHash<Utils::Id, bool> tools;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
class TestSettings : public Utils::AspectContainer, public NonAspectSettings
|
||||
{
|
||||
public:
|
||||
TestSettings();
|
||||
|
||||
static TestSettings *instance();
|
||||
|
||||
void toSettings(QSettings *s) const;
|
||||
void fromSettings(QSettings *s);
|
||||
|
||||
Utils::IntegerAspect timeout;
|
||||
Utils::BoolAspect omitInternalMsg;
|
||||
Utils::BoolAspect omitRunConfigWarn;
|
||||
Utils::BoolAspect limitResultOutput;
|
||||
Utils::BoolAspect limitResultDescription;
|
||||
Utils::IntegerAspect resultDescriptionMaxSize;
|
||||
Utils::BoolAspect autoScroll;
|
||||
Utils::BoolAspect processArgs;
|
||||
Utils::BoolAspect displayApplication;
|
||||
Utils::BoolAspect popupOnStart;
|
||||
Utils::BoolAspect popupOnFinish;
|
||||
Utils::BoolAspect popupOnFail;
|
||||
Utils::SelectionAspect runAfterBuild;
|
||||
|
||||
RunAfterBuildMode runAfterBuildMode() const;
|
||||
};
|
||||
|
||||
} // Autotest::Internal
|
||||
|
@@ -25,7 +25,6 @@
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QSpacerItem>
|
||||
#include <QSpinBox>
|
||||
#include <QTreeWidget>
|
||||
|
||||
using namespace Utils;
|
||||
@@ -35,100 +34,24 @@ namespace Autotest::Internal {
|
||||
class TestSettingsWidget : public Core::IOptionsPageWidget
|
||||
{
|
||||
public:
|
||||
explicit TestSettingsWidget(TestSettings *settings);
|
||||
TestSettingsWidget();
|
||||
|
||||
private:
|
||||
void populateFrameworksListWidget(const QHash<Id, bool> &frameworks,
|
||||
const QHash<Id, bool> &testTools);
|
||||
void testSettings(TestSettings &settings) const;
|
||||
void testToolsSettings(TestSettings &settings) const;
|
||||
void testSettings(NonAspectSettings &settings) const;
|
||||
void testToolsSettings(NonAspectSettings &settings) const;
|
||||
void onFrameworkItemChanged();
|
||||
|
||||
TestSettings *m_settings;
|
||||
QCheckBox *m_omitInternalMsgCB;
|
||||
QCheckBox *m_omitRunConfigWarnCB;
|
||||
QCheckBox *m_limitResultOutputCB;
|
||||
QCheckBox *m_limitResultDescriptionCb;
|
||||
QSpinBox *m_limitResultDescriptionSpinBox;
|
||||
QCheckBox *m_openResultsOnStartCB;
|
||||
QCheckBox *m_openResultsOnFinishCB;
|
||||
QCheckBox *m_openResultsOnFailCB;
|
||||
QCheckBox *m_autoScrollCB;
|
||||
QCheckBox *m_displayAppCB;
|
||||
QCheckBox *m_processArgsCB;
|
||||
QComboBox *m_runAfterBuildCB;
|
||||
QSpinBox *m_timeoutSpin;
|
||||
QTreeWidget *m_frameworkTreeWidget;
|
||||
InfoLabel *m_frameworksWarn;
|
||||
};
|
||||
|
||||
TestSettingsWidget::TestSettingsWidget(TestSettings *settings)
|
||||
: m_settings(settings)
|
||||
TestSettingsWidget::TestSettingsWidget()
|
||||
{
|
||||
m_omitInternalMsgCB = new QCheckBox(Tr::tr("Omit internal messages"));
|
||||
m_omitInternalMsgCB->setChecked(true);
|
||||
m_omitInternalMsgCB->setToolTip(Tr::tr("Hides internal messages by default. "
|
||||
"You can still enable them by using the test results filter."));
|
||||
|
||||
m_omitRunConfigWarnCB = new QCheckBox(Tr::tr("Omit run configuration warnings"));
|
||||
m_omitRunConfigWarnCB->setToolTip(Tr::tr("Hides warnings related to a deduced run configuration."));
|
||||
|
||||
m_limitResultOutputCB = new QCheckBox(Tr::tr("Limit result output"));
|
||||
m_limitResultOutputCB->setChecked(true);
|
||||
m_limitResultOutputCB->setToolTip(Tr::tr("Limits result output to 100000 characters."));
|
||||
|
||||
m_limitResultDescriptionCb = new QCheckBox(Tr::tr("Limit result description:"));
|
||||
m_limitResultDescriptionCb->setToolTip(
|
||||
Tr::tr("Limit number of lines shown in test result tooltip and description."));
|
||||
|
||||
m_limitResultDescriptionSpinBox = new QSpinBox;
|
||||
m_limitResultDescriptionSpinBox->setEnabled(false);
|
||||
m_limitResultDescriptionSpinBox->setMinimum(1);
|
||||
m_limitResultDescriptionSpinBox->setMaximum(1000000);
|
||||
m_limitResultDescriptionSpinBox->setValue(10);
|
||||
|
||||
m_openResultsOnStartCB = new QCheckBox(Tr::tr("Open results when tests start"));
|
||||
m_openResultsOnStartCB->setToolTip(
|
||||
Tr::tr("Displays test results automatically when tests are started."));
|
||||
|
||||
m_openResultsOnFinishCB = new QCheckBox(Tr::tr("Open results when tests finish"));
|
||||
m_openResultsOnFinishCB->setChecked(true);
|
||||
m_openResultsOnFinishCB->setToolTip(
|
||||
Tr::tr("Displays test results automatically when tests are finished."));
|
||||
|
||||
m_openResultsOnFailCB = new QCheckBox(Tr::tr("Only for unsuccessful test runs"));
|
||||
m_openResultsOnFailCB->setToolTip(
|
||||
Tr::tr("Displays test results only if the test run contains failed, fatal or unexpectedly passed tests."));
|
||||
|
||||
m_autoScrollCB = new QCheckBox(Tr::tr("Automatically scroll results"));
|
||||
m_autoScrollCB->setChecked(true);
|
||||
m_autoScrollCB->setToolTip(Tr::tr("Automatically scrolls down when new items are added and scrollbar is at bottom."));
|
||||
|
||||
m_displayAppCB = new QCheckBox(Tr::tr("Group results by application"));
|
||||
|
||||
m_processArgsCB = new QCheckBox(Tr::tr("Process arguments"));
|
||||
m_processArgsCB->setToolTip(
|
||||
Tr::tr("Allow passing arguments specified on the respective run configuration.\n"
|
||||
"Warning: this is an experimental feature and might lead to failing to execute the test executable."));
|
||||
|
||||
m_runAfterBuildCB = new QComboBox;
|
||||
m_runAfterBuildCB->setToolTip(Tr::tr("Runs chosen tests automatically if a build succeeded."));
|
||||
m_runAfterBuildCB->addItem(Tr::tr("None"));
|
||||
m_runAfterBuildCB->addItem(Tr::tr("All"));
|
||||
m_runAfterBuildCB->addItem(Tr::tr("Selected"));
|
||||
|
||||
auto timeoutLabel = new QLabel(Tr::tr("Timeout:"));
|
||||
timeoutLabel->setToolTip(Tr::tr("Timeout used when executing each test case."));
|
||||
|
||||
m_timeoutSpin = new QSpinBox;
|
||||
m_timeoutSpin->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
m_timeoutSpin->setRange(5, 36000);
|
||||
m_timeoutSpin->setValue(60);
|
||||
m_timeoutSpin->setSuffix(Tr::tr(" s"));
|
||||
m_timeoutSpin->setToolTip(
|
||||
Tr::tr("Timeout used when executing test cases. This will apply "
|
||||
"for each test case on its own, not the whole project."));
|
||||
|
||||
m_frameworkTreeWidget = new QTreeWidget;
|
||||
m_frameworkTreeWidget->setRootIsDecorated(false);
|
||||
m_frameworkTreeWidget->setHeaderHidden(false);
|
||||
@@ -156,21 +79,22 @@ TestSettingsWidget::TestSettingsWidget(TestSettings *settings)
|
||||
onClicked([] { AutotestPlugin::clearChoiceCache(); }, this)
|
||||
};
|
||||
|
||||
TestSettings &s = *TestSettings::instance();
|
||||
Group generalGroup {
|
||||
title(Tr::tr("General")),
|
||||
Column {
|
||||
m_omitInternalMsgCB,
|
||||
m_omitRunConfigWarnCB,
|
||||
m_limitResultOutputCB,
|
||||
Row { m_limitResultDescriptionCb, m_limitResultDescriptionSpinBox, st },
|
||||
m_openResultsOnStartCB,
|
||||
m_openResultsOnFinishCB,
|
||||
Row { Space(20), m_openResultsOnFailCB },
|
||||
m_autoScrollCB,
|
||||
m_displayAppCB,
|
||||
m_processArgsCB,
|
||||
Row { Tr::tr("Automatically run"), m_runAfterBuildCB, st },
|
||||
Row { timeoutLabel, m_timeoutSpin, st },
|
||||
s.omitInternalMsg,
|
||||
s.omitRunConfigWarn,
|
||||
s.limitResultOutput,
|
||||
Row { s.limitResultDescription, s.resultDescriptionMaxSize, st },
|
||||
s.popupOnStart,
|
||||
s.popupOnFinish,
|
||||
Row { Space(20), s.popupOnFail },
|
||||
s.autoScroll,
|
||||
s.displayApplication,
|
||||
s.processArgs,
|
||||
Row { Tr::tr("Automatically run"), s.runAfterBuild, st },
|
||||
Row { timeoutLabel, s.timeout, st },
|
||||
Row { resetChoicesButton, st }
|
||||
}
|
||||
};
|
||||
@@ -193,61 +117,32 @@ TestSettingsWidget::TestSettingsWidget(TestSettings *settings)
|
||||
|
||||
connect(m_frameworkTreeWidget, &QTreeWidget::itemChanged,
|
||||
this, &TestSettingsWidget::onFrameworkItemChanged);
|
||||
connect(m_openResultsOnFinishCB, &QCheckBox::toggled,
|
||||
m_openResultsOnFailCB, &QCheckBox::setEnabled);
|
||||
connect(m_limitResultDescriptionCb, &QCheckBox::toggled,
|
||||
m_limitResultDescriptionSpinBox, &QSpinBox::setEnabled);
|
||||
|
||||
|
||||
m_timeoutSpin->setValue(settings->timeout / 1000); // we store milliseconds
|
||||
m_omitInternalMsgCB->setChecked(settings->omitInternalMssg);
|
||||
m_omitRunConfigWarnCB->setChecked(settings->omitRunConfigWarn);
|
||||
m_limitResultOutputCB->setChecked(settings->limitResultOutput);
|
||||
m_limitResultDescriptionCb->setChecked(settings->limitResultDescription);
|
||||
m_limitResultDescriptionSpinBox->setEnabled(settings->limitResultDescription);
|
||||
m_limitResultDescriptionSpinBox->setValue(settings->resultDescriptionMaxSize);
|
||||
m_autoScrollCB->setChecked(settings->autoScroll);
|
||||
m_processArgsCB->setChecked(settings->processArgs);
|
||||
m_displayAppCB->setChecked(settings->displayApplication);
|
||||
m_openResultsOnStartCB->setChecked(settings->popupOnStart);
|
||||
m_openResultsOnFinishCB->setChecked(settings->popupOnFinish);
|
||||
m_openResultsOnFailCB->setChecked(settings->popupOnFail);
|
||||
m_runAfterBuildCB->setCurrentIndex(int(settings->runAfterBuild));
|
||||
populateFrameworksListWidget(settings->frameworks, settings->tools);
|
||||
populateFrameworksListWidget(s.frameworks, s.tools);
|
||||
|
||||
setOnApply([this] {
|
||||
TestSettings result;
|
||||
result.timeout = m_timeoutSpin->value() * 1000; // we display seconds
|
||||
result.omitInternalMssg = m_omitInternalMsgCB->isChecked();
|
||||
result.omitRunConfigWarn = m_omitRunConfigWarnCB->isChecked();
|
||||
result.limitResultOutput = m_limitResultOutputCB->isChecked();
|
||||
result.limitResultDescription = m_limitResultDescriptionCb->isChecked();
|
||||
result.resultDescriptionMaxSize = m_limitResultDescriptionSpinBox->value();
|
||||
result.autoScroll = m_autoScrollCB->isChecked();
|
||||
result.processArgs = m_processArgsCB->isChecked();
|
||||
result.displayApplication = m_displayAppCB->isChecked();
|
||||
result.popupOnStart = m_openResultsOnStartCB->isChecked();
|
||||
result.popupOnFinish = m_openResultsOnFinishCB->isChecked();
|
||||
result.popupOnFail = m_openResultsOnFailCB->isChecked();
|
||||
result.runAfterBuild = RunAfterBuildMode(m_runAfterBuildCB->currentIndex());
|
||||
testSettings(result);
|
||||
testToolsSettings(result);
|
||||
TestSettings &s = *TestSettings::instance();
|
||||
|
||||
const QList<Utils::Id> changedIds = Utils::filtered(result.frameworksGrouping.keys(),
|
||||
[result, this](Utils::Id id) {
|
||||
return result.frameworksGrouping[id] != m_settings->frameworksGrouping[id];
|
||||
NonAspectSettings tmp;
|
||||
testSettings(tmp);
|
||||
testToolsSettings(tmp);
|
||||
|
||||
const QList<Utils::Id> changedIds = Utils::filtered(tmp.frameworksGrouping.keys(),
|
||||
[&tmp, &s](Utils::Id id) {
|
||||
return tmp.frameworksGrouping[id] != s.frameworksGrouping[id];
|
||||
});
|
||||
|
||||
*m_settings = result;
|
||||
m_settings->toSettings(Core::ICore::settings());
|
||||
testSettings(s);
|
||||
testToolsSettings(s);
|
||||
s.toSettings(Core::ICore::settings());
|
||||
|
||||
for (ITestFramework *framework : TestFrameworkManager::registeredFrameworks()) {
|
||||
framework->setActive(m_settings->frameworks.value(framework->id(), false));
|
||||
framework->setGrouping(m_settings->frameworksGrouping.value(framework->id(), false));
|
||||
framework->setActive(s.frameworks.value(framework->id(), false));
|
||||
framework->setGrouping(s.frameworksGrouping.value(framework->id(), false));
|
||||
}
|
||||
|
||||
for (ITestTool *testTool : TestFrameworkManager::registeredTestTools())
|
||||
testTool->setActive(m_settings->tools.value(testTool->id(), false));
|
||||
testTool->setActive(s.tools.value(testTool->id(), false));
|
||||
|
||||
TestTreeModel::instance()->synchronizeTestFrameworks();
|
||||
TestTreeModel::instance()->synchronizeTestTools();
|
||||
@@ -294,7 +189,7 @@ void TestSettingsWidget::populateFrameworksListWidget(const QHash<Id, bool> &fra
|
||||
}
|
||||
}
|
||||
|
||||
void TestSettingsWidget::testSettings(TestSettings &settings) const
|
||||
void TestSettingsWidget::testSettings(NonAspectSettings &settings) const
|
||||
{
|
||||
const QAbstractItemModel *model = m_frameworkTreeWidget->model();
|
||||
QTC_ASSERT(model, return);
|
||||
@@ -309,7 +204,7 @@ void TestSettingsWidget::testSettings(TestSettings &settings) const
|
||||
}
|
||||
}
|
||||
|
||||
void TestSettingsWidget::testToolsSettings(TestSettings &settings) const
|
||||
void TestSettingsWidget::testToolsSettings(NonAspectSettings &settings) const
|
||||
{
|
||||
const QAbstractItemModel *model = m_frameworkTreeWidget->model();
|
||||
QTC_ASSERT(model, return);
|
||||
@@ -356,14 +251,14 @@ void TestSettingsWidget::onFrameworkItemChanged()
|
||||
|
||||
// TestSettingsPage
|
||||
|
||||
TestSettingsPage::TestSettingsPage(TestSettings *settings)
|
||||
TestSettingsPage::TestSettingsPage()
|
||||
{
|
||||
setId(Constants::AUTOTEST_SETTINGS_ID);
|
||||
setDisplayName(Tr::tr("General"));
|
||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||
setDisplayCategory(Tr::tr("Testing"));
|
||||
setCategoryIconPath(":/autotest/images/settingscategory_autotest.png");
|
||||
setWidgetCreator([settings] { return new TestSettingsWidget(settings); });
|
||||
setWidgetCreator([] { return new TestSettingsWidget; });
|
||||
}
|
||||
|
||||
} // Autotest::Internal
|
||||
|
@@ -7,12 +7,10 @@
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
struct TestSettings;
|
||||
|
||||
class TestSettingsPage : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
explicit TestSettingsPage(TestSettings *settings);
|
||||
TestSettingsPage();
|
||||
};
|
||||
|
||||
} // Autotest::Internal
|
||||
|
Reference in New Issue
Block a user