AutoTest: Aspectify CatchTest settingspage

Change-Id: I281891fecdcd97e4ec450a795d51981cfb47ef69
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-03-31 10:36:25 +02:00
parent e87e70dcf6
commit cbc26f5dce
10 changed files with 102 additions and 466 deletions

View File

@@ -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()

View File

@@ -182,6 +182,7 @@ public:
signals:
void valueChanged(bool newValue);
void volatileValueChanged(bool newValue);
private:
std::unique_ptr<Internal::BoolAspectPrivate> d;

View File

@@ -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

View File

@@ -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) {

View File

@@ -27,7 +27,6 @@
#include "../itestframework.h"
#include "catchtestsettings.h"
#include "catchtestsettingspage.h"
namespace Autotest {
namespace Internal {

View File

@@ -25,6 +25,14 @@
#include "catchtestsettings.h"
#include "../autotestconstants.h"
#include <coreplugin/icore.h>
#include <utils/layoutbuilder.h>
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<BoolAspect *>(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

View File

@@ -25,6 +25,8 @@
#pragma once
#include <coreplugin/dialogs/ioptionspage.h>
#include <utils/aspects.h>
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

View File

@@ -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 <coreplugin/icore.h>
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

View File

@@ -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 <coreplugin/dialogs/ioptionspage.h>
namespace Autotest {
namespace Internal {
class CatchTestSettings;
class CatchTestSettingsPage : public Core::IOptionsPage
{
public:
CatchTestSettingsPage(CatchTestSettings *settings, Utils::Id settingsId);
};
} // namespace Internal
} // namespace Autotest

View File

@@ -1,306 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CatchTestSettingsPage</class>
<widget class="QWidget" name="CatchTestSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>314</width>
<height>323</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="showSuccessCB">
<property name="toolTip">
<string>Show success for tests.</string>
</property>
<property name="text">
<string>Show success</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="breakOnFailCB">
<property name="toolTip">
<string>Turns failures into debugger breakpoints.</string>
</property>
<property name="text">
<string>Break on failure while debugging</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="noThrowCB">
<property name="toolTip">
<string>Skips all assertions that test for thrown exceptions.</string>
</property>
<property name="text">
<string>Skip throwing assertions</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="visibleWhiteCB">
<property name="toolTip">
<string>Makes whitespace visible.</string>
</property>
<property name="text">
<string>Visualize whitespace</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="warnOnEmpty">
<property name="toolTip">
<string>Warns if a test section does not check any assertion.</string>
</property>
<property name="text">
<string>Warn on empty tests</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="abortHL">
<item>
<widget class="QCheckBox" name="abortCB">
<property name="toolTip">
<string>Aborts after the specified number of failures.</string>
</property>
<property name="text">
<string>Abort after</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="abortSB">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="samplesHL">
<item>
<widget class="QCheckBox" name="samplesCB">
<property name="toolTip">
<string>Number of samples to collect while running benchmarks.</string>
</property>
<property name="text">
<string>Benchmark samples</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="samplesSB">
<property name="maximum">
<number>999999</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="resamplesHL">
<item>
<widget class="QCheckBox" name="resamplesCB">
<property name="toolTip">
<string>Number of resamples used for statistical bootstrapping.</string>
</property>
<property name="text">
<string>Benchmark resamples</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="resamplesSB">
<property name="toolTip">
<string>Number of resamples for bootstrapping.</string>
</property>
<property name="maximum">
<number>9999999</number>
</property>
<property name="value">
<number>100000</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="confIntHL">
<item>
<widget class="QCheckBox" name="confIntCB">
<property name="toolTip">
<string>Confidence interval used for statistical bootstrapping.</string>
</property>
<property name="text">
<string>Benchmark confidence interval</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDoubleSpinBox" name="confIntSB">
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
<property name="value">
<double>0.950000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="warmupHL">
<item>
<widget class="QCheckBox" name="warmupCB">
<property name="toolTip">
<string>Warmup time for each test.</string>
</property>
<property name="text">
<string>Benchmark warmup time</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="warmupSB">
<property name="suffix">
<string> ms</string>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="noAnalysisCB">
<property name="toolTip">
<string>Disables statistical analysis and bootstrapping.</string>
</property>
<property name="text">
<string>Disable analysis</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>