AutoTest: Drop ITestSettingsPage intermediate class

Less code in total, and more uniform with other IOptionPage subclasses.

Change-Id: I3d1cb9fae0faf32a360394cc5cf3262a9b59b456
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2020-01-10 12:00:37 +01:00
parent d86fba3ee1
commit 03003872bc
19 changed files with 41 additions and 100 deletions

View File

@@ -35,7 +35,6 @@ add_qtc_plugin(AutoTest
iframeworksettings.h
itestframework.h
itestparser.cpp itestparser.h
itestsettingspage.h
projectsettingswidget.cpp projectsettingswidget.h
qtest/qttest_utils.cpp qtest/qttest_utils.h
qtest/qttestconfiguration.cpp qtest/qttestconfiguration.h

View File

@@ -71,7 +71,6 @@ HEADERS += \
iframeworksettings.h \
itestframework.h \
itestparser.h \
itestsettingspage.h \
projectsettingswidget.h \
testcodeparser.h \
testconfiguration.h \

View File

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

View File

@@ -62,9 +62,9 @@ IFrameworkSettings *BoostTestFramework::createFrameworkSettings() const
return new BoostTestSettings;
}
ITestSettingsPage *BoostTestFramework::createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const
Core::IOptionsPage *BoostTestFramework::createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const
{
return new BoostTestSettingsPage(settings, this);
return new BoostTestSettingsPage(settings, settingsId());
}
bool BoostTestFramework::hasFrameworkSettings() const

View File

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

View File

@@ -103,9 +103,10 @@ void BoostTestSettingsWidget::fillComboBoxes()
}
BoostTestSettingsPage::BoostTestSettingsPage(QSharedPointer<IFrameworkSettings> settings,
const ITestFramework *framework)
: ITestSettingsPage(framework)
Core::Id settingsId)
{
setId(settingsId);
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
setDisplayName(QCoreApplication::translate("BoostTestFramework",
BoostTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
setWidgetCreator([settings] {

View File

@@ -25,7 +25,7 @@
#pragma once
#include "../itestsettingspage.h"
#include <coreplugin/dialogs/ioptionspage.h>
namespace Autotest {
@@ -33,11 +33,10 @@ class IFrameworkSettings;
namespace Internal {
class BoostTestSettingsPage final : public ITestSettingsPage
class BoostTestSettingsPage final : public Core::IOptionsPage
{
public:
BoostTestSettingsPage(QSharedPointer<IFrameworkSettings> settings,
const ITestFramework *framework);
BoostTestSettingsPage(QSharedPointer<IFrameworkSettings> settings, Core::Id settingsId);
};
} // Internal

View File

@@ -61,9 +61,9 @@ IFrameworkSettings *GTestFramework::createFrameworkSettings() const
return new GTestSettings;
}
ITestSettingsPage *GTestFramework::createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const
Core::IOptionsPage *GTestFramework::createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const
{
return new GTestSettingsPage(settings, this);
return new GTestSettingsPage(settings, settingsId());
}
bool GTestFramework::hasFrameworkSettings() const

View File

@@ -38,7 +38,7 @@ public:
const char *name() const override;
unsigned priority() const override;
IFrameworkSettings *createFrameworkSettings() const override;
ITestSettingsPage *createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const override;
Core::IOptionsPage *createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const override;
bool hasFrameworkSettings() const override;
static GTest::Constants::GroupMode groupMode();
static QString currentGTestFilter();

View File

@@ -111,9 +111,10 @@ void GTestSettingsWidget::apply()
}
GTestSettingsPage::GTestSettingsPage(QSharedPointer<IFrameworkSettings> settings,
const ITestFramework *framework)
: ITestSettingsPage(framework)
Core::Id settingsId)
{
setId(settingsId);
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
setDisplayName(QCoreApplication::translate("GTestFramework",
GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
setWidgetCreator([settings] { return new GTestSettingsWidget(qSharedPointerCast<GTestSettings>(settings)); });

View File

@@ -25,7 +25,7 @@
#pragma once
#include "../itestsettingspage.h"
#include <coreplugin/dialogs/ioptionspage.h>
namespace Autotest {
@@ -33,10 +33,10 @@ class IFrameworkSettings;
namespace Internal {
class GTestSettingsPage final : public ITestSettingsPage
class GTestSettingsPage final : public Core::IOptionsPage
{
public:
GTestSettingsPage(QSharedPointer<IFrameworkSettings> settings, const ITestFramework *framework);
GTestSettingsPage(QSharedPointer<IFrameworkSettings> settings, Core::Id settingsId);
};
} // namespace Internal

View File

@@ -28,10 +28,11 @@
#include "testtreeitem.h"
#include "itestparser.h"
namespace Core { class IOptionsPage; }
namespace Autotest {
class IFrameworkSettings;
class ITestSettingsPage;
class ITestFramework
{
@@ -47,7 +48,7 @@ public:
virtual unsigned priority() const = 0; // should this be modifyable?
virtual bool hasFrameworkSettings() const { return false; }
virtual IFrameworkSettings *createFrameworkSettings() const { return nullptr; }
virtual ITestSettingsPage *createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const
virtual Core::IOptionsPage *createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const
{
Q_UNUSED(settings)
return nullptr;
@@ -66,6 +67,8 @@ public:
return m_testParser;
}
Core::Id settingsId() const;
bool active() const { return m_active; }
void setActive(bool active) { m_active = active; }
bool grouping() const { return m_grouping; }

View File

@@ -1,66 +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 "autotestconstants.h"
#include "itestframework.h"
#include <coreplugin/dialogs/ioptionspage.h>
namespace Autotest {
class IFrameworkSettings;
class ITestSettingsPage : public Core::IOptionsPage
{
public:
explicit ITestSettingsPage(const ITestFramework *framework)
{
setId(Core::Id(Constants::SETTINGSPAGE_PREFIX).withSuffix(
QString("%1.%2").arg(framework->priority()).arg(QLatin1String(framework->name()))));
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
}
void finish() override {}
private:
void setId(Core::Id id)
{
Core::IOptionsPage::setId(id);
}
void setCategory(Core::Id category)
{
Core::IOptionsPage::setCategory(category);
}
void setDisplayCategory(const QString &displayCategory)
{
Core::IOptionsPage::setDisplayCategory(displayCategory);
}
};
} // namespace Autotest

View File

@@ -51,9 +51,9 @@ IFrameworkSettings *QtTestFramework::createFrameworkSettings() const
return new QtTestSettings;
}
ITestSettingsPage *QtTestFramework::createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const
Core::IOptionsPage *QtTestFramework::createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const
{
return new QtTestSettingsPage(settings, this);
return new QtTestSettingsPage(settings, settingsId());
}
bool QtTestFramework::hasFrameworkSettings() const

View File

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

View File

@@ -102,9 +102,10 @@ void QtTestSettingsWidget::apply()
}
QtTestSettingsPage::QtTestSettingsPage(QSharedPointer<IFrameworkSettings> settings,
const ITestFramework *framework)
: ITestSettingsPage(framework)
Core::Id settingsId)
{
setId(settingsId);
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
setDisplayName(QCoreApplication::translate("QtTestFramework",
QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
setWidgetCreator([settings] {

View File

@@ -25,7 +25,7 @@
#pragma once
#include "../itestsettingspage.h"
#include <coreplugin/dialogs/ioptionspage.h>
namespace Autotest {
@@ -33,10 +33,10 @@ class IFrameworkSettings;
namespace Internal {
class QtTestSettingsPage final : public ITestSettingsPage
class QtTestSettingsPage final : public Core::IOptionsPage
{
public:
QtTestSettingsPage(QSharedPointer<IFrameworkSettings> settings, const ITestFramework *framework);
QtTestSettingsPage(QSharedPointer<IFrameworkSettings> settings, Core::Id settingsId);
};
} // namespace Internal

View File

@@ -28,12 +28,13 @@
#include "autotestplugin.h"
#include "iframeworksettings.h"
#include "itestparser.h"
#include "itestsettingspage.h"
#include "testrunner.h"
#include "testsettings.h"
#include "testtreeitem.h"
#include "testtreemodel.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
@@ -218,4 +219,10 @@ unsigned TestFrameworkManager::priority(const Id &frameworkId) const
return unsigned(-1);
}
Id ITestFramework::settingsId() const
{
return Core::Id(Constants::SETTINGSPAGE_PREFIX)
.withSuffix(QString("%1.%2").arg(priority()).arg(QLatin1String(name())));
}
} // namespace Autotest

View File

@@ -44,12 +44,10 @@ namespace Internal {
class TestRunner;
struct TestSettings;
}
class IFrameworkSettings;
class ITestParser;
class ITestSettingsPage;
class TestTreeModel;
class TestFrameworkManager
@@ -80,7 +78,7 @@ private:
explicit TestFrameworkManager();
QHash<Core::Id, ITestFramework *> m_registeredFrameworks;
QHash<Core::Id, QSharedPointer<IFrameworkSettings> > m_frameworkSettings;
QVector<ITestSettingsPage *> m_frameworkSettingsPages;
QVector<Core::IOptionsPage *> m_frameworkSettingsPages;
TestTreeModel *m_testTreeModel;
Internal::TestRunner *m_testRunner;