diff --git a/src/plugins/autotest/autotest.pro b/src/plugins/autotest/autotest.pro index 6c7a014fc75..07d38fdab3a 100644 --- a/src/plugins/autotest/autotest.pro +++ b/src/plugins/autotest/autotest.pro @@ -31,6 +31,7 @@ SOURCES += \ gtest/gtestvisitors.cpp \ gtest/gtestframework.cpp \ gtest/gtestsettings.cpp \ + gtest/gtestsettingspage.cpp \ qtest/qttesttreeitem.cpp \ qtest/qttestvisitors.cpp \ qtest/qttestconfiguration.cpp \ @@ -39,6 +40,7 @@ SOURCES += \ qtest/qttestparser.cpp \ qtest/qttestframework.cpp \ qtest/qttestsettings.cpp \ + qtest/qttestsettingspage.cpp \ quick/quicktestconfiguration.cpp \ quick/quicktestparser.cpp \ quick/quicktesttreeitem.cpp \ @@ -80,6 +82,7 @@ HEADERS += \ gtest/gtestvisitors.h \ gtest/gtestframework.h \ gtest/gtestsettings.h \ + gtest/gtestsettingspage.h \ gtest/gtestconstants.h \ qtest/qttesttreeitem.h \ qtest/qttest_utils.h \ @@ -90,6 +93,7 @@ HEADERS += \ qtest/qttestparser.h \ qtest/qttestframework.h \ qtest/qttestsettings.h \ + qtest/qttestsettingspage.h \ qtest/qttestconstants.h \ quick/quicktestconfiguration.h \ quick/quicktestparser.h \ @@ -104,7 +108,9 @@ RESOURCES += \ autotest.qrc FORMS += \ - testsettingspage.ui + testsettingspage.ui \ + qtest/qttestsettingspage.ui \ + gtest/gtestsettingspage.ui equals(TEST, 1) { HEADERS += autotestunittests.h diff --git a/src/plugins/autotest/autotestconstants.h b/src/plugins/autotest/autotestconstants.h index 5b633763d8f..b4bef1400c1 100644 --- a/src/plugins/autotest/autotestconstants.h +++ b/src/plugins/autotest/autotestconstants.h @@ -39,6 +39,7 @@ const char AUTOTEST_CONTEXT[] = "Auto Tests"; const char TASK_INDEX[] = "AutoTest.Task.Index"; const char TASK_PARSE[] = "AutoTest.Task.Parse"; const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests"; +const char AUTOTEST_SETTINGS_TR[] = QT_TRANSLATE_NOOP("AutoTest", "Test Settings"); const char FRAMEWORK_PREFIX[] = "AutoTest.Framework."; diff --git a/src/plugins/autotest/gtest/gtestframework.cpp b/src/plugins/autotest/gtest/gtestframework.cpp index 5389b94b456..4ec6cd9962d 100644 --- a/src/plugins/autotest/gtest/gtestframework.cpp +++ b/src/plugins/autotest/gtest/gtestframework.cpp @@ -26,6 +26,7 @@ #include "gtestframework.h" #include "gtestconstants.h" #include "gtestsettings.h" +#include "gtestsettingspage.h" #include "gtesttreeitem.h" #include "gtestparser.h" @@ -60,6 +61,11 @@ IFrameworkSettings *GTestFramework::createFrameworkSettings() const return new GTestSettings; } +Core::IOptionsPage *GTestFramework::createSettingsPage(QSharedPointer settings) const +{ + return new GTestSettingsPage(settings); +} + bool GTestFramework::hasFrameworkSettings() const { return true; diff --git a/src/plugins/autotest/gtest/gtestframework.h b/src/plugins/autotest/gtest/gtestframework.h index 29d241c117c..6645da15336 100644 --- a/src/plugins/autotest/gtest/gtestframework.h +++ b/src/plugins/autotest/gtest/gtestframework.h @@ -37,8 +37,8 @@ public: const char *name() const override; unsigned priority() const override; IFrameworkSettings *createFrameworkSettings() const override; + Core::IOptionsPage *createSettingsPage(QSharedPointer settings) const override; bool hasFrameworkSettings() const override; - protected: ITestParser *createTestParser() const override; TestTreeItem *createRootNode() const override; diff --git a/src/plugins/autotest/gtest/gtestsettings.cpp b/src/plugins/autotest/gtest/gtestsettings.cpp index 739871cf402..9e68e7912b4 100644 --- a/src/plugins/autotest/gtest/gtestsettings.cpp +++ b/src/plugins/autotest/gtest/gtestsettings.cpp @@ -41,7 +41,7 @@ QString GTestSettings::name() const return QString("GTest"); } -void GTestSettings::fromSettings(const QSettings *s) +void GTestSettings::fromFrameworkSettings(const QSettings *s) { runDisabled = s->value(runDisabledKey, false).toBool(); repeat = s->value(repeatKey, false).toBool(); @@ -52,7 +52,7 @@ void GTestSettings::fromSettings(const QSettings *s) throwOnFailure = s->value(throwOnFailureKey, false).toBool(); } -void GTestSettings::toSettings(QSettings *s) const +void GTestSettings::toFrameworkSettings(QSettings *s) const { s->setValue(runDisabledKey, runDisabled); s->setValue(repeatKey, repeat); diff --git a/src/plugins/autotest/gtest/gtestsettings.h b/src/plugins/autotest/gtest/gtestsettings.h index f79bf645521..5cc68523f83 100644 --- a/src/plugins/autotest/gtest/gtestsettings.h +++ b/src/plugins/autotest/gtest/gtestsettings.h @@ -35,8 +35,6 @@ class GTestSettings : public IFrameworkSettings public: GTestSettings() {} QString name() const override; - void fromSettings(const QSettings *s) override; - void toSettings(QSettings *s) const override; int iterations = 1; int seed = 0; @@ -45,6 +43,10 @@ public: bool repeat = false; bool throwOnFailure = false; bool breakOnFailure = true; + +protected: + void fromFrameworkSettings(const QSettings *s) override; + void toFrameworkSettings(QSettings *s) const override; }; } // namespace Internal diff --git a/src/plugins/autotest/gtest/gtestsettingspage.cpp b/src/plugins/autotest/gtest/gtestsettingspage.cpp new file mode 100644 index 00000000000..77b34d0d45d --- /dev/null +++ b/src/plugins/autotest/gtest/gtestsettingspage.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#include "../autotestconstants.h" +#include "gtestconstants.h" +#include "gtestsettingspage.h" +#include "gtestsettings.h" + +#include + +namespace Autotest { +namespace Internal { + +GTestSettingsWidget::GTestSettingsWidget(QWidget *parent) + : QWidget(parent) +{ + m_ui.setupUi(this); + connect(m_ui.repeatGTestsCB, &QCheckBox::toggled, m_ui.repetitionSpin, &QSpinBox::setEnabled); + connect(m_ui.shuffleGTestsCB, &QCheckBox::toggled, m_ui.seedSpin, &QSpinBox::setEnabled); +} + +void GTestSettingsWidget::setSettings(const GTestSettings &settings) +{ + m_ui.runDisabledGTestsCB->setChecked(settings.runDisabled); + m_ui.repeatGTestsCB->setChecked(settings.repeat); + m_ui.shuffleGTestsCB->setChecked(settings.shuffle); + m_ui.repetitionSpin->setValue(settings.iterations); + m_ui.seedSpin->setValue(settings.seed); + m_ui.breakOnFailureCB->setChecked(settings.breakOnFailure); + m_ui.throwOnFailureCB->setChecked(settings.throwOnFailure); +} + +GTestSettings GTestSettingsWidget::settings() const +{ + GTestSettings result; + result.runDisabled = m_ui.runDisabledGTestsCB->isChecked(); + result.repeat = m_ui.repeatGTestsCB->isChecked(); + result.shuffle = m_ui.shuffleGTestsCB->isChecked(); + result.iterations = m_ui.repetitionSpin->value(); + result.seed = m_ui.seedSpin->value(); + result.breakOnFailure = m_ui.breakOnFailureCB->isChecked(); + result.throwOnFailure = m_ui.throwOnFailureCB->isChecked(); + return result; +} + +GTestSettingsPage::GTestSettingsPage(QSharedPointer settings) + : m_settings(qSharedPointerCast(settings)), m_widget(0) +{ + setId("A.AutoTest.10.GTest"); // FIXME + setDisplayName(QCoreApplication::translate("GTestFramework", + GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY)); + setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY); + setDisplayCategory(QCoreApplication::translate("AutoTest", Constants::AUTOTEST_SETTINGS_TR)); +} + +GTestSettingsPage::~GTestSettingsPage() +{ +} + +QWidget *GTestSettingsPage::widget() +{ + if (!m_widget) { + m_widget = new GTestSettingsWidget; + m_widget->setSettings(*m_settings); + } + return m_widget; +} + +void GTestSettingsPage::apply() +{ + if (!m_widget) // page was not shown at all + return; + *m_settings = m_widget->settings(); + m_settings->toSettings(Core::ICore::settings()); +} + +} // namespace Internal +} // namespace Autotest diff --git a/src/plugins/autotest/gtest/gtestsettingspage.h b/src/plugins/autotest/gtest/gtestsettingspage.h new file mode 100644 index 00000000000..cdef183de09 --- /dev/null +++ b/src/plugins/autotest/gtest/gtestsettingspage.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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 "ui_gtestsettingspage.h" + +#include + +#include + +namespace Autotest { +namespace Internal { + +class IFrameworkSettings; +class GTestSettings; + +class GTestSettingsWidget : public QWidget +{ + Q_OBJECT +public: + explicit GTestSettingsWidget(QWidget *parent = 0); + + void setSettings(const GTestSettings &settings); + GTestSettings settings() const; + +private: + Ui::GTestSettingsPage m_ui; +}; + +class GTestSettingsPage : public Core::IOptionsPage +{ + Q_OBJECT +public: + explicit GTestSettingsPage(QSharedPointer settings); + ~GTestSettingsPage(); + + QWidget *widget() override; + void apply() override; + void finish() override { } + +private: + QSharedPointer m_settings; + QPointer m_widget; +}; + +} // namespace Internal +} // namespace Autotest diff --git a/src/plugins/autotest/gtest/gtestsettingspage.ui b/src/plugins/autotest/gtest/gtestsettingspage.ui new file mode 100644 index 00000000000..4b2f998310f --- /dev/null +++ b/src/plugins/autotest/gtest/gtestsettingspage.ui @@ -0,0 +1,219 @@ + + + Autotest::Internal::GTestSettingsPage + + + + 0 + 0 + 397 + 205 + + + + Form + + + + + + + + Executes disabled tests when performing a test run. + + + Run disabled tests + + + + + + + Turn failures into debugger breakpoints. + + + Break on failure while debugging + + + true + + + + + + + + + Repeats a test run (you might be required to increase the timeout to avoid canceling the tests). + + + Repeat tests + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Iterations: + + + + + + + false + + + 1 + + + 9999 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Shuffle tests automatically on every iteration by the given seed. + + + Shuffle tests + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Seed: + + + + + + + false + + + A seed of 0 generates a seed based on the current timestamp. + + + + + + 99999 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Turn assertion failures into C++ exceptions. + + + Throw on failure + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + diff --git a/src/plugins/autotest/iframeworksettings.h b/src/plugins/autotest/iframeworksettings.h index 8cc3f0b3ea7..51ff6a79fa7 100644 --- a/src/plugins/autotest/iframeworksettings.h +++ b/src/plugins/autotest/iframeworksettings.h @@ -25,6 +25,8 @@ #pragma once +#include "autotestconstants.h" + #include namespace Autotest { @@ -37,8 +39,28 @@ public: virtual ~IFrameworkSettings() {} virtual QString name() const = 0; - virtual void toSettings(QSettings *s) const = 0; - virtual void fromSettings(const QSettings *s) = 0; + + void toSettings(QSettings *s) const + { + s->beginGroup(Constants::SETTINGSGROUP); + s->beginGroup(name()); + toFrameworkSettings(s); + s->endGroup(); + s->endGroup(); + } + + void fromSettings(QSettings *s) + { + s->beginGroup(Constants::SETTINGSGROUP); + s->beginGroup(name()); + fromFrameworkSettings(s); + s->endGroup(); + s->endGroup(); + } + +protected: + virtual void toFrameworkSettings(QSettings *s) const = 0; + virtual void fromFrameworkSettings(const QSettings *s) = 0; }; } // namespace Internal diff --git a/src/plugins/autotest/itestframework.h b/src/plugins/autotest/itestframework.h index 35e0df68cd8..d752da02506 100644 --- a/src/plugins/autotest/itestframework.h +++ b/src/plugins/autotest/itestframework.h @@ -28,6 +28,8 @@ #include "testtreeitem.h" #include "itestparser.h" +namespace Core { class IOptionsPage; } + namespace Autotest { namespace Internal { @@ -47,6 +49,11 @@ public: virtual unsigned priority() const = 0; // should this be modifyable? virtual bool hasFrameworkSettings() const { return false; } virtual IFrameworkSettings *createFrameworkSettings() const { return 0; } + virtual Core::IOptionsPage *createSettingsPage(QSharedPointer settings) const + { + Q_UNUSED(settings); + return 0; + } TestTreeItem *rootNode() { if (!m_rootNode) diff --git a/src/plugins/autotest/qtest/qttestframework.cpp b/src/plugins/autotest/qtest/qttestframework.cpp index 860ff7187b1..8bcefb248b0 100644 --- a/src/plugins/autotest/qtest/qttestframework.cpp +++ b/src/plugins/autotest/qtest/qttestframework.cpp @@ -27,6 +27,7 @@ #include "qttestconstants.h" #include "qttestparser.h" #include "qttestsettings.h" +#include "qttestsettingspage.h" #include "qttesttreeitem.h" namespace Autotest { @@ -50,6 +51,11 @@ IFrameworkSettings *QtTestFramework::createFrameworkSettings() const return new QtTestSettings; } +Core::IOptionsPage *QtTestFramework::createSettingsPage(QSharedPointer settings) const +{ + return new QtTestSettingsPage(settings); +} + bool QtTestFramework::hasFrameworkSettings() const { return true; diff --git a/src/plugins/autotest/qtest/qttestframework.h b/src/plugins/autotest/qtest/qttestframework.h index 41c5c7c06c1..a6cfcb9f2a5 100644 --- a/src/plugins/autotest/qtest/qttestframework.h +++ b/src/plugins/autotest/qtest/qttestframework.h @@ -37,6 +37,7 @@ public: const char *name() const override; unsigned priority() const override; IFrameworkSettings *createFrameworkSettings() const override; + Core::IOptionsPage *createSettingsPage(QSharedPointer settings) const override; bool hasFrameworkSettings() const override; protected: diff --git a/src/plugins/autotest/qtest/qttestsettings.cpp b/src/plugins/autotest/qtest/qttestsettings.cpp index bdb11d4440b..d269db30da1 100644 --- a/src/plugins/autotest/qtest/qttestsettings.cpp +++ b/src/plugins/autotest/qtest/qttestsettings.cpp @@ -54,13 +54,13 @@ QString QtTestSettings::name() const return QString("QtTest"); } -void QtTestSettings::fromSettings(const QSettings *s) +void QtTestSettings::fromFrameworkSettings(const QSettings *s) { metrics = intToMetrics(s->value(metricsKey, Walltime).toInt()); noCrashHandler = s->value(noCrashhandlerKey, true).toBool(); } -void QtTestSettings::toSettings(QSettings *s) const +void QtTestSettings::toFrameworkSettings(QSettings *s) const { s->setValue(metricsKey, metrics); s->setValue(noCrashhandlerKey, noCrashHandler); diff --git a/src/plugins/autotest/qtest/qttestsettings.h b/src/plugins/autotest/qtest/qttestsettings.h index d1811d52287..c80a93165e3 100644 --- a/src/plugins/autotest/qtest/qttestsettings.h +++ b/src/plugins/autotest/qtest/qttestsettings.h @@ -44,12 +44,14 @@ class QtTestSettings : public IFrameworkSettings public: QtTestSettings() {} QString name() const override; - void fromSettings(const QSettings *s) override; - void toSettings(QSettings *s) const override; static QString metricsTypeToOption(const MetricsType type); MetricsType metrics = Walltime; bool noCrashHandler = true; + +protected: + void fromFrameworkSettings(const QSettings *s) override; + void toFrameworkSettings(QSettings *s) const override; }; } // namespace Internal diff --git a/src/plugins/autotest/qtest/qttestsettingspage.cpp b/src/plugins/autotest/qtest/qttestsettingspage.cpp new file mode 100644 index 00000000000..fbaf252fdaf --- /dev/null +++ b/src/plugins/autotest/qtest/qttestsettingspage.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** 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. +** +****************************************************************************/ + +#include "../autotestconstants.h" +#include "qttestconstants.h" +#include "qttestsettingspage.h" +#include "qttestsettings.h" + +#include + +#include + +namespace Autotest { +namespace Internal { + +QtTestSettingsWidget::QtTestSettingsWidget(QWidget *parent) + : QWidget(parent) +{ + m_ui.setupUi(this); + m_ui.callgrindRB->setEnabled(Utils::HostOsInfo::isAnyUnixHost()); // valgrind available on UNIX + m_ui.perfRB->setEnabled(Utils::HostOsInfo::isLinuxHost()); // according to docs perf Linux only +} + +void QtTestSettingsWidget::setSettings(const QtTestSettings &settings) +{ + m_ui.disableCrashhandlerCB->setChecked(settings.noCrashHandler); + switch (settings.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); + } +} + +QtTestSettings QtTestSettingsWidget::settings() const +{ + QtTestSettings result; + + result.noCrashHandler = m_ui.disableCrashhandlerCB->isChecked(); + if (m_ui.walltimeRB->isChecked()) + result.metrics = MetricsType::Walltime; + else if (m_ui.tickcounterRB->isChecked()) + result.metrics = MetricsType::TickCounter; + else if (m_ui.eventCounterRB->isChecked()) + result.metrics = MetricsType::EventCounter; + else if (m_ui.callgrindRB->isChecked()) + result.metrics = MetricsType::CallGrind; + else if (m_ui.perfRB->isChecked()) + result.metrics = MetricsType::Perf; + + return result; +} + +QtTestSettingsPage::QtTestSettingsPage(QSharedPointer settings) + : m_settings(qSharedPointerCast(settings)), m_widget(0) +{ + setId("A.AutoTest.1.QtTest"); // FIXME + setDisplayName(QCoreApplication::translate("QtTestFramework", + QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY)); + setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY); + setDisplayCategory(QCoreApplication::translate("AutoTest", Constants::AUTOTEST_SETTINGS_TR)); +} + +QtTestSettingsPage::~QtTestSettingsPage() +{ +} + +QWidget *QtTestSettingsPage::widget() +{ + if (!m_widget) { + m_widget = new QtTestSettingsWidget; + m_widget->setSettings(*m_settings); + } + return m_widget; +} + +void QtTestSettingsPage::apply() +{ + if (!m_widget) // page was not shown at all + return; + *m_settings = m_widget->settings(); + m_settings->toSettings(Core::ICore::settings()); +} + +} // namespace Internal +} // namespace Autotest diff --git a/src/plugins/autotest/qtest/qttestsettingspage.h b/src/plugins/autotest/qtest/qttestsettingspage.h new file mode 100644 index 00000000000..2b5c64d5340 --- /dev/null +++ b/src/plugins/autotest/qtest/qttestsettingspage.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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 "ui_qttestsettingspage.h" + +#include + +#include + +namespace Autotest { +namespace Internal { + +class IFrameworkSettings; +class QtTestSettings; + +class QtTestSettingsWidget : public QWidget +{ + Q_OBJECT +public: + explicit QtTestSettingsWidget(QWidget *parent = 0); + + void setSettings(const QtTestSettings &settings); + QtTestSettings settings() const; + +private: + Ui::QtTestSettingsPage m_ui; +}; + +class QtTestSettingsPage : public Core::IOptionsPage +{ + Q_OBJECT +public: + explicit QtTestSettingsPage(QSharedPointer settings); + ~QtTestSettingsPage(); + + QWidget *widget() override; + void apply() override; + void finish() override { } + +private: + QSharedPointer m_settings; + QPointer m_widget; +}; + +} // namespace Internal +} // namespace Autotest diff --git a/src/plugins/autotest/qtest/qttestsettingspage.ui b/src/plugins/autotest/qtest/qttestsettingspage.ui new file mode 100644 index 00000000000..6c5db71a30a --- /dev/null +++ b/src/plugins/autotest/qtest/qttestsettingspage.ui @@ -0,0 +1,169 @@ + + + Autotest::Internal::QtTestSettingsPage + + + + 0 + 0 + 327 + 266 + + + + Form + + + + + + + + + + Enables interrupting tests on assertions. + + + Disable crash handler while debugging + + + true + + + + + + + Benchmark Metrics + + + true + + + + + + + 0 + 0 + + + + Uses walltime metrics for executing benchmarks (default). + + + Walltime + + + true + + + + + + + + 0 + 0 + + + + Uses tick counter when executing benchmarks. + + + Tick counter + + + + + + + + 0 + 0 + + + + Uses event counter when executing benchmarks. + + + Event counter + + + + + + + false + + + + 0 + 0 + + + + Uses Valgrind Callgrind when executing benchmarks (it must be installed). + + + Callgrind + + + + + + + false + + + + 0 + 0 + + + + Uses Perf when executing benchmarks (it must be installed). + + + Perf + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/src/plugins/autotest/testframeworkmanager.cpp b/src/plugins/autotest/testframeworkmanager.cpp index 3770790426f..0b65a79e179 100644 --- a/src/plugins/autotest/testframeworkmanager.cpp +++ b/src/plugins/autotest/testframeworkmanager.cpp @@ -34,10 +34,12 @@ #include "testtreeitem.h" #include "testtreemodel.h" +#include #include #include #include +#include static Q_LOGGING_CATEGORY(LOG, "qtc.autotest.frameworkmanager") @@ -77,9 +79,13 @@ bool TestFrameworkManager::registerTestFramework(ITestFramework *framework) qCDebug(LOG) << "Registering" << id; m_registeredFrameworks.insert(id, framework); + AutotestPlugin *plugin = AutotestPlugin::instance(); + if (framework->hasFrameworkSettings()) { QSharedPointer frameworkSettings(framework->createFrameworkSettings()); m_frameworkSettings.insert(id, frameworkSettings); + if (auto page = framework->createSettingsPage(frameworkSettings)) + plugin->addAutoReleasedObject(page); } return true; } diff --git a/src/plugins/autotest/testsettings.cpp b/src/plugins/autotest/testsettings.cpp index 9a2f1bd8b7c..13d302f901e 100644 --- a/src/plugins/autotest/testsettings.cpp +++ b/src/plugins/autotest/testsettings.cpp @@ -25,7 +25,6 @@ #include "testsettings.h" #include "autotestconstants.h" -#include "iframeworksettings.h" #include "testframeworkmanager.h" #include @@ -62,13 +61,6 @@ void TestSettings::toSettings(QSettings *s) const for (const Core::Id &id : frameworks.keys()) s->setValue(QLatin1String(id.name()), frameworks.value(id)); 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) @@ -89,11 +81,6 @@ void TestSettings::fromSettings(QSettings *s) frameworkManager->isActive(id)).toBool()); } 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/testsettingspage.cpp b/src/plugins/autotest/testsettingspage.cpp index ca34242033b..bfc39f2048e 100644 --- a/src/plugins/autotest/testsettingspage.cpp +++ b/src/plugins/autotest/testsettingspage.cpp @@ -29,30 +29,17 @@ #include "testsettings.h" #include "testtreemodel.h" -#include "gtest/gtestconstants.h" -#include "gtest/gtestsettings.h" -#include "qtest/qttestconstants.h" -#include "qtest/qttestsettings.h" - #include -#include #include 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) { m_ui.setupUi(this); - m_ui.callgrindRB->setEnabled(Utils::HostOsInfo::isAnyUnixHost()); // valgrind available on UNIX - m_ui.perfRB->setEnabled(Utils::HostOsInfo::isLinuxHost()); // according to docs perf Linux only m_ui.frameworksWarnIcon->setVisible(false); m_ui.frameworksWarnIcon->setPixmap(Utils::Icons::WARNING.pixmap()); @@ -60,8 +47,6 @@ TestSettingsWidget::TestSettingsWidget(QWidget *parent) m_ui.frameworksWarn->setText(tr("No active test frameworks.")); m_ui.frameworksWarn->setToolTip(tr("You will not be able to use the AutoTest plugin without " "having at least one active test framework.")); - connect(m_ui.repeatGTestsCB, &QCheckBox::toggled, m_ui.repetitionSpin, &QSpinBox::setEnabled); - connect(m_ui.shuffleGTestsCB, &QCheckBox::toggled, m_ui.seedSpin, &QSpinBox::setEnabled); connect(m_ui.frameworkListWidget, &QListWidget::itemChanged, this, &TestSettingsWidget::onFrameworkItemChanged); } @@ -75,44 +60,6 @@ void TestSettingsWidget::setSettings(const TestSettings &settings) m_ui.autoScrollCB->setChecked(settings.autoScroll); m_ui.alwaysParseCB->setChecked(settings.alwaysParse); populateFrameworksListWidget(settings.frameworks); - - 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); - } - } - - 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 @@ -125,37 +72,6 @@ TestSettings TestSettingsWidget::settings() const result.autoScroll = m_ui.autoScrollCB->isChecked(); result.alwaysParse = m_ui.alwaysParseCB->isChecked(); result.frameworks = frameworks(); - - // QtTestSettings - 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 - 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; } @@ -202,10 +118,10 @@ void TestSettingsWidget::onFrameworkItemChanged() TestSettingsPage::TestSettingsPage(const QSharedPointer &settings) : m_settings(settings), m_widget(0) { - setId("A.AutoTest.General"); + setId("A.AutoTest.0.General"); setDisplayName(tr("General")); setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY); - setDisplayCategory(tr("Test Settings")); + setDisplayCategory(QCoreApplication::translate("AutoTest", Constants::AUTOTEST_SETTINGS_TR)); setCategoryIcon(Utils::Icon(":/images/autotest.png")); } diff --git a/src/plugins/autotest/testsettingspage.ui b/src/plugins/autotest/testsettingspage.ui index 349282b889c..345f48965d8 100644 --- a/src/plugins/autotest/testsettingspage.ui +++ b/src/plugins/autotest/testsettingspage.ui @@ -6,8 +6,8 @@ 0 0 - 655 - 427 + 585 + 324 @@ -150,6 +150,23 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + @@ -186,310 +203,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt Test - - - - - - Enables interrupting tests on assertions. - - - Disable crash handler while debugging - - - true - - - - - - - Benchmark Metrics - - - true - - - - - - - 0 - 0 - - - - Uses walltime metrics for executing benchmarks (default). - - - Walltime - - - true - - - - - - - - 0 - 0 - - - - Uses tick counter when executing benchmarks. - - - Tick counter - - - - - - - - 0 - 0 - - - - Uses event counter when executing benchmarks. - - - Event counter - - - - - - - false - - - - 0 - 0 - - - - Uses Valgrind Callgrind when executing benchmarks (it must be installed). - - - Callgrind - - - - - - - false - - - - 0 - 0 - - - - Uses Perf when executing benchmarks (it must be installed). - - - Perf - - - - - - - Qt::Horizontal - - - - 40 - 0 - - - - - - - - - - - - - - Google Test - - - - - - Executes disabled tests when performing a test run. - - - Run disabled tests - - - - - - - - - Repeats a test run (you might be required to increase the timeout to avoid canceling the tests). - - - Repeat tests - - - - - - - - 0 - 0 - - - - Iterations: - - - - - - - false - - - 1 - - - 9999 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Shuffle tests automatically on every iteration by the given seed. - - - Shuffle tests - - - - - - - - 0 - 0 - - - - Seed: - - - - - - - false - - - A seed of 0 generates a seed based on the current timestamp. - - - - - - 99999 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Turn assertion failures into C++ exceptions. - - - Throw on failure - - - - - - - Turn failures into debugger breakpoints. - - - Break on failure while debugging - - - true - - - - - -