AutoTest: Separate settings pages

Change-Id: Ib7fedbd5c3bfdc793e1ef203a3ad808c55ac1a70
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2016-10-05 13:34:57 +02:00
parent 18dc7a5de9
commit 4048403ae7
22 changed files with 841 additions and 417 deletions

View File

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

View File

@@ -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.";

View File

@@ -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<IFrameworkSettings> settings) const
{
return new GTestSettingsPage(settings);
}
bool GTestFramework::hasFrameworkSettings() const
{
return true;

View File

@@ -37,8 +37,8 @@ public:
const char *name() const override;
unsigned priority() const override;
IFrameworkSettings *createFrameworkSettings() const override;
Core::IOptionsPage *createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const override;
bool hasFrameworkSettings() const override;
protected:
ITestParser *createTestParser() const override;
TestTreeItem *createRootNode() const override;

View File

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

View File

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

View File

@@ -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 <coreplugin/icore.h>
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<IFrameworkSettings> settings)
: m_settings(qSharedPointerCast<GTestSettings>(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

View File

@@ -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 <coreplugin/dialogs/ioptionspage.h>
#include <QPointer>
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<IFrameworkSettings> settings);
~GTestSettingsPage();
QWidget *widget() override;
void apply() override;
void finish() override { }
private:
QSharedPointer<GTestSettings> m_settings;
QPointer<GTestSettingsWidget> m_widget;
};
} // namespace Internal
} // namespace Autotest

View File

@@ -0,0 +1,219 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Autotest::Internal::GTestSettingsPage</class>
<widget class="QWidget" name="Autotest::Internal::GTestSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>397</width>
<height>205</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="runDisabledGTestsCB">
<property name="toolTip">
<string>Executes disabled tests when performing a test run.</string>
</property>
<property name="text">
<string>Run disabled tests</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="breakOnFailureCB">
<property name="toolTip">
<string>Turn 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>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="repeatGTestsCB">
<property name="toolTip">
<string>Repeats a test run (you might be required to increase the timeout to avoid canceling the tests).</string>
</property>
<property name="text">
<string>Repeat tests</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="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Iterations:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="repetitionSpin">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>9999</number>
</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>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QCheckBox" name="shuffleGTestsCB">
<property name="toolTip">
<string>Shuffle tests automatically on every iteration by the given seed.</string>
</property>
<property name="text">
<string>Shuffle tests</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="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Seed:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="seedSpin">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>A seed of 0 generates a seed based on the current timestamp.</string>
</property>
<property name="specialValueText">
<string/>
</property>
<property name="maximum">
<number>99999</number>
</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>
</layout>
</item>
<item>
<widget class="QCheckBox" name="throwOnFailureCB">
<property name="toolTip">
<string>Turn assertion failures into C++ exceptions.</string>
</property>
<property name="text">
<string>Throw on failure</string>
</property>
</widget>
</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>
</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>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -25,6 +25,8 @@
#pragma once
#include "autotestconstants.h"
#include <QSettings>
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

View File

@@ -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<IFrameworkSettings> settings) const
{
Q_UNUSED(settings);
return 0;
}
TestTreeItem *rootNode()
{ if (!m_rootNode)

View File

@@ -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<IFrameworkSettings> settings) const
{
return new QtTestSettingsPage(settings);
}
bool QtTestFramework::hasFrameworkSettings() const
{
return true;

View File

@@ -37,6 +37,7 @@ public:
const char *name() const override;
unsigned priority() const override;
IFrameworkSettings *createFrameworkSettings() const override;
Core::IOptionsPage *createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const override;
bool hasFrameworkSettings() const override;
protected:

View File

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

View File

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

View File

@@ -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 <coreplugin/icore.h>
#include <utils/hostosinfo.h>
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<IFrameworkSettings> settings)
: m_settings(qSharedPointerCast<QtTestSettings>(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

View File

@@ -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 <coreplugin/dialogs/ioptionspage.h>
#include <QPointer>
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<IFrameworkSettings> settings);
~QtTestSettingsPage();
QWidget *widget() override;
void apply() override;
void finish() override { }
private:
QSharedPointer<QtTestSettings> m_settings;
QPointer<QtTestSettingsWidget> m_widget;
};
} // namespace Internal
} // namespace Autotest

View File

@@ -0,0 +1,169 @@
<?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>Form</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="QGroupBox" name="groupBox">
<property name="title">
<string>Benchmark Metrics</string>
</property>
<property name="flat">
<bool>true</bool>
</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>

View File

@@ -34,10 +34,12 @@
#include "testtreeitem.h"
#include "testtreemodel.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
#include <QLoggingCategory>
#include <QSettings>
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<IFrameworkSettings> frameworkSettings(framework->createFrameworkSettings());
m_frameworkSettings.insert(id, frameworkSettings);
if (auto page = framework->createSettingsPage(frameworkSettings))
plugin->addAutoReleasedObject(page);
}
return true;
}

View File

@@ -25,7 +25,6 @@
#include "testsettings.h"
#include "autotestconstants.h"
#include "iframeworksettings.h"
#include "testframeworkmanager.h"
#include <coreplugin/id.h>
@@ -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<Core::Id> &registered = frameworkManager->registeredFrameworkIds();
for (const Core::Id &id : registered) {
QSharedPointer<IFrameworkSettings> 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<IFrameworkSettings> fSettings = frameworkManager->settingsForTestFramework(id);
if (!fSettings.isNull())
fSettings->fromSettings(s);
}
}
} // namespace Internal

View File

@@ -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 <coreplugin/icore.h>
#include <utils/hostosinfo.h>
#include <utils/utilsicons.h>
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<QtTestSettings>(
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<GTestSettings>(
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<QtTestSettings>(
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<GTestSettings>(
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<TestSettings> &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"));
}

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>655</width>
<height>427</height>
<width>585</width>
<height>324</height>
</rect>
</property>
<property name="windowTitle">
@@ -150,6 +150,23 @@
</layout>
</widget>
</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>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
@@ -186,310 +203,6 @@
</layout>
</widget>
</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>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Qt Test</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<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="QGroupBox" name="groupBox">
<property name="title">
<string>Benchmark Metrics</string>
</property>
<property name="flat">
<bool>true</bool>
</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>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Google Test</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QCheckBox" name="runDisabledGTestsCB">
<property name="toolTip">
<string>Executes disabled tests when performing a test run.</string>
</property>
<property name="text">
<string>Run disabled tests</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="repeatGTestsCB">
<property name="toolTip">
<string>Repeats a test run (you might be required to increase the timeout to avoid canceling the tests).</string>
</property>
<property name="text">
<string>Repeat tests</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Iterations:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="repetitionSpin">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>9999</number>
</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>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="shuffleGTestsCB">
<property name="toolTip">
<string>Shuffle tests automatically on every iteration by the given seed.</string>
</property>
<property name="text">
<string>Shuffle tests</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Seed:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="seedSpin">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>A seed of 0 generates a seed based on the current timestamp.</string>
</property>
<property name="specialValueText">
<string/>
</property>
<property name="maximum">
<number>99999</number>
</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>
</layout>
</item>
<item>
<widget class="QCheckBox" name="throwOnFailureCB">
<property name="toolTip">
<string>Turn assertion failures into C++ exceptions.</string>
</property>
<property name="text">
<string>Throw on failure</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="breakOnFailureCB">
<property name="toolTip">
<string>Turn 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>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">