forked from qt-creator/qt-creator
Autotest: Use LayoutBuilder for QtTestSettingsPage
Change-Id: I6f454bedbe0f1d2b9a1a14c146e35bcf41752533 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -52,7 +52,6 @@ add_qtc_plugin(AutoTest
|
||||
qtest/qttestparser.cpp qtest/qttestparser.h
|
||||
qtest/qttestresult.cpp qtest/qttestresult.h
|
||||
qtest/qttestsettings.cpp qtest/qttestsettings.h
|
||||
qtest/qttestsettingspage.cpp qtest/qttestsettingspage.h qtest/qttestsettingspage.ui
|
||||
qtest/qttesttreeitem.cpp qtest/qttesttreeitem.h
|
||||
qtest/qttestvisitors.cpp qtest/qttestvisitors.h
|
||||
quick/quicktest_utils.cpp quick/quicktest_utils.h
|
||||
|
||||
@@ -59,7 +59,6 @@ SOURCES += \
|
||||
qtest/qttestparser.cpp \
|
||||
qtest/qttestframework.cpp \
|
||||
qtest/qttestsettings.cpp \
|
||||
qtest/qttestsettingspage.cpp \
|
||||
qtest/qttest_utils.cpp \
|
||||
quick/quicktestconfiguration.cpp \
|
||||
quick/quicktestparser.cpp \
|
||||
@@ -138,7 +137,6 @@ HEADERS += \
|
||||
qtest/qttestparser.h \
|
||||
qtest/qttestframework.h \
|
||||
qtest/qttestsettings.h \
|
||||
qtest/qttestsettingspage.h \
|
||||
qtest/qttestconstants.h \
|
||||
quick/quicktestconfiguration.h \
|
||||
quick/quicktestparser.h \
|
||||
@@ -164,7 +162,6 @@ FORMS += \
|
||||
testsettingspage.ui \
|
||||
boost/boosttestsettingspage.ui \
|
||||
catch/catchtestsettingspage.ui \
|
||||
qtest/qttestsettingspage.ui \
|
||||
gtest/gtestsettingspage.ui
|
||||
|
||||
equals(TEST, 1) {
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "../itestframework.h"
|
||||
|
||||
#include "qttestsettings.h"
|
||||
#include "qttestsettingspage.h"
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
@@ -25,27 +25,16 @@
|
||||
|
||||
#include "qttestsettings.h"
|
||||
|
||||
#include "../autotestconstants.h"
|
||||
#include "qttestconstants.h"
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
static MetricsType intToMetrics(int value)
|
||||
{
|
||||
switch (value) {
|
||||
case Walltime:
|
||||
return Walltime;
|
||||
case TickCounter:
|
||||
return TickCounter;
|
||||
case EventCounter:
|
||||
return EventCounter;
|
||||
case CallGrind:
|
||||
return CallGrind;
|
||||
case Perf:
|
||||
return Perf;
|
||||
default:
|
||||
return Walltime;
|
||||
}
|
||||
}
|
||||
|
||||
QtTestSettings::QtTestSettings()
|
||||
{
|
||||
setSettingsGroups("Autotest", "QtTest");
|
||||
@@ -54,20 +43,42 @@ QtTestSettings::QtTestSettings()
|
||||
registerAspect(&metrics);
|
||||
metrics.setSettingsKey("Metrics");
|
||||
metrics.setDefaultValue(Walltime);
|
||||
metrics.addOption(tr("Walltime"), tr("Uses walltime metrics for executing benchmarks (default)."));
|
||||
metrics.addOption(tr("Tick counter"), tr("Uses tick counter when executing benchmarks."));
|
||||
metrics.addOption(tr("Event counter"), tr("Uses event counter when executing benchmarks."));
|
||||
metrics.addOption({
|
||||
tr("Callgrind"),
|
||||
tr("Uses Valgrind Callgrind when executing benchmarks (it must be installed)."),
|
||||
HostOsInfo::isAnyUnixHost() // valgrind available on UNIX
|
||||
});
|
||||
metrics.addOption({
|
||||
tr("Perf"),
|
||||
tr("Uses Perf when executing benchmarks (it must be installed)."),
|
||||
HostOsInfo::isLinuxHost() // according to docs perf Linux only
|
||||
});
|
||||
|
||||
registerAspect(&noCrashHandler);
|
||||
noCrashHandler.setSettingsKey("NoCrashhandlerOnDebug");
|
||||
noCrashHandler.setDefaultValue(true);
|
||||
noCrashHandler.setLabelText(tr("Disable crash handler while debugging"));
|
||||
noCrashHandler.setToolTip(tr("Enables interrupting tests on assertions."));
|
||||
|
||||
registerAspect(&useXMLOutput);
|
||||
useXMLOutput.setSettingsKey("UseXMLOutput");
|
||||
useXMLOutput.setDefaultValue(true);
|
||||
useXMLOutput.setLabelText(tr("Use XML output"));
|
||||
useXMLOutput.setToolTip(tr("XML output is recommended, because it avoids parsing issues, "
|
||||
"while plain text is more human readable.\n\n"
|
||||
"Warning: Plain text misses some information, such as duration."));
|
||||
|
||||
registerAspect(&verboseBench);
|
||||
verboseBench.setSettingsKey("VerboseBench");
|
||||
verboseBench.setLabelText(tr("Verbose benchmarks"));
|
||||
|
||||
registerAspect(&logSignalsSlots);
|
||||
logSignalsSlots.setSettingsKey("LogSignalsSlots");
|
||||
logSignalsSlots.setLabelText(tr("Log signals and slots"));
|
||||
logSignalsSlots.setToolTip(tr("Log every signal emission and resulting slot invocations."));
|
||||
}
|
||||
|
||||
QString QtTestSettings::metricsTypeToOption(const MetricsType type)
|
||||
@@ -87,5 +98,32 @@ QString QtTestSettings::metricsTypeToOption(const MetricsType type)
|
||||
return QString();
|
||||
}
|
||||
|
||||
QtTestSettingsPage::QtTestSettingsPage(QtTestSettings *settings, Id settingsId)
|
||||
{
|
||||
setId(settingsId);
|
||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||
setDisplayName(QCoreApplication::translate("QtTestFramework",
|
||||
QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
|
||||
setSettings(settings);
|
||||
|
||||
setLayouter([settings](QWidget *widget) {
|
||||
QtTestSettings &s = *settings;
|
||||
using namespace Layouting;
|
||||
|
||||
Column col {
|
||||
s.noCrashHandler,
|
||||
s.useXMLOutput,
|
||||
s.verboseBench,
|
||||
s.logSignalsSlots,
|
||||
Group {
|
||||
Title(QtTestSettings::tr("Benchmark Metrics")),
|
||||
s.metrics
|
||||
},
|
||||
};
|
||||
|
||||
Column { Row { col, Stretch() }, Stretch() }.attachTo(widget);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <utils/aspects.h>
|
||||
|
||||
namespace Autotest {
|
||||
@@ -41,6 +43,7 @@ enum MetricsType
|
||||
|
||||
class QtTestSettings : public Utils::AspectContainer
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Autotest::Internal::QtTestSettings)
|
||||
public:
|
||||
QtTestSettings();
|
||||
|
||||
@@ -53,5 +56,11 @@ public:
|
||||
Utils::BoolAspect logSignalsSlots;
|
||||
};
|
||||
|
||||
class QtTestSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
QtTestSettingsPage(QtTestSettings *settings, Utils::Id settingsId);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "ui_qttestsettingspage.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
class QtTestSettingsWidget final : public Core::IOptionsPageWidget
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Autotest::Internal::QtTestSettingsWidget)
|
||||
|
||||
public:
|
||||
explicit QtTestSettingsWidget(QtTestSettings *settings);
|
||||
|
||||
void apply() final;
|
||||
|
||||
private:
|
||||
Ui::QtTestSettingsPage m_ui;
|
||||
QtTestSettings *m_settings;
|
||||
};
|
||||
|
||||
QtTestSettingsWidget::QtTestSettingsWidget(QtTestSettings *settings)
|
||||
: m_settings(settings)
|
||||
{
|
||||
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.disableCrashhandlerCB->setChecked(m_settings->noCrashHandler.value());
|
||||
m_ui.useXMLOutputCB->setChecked(m_settings->useXMLOutput.value());
|
||||
m_ui.verboseBenchmarksCB->setChecked(m_settings->verboseBench.value());
|
||||
m_ui.logSignalsAndSlotsCB->setChecked(m_settings->logSignalsSlots.value());
|
||||
switch (m_settings->metrics.value()) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void QtTestSettingsWidget::apply()
|
||||
{
|
||||
m_settings->noCrashHandler.setValue(m_ui.disableCrashhandlerCB->isChecked());
|
||||
m_settings->useXMLOutput.setValue(m_ui.useXMLOutputCB->isChecked());
|
||||
m_settings->verboseBench.setValue(m_ui.verboseBenchmarksCB->isChecked());
|
||||
m_settings->logSignalsSlots.setValue(m_ui.logSignalsAndSlotsCB->isChecked());
|
||||
if (m_ui.walltimeRB->isChecked())
|
||||
m_settings->metrics.setValue(MetricsType::Walltime);
|
||||
else if (m_ui.tickcounterRB->isChecked())
|
||||
m_settings->metrics.setValue(MetricsType::TickCounter);
|
||||
else if (m_ui.eventCounterRB->isChecked())
|
||||
m_settings->metrics.setValue(MetricsType::EventCounter);
|
||||
else if (m_ui.callgrindRB->isChecked())
|
||||
m_settings->metrics.setValue(MetricsType::CallGrind);
|
||||
else if (m_ui.perfRB->isChecked())
|
||||
m_settings->metrics.setValue(MetricsType::Perf);
|
||||
|
||||
m_settings->writeSettings(Core::ICore::settings());
|
||||
}
|
||||
|
||||
QtTestSettingsPage::QtTestSettingsPage(QtTestSettings *settings, Utils::Id settingsId)
|
||||
{
|
||||
setId(settingsId);
|
||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
||||
setDisplayName(QCoreApplication::translate("QtTestFramework",
|
||||
QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
|
||||
setWidgetCreator([settings] { return new QtTestSettingsWidget(settings); });
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
@@ -1,42 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
class QtTestSettings;
|
||||
|
||||
class QtTestSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
QtTestSettingsPage(QtTestSettings *settings, Utils::Id settingsId);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
@@ -1,198 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Autotest::Internal::QtTestSettingsPage</class>
|
||||
<widget class="QWidget" name="Autotest::Internal::QtTestSettingsPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>327</width>
|
||||
<height>266</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="disableCrashhandlerCB">
|
||||
<property name="toolTip">
|
||||
<string>Enables interrupting tests on assertions.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Disable crash handler while debugging</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useXMLOutputCB">
|
||||
<property name="toolTip">
|
||||
<string>XML output is recommended, because it avoids parsing issues, while plain text is more human readable.
|
||||
|
||||
Warning: Plain text misses some information, such as duration.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use XML output</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="verboseBenchmarksCB">
|
||||
<property name="text">
|
||||
<string>Verbose benchmarks</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="logSignalsAndSlotsCB">
|
||||
<property name="toolTip">
|
||||
<string>Log every signal emission and resulting slot invocations.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Log signals and slots</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Benchmark Metrics</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="walltimeRB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Uses walltime metrics for executing benchmarks (default).</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Walltime</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="tickcounterRB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Uses tick counter when executing benchmarks.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Tick counter</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="eventCounterRB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Uses event counter when executing benchmarks.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Event counter</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="callgrindRB">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Uses Valgrind Callgrind when executing benchmarks (it must be installed).</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Callgrind</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="perfRB">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Uses Perf when executing benchmarks (it must be installed).</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Perf</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user