diff --git a/src/libs/utils/aspects.cpp b/src/libs/utils/aspects.cpp index 3f1b3bee226..89775b9c02f 100644 --- a/src/libs/utils/aspects.cpp +++ b/src/libs/utils/aspects.cpp @@ -1248,6 +1248,8 @@ void BoolAspect::addToLayout(LayoutBuilder &builder) connect(d->m_checkBox.data(), &QAbstractButton::clicked, this, [this](bool val) { setValue(val); }); } + connect(d->m_checkBox.data(), &QAbstractButton::clicked, + this, &BoolAspect::volatileValueChanged); } QAction *BoolAspect::action() diff --git a/src/libs/utils/aspects.h b/src/libs/utils/aspects.h index 346e776786a..f52d1173a2e 100644 --- a/src/libs/utils/aspects.h +++ b/src/libs/utils/aspects.h @@ -182,6 +182,7 @@ public: signals: void valueChanged(bool newValue); + void volatileValueChanged(bool newValue); private: std::unique_ptr d; diff --git a/src/plugins/autotest/CMakeLists.txt b/src/plugins/autotest/CMakeLists.txt index a537e5616eb..dfcbdda19d1 100644 --- a/src/plugins/autotest/CMakeLists.txt +++ b/src/plugins/autotest/CMakeLists.txt @@ -24,7 +24,6 @@ add_qtc_plugin(AutoTest catch/catchoutputreader.cpp catch/catchresult.h catch/catchresult.cpp catch/catchtestparser.h catch/catchtestparser.cpp catch/catchtreeitem.h catch/catchtreeitem.cpp catch/catchtestsettings.cpp catch/catchtestsettings.h - catch/catchtestsettingspage.cpp catch/catchtestsettingspage.h catch/catchtestsettingspage.ui ctest/ctestconfiguration.cpp ctest/ctestconfiguration.h ctest/ctestoutputreader.cpp ctest/ctestoutputreader.h ctest/ctesttool.cpp ctest/ctesttool.h diff --git a/src/plugins/autotest/autotest.pro b/src/plugins/autotest/autotest.pro index 7c3c3bec8bf..70041f1fc0a 100644 --- a/src/plugins/autotest/autotest.pro +++ b/src/plugins/autotest/autotest.pro @@ -39,7 +39,6 @@ SOURCES += \ catch/catchresult.cpp \ catch/catchtestparser.cpp \ catch/catchtestsettings.cpp \ - catch/catchtestsettingspage.cpp \ catch/catchtreeitem.cpp \ gtest/gtestconfiguration.cpp \ gtest/gtestparser.cpp \ @@ -115,7 +114,6 @@ HEADERS += \ catch/catchresult.h \ catch/catchtestparser.h \ catch/catchtestsettings.h \ - catch/catchtestsettingspage.h \ catch/catchtreeitem.h \ gtest/gtestconfiguration.h \ gtest/gtestparser.h \ @@ -161,7 +159,6 @@ RESOURCES += \ FORMS += \ testsettingspage.ui \ boost/boosttestsettingspage.ui \ - catch/catchtestsettingspage.ui \ gtest/gtestsettingspage.ui equals(TEST, 1) { diff --git a/src/plugins/autotest/catch/catchframework.h b/src/plugins/autotest/catch/catchframework.h index 0b143472ea3..c49e79c9293 100644 --- a/src/plugins/autotest/catch/catchframework.h +++ b/src/plugins/autotest/catch/catchframework.h @@ -27,7 +27,6 @@ #include "../itestframework.h" #include "catchtestsettings.h" -#include "catchtestsettingspage.h" namespace Autotest { namespace Internal { diff --git a/src/plugins/autotest/catch/catchtestsettings.cpp b/src/plugins/autotest/catch/catchtestsettings.cpp index abb46518456..e218940c3c8 100644 --- a/src/plugins/autotest/catch/catchtestsettings.cpp +++ b/src/plugins/autotest/catch/catchtestsettings.cpp @@ -25,6 +25,14 @@ #include "catchtestsettings.h" +#include "../autotestconstants.h" + +#include + +#include + +using namespace Utils; + namespace Autotest { namespace Internal { @@ -35,55 +43,136 @@ CatchTestSettings::CatchTestSettings() registerAspect(&abortAfter); abortAfter.setSettingsKey("AbortAfter"); + abortAfter.setRange(1, 9999); + abortAfter.setEnabled(false); registerAspect(&benchmarkSamples); benchmarkSamples.setSettingsKey("BenchSamples"); + benchmarkSamples.setRange(1, 999999); benchmarkSamples.setDefaultValue(100); + benchmarkSamples.setEnabled(false); registerAspect(&benchmarkResamples); benchmarkResamples.setSettingsKey("BenchResamples"); + benchmarkResamples.setRange(1, 9999999); benchmarkResamples.setDefaultValue(100000); + benchmarkResamples.setToolTip(tr("Number of resamples for bootstrapping.")); + benchmarkResamples.setEnabled(false); registerAspect(&confidenceInterval); confidenceInterval.setSettingsKey("BenchConfInt"); + confidenceInterval.setRange(0., 1.); + confidenceInterval.setSingleStep(0.05); confidenceInterval.setDefaultValue(0.95); + confidenceInterval.setEnabled(false); registerAspect(&benchmarkWarmupTime); benchmarkWarmupTime.setSettingsKey("BenchWarmup"); + benchmarkWarmupTime.setSuffix(tr(" ms")); + benchmarkWarmupTime.setRange(0, 10000); + benchmarkWarmupTime.setEnabled(false); registerAspect(&abortAfterChecked); abortAfterChecked.setSettingsKey("AbortChecked"); + abortAfterChecked.setLabelText(tr("Abort after")); + abortAfterChecked.setToolTip(tr("Aborts after the specified number of failures.")); registerAspect(&samplesChecked); samplesChecked.setSettingsKey("SamplesChecked"); + samplesChecked.setLabelText(tr("Benchmark samples")); + samplesChecked.setToolTip(tr("Number of samples to collect while running benchmarks.")); registerAspect(&resamplesChecked); resamplesChecked.setSettingsKey("ResamplesChecked"); + resamplesChecked.setLabelText(tr("Benchmark resamples")); + resamplesChecked.setToolTip(tr("Number of resamples used for statistical bootstrapping.")); registerAspect(&confidenceIntervalChecked); confidenceIntervalChecked.setSettingsKey("ConfIntChecked"); + confidenceIntervalChecked.setToolTip(tr("Confidence interval used for statistical bootstrapping.")); + confidenceIntervalChecked.setLabelText(tr("Benchmark confidence interval")); registerAspect(&warmupChecked); warmupChecked.setSettingsKey("WarmupChecked"); + warmupChecked.setLabelText(tr("Benchmark warmup time")); + warmupChecked.setToolTip(tr("Warmup time for each test.")); registerAspect(&noAnalysis); noAnalysis.setSettingsKey("NoAnalysis"); + noAnalysis.setLabelText(tr("Disable analysis")); + noAnalysis.setToolTip(tr("Disables statistical analysis and bootstrapping.")); registerAspect(&showSuccess); showSuccess.setSettingsKey("ShowSuccess"); + showSuccess.setLabelText(tr("Show success")); + showSuccess.setToolTip(tr("Show success for tests.")); registerAspect(&breakOnFailure); breakOnFailure.setSettingsKey("BreakOnFailure"); breakOnFailure.setDefaultValue(true); + breakOnFailure.setLabelText(tr("Break on failure while debugging")); + breakOnFailure.setToolTip(tr("Turns failures into debugger breakpoints.")); registerAspect(&noThrow); noThrow.setSettingsKey("NoThrow"); + noThrow.setLabelText(tr("Skip throwing assertions")); + noThrow.setToolTip(tr("Skips all assertions that test for thrown exceptions.")); registerAspect(&visibleWhitespace); visibleWhitespace.setSettingsKey("VisibleWS"); + visibleWhitespace.setLabelText(tr("Visualize whitespace")); + visibleWhitespace.setToolTip(tr("Makes whitespace visible.")); registerAspect(&warnOnEmpty); warnOnEmpty.setSettingsKey("WarnEmpty"); + warnOnEmpty.setLabelText(tr("Warn on empty tests")); + warnOnEmpty.setToolTip(tr("Warns if a test section does not check any assertion.")); + + forEachAspect([](BaseAspect *aspect) { + // FIXME: Make the positioning part of the LayoutBuilder later + if (auto boolAspect = dynamic_cast(aspect)) + boolAspect->setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel); + }); + + QObject::connect(&abortAfterChecked, &BoolAspect::volatileValueChanged, + &abortAfter, &BaseAspect::setEnabled); + QObject::connect(&samplesChecked, &BoolAspect::volatileValueChanged, + &benchmarkSamples, &BaseAspect::setEnabled); + QObject::connect(&resamplesChecked, &BoolAspect::volatileValueChanged, + &benchmarkResamples, &BaseAspect::setEnabled); + QObject::connect(&confidenceIntervalChecked, &BoolAspect::volatileValueChanged, + &confidenceInterval, &BaseAspect::setEnabled); + QObject::connect(&warmupChecked, &BoolAspect::volatileValueChanged, + &benchmarkWarmupTime, &BaseAspect::setEnabled); +} + +CatchTestSettingsPage::CatchTestSettingsPage(CatchTestSettings *settings, Utils::Id settingsId) +{ + setId(settingsId); + setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY); + setDisplayName(QCoreApplication::translate("CatchTestFramework", "Catch Test")); + setSettings(settings); + + setLayouter([settings](QWidget *widget) { + CatchTestSettings &s = *settings; + using namespace Layouting; + const Break nl; + + Grid col { + s.showSuccess, nl, + s.breakOnFailure, nl, + s.noThrow, nl, + s.visibleWhitespace, nl, + s.abortAfterChecked, s.abortAfter, nl, + s.samplesChecked, s.benchmarkSamples, nl, + s.resamplesChecked, s.benchmarkResamples, nl, + s.confidenceIntervalChecked, s.confidenceInterval, nl, + s.warmupChecked, s.benchmarkWarmupTime, nl, + s.noAnalysis + }; + + Column { Row { col, Stretch() }, Stretch() }.attachTo(widget); + }); } } // namespace Internal diff --git a/src/plugins/autotest/catch/catchtestsettings.h b/src/plugins/autotest/catch/catchtestsettings.h index 061ef80a139..79498edd7a9 100644 --- a/src/plugins/autotest/catch/catchtestsettings.h +++ b/src/plugins/autotest/catch/catchtestsettings.h @@ -25,6 +25,8 @@ #pragma once +#include + #include namespace Autotest { @@ -32,6 +34,8 @@ namespace Internal { class CatchTestSettings : public Utils::AspectContainer { + Q_DECLARE_TR_FUNCTIONS(Autotest::Internal::CatchTestSettings) + public: CatchTestSettings(); @@ -53,5 +57,11 @@ public: Utils::BoolAspect warnOnEmpty; }; +class CatchTestSettingsPage : public Core::IOptionsPage +{ +public: + CatchTestSettingsPage(CatchTestSettings *settings, Utils::Id settingsId); +}; + } // namespace Internal } // namespace Autotest diff --git a/src/plugins/autotest/catch/catchtestsettingspage.cpp b/src/plugins/autotest/catch/catchtestsettingspage.cpp deleted file mode 100644 index 736beaf1076..00000000000 --- a/src/plugins/autotest/catch/catchtestsettingspage.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 "catchtestsettingspage.h" -#include "catchtestsettings.h" -#include "ui_catchtestsettingspage.h" -#include "../autotestconstants.h" - -#include - -namespace Autotest { -namespace Internal { - -class CatchTestSettingsWidget final : public Core::IOptionsPageWidget -{ - Q_DECLARE_TR_FUNCTIONS(Autotest::Internal::CatchTestSettingsWidget) -public: - explicit CatchTestSettingsWidget(CatchTestSettings *settings); - void apply() override; -private: - Ui::CatchTestSettingsPage m_ui; - CatchTestSettings *m_settings; -}; - -CatchTestSettingsWidget::CatchTestSettingsWidget(CatchTestSettings *settings) - : m_settings(settings) -{ - m_ui.setupUi(this); - - m_ui.abortSB->setEnabled(m_settings->abortAfterChecked.value()); - m_ui.samplesSB->setEnabled(m_settings->samplesChecked.value()), - m_ui.resamplesSB->setEnabled(m_settings->resamplesChecked.value()); - m_ui.confIntSB->setEnabled(m_settings->confidenceIntervalChecked.value()); - m_ui.warmupSB->setEnabled(m_settings->warmupChecked.value()); - - connect(m_ui.abortCB, &QCheckBox::toggled, m_ui.abortSB, &QSpinBox::setEnabled); - connect(m_ui.samplesCB, &QCheckBox::toggled, m_ui.samplesSB, &QSpinBox::setEnabled); - connect(m_ui.resamplesCB, &QCheckBox::toggled, m_ui.resamplesSB, &QSpinBox::setEnabled); - connect(m_ui.confIntCB, &QCheckBox::toggled, m_ui.confIntSB, &QDoubleSpinBox::setEnabled); - connect(m_ui.warmupCB, &QCheckBox::toggled, m_ui.warmupSB, &QSpinBox::setEnabled); - - m_ui.showSuccessCB->setChecked(m_settings->showSuccess.value()); - m_ui.breakOnFailCB->setChecked(m_settings->breakOnFailure.value()); - m_ui.noThrowCB->setChecked(m_settings->noThrow.value()); - m_ui.visibleWhiteCB->setChecked(m_settings->visibleWhitespace.value()); - m_ui.warnOnEmpty->setChecked(m_settings->warnOnEmpty.value()); - m_ui.noAnalysisCB->setChecked(m_settings->noAnalysis.value()); - m_ui.abortCB->setChecked(m_settings->abortAfterChecked.value()); - m_ui.abortSB->setValue(m_settings->abortAfter.value()); - m_ui.samplesCB->setChecked(m_settings->samplesChecked.value()); - m_ui.samplesSB->setValue(m_settings->benchmarkSamples.value()); - m_ui.resamplesCB->setChecked(m_settings->resamplesChecked.value()); - m_ui.resamplesSB->setValue(m_settings->benchmarkResamples.value()); - m_ui.confIntCB->setChecked(m_settings->confidenceIntervalChecked.value()); - m_ui.confIntSB->setValue(m_settings->confidenceInterval.value()); - m_ui.warmupCB->setChecked(m_settings->warmupChecked.value()); - m_ui.warmupSB->setValue(m_settings->benchmarkWarmupTime.value()); -} - -void CatchTestSettingsWidget::apply() -{ - m_settings->showSuccess.setValue(m_ui.showSuccessCB->isChecked()); - m_settings->breakOnFailure.setValue(m_ui.breakOnFailCB->isChecked()); - m_settings->noThrow.setValue(m_ui.noThrowCB->isChecked()); - m_settings->visibleWhitespace.setValue(m_ui.visibleWhiteCB->isChecked()); - m_settings->warnOnEmpty.setValue(m_ui.warnOnEmpty->isChecked()); - m_settings->noAnalysis.setValue(m_ui.noAnalysisCB->isChecked()); - m_settings->abortAfterChecked.setValue(m_ui.abortCB->isChecked()); - m_settings->abortAfter.setValue(m_ui.abortSB->value()); - m_settings->samplesChecked.setValue(m_ui.samplesCB->isChecked()); - m_settings->benchmarkSamples.setValue(m_ui.samplesSB->value()); - m_settings->resamplesChecked.setValue(m_ui.resamplesCB->isChecked()); - m_settings->benchmarkResamples.setValue(m_ui.resamplesSB->value()); - m_settings->confidenceIntervalChecked.setValue(m_ui.confIntCB->isChecked()); - m_settings->confidenceInterval.setValue(m_ui.confIntSB->value()); - m_settings->warmupChecked.setValue(m_ui.warmupCB->isChecked()); - m_settings->benchmarkWarmupTime.setValue(m_ui.warmupSB->value()); - - m_settings->writeSettings(Core::ICore::settings()); -} - -CatchTestSettingsPage::CatchTestSettingsPage(CatchTestSettings *settings, Utils::Id settingsId) -{ - setId(settingsId); - setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY); - setDisplayName(QCoreApplication::translate("CatchTestFramework", "Catch Test")); - setWidgetCreator([settings] { return new CatchTestSettingsWidget(settings); }); -} - -} // namespace Internal -} // namespace Autotest diff --git a/src/plugins/autotest/catch/catchtestsettingspage.h b/src/plugins/autotest/catch/catchtestsettingspage.h deleted file mode 100644 index b2f9fe79697..00000000000 --- a/src/plugins/autotest/catch/catchtestsettingspage.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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 Internal { - -class CatchTestSettings; - -class CatchTestSettingsPage : public Core::IOptionsPage -{ -public: - CatchTestSettingsPage(CatchTestSettings *settings, Utils::Id settingsId); -}; - -} // namespace Internal -} // namespace Autotest diff --git a/src/plugins/autotest/catch/catchtestsettingspage.ui b/src/plugins/autotest/catch/catchtestsettingspage.ui deleted file mode 100644 index aaa3ea26ddd..00000000000 --- a/src/plugins/autotest/catch/catchtestsettingspage.ui +++ /dev/null @@ -1,306 +0,0 @@ - - - CatchTestSettingsPage - - - - 0 - 0 - 314 - 323 - - - - - - - - - - - Show success for tests. - - - Show success - - - - - - - Turns failures into debugger breakpoints. - - - Break on failure while debugging - - - true - - - - - - - Skips all assertions that test for thrown exceptions. - - - Skip throwing assertions - - - - - - - Makes whitespace visible. - - - Visualize whitespace - - - - - - - Warns if a test section does not check any assertion. - - - Warn on empty tests - - - - - - - - - Aborts after the specified number of failures. - - - Abort after - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 1 - - - 9999 - - - - - - - - - - - Number of samples to collect while running benchmarks. - - - Benchmark samples - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 999999 - - - 100 - - - - - - - - - - - Number of resamples used for statistical bootstrapping. - - - Benchmark resamples - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Number of resamples for bootstrapping. - - - 9999999 - - - 100000 - - - - - - - - - - - Confidence interval used for statistical bootstrapping. - - - Benchmark confidence interval - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 1.000000000000000 - - - 0.050000000000000 - - - 0.950000000000000 - - - - - - - - - - - Warmup time for each test. - - - Benchmark warmup time - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - ms - - - 10000 - - - - - - - - - Disables statistical analysis and bootstrapping. - - - Disable analysis - - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - - - - - -