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/quicktestvisitors.h \
|
||||||
quick/quicktestframework.h \
|
quick/quicktestframework.h \
|
||||||
testframeworkmanager.h \
|
testframeworkmanager.h \
|
||||||
testrunconfiguration.h
|
testrunconfiguration.h \
|
||||||
|
itestsettingspage.h
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
autotest.qrc
|
autotest.qrc
|
||||||
|
@@ -72,6 +72,7 @@ QtcPlugin {
|
|||||||
"itestparser.h",
|
"itestparser.h",
|
||||||
"itestframework.h",
|
"itestframework.h",
|
||||||
"iframeworksettings.h",
|
"iframeworksettings.h",
|
||||||
|
"itestsettingspage.h",
|
||||||
"testframeworkmanager.cpp",
|
"testframeworkmanager.cpp",
|
||||||
"testframeworkmanager.h",
|
"testframeworkmanager.h",
|
||||||
"testrunconfiguration.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 AUTOTEST_SETTINGS_TR[] = QT_TRANSLATE_NOOP("AutoTest", "Test Settings");
|
||||||
const char FRAMEWORK_PREFIX[] = "AutoTest.Framework.";
|
const char FRAMEWORK_PREFIX[] = "AutoTest.Framework.";
|
||||||
|
|
||||||
|
const char SETTINGSPAGE_PREFIX[] = "A.AutoTest.";
|
||||||
const char SETTINGSGROUP[] = "Autotest";
|
const char SETTINGSGROUP[] = "Autotest";
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
} // namespace Autotest
|
} // namespace Autotest
|
||||||
|
@@ -61,9 +61,9 @@ IFrameworkSettings *GTestFramework::createFrameworkSettings() const
|
|||||||
return new GTestSettings;
|
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
|
bool GTestFramework::hasFrameworkSettings() const
|
||||||
|
@@ -37,7 +37,7 @@ public:
|
|||||||
const char *name() const override;
|
const char *name() const override;
|
||||||
unsigned priority() const override;
|
unsigned priority() const override;
|
||||||
IFrameworkSettings *createFrameworkSettings() 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;
|
bool hasFrameworkSettings() const override;
|
||||||
protected:
|
protected:
|
||||||
ITestParser *createTestParser() const override;
|
ITestParser *createTestParser() const override;
|
||||||
|
@@ -65,18 +65,14 @@ GTestSettings GTestSettingsWidget::settings() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
GTestSettingsPage::GTestSettingsPage(QSharedPointer<IFrameworkSettings> settings)
|
GTestSettingsPage::GTestSettingsPage(QSharedPointer<IFrameworkSettings> settings,
|
||||||
: m_settings(qSharedPointerCast<GTestSettings>(settings)), m_widget(0)
|
const ITestFramework *framework)
|
||||||
|
: ITestSettingsPage(framework),
|
||||||
|
m_settings(qSharedPointerCast<GTestSettings>(settings)),
|
||||||
|
m_widget(0)
|
||||||
{
|
{
|
||||||
setId("A.AutoTest.10.GTest"); // FIXME
|
|
||||||
setDisplayName(QCoreApplication::translate("GTestFramework",
|
setDisplayName(QCoreApplication::translate("GTestFramework",
|
||||||
GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
|
GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
|
||||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
|
||||||
setDisplayCategory(QCoreApplication::translate("AutoTest", Constants::AUTOTEST_SETTINGS_TR));
|
|
||||||
}
|
|
||||||
|
|
||||||
GTestSettingsPage::~GTestSettingsPage()
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *GTestSettingsPage::widget()
|
QWidget *GTestSettingsPage::widget()
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include "ui_gtestsettingspage.h"
|
#include "ui_gtestsettingspage.h"
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include "../itestsettingspage.h"
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
@@ -50,12 +50,11 @@ private:
|
|||||||
Ui::GTestSettingsPage m_ui;
|
Ui::GTestSettingsPage m_ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GTestSettingsPage : public Core::IOptionsPage
|
class GTestSettingsPage : public ITestSettingsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit GTestSettingsPage(QSharedPointer<IFrameworkSettings> settings);
|
GTestSettingsPage(QSharedPointer<IFrameworkSettings> settings, const ITestFramework *framework);
|
||||||
~GTestSettingsPage();
|
|
||||||
|
|
||||||
QWidget *widget() override;
|
QWidget *widget() override;
|
||||||
void apply() override;
|
void apply() override;
|
||||||
|
@@ -28,12 +28,11 @@
|
|||||||
#include "testtreeitem.h"
|
#include "testtreeitem.h"
|
||||||
#include "itestparser.h"
|
#include "itestparser.h"
|
||||||
|
|
||||||
namespace Core { class IOptionsPage; }
|
|
||||||
|
|
||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class IFrameworkSettings;
|
class IFrameworkSettings;
|
||||||
|
class ITestSettingsPage;
|
||||||
|
|
||||||
class ITestFramework
|
class ITestFramework
|
||||||
{
|
{
|
||||||
@@ -49,7 +48,7 @@ public:
|
|||||||
virtual unsigned priority() const = 0; // should this be modifyable?
|
virtual unsigned priority() const = 0; // should this be modifyable?
|
||||||
virtual bool hasFrameworkSettings() const { return false; }
|
virtual bool hasFrameworkSettings() const { return false; }
|
||||||
virtual IFrameworkSettings *createFrameworkSettings() const { return 0; }
|
virtual IFrameworkSettings *createFrameworkSettings() const { return 0; }
|
||||||
virtual Core::IOptionsPage *createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const
|
virtual ITestSettingsPage *createSettingsPage(QSharedPointer<IFrameworkSettings> settings) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(settings);
|
Q_UNUSED(settings);
|
||||||
return 0;
|
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;
|
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
|
bool QtTestFramework::hasFrameworkSettings() const
|
||||||
|
@@ -37,7 +37,7 @@ public:
|
|||||||
const char *name() const override;
|
const char *name() const override;
|
||||||
unsigned priority() const override;
|
unsigned priority() const override;
|
||||||
IFrameworkSettings *createFrameworkSettings() 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;
|
bool hasFrameworkSettings() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -86,18 +86,14 @@ QtTestSettings QtTestSettingsWidget::settings() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QtTestSettingsPage::QtTestSettingsPage(QSharedPointer<IFrameworkSettings> settings)
|
QtTestSettingsPage::QtTestSettingsPage(QSharedPointer<IFrameworkSettings> settings,
|
||||||
: m_settings(qSharedPointerCast<QtTestSettings>(settings)), m_widget(0)
|
const ITestFramework *framework)
|
||||||
|
: ITestSettingsPage(framework),
|
||||||
|
m_settings(qSharedPointerCast<QtTestSettings>(settings)),
|
||||||
|
m_widget(0)
|
||||||
{
|
{
|
||||||
setId("A.AutoTest.1.QtTest"); // FIXME
|
|
||||||
setDisplayName(QCoreApplication::translate("QtTestFramework",
|
setDisplayName(QCoreApplication::translate("QtTestFramework",
|
||||||
QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
|
QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY));
|
||||||
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
|
||||||
setDisplayCategory(QCoreApplication::translate("AutoTest", Constants::AUTOTEST_SETTINGS_TR));
|
|
||||||
}
|
|
||||||
|
|
||||||
QtTestSettingsPage::~QtTestSettingsPage()
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *QtTestSettingsPage::widget()
|
QWidget *QtTestSettingsPage::widget()
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include "ui_qttestsettingspage.h"
|
#include "ui_qttestsettingspage.h"
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include "../itestsettingspage.h"
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
@@ -50,12 +50,11 @@ private:
|
|||||||
Ui::QtTestSettingsPage m_ui;
|
Ui::QtTestSettingsPage m_ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QtTestSettingsPage : public Core::IOptionsPage
|
class QtTestSettingsPage : public ITestSettingsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit QtTestSettingsPage(QSharedPointer<IFrameworkSettings> settings);
|
QtTestSettingsPage(QSharedPointer<IFrameworkSettings> settings, const ITestFramework *framework);
|
||||||
~QtTestSettingsPage();
|
|
||||||
|
|
||||||
QWidget *widget() override;
|
QWidget *widget() override;
|
||||||
void apply() override;
|
void apply() override;
|
||||||
|
@@ -29,12 +29,12 @@
|
|||||||
#include "iframeworksettings.h"
|
#include "iframeworksettings.h"
|
||||||
#include "itestframework.h"
|
#include "itestframework.h"
|
||||||
#include "itestparser.h"
|
#include "itestparser.h"
|
||||||
|
#include "itestsettingspage.h"
|
||||||
#include "testrunner.h"
|
#include "testrunner.h"
|
||||||
#include "testsettings.h"
|
#include "testsettings.h"
|
||||||
#include "testtreeitem.h"
|
#include "testtreeitem.h"
|
||||||
#include "testtreemodel.h"
|
#include "testtreemodel.h"
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user