diff --git a/src/plugins/autotest/autotest.pro b/src/plugins/autotest/autotest.pro index d1c82afe39d..6c7a014fc75 100644 --- a/src/plugins/autotest/autotest.pro +++ b/src/plugins/autotest/autotest.pro @@ -80,6 +80,7 @@ HEADERS += \ gtest/gtestvisitors.h \ gtest/gtestframework.h \ gtest/gtestsettings.h \ + gtest/gtestconstants.h \ qtest/qttesttreeitem.h \ qtest/qttest_utils.h \ qtest/qttestresult.h \ @@ -89,6 +90,7 @@ HEADERS += \ qtest/qttestparser.h \ qtest/qttestframework.h \ qtest/qttestsettings.h \ + qtest/qttestconstants.h \ quick/quicktestconfiguration.h \ quick/quicktestparser.h \ quick/quicktesttreeitem.h \ diff --git a/src/plugins/autotest/autotestconstants.h b/src/plugins/autotest/autotestconstants.h index 860bdccbe4f..5b633763d8f 100644 --- a/src/plugins/autotest/autotestconstants.h +++ b/src/plugins/autotest/autotestconstants.h @@ -41,5 +41,7 @@ const char TASK_PARSE[] = "AutoTest.Task.Parse"; const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests"; const char FRAMEWORK_PREFIX[] = "AutoTest.Framework."; + +const char SETTINGSGROUP[] = "Autotest"; } // namespace Constants } // namespace Autotest diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp index 98b58c0e352..abde0d4d69a 100644 --- a/src/plugins/autotest/autotestplugin.cpp +++ b/src/plugins/autotest/autotestplugin.cpp @@ -135,7 +135,7 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri m_frameworkManager->registerTestFramework(new QuickTestFramework); m_frameworkManager->registerTestFramework(new GTestFramework); - m_settings->fromSettings(ICore::settings()); + m_frameworkManager->synchronizeSettings(ICore::settings()); addAutoReleasedObject(new TestSettingsPage(m_settings)); addAutoReleasedObject(new TestNavigationWidgetFactory); addAutoReleasedObject(TestResultsPane::instance()); diff --git a/src/plugins/autotest/gtest/gtestconfiguration.cpp b/src/plugins/autotest/gtest/gtestconfiguration.cpp index f0dcd8bdb10..62f910df2e5 100644 --- a/src/plugins/autotest/gtest/gtestconfiguration.cpp +++ b/src/plugins/autotest/gtest/gtestconfiguration.cpp @@ -24,8 +24,10 @@ ****************************************************************************/ #include "gtestconfiguration.h" +#include "gtestconstants.h" #include "gtestoutputreader.h" -#include "../testsettings.h" +#include "gtestsettings.h" +#include "../testframeworkmanager.h" namespace Autotest { namespace Internal { @@ -36,25 +38,32 @@ TestOutputReader *GTestConfiguration::outputReader(const QFutureInterfacerepeat) + arguments << QString("--gtest_repeat=%1").arg(gSettings->iterations); + if (gSettings->shuffle) + arguments << "--gtest_shuffle" << QString("--gtest_random_seed=%1").arg(gSettings->seed); + if (gSettings->throwOnFailure) arguments << "--gtest_throw_on_failure"; if (runMode() == DebuggableTestConfiguration::Debug) { - if (settings.gTestSettings.breakOnFailure) + if (gSettings->breakOnFailure) arguments << "--gtest_break_on_failure"; } return arguments; diff --git a/src/plugins/autotest/gtest/gtestconfiguration.h b/src/plugins/autotest/gtest/gtestconfiguration.h index 9552b7db3ce..141e7709378 100644 --- a/src/plugins/autotest/gtest/gtestconfiguration.h +++ b/src/plugins/autotest/gtest/gtestconfiguration.h @@ -36,7 +36,7 @@ public: explicit GTestConfiguration() {} TestOutputReader *outputReader(const QFutureInterface &fi, QProcess *app) const override; - QStringList argumentsForTestRunner(const TestSettings &settings) const override; + QStringList argumentsForTestRunner() const override; }; } // namespace Internal diff --git a/src/plugins/autotest/gtest/gtestconstants.h b/src/plugins/autotest/gtest/gtestconstants.h new file mode 100644 index 00000000000..ef7c3e94f68 --- /dev/null +++ b/src/plugins/autotest/gtest/gtestconstants.h @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include + +namespace Autotest { +namespace GTest { +namespace Constants { + +const char FRAMEWORK_NAME[] = "GTest"; +const char FRAMEWORK_SETTINGS_CATEGORY[] = QT_TRANSLATE_NOOP("GTestFramework", "Google Test"); +const unsigned FRAMEWORK_PRIORITY = 10; + +} // namespace Constants +} // namespace GTest +} // namespace AutoTest diff --git a/src/plugins/autotest/gtest/gtestframework.cpp b/src/plugins/autotest/gtest/gtestframework.cpp index 6aea62f5c31..5389b94b456 100644 --- a/src/plugins/autotest/gtest/gtestframework.cpp +++ b/src/plugins/autotest/gtest/gtestframework.cpp @@ -24,6 +24,8 @@ ****************************************************************************/ #include "gtestframework.h" +#include "gtestconstants.h" +#include "gtestsettings.h" #include "gtesttreeitem.h" #include "gtestparser.h" @@ -37,18 +39,30 @@ ITestParser *GTestFramework::createTestParser() const TestTreeItem *GTestFramework::createRootNode() const { - return new GTestTreeItem(QCoreApplication::translate("GTestFramework", "Google Tests"), - QString(), TestTreeItem::Root); + return new GTestTreeItem( + QCoreApplication::translate("GTestFramework", + GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY), + QString(), TestTreeItem::Root); } const char *GTestFramework::name() const { - return "GTest"; + return GTest::Constants::FRAMEWORK_NAME; } unsigned GTestFramework::priority() const { - return 10; + return GTest::Constants::FRAMEWORK_PRIORITY; +} + +IFrameworkSettings *GTestFramework::createFrameworkSettings() const +{ + return new GTestSettings; +} + +bool GTestFramework::hasFrameworkSettings() const +{ + return true; } } // namespace Internal diff --git a/src/plugins/autotest/gtest/gtestframework.h b/src/plugins/autotest/gtest/gtestframework.h index 6790f31dab0..29d241c117c 100644 --- a/src/plugins/autotest/gtest/gtestframework.h +++ b/src/plugins/autotest/gtest/gtestframework.h @@ -36,6 +36,8 @@ public: GTestFramework() : ITestFramework(true) {} const char *name() const override; unsigned priority() const override; + IFrameworkSettings *createFrameworkSettings() const override; + bool hasFrameworkSettings() const override; protected: ITestParser *createTestParser() const override; diff --git a/src/plugins/autotest/itestframework.h b/src/plugins/autotest/itestframework.h index 6703a1ca338..35e0df68cd8 100644 --- a/src/plugins/autotest/itestframework.h +++ b/src/plugins/autotest/itestframework.h @@ -31,6 +31,8 @@ namespace Autotest { namespace Internal { +class IFrameworkSettings; + class ITestFramework { public: @@ -43,6 +45,8 @@ public: virtual const char *name() const = 0; virtual unsigned priority() const = 0; // should this be modifyable? + virtual bool hasFrameworkSettings() const { return false; } + virtual IFrameworkSettings *createFrameworkSettings() const { return 0; } TestTreeItem *rootNode() { if (!m_rootNode) diff --git a/src/plugins/autotest/qtest/qttestconfiguration.cpp b/src/plugins/autotest/qtest/qttestconfiguration.cpp index f2d8abd5fb8..57ab6fc86a6 100644 --- a/src/plugins/autotest/qtest/qttestconfiguration.cpp +++ b/src/plugins/autotest/qtest/qttestconfiguration.cpp @@ -24,8 +24,10 @@ ****************************************************************************/ #include "qttestconfiguration.h" +#include "qttestconstants.h" #include "qttestoutputreader.h" -#include "../testsettings.h" +#include "qttestsettings.h" +#include "../testframeworkmanager.h" namespace Autotest { namespace Internal { @@ -36,19 +38,26 @@ TestOutputReader *QtTestConfiguration::outputReader(const QFutureInterface(manager->settingsForTestFramework(id)); + if (qtSettings.isNull()) + return arguments; + + const QString &metricsOption = QtTestSettings::metricsTypeToOption(qtSettings->metrics); + if (!metricsOption.isEmpty()) + arguments << metricsOption; + if (runMode() == DebuggableTestConfiguration::Debug) { - if (settings.qtTestSettings.noCrashHandler) + if (qtSettings->noCrashHandler) arguments << "-nocrashhandler"; } diff --git a/src/plugins/autotest/qtest/qttestconfiguration.h b/src/plugins/autotest/qtest/qttestconfiguration.h index e48da49e5a4..f32737e7659 100644 --- a/src/plugins/autotest/qtest/qttestconfiguration.h +++ b/src/plugins/autotest/qtest/qttestconfiguration.h @@ -36,7 +36,7 @@ public: explicit QtTestConfiguration() {} TestOutputReader *outputReader(const QFutureInterface &fi, QProcess *app) const override; - QStringList argumentsForTestRunner(const TestSettings &settings) const override; + QStringList argumentsForTestRunner() const override; }; } // namespace Internal diff --git a/src/plugins/autotest/qtest/qttestconstants.h b/src/plugins/autotest/qtest/qttestconstants.h new file mode 100644 index 00000000000..ee944b279f9 --- /dev/null +++ b/src/plugins/autotest/qtest/qttestconstants.h @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include + +namespace Autotest { +namespace QtTest { +namespace Constants { + +const char FRAMEWORK_NAME[] = "QtTest"; +const char FRAMEWORK_SETTINGS_CATEGORY[] = QT_TRANSLATE_NOOP("QtTestFramework", "Qt Test"); +const unsigned FRAMEWORK_PRIORITY = 1; + +} // namespace Constants +} // namespace QtTest +} // namespace Autotest diff --git a/src/plugins/autotest/qtest/qttestframework.cpp b/src/plugins/autotest/qtest/qttestframework.cpp index 710afd17bfa..860ff7187b1 100644 --- a/src/plugins/autotest/qtest/qttestframework.cpp +++ b/src/plugins/autotest/qtest/qttestframework.cpp @@ -24,7 +24,9 @@ ****************************************************************************/ #include "qttestframework.h" +#include "qttestconstants.h" #include "qttestparser.h" +#include "qttestsettings.h" #include "qttesttreeitem.h" namespace Autotest { @@ -37,18 +39,30 @@ ITestParser *QtTestFramework::createTestParser() const TestTreeItem *QtTestFramework::createRootNode() const { - return new QtTestTreeItem(QCoreApplication::translate("QtTestFramework", "Qt Tests"), - QString(), TestTreeItem::Root); + return new QtTestTreeItem( + QCoreApplication::translate("QtTestFramework", + QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY), + QString(), TestTreeItem::Root); +} + +IFrameworkSettings *QtTestFramework::createFrameworkSettings() const +{ + return new QtTestSettings; +} + +bool QtTestFramework::hasFrameworkSettings() const +{ + return true; } const char *QtTestFramework::name() const { - return "QtTest"; + return QtTest::Constants::FRAMEWORK_NAME; } unsigned QtTestFramework::priority() const { - return 1; + return QtTest::Constants::FRAMEWORK_PRIORITY; } } // namespace Internal diff --git a/src/plugins/autotest/qtest/qttestframework.h b/src/plugins/autotest/qtest/qttestframework.h index ec26481b74c..41c5c7c06c1 100644 --- a/src/plugins/autotest/qtest/qttestframework.h +++ b/src/plugins/autotest/qtest/qttestframework.h @@ -36,6 +36,8 @@ public: QtTestFramework() : ITestFramework(true) {} const char *name() const override; unsigned priority() const override; + IFrameworkSettings *createFrameworkSettings() const override; + bool hasFrameworkSettings() const override; protected: ITestParser *createTestParser() const override; diff --git a/src/plugins/autotest/quick/quicktestconfiguration.cpp b/src/plugins/autotest/quick/quicktestconfiguration.cpp index d7ccfe7638a..b92c1252c02 100644 --- a/src/plugins/autotest/quick/quicktestconfiguration.cpp +++ b/src/plugins/autotest/quick/quicktestconfiguration.cpp @@ -24,8 +24,10 @@ ****************************************************************************/ #include "quicktestconfiguration.h" +#include "../qtest/qttestconstants.h" #include "../qtest/qttestoutputreader.h" -#include "../testsettings.h" +#include "../qtest/qttestsettings.h" +#include "../testframeworkmanager.h" namespace Autotest { namespace Internal { @@ -36,16 +38,23 @@ TestOutputReader *QuickTestConfiguration::outputReader(const QFutureInterface(manager->settingsForTestFramework(id)); + if (qtSettings.isNull()) + return arguments; + + const QString &metricsOption = QtTestSettings::metricsTypeToOption(qtSettings->metrics); + if (!metricsOption.isEmpty()) + arguments << metricsOption; return arguments; } diff --git a/src/plugins/autotest/quick/quicktestconfiguration.h b/src/plugins/autotest/quick/quicktestconfiguration.h index 3861e46ce36..8ff754202ba 100644 --- a/src/plugins/autotest/quick/quicktestconfiguration.h +++ b/src/plugins/autotest/quick/quicktestconfiguration.h @@ -36,7 +36,7 @@ public: explicit QuickTestConfiguration() {} TestOutputReader *outputReader(const QFutureInterface &fi, QProcess *app) const override; - QStringList argumentsForTestRunner(const TestSettings &settings) const override; + QStringList argumentsForTestRunner() const override; void setUnnamedOnly(bool unnamedOnly); bool unnamedOnly() const { return m_unnamedOnly; } diff --git a/src/plugins/autotest/testconfiguration.cpp b/src/plugins/autotest/testconfiguration.cpp index 650df3b8f3b..2b3740ead3e 100644 --- a/src/plugins/autotest/testconfiguration.cpp +++ b/src/plugins/autotest/testconfiguration.cpp @@ -27,7 +27,6 @@ #include "testoutputreader.h" #include "testrunconfiguration.h" #include "testrunner.h" -#include "testsettings.h" #include #include diff --git a/src/plugins/autotest/testconfiguration.h b/src/plugins/autotest/testconfiguration.h index e5eff3f2846..fd00047070c 100644 --- a/src/plugins/autotest/testconfiguration.h +++ b/src/plugins/autotest/testconfiguration.h @@ -45,7 +45,6 @@ namespace Internal { class TestOutputReader; class TestResult; class TestRunConfiguration; -struct TestSettings; using TestResultPtr = QSharedPointer; @@ -86,7 +85,7 @@ public: virtual TestOutputReader *outputReader(const QFutureInterface &fi, QProcess *app) const = 0; - virtual QStringList argumentsForTestRunner(const TestSettings &settings) const = 0; + virtual QStringList argumentsForTestRunner() const = 0; private: QStringList m_testCases; diff --git a/src/plugins/autotest/testframeworkmanager.cpp b/src/plugins/autotest/testframeworkmanager.cpp index 8b1a8303e50..3770790426f 100644 --- a/src/plugins/autotest/testframeworkmanager.cpp +++ b/src/plugins/autotest/testframeworkmanager.cpp @@ -25,6 +25,8 @@ #include "testframeworkmanager.h" #include "autotestconstants.h" +#include "autotestplugin.h" +#include "iframeworksettings.h" #include "itestframework.h" #include "itestparser.h" #include "testrunner.h" @@ -74,6 +76,11 @@ bool TestFrameworkManager::registerTestFramework(ITestFramework *framework) // TODO check for unique priority before registering qCDebug(LOG) << "Registering" << id; m_registeredFrameworks.insert(id, framework); + + if (framework->hasFrameworkSettings()) { + QSharedPointer frameworkSettings(framework->createFrameworkSettings()); + m_frameworkSettings.insert(id, frameworkSettings); + } return true; } @@ -145,6 +152,23 @@ ITestParser *TestFrameworkManager::testParserForTestFramework(const Core::Id &fr return testParser; } +QSharedPointer TestFrameworkManager::settingsForTestFramework( + const Core::Id &frameworkId) const +{ + return m_frameworkSettings.contains(frameworkId) ? m_frameworkSettings.value(frameworkId) + : QSharedPointer(); +} + +void TestFrameworkManager::synchronizeSettings(QSettings *s) +{ + AutotestPlugin::instance()->settings()->fromSettings(s); + for (const Core::Id &id : m_frameworkSettings.keys()) { + QSharedPointer fSettings = settingsForTestFramework(id); + if (!fSettings.isNull()) + fSettings->fromSettings(s); + } +} + bool TestFrameworkManager::isActive(const Core::Id &frameworkId) const { ITestFramework *framework = m_registeredFrameworks.value(frameworkId); diff --git a/src/plugins/autotest/testframeworkmanager.h b/src/plugins/autotest/testframeworkmanager.h index cd25f164414..5b92d710d19 100644 --- a/src/plugins/autotest/testframeworkmanager.h +++ b/src/plugins/autotest/testframeworkmanager.h @@ -28,11 +28,16 @@ #include #include +QT_BEGIN_NAMESPACE +class QSettings; +QT_END_NAMESPACE + namespace Core { class Id; } namespace Autotest { namespace Internal { +class IFrameworkSettings; class ITestFramework; class ITestParser; class TestRunner; @@ -55,6 +60,8 @@ public: TestTreeItem *rootNodeForTestFramework(const Core::Id &frameworkId) const; ITestParser *testParserForTestFramework(const Core::Id &frameworkId) const; + QSharedPointer settingsForTestFramework(const Core::Id &frameworkId) const; + void synchronizeSettings(QSettings *s); bool isActive(const Core::Id &frameworkId) const; bool hasActiveFrameworks() const; @@ -62,6 +69,7 @@ private: QVector activeFrameworkIds() const; explicit TestFrameworkManager(); QHash m_registeredFrameworks; + QHash > m_frameworkSettings; TestTreeModel *m_testTreeModel; TestRunner *m_testRunner; diff --git a/src/plugins/autotest/testrunconfiguration.h b/src/plugins/autotest/testrunconfiguration.h index 24b00e47600..c066032b138 100644 --- a/src/plugins/autotest/testrunconfiguration.h +++ b/src/plugins/autotest/testrunconfiguration.h @@ -64,8 +64,7 @@ public: ProjectExplorer::StandardRunnable r; QTC_ASSERT(m_testConfig, return r); r.executable = m_testConfig->targetFile(); - r.commandLineArguments = m_testConfig->argumentsForTestRunner( - *AutotestPlugin::instance()->settings()).join(' '); + r.commandLineArguments = m_testConfig->argumentsForTestRunner().join(' '); r.workingDirectory = m_testConfig->workingDirectory(); r.environment = m_testConfig->environment(); r.runMode = ProjectExplorer::ApplicationLauncher::Gui; diff --git a/src/plugins/autotest/testrunner.cpp b/src/plugins/autotest/testrunner.cpp index 4f96cf96aad..bec21cba0eb 100644 --- a/src/plugins/autotest/testrunner.cpp +++ b/src/plugins/autotest/testrunner.cpp @@ -138,7 +138,7 @@ static void performTestRun(QFutureInterface &futureInterface, continue; } - testProcess.setArguments(testConfiguration->argumentsForTestRunner(settings)); + testProcess.setArguments(testConfiguration->argumentsForTestRunner()); testProcess.setWorkingDirectory(testConfiguration->workingDirectory()); if (Utils::HostOsInfo::isWindowsHost()) environment.insert("QT_LOGGING_TO_CONSOLE", "1"); @@ -304,8 +304,7 @@ void TestRunner::debugTests() Debugger::DebuggerStartParameters sp; sp.inferior.executable = commandFilePath; - sp.inferior.commandLineArguments = config->argumentsForTestRunner( - *AutotestPlugin::instance()->settings()).join(' '); + sp.inferior.commandLineArguments = config->argumentsForTestRunner().join(' '); sp.inferior.environment = config->environment(); sp.inferior.workingDirectory = config->workingDirectory(); sp.displayName = config->displayName(); diff --git a/src/plugins/autotest/testsettings.cpp b/src/plugins/autotest/testsettings.cpp index a1325e74547..9a2f1bd8b7c 100644 --- a/src/plugins/autotest/testsettings.cpp +++ b/src/plugins/autotest/testsettings.cpp @@ -24,6 +24,8 @@ ****************************************************************************/ #include "testsettings.h" +#include "autotestconstants.h" +#include "iframeworksettings.h" #include "testframeworkmanager.h" #include @@ -33,7 +35,6 @@ namespace Autotest { namespace Internal { -static const char group[] = "Autotest"; static const char timeoutKey[] = "Timeout"; static const char omitInternalKey[] = "OmitInternal"; static const char omitRunConfigWarnKey[] = "OmitRCWarnings"; @@ -50,7 +51,7 @@ TestSettings::TestSettings() void TestSettings::toSettings(QSettings *s) const { - s->beginGroup(group); + s->beginGroup(Constants::SETTINGSGROUP); s->setValue(timeoutKey, timeout); s->setValue(omitInternalKey, omitInternalMssg); s->setValue(omitRunConfigWarnKey, omitRunConfigWarn); @@ -60,20 +61,19 @@ void TestSettings::toSettings(QSettings *s) const // store frameworks and their current active state for (const Core::Id &id : frameworks.keys()) s->setValue(QLatin1String(id.name()), frameworks.value(id)); - - s->beginGroup(qtTestSettings.name()); - qtTestSettings.toSettings(s); - s->endGroup(); - s->beginGroup(gTestSettings.name()); - gTestSettings.toSettings(s); - s->endGroup(); - s->endGroup(); + TestFrameworkManager *frameworkManager = TestFrameworkManager::instance(); + const QList ®istered = frameworkManager->registeredFrameworkIds(); + for (const Core::Id &id : registered) { + QSharedPointer fSettings = frameworkManager->settingsForTestFramework(id); + if (!fSettings.isNull()) + fSettings->toSettings(s); + } } void TestSettings::fromSettings(QSettings *s) { - s->beginGroup(group); + s->beginGroup(Constants::SETTINGSGROUP); timeout = s->value(timeoutKey, defaultTimeout).toInt(); omitInternalMssg = s->value(omitInternalKey, true).toBool(); omitRunConfigWarn = s->value(omitRunConfigWarnKey, false).toBool(); @@ -88,15 +88,12 @@ void TestSettings::fromSettings(QSettings *s) frameworks.insert(id, s->value(QLatin1String(id.name()), frameworkManager->isActive(id)).toBool()); } - - s->beginGroup(qtTestSettings.name()); - qtTestSettings.fromSettings(s); - s->endGroup(); - s->beginGroup(gTestSettings.name()); - gTestSettings.fromSettings(s); - s->endGroup(); - s->endGroup(); + for (const Core::Id &id : registered) { + QSharedPointer fSettings = frameworkManager->settingsForTestFramework(id); + if (!fSettings.isNull()) + fSettings->fromSettings(s); + } } } // namespace Internal diff --git a/src/plugins/autotest/testsettings.h b/src/plugins/autotest/testsettings.h index 2cf8882ed16..e35833defe7 100644 --- a/src/plugins/autotest/testsettings.h +++ b/src/plugins/autotest/testsettings.h @@ -25,9 +25,6 @@ #pragma once -#include "gtest/gtestsettings.h" -#include "qtest/qttestsettings.h" - #include namespace Core { class Id; } @@ -52,9 +49,6 @@ struct TestSettings bool autoScroll = true; bool alwaysParse = true; QHash frameworks; - - QtTestSettings qtTestSettings; - GTestSettings gTestSettings; }; } // namespace Internal diff --git a/src/plugins/autotest/testsettingspage.cpp b/src/plugins/autotest/testsettingspage.cpp index 3dd382ed3e5..ca34242033b 100644 --- a/src/plugins/autotest/testsettingspage.cpp +++ b/src/plugins/autotest/testsettingspage.cpp @@ -29,6 +29,11 @@ #include "testsettings.h" #include "testtreemodel.h" +#include "gtest/gtestconstants.h" +#include "gtest/gtestsettings.h" +#include "qtest/qttestconstants.h" +#include "qtest/qttestsettings.h" + #include #include @@ -37,6 +42,11 @@ namespace Autotest { namespace Internal { +static const Core::Id qid + = Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(QtTest::Constants::FRAMEWORK_NAME); +static const Core::Id gid + = Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(GTest::Constants::FRAMEWORK_NAME); + TestSettingsWidget::TestSettingsWidget(QWidget *parent) : QWidget(parent) { @@ -66,34 +76,43 @@ void TestSettingsWidget::setSettings(const TestSettings &settings) m_ui.alwaysParseCB->setChecked(settings.alwaysParse); populateFrameworksListWidget(settings.frameworks); - m_ui.disableCrashhandlerCB->setChecked(settings.qtTestSettings.noCrashHandler); - switch (settings.qtTestSettings.metrics) { - case MetricsType::Walltime: - m_ui.walltimeRB->setChecked(true); - break; - case MetricsType::TickCounter: - m_ui.tickcounterRB->setChecked(true); - break; - case MetricsType::EventCounter: - m_ui.eventCounterRB->setChecked(true); - break; - case MetricsType::CallGrind: - m_ui.callgrindRB->setChecked(true); - break; - case MetricsType::Perf: - m_ui.perfRB->setChecked(true); - break; - default: - m_ui.walltimeRB->setChecked(true); + auto qtTestSettings = qSharedPointerCast( + TestFrameworkManager::instance()->settingsForTestFramework(qid)); + + if (!qtTestSettings.isNull()) { + m_ui.disableCrashhandlerCB->setChecked(qtTestSettings->noCrashHandler); + switch (qtTestSettings->metrics) { + case MetricsType::Walltime: + m_ui.walltimeRB->setChecked(true); + break; + case MetricsType::TickCounter: + m_ui.tickcounterRB->setChecked(true); + break; + case MetricsType::EventCounter: + m_ui.eventCounterRB->setChecked(true); + break; + case MetricsType::CallGrind: + m_ui.callgrindRB->setChecked(true); + break; + case MetricsType::Perf: + m_ui.perfRB->setChecked(true); + break; + default: + m_ui.walltimeRB->setChecked(true); + } } - m_ui.runDisabledGTestsCB->setChecked(settings.gTestSettings.runDisabled); - m_ui.repeatGTestsCB->setChecked(settings.gTestSettings.repeat); - m_ui.shuffleGTestsCB->setChecked(settings.gTestSettings.shuffle); - m_ui.repetitionSpin->setValue(settings.gTestSettings.iterations); - m_ui.seedSpin->setValue(settings.gTestSettings.seed); - m_ui.breakOnFailureCB->setChecked(settings.gTestSettings.breakOnFailure); - m_ui.throwOnFailureCB->setChecked(settings.gTestSettings.throwOnFailure); + auto gTestSettings = qSharedPointerCast( + TestFrameworkManager::instance()->settingsForTestFramework(gid)); + if (!gTestSettings.isNull()) { + m_ui.runDisabledGTestsCB->setChecked(gTestSettings->runDisabled); + m_ui.repeatGTestsCB->setChecked(gTestSettings->repeat); + m_ui.shuffleGTestsCB->setChecked(gTestSettings->shuffle); + m_ui.repetitionSpin->setValue(gTestSettings->iterations); + m_ui.seedSpin->setValue(gTestSettings->seed); + m_ui.breakOnFailureCB->setChecked(gTestSettings->breakOnFailure); + m_ui.throwOnFailureCB->setChecked(gTestSettings->throwOnFailure); + } } TestSettings TestSettingsWidget::settings() const @@ -108,26 +127,34 @@ TestSettings TestSettingsWidget::settings() const result.frameworks = frameworks(); // QtTestSettings - result.qtTestSettings.noCrashHandler = m_ui.disableCrashhandlerCB->isChecked(); - if (m_ui.walltimeRB->isChecked()) - result.qtTestSettings.metrics = MetricsType::Walltime; - else if (m_ui.tickcounterRB->isChecked()) - result.qtTestSettings.metrics = MetricsType::TickCounter; - else if (m_ui.eventCounterRB->isChecked()) - result.qtTestSettings.metrics = MetricsType::EventCounter; - else if (m_ui.callgrindRB->isChecked()) - result.qtTestSettings.metrics = MetricsType::CallGrind; - else if (m_ui.perfRB->isChecked()) - result.qtTestSettings.metrics = MetricsType::Perf; + auto qtTestSettings = qSharedPointerCast( + TestFrameworkManager::instance()->settingsForTestFramework(qid)); + if (!qtTestSettings.isNull()) { + qtTestSettings->noCrashHandler = m_ui.disableCrashhandlerCB->isChecked(); + if (m_ui.walltimeRB->isChecked()) + qtTestSettings->metrics = MetricsType::Walltime; + else if (m_ui.tickcounterRB->isChecked()) + qtTestSettings->metrics = MetricsType::TickCounter; + else if (m_ui.eventCounterRB->isChecked()) + qtTestSettings->metrics = MetricsType::EventCounter; + else if (m_ui.callgrindRB->isChecked()) + qtTestSettings->metrics = MetricsType::CallGrind; + else if (m_ui.perfRB->isChecked()) + qtTestSettings->metrics = MetricsType::Perf; + } // GTestSettings - result.gTestSettings.runDisabled = m_ui.runDisabledGTestsCB->isChecked(); - result.gTestSettings.repeat = m_ui.repeatGTestsCB->isChecked(); - result.gTestSettings.shuffle = m_ui.shuffleGTestsCB->isChecked(); - result.gTestSettings.iterations = m_ui.repetitionSpin->value(); - result.gTestSettings.seed = m_ui.seedSpin->value(); - result.gTestSettings.breakOnFailure = m_ui.breakOnFailureCB->isChecked(); - result.gTestSettings.throwOnFailure = m_ui.throwOnFailureCB->isChecked(); + auto gTestSettings = qSharedPointerCast( + TestFrameworkManager::instance()->settingsForTestFramework(gid)); + if (!gTestSettings.isNull()) { + gTestSettings->runDisabled = m_ui.runDisabledGTestsCB->isChecked(); + gTestSettings->repeat = m_ui.repeatGTestsCB->isChecked(); + gTestSettings->shuffle = m_ui.shuffleGTestsCB->isChecked(); + gTestSettings->iterations = m_ui.repetitionSpin->value(); + gTestSettings->seed = m_ui.seedSpin->value(); + gTestSettings->breakOnFailure = m_ui.breakOnFailureCB->isChecked(); + gTestSettings->throwOnFailure = m_ui.throwOnFailureCB->isChecked(); + } return result; }