AutoTest: Generalize framework specific settings

Change-Id: Ie8a1db6408d2ceac7331d29ef25d193a15186a4c
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2016-09-13 13:38:19 +02:00
parent 7f89df16a2
commit b5875e84cb
8 changed files with 71 additions and 12 deletions

View File

@@ -70,6 +70,7 @@ HEADERS += \
testoutputreader.h \ testoutputreader.h \
autotesticons.h \ autotesticons.h \
itestframework.h \ itestframework.h \
iframeworksettings.h \
itestparser.h \ itestparser.h \
gtest/gtestconfiguration.h \ gtest/gtestconfiguration.h \
gtest/gtestparser.h \ gtest/gtestparser.h \

View File

@@ -71,6 +71,7 @@ QtcPlugin {
"itestparser.cpp", "itestparser.cpp",
"itestparser.h", "itestparser.h",
"itestframework.h", "itestframework.h",
"iframeworksettings",
"testframeworkmanager.cpp", "testframeworkmanager.cpp",
"testframeworkmanager.h", "testframeworkmanager.h",
"testrunconfiguration.h" "testrunconfiguration.h"

View File

@@ -36,6 +36,11 @@ static const char seedKey[] = "Seed";
static const char shuffleKey[] = "Shuffle"; static const char shuffleKey[] = "Shuffle";
static const char throwOnFailureKey[] = "ThrowOnFailure"; static const char throwOnFailureKey[] = "ThrowOnFailure";
QString GTestSettings::name() const
{
return QString("GTest");
}
void GTestSettings::fromSettings(const QSettings *s) void GTestSettings::fromSettings(const QSettings *s)
{ {
runDisabled = s->value(QLatin1String(runDisabledKey), false).toBool(); runDisabled = s->value(QLatin1String(runDisabledKey), false).toBool();

View File

@@ -25,17 +25,18 @@
#pragma once #pragma once
#include <QSettings> #include "../iframeworksettings.h"
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
class GTestSettings class GTestSettings : public IFrameworkSettings
{ {
public: public:
GTestSettings() {} GTestSettings() {}
void fromSettings(const QSettings *s); QString name() const override;
void toSettings(QSettings *s) const; void fromSettings(const QSettings *s) override;
void toSettings(QSettings *s) const override;
int iterations = 1; int iterations = 1;
int seed = 0; int seed = 0;

View File

@@ -0,0 +1,45 @@
/****************************************************************************
**
** 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 <QSettings>
namespace Autotest {
namespace Internal {
class IFrameworkSettings
{
public:
IFrameworkSettings() {}
virtual ~IFrameworkSettings() {}
virtual QString name() const = 0;
virtual void toSettings(QSettings *s) const = 0;
virtual void fromSettings(const QSettings *s) = 0;
};
} // namespace Internal
} // namespace Autotest

View File

@@ -49,6 +49,11 @@ static MetricsType intToMetrics(int value)
} }
} }
QString QtTestSettings::name() const
{
return QString("QtTest");
}
void QtTestSettings::fromSettings(const QSettings *s) void QtTestSettings::fromSettings(const QSettings *s)
{ {
metrics = intToMetrics(s->value(QLatin1String(metricsKey), Walltime).toInt()); metrics = intToMetrics(s->value(QLatin1String(metricsKey), Walltime).toInt());

View File

@@ -25,7 +25,7 @@
#pragma once #pragma once
#include <QSettings> #include "../iframeworksettings.h"
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
@@ -39,12 +39,13 @@ enum MetricsType
Perf Perf
}; };
class QtTestSettings class QtTestSettings : public IFrameworkSettings
{ {
public: public:
QtTestSettings() {} QtTestSettings() {}
void fromSettings(const QSettings *s); QString name() const override;
void toSettings(QSettings *s) const; void fromSettings(const QSettings *s) override;
void toSettings(QSettings *s) const override;
static QString metricsTypeToOption(const MetricsType type); static QString metricsTypeToOption(const MetricsType type);
MetricsType metrics = Walltime; MetricsType metrics = Walltime;

View File

@@ -61,10 +61,10 @@ void TestSettings::toSettings(QSettings *s) const
for (const Core::Id &id : frameworks.keys()) for (const Core::Id &id : frameworks.keys())
s->setValue(QLatin1String(id.name()), frameworks.value(id)); s->setValue(QLatin1String(id.name()), frameworks.value(id));
s->beginGroup("QtTest"); s->beginGroup(qtTestSettings.name());
qtTestSettings.toSettings(s); qtTestSettings.toSettings(s);
s->endGroup(); s->endGroup();
s->beginGroup("GTest"); s->beginGroup(gTestSettings.name());
gTestSettings.toSettings(s); gTestSettings.toSettings(s);
s->endGroup(); s->endGroup();
@@ -89,10 +89,10 @@ void TestSettings::fromSettings(QSettings *s)
frameworkManager->isActive(id)).toBool()); frameworkManager->isActive(id)).toBool());
} }
s->beginGroup("QtTest"); s->beginGroup(qtTestSettings.name());
qtTestSettings.fromSettings(s); qtTestSettings.fromSettings(s);
s->endGroup(); s->endGroup();
s->beginGroup("GTest"); s->beginGroup(gTestSettings.name());
gTestSettings.fromSettings(s); gTestSettings.fromSettings(s);
s->endGroup(); s->endGroup();