forked from qt-creator/qt-creator
AutoTest: Simplify settingspage creation for frameworks
Change-Id: Icb262e48a7980748cb0f03e578a49ca26d0c6b29 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -102,7 +102,8 @@ HEADERS += \
|
||||
quick/quicktestvisitors.h \
|
||||
quick/quicktestframework.h \
|
||||
testframeworkmanager.h \
|
||||
testrunconfiguration.h
|
||||
testrunconfiguration.h \
|
||||
itestsettingspage.h
|
||||
|
||||
RESOURCES += \
|
||||
autotest.qrc
|
||||
|
@@ -72,6 +72,7 @@ QtcPlugin {
|
||||
"itestparser.h",
|
||||
"itestframework.h",
|
||||
"iframeworksettings.h",
|
||||
"itestsettingspage.h",
|
||||
"testframeworkmanager.cpp",
|
||||
"testframeworkmanager.h",
|
||||
"testrunconfiguration.h"
|
||||
|
@@ -42,7 +42,7 @@ const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests";
|
||||
const char AUTOTEST_SETTINGS_TR[] = QT_TRANSLATE_NOOP("AutoTest", "Test Settings");
|
||||
const char FRAMEWORK_PREFIX[] = "AutoTest.Framework.";
|
||||
|
||||
|
||||
const char SETTINGSPAGE_PREFIX[] = "A.AutoTest.";
|
||||
const char SETTINGSGROUP[] = "Autotest";
|
||||
} // namespace Constants
|
||||
} // namespace Autotest
|
||||
|
@@ -61,9 +61,9 @@ IFrameworkSettings *GTestFramework::createFrameworkSettings() const
|
||||
return new GTestSettings;
|
||||
}
|
||||
|
||||
Core::IOptionsPage *GTestFramework::createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const
|
||||
ITestSettingsPage *GTestFramework::createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const
|
||||
{
|
||||
return new GTestSettingsPage(settings);
|
||||
return new GTestSettingsPage(settings, this);
|
||||
}
|
||||
|
||||
bool GTestFramework::hasFrameworkSettings() const
|
||||
|
@@ -37,7 +37,7 @@ public:
|
||||
const char *name() const override;
|
||||
unsigned priority() const override;
|
||||
IFrameworkSettings *createFrameworkSettings() const override;
|
||||
Core::IOptionsPage *createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const override;
|
||||
ITestSettingsPage *createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const override;
|
||||
bool hasFrameworkSettings() const override;
|
||||
protected:
|
||||
ITestParser *createTestParser() const override;
|
||||
|
@@ -65,18 +65,14 @@ GTestSettings GTestSettingsWidget::settings() const
|
||||
return result;
|
||||
}
|
||||
|
||||
GTestSettingsPage::GTestSettingsPage(QSharedPointer<IFrameworkSettings> settings)
|
||||
: m_settings(qSharedPointerCast<GTestSettings>(settings)), m_widget(0)
|
||||
GTestSettingsPage::GTestSettingsPage(QSharedPointer<IFrameworkSettings> settings,
|
||||
const ITestFramework *framework)
|
||||
: ITestSettingsPage(framework),
|
||||
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()
|
||||
|
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "ui_gtestsettingspage.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include "../itestsettingspage.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
@@ -50,12 +50,11 @@ private:
|
||||
Ui::GTestSettingsPage m_ui;
|
||||
};
|
||||
|
||||
class GTestSettingsPage : public Core::IOptionsPage
|
||||
class GTestSettingsPage : public ITestSettingsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GTestSettingsPage(QSharedPointer<IFrameworkSettings> settings);
|
||||
~GTestSettingsPage();
|
||||
GTestSettingsPage(QSharedPointer<IFrameworkSettings> settings, const ITestFramework *framework);
|
||||
|
||||
QWidget *widget() override;
|
||||
void apply() override;
|
||||
|
@@ -28,12 +28,11 @@
|
||||
#include "testtreeitem.h"
|
||||
#include "itestparser.h"
|
||||
|
||||
namespace Core { class IOptionsPage; }
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
class IFrameworkSettings;
|
||||
class ITestSettingsPage;
|
||||
|
||||
class ITestFramework
|
||||
{
|
||||
@@ -49,7 +48,7 @@ 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
|
||||
virtual ITestSettingsPage *createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const
|
||||
{
|
||||
Q_UNUSED(settings);
|
||||
return 0;
|
||||
|
70
src/plugins/autotest/itestsettingspage.h
Normal file
70
src/plugins/autotest/itestsettingspage.h
Normal 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 "autotestconstants.h"
|
||||
#include "itestframework.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
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);
|
||||
setDisplayCategory(QCoreApplication::translate("AutoTest",
|
||||
Constants::AUTOTEST_SETTINGS_TR));
|
||||
}
|
||||
|
||||
virtual ~ITestSettingsPage() {}
|
||||
|
||||
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 Internal
|
||||
} // namespace Autotest
|
@@ -51,9 +51,9 @@ IFrameworkSettings *QtTestFramework::createFrameworkSettings() const
|
||||
return new QtTestSettings;
|
||||
}
|
||||
|
||||
Core::IOptionsPage *QtTestFramework::createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const
|
||||
ITestSettingsPage *QtTestFramework::createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const
|
||||
{
|
||||
return new QtTestSettingsPage(settings);
|
||||
return new QtTestSettingsPage(settings, this);
|
||||
}
|
||||
|
||||
bool QtTestFramework::hasFrameworkSettings() const
|
||||
|
@@ -37,7 +37,7 @@ public:
|
||||
const char *name() const override;
|
||||
unsigned priority() const override;
|
||||
IFrameworkSettings *createFrameworkSettings() const override;
|
||||
Core::IOptionsPage *createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const override;
|
||||
ITestSettingsPage *createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const override;
|
||||
bool hasFrameworkSettings() const override;
|
||||
|
||||
protected:
|
||||
|
@@ -86,18 +86,14 @@ QtTestSettings QtTestSettingsWidget::settings() const
|
||||
return result;
|
||||
}
|
||||
|
||||
QtTestSettingsPage::QtTestSettingsPage(QSharedPointer<IFrameworkSettings> settings)
|
||||
: m_settings(qSharedPointerCast<QtTestSettings>(settings)), m_widget(0)
|
||||
QtTestSettingsPage::QtTestSettingsPage(QSharedPointer<IFrameworkSettings> settings,
|
||||
const ITestFramework *framework)
|
||||
: ITestSettingsPage(framework),
|
||||
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()
|
||||
|
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "ui_qttestsettingspage.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include "../itestsettingspage.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
@@ -50,12 +50,11 @@ private:
|
||||
Ui::QtTestSettingsPage m_ui;
|
||||
};
|
||||
|
||||
class QtTestSettingsPage : public Core::IOptionsPage
|
||||
class QtTestSettingsPage : public ITestSettingsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QtTestSettingsPage(QSharedPointer<IFrameworkSettings> settings);
|
||||
~QtTestSettingsPage();
|
||||
QtTestSettingsPage(QSharedPointer<IFrameworkSettings> settings, const ITestFramework *framework);
|
||||
|
||||
QWidget *widget() override;
|
||||
void apply() override;
|
||||
|
@@ -29,12 +29,12 @@
|
||||
#include "iframeworksettings.h"
|
||||
#include "itestframework.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>
|
||||
|
||||
|
Reference in New Issue
Block a user