From 67682f01a7e06416ac5986f15e5b9a662ee8bf14 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Mon, 11 May 2015 15:06:33 +0200 Subject: Add settings page for Squish tests Change-Id: I665b0d33c6da415578ec8f145926e4a770b64916 Reviewed-by: Christian Stenger --- plugins/autotest/autotest.pro | 5 +++ plugins/autotest/autotest.qbs | 5 +++ plugins/autotest/autotestplugin.cpp | 19 ++++++--- plugins/autotest/autotestplugin.h | 7 ++- plugins/autotest/squishsettings.cpp | 50 ++++++++++++++++++++++ plugins/autotest/squishsettings.h | 45 ++++++++++++++++++++ plugins/autotest/squishsettingspage.cpp | 75 +++++++++++++++++++++++++++++++++ plugins/autotest/squishsettingspage.h | 68 ++++++++++++++++++++++++++++++ plugins/autotest/squishsettingspage.ui | 18 ++++++++ plugins/autotest/testresultdelegate.cpp | 4 +- plugins/autotest/testresultspane.cpp | 2 +- plugins/autotest/testrunner.cpp | 2 +- plugins/autotest/testsettings.cpp | 2 +- plugins/autotest/testsettingspage.cpp | 4 +- plugins/autotest/testsettingspage.h | 1 + 15 files changed, 293 insertions(+), 14 deletions(-) create mode 100644 plugins/autotest/squishsettings.cpp create mode 100644 plugins/autotest/squishsettings.h create mode 100644 plugins/autotest/squishsettingspage.cpp create mode 100644 plugins/autotest/squishsettingspage.h create mode 100644 plugins/autotest/squishsettingspage.ui diff --git a/plugins/autotest/autotest.pro b/plugins/autotest/autotest.pro index 9b9c7a8a01..b60a83f656 100644 --- a/plugins/autotest/autotest.pro +++ b/plugins/autotest/autotest.pro @@ -9,6 +9,8 @@ include(autotest_dependencies.pri) DEFINES += AUTOTEST_LIBRARY SOURCES += \ + squishsettings.cpp \ + squishsettingspage.cpp \ testtreeview.cpp \ testtreemodel.cpp \ testtreeitem.cpp \ @@ -32,6 +34,8 @@ SOURCES += \ testsquishutils.cpp HEADERS += \ + squishsettings.h \ + squishsettingspage.h \ testtreeview.h \ testtreemodel.h \ testtreeitem.h \ @@ -60,6 +64,7 @@ RESOURCES += \ autotest.qrc FORMS += \ + squishsettingspage.ui \ testsettingspage.ui \ opensquishsuitesdialog.ui diff --git a/plugins/autotest/autotest.qbs b/plugins/autotest/autotest.qbs index a9f17682a3..09581cfdee 100644 --- a/plugins/autotest/autotest.qbs +++ b/plugins/autotest/autotest.qbs @@ -31,6 +31,11 @@ QtcPlugin { "autotestconstants.h", "autotestplugin.cpp", "autotestplugin.h", + "squishsettings.cpp", + "squishsettings.h", + "squishsettingspage.cpp", + "squishsettingspage.h", + "squishsettingspage.ui", "testcodeparser.cpp", "testcodeparser.h", "testconfiguration.cpp", diff --git a/plugins/autotest/autotestplugin.cpp b/plugins/autotest/autotestplugin.cpp index a2ab783418..6992166c6b 100644 --- a/plugins/autotest/autotestplugin.cpp +++ b/plugins/autotest/autotestplugin.cpp @@ -19,6 +19,8 @@ #include "autotestplugin.h" #include "autotestconstants.h" +#include "squishsettings.h" +#include "squishsettingspage.h" #include "testcodeparser.h" #include "testrunner.h" #include "testsettings.h" @@ -57,7 +59,7 @@ using namespace Core; static AutotestPlugin *m_instance = 0; AutotestPlugin::AutotestPlugin() - : m_settings(new TestSettings) + : m_qtestSettings(new TestSettings), m_squishSettings(new SquishSettings) { // needed to be used in QueuedConnection connects qRegisterMetaType(); @@ -82,9 +84,14 @@ AutotestPlugin *AutotestPlugin::instance() return m_instance; } -QSharedPointer AutotestPlugin::settings() const +QSharedPointer AutotestPlugin::qtestSettings() const { - return m_settings; + return m_qtestSettings; +} + +QSharedPointer AutotestPlugin::squishSettings() const +{ + return m_squishSettings; } bool AutotestPlugin::checkLicense() @@ -142,8 +149,10 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri initializeMenuEntries(); - m_settings->fromSettings(ICore::settings()); - addAutoReleasedObject(new TestSettingsPage(m_settings)); + m_qtestSettings->fromSettings(ICore::settings()); + m_squishSettings->fromSettings(ICore::settings()); + addAutoReleasedObject(new TestSettingsPage(m_qtestSettings)); + addAutoReleasedObject(new SquishSettingsPage(m_squishSettings)); addAutoReleasedObject(new TestNavigationWidgetFactory); addAutoReleasedObject(TestResultsPane::instance()); diff --git a/plugins/autotest/autotestplugin.h b/plugins/autotest/autotestplugin.h index b7a02d89e7..ad6a2b9a2a 100644 --- a/plugins/autotest/autotestplugin.h +++ b/plugins/autotest/autotestplugin.h @@ -28,6 +28,7 @@ namespace Autotest { namespace Internal { struct TestSettings; +struct SquishSettings; class AutotestPlugin : public ExtensionSystem::IPlugin { @@ -40,7 +41,8 @@ public: static AutotestPlugin *instance(); - QSharedPointer settings() const; + QSharedPointer qtestSettings() const; + QSharedPointer squishSettings() const; bool initialize(const QStringList &arguments, QString *errorString); void extensionsInitialized(); @@ -53,7 +55,8 @@ private: void onRunSelectedTriggered(); void updateMenuItemsEnabledState(); QList createTestObjects() const; - const QSharedPointer m_settings; + const QSharedPointer m_qtestSettings; + const QSharedPointer m_squishSettings; }; } // namespace Internal diff --git a/plugins/autotest/squishsettings.cpp b/plugins/autotest/squishsettings.cpp new file mode 100644 index 0000000000..c66a30d16d --- /dev/null +++ b/plugins/autotest/squishsettings.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd +** All rights reserved. +** For any questions to The Qt Company, please use contact form at +** http://www.qt.io/contact-us +** +** This file is part of the Qt Creator Enterprise Auto Test Add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. +** +** If you have questions regarding the use of this file, please use +** contact form at http://www.qt.io/contact-us +** +****************************************************************************/ + +#include "squishsettings.h" + +#include + +namespace Autotest { +namespace Internal { + +static const char group[] = "Squish"; + +void SquishSettings::toSettings(QSettings *s) const +{ + s->beginGroup(QLatin1String(group)); + s->endGroup(); +} + +void SquishSettings::fromSettings(const QSettings *s) +{ +} + +bool SquishSettings::operator==(const SquishSettings &other) const +{ + return true; +} + +bool SquishSettings::operator!=(const SquishSettings &other) const +{ + return !(*this == other); +} + +} // namespace Internal +} // namespace Autotest diff --git a/plugins/autotest/squishsettings.h b/plugins/autotest/squishsettings.h new file mode 100644 index 0000000000..0764735855 --- /dev/null +++ b/plugins/autotest/squishsettings.h @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd +** All rights reserved. +** For any questions to The Qt Company, please use contact form at +** http://www.qt.io/contact-us +** +** This file is part of the Qt Creator Enterprise Auto Test Add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. +** +** If you have questions regarding the use of this file, please use +** contact form at http://www.qt.io/contact-us +** +****************************************************************************/ + +#ifndef SQUISHSETTINGS_H +#define SQUISHSETTINGS_H + +#include + +QT_BEGIN_NAMESPACE +class QSettings; +QT_END_NAMESPACE + +namespace Autotest { +namespace Internal { + +struct SquishSettings +{ + void toSettings(QSettings *s) const; + void fromSettings(const QSettings *s); + + bool operator==(const SquishSettings &other) const; + bool operator!=(const SquishSettings &other) const; +}; + + +} // namespace Internal +} // namespace Autotest + +#endif // SQUISHSETTINGS_H diff --git a/plugins/autotest/squishsettingspage.cpp b/plugins/autotest/squishsettingspage.cpp new file mode 100644 index 0000000000..9c650c2c01 --- /dev/null +++ b/plugins/autotest/squishsettingspage.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd +** All rights reserved. +** For any questions to The Qt Company, please use contact form at +** http://www.qt.io/contact-us +** +** This file is part of the Qt Creator Enterprise Auto Test Add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. +** +** If you have questions regarding the use of this file, please use +** contact form at http://www.qt.io/contact-us +** +****************************************************************************/ + +#include "autotestconstants.h" +#include "squishsettingspage.h" +#include "squishsettings.h" + +#include +#include + +namespace Autotest { +namespace Internal { + +SquishSettingsWidget::SquishSettingsWidget(QWidget *parent) + : QWidget(parent) +{ + m_ui.setupUi(this); +} + +void SquishSettingsWidget::setSettings(const SquishSettings &settings) +{ +} + +SquishSettings SquishSettingsWidget::settings() const +{ + SquishSettings result; + return result; +} + +SquishSettingsPage::SquishSettingsPage(const QSharedPointer &settings) + : m_settings(settings), m_widget(0) +{ + setId("B.Squish"); + setDisplayName(tr("Squish")); + setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY); +} + +QWidget *SquishSettingsPage::widget() +{ + if (!m_widget) { + m_widget = new SquishSettingsWidget; + m_widget->setSettings(*m_settings); + } + return m_widget; +} + +void SquishSettingsPage::apply() +{ + if (!m_widget) // page was not shown at all + return; + const SquishSettings newSettings = m_widget->settings(); + if (newSettings != *m_settings) { + *m_settings = newSettings; + m_settings->toSettings(Core::ICore::settings()); + } +} + +} // namespace Internal +} // namespace Autotest diff --git a/plugins/autotest/squishsettingspage.h b/plugins/autotest/squishsettingspage.h new file mode 100644 index 0000000000..b15c39ef00 --- /dev/null +++ b/plugins/autotest/squishsettingspage.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd +** All rights reserved. +** For any questions to The Qt Company, please use contact form at +** http://www.qt.io/contact-us +** +** This file is part of the Qt Creator Enterprise Auto Test Add-on. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. +** +** If you have questions regarding the use of this file, please use +** contact form at http://www.qt.io/contact-us +** +****************************************************************************/ + +#ifndef SQUISHSETTINGSPAGE_H +#define SQUISHSETTINGSPAGE_H + +#include "ui_squishsettingspage.h" + +#include + +#include +#include +#include + +namespace Autotest { +namespace Internal { + +struct SquishSettings; + +class SquishSettingsWidget : public QWidget +{ + Q_OBJECT +public: + explicit SquishSettingsWidget(QWidget *parent = 0); + + void setSettings(const SquishSettings &settings); + SquishSettings settings() const; + +private: + Ui::SquishSettingsPage m_ui; + +}; + +class SquishSettingsPage : public Core::IOptionsPage +{ + Q_OBJECT +public: + explicit SquishSettingsPage(const QSharedPointer &settings); + + QWidget *widget(); + void apply(); + void finish() { } + +private: + QSharedPointer m_settings; + QPointer m_widget; +}; + +} // namespace Internal +} // namespace Autotest + +#endif // SQUISHSETTINGSPAGE_H diff --git a/plugins/autotest/squishsettingspage.ui b/plugins/autotest/squishsettingspage.ui new file mode 100644 index 0000000000..626137663a --- /dev/null +++ b/plugins/autotest/squishsettingspage.ui @@ -0,0 +1,18 @@ + + + Autotest::Internal::SquishSettingsPage + + + + 0 + 0 + 463 + 338 + + + + Form + + + + diff --git a/plugins/autotest/testresultdelegate.cpp b/plugins/autotest/testresultdelegate.cpp index c20ce11200..0eedd68eef 100644 --- a/plugins/autotest/testresultdelegate.cpp +++ b/plugins/autotest/testresultdelegate.cpp @@ -131,7 +131,7 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op int fontHeight = fm.height(); output.replace(QLatin1Char('\n'), QChar::LineSeparator); - if (AutotestPlugin::instance()->settings()->limitResultOutput + if (AutotestPlugin::instance()->qtestSettings()->limitResultOutput && output.length() > outputLimit) output = output.left(outputLimit).append(QLatin1String("...")); @@ -237,7 +237,7 @@ QSize TestResultDelegate::sizeHint(const QStyleOptionViewItem &option, const QMo int height = 0; int leading = fm.leading(); - if (AutotestPlugin::instance()->settings()->limitResultOutput + if (AutotestPlugin::instance()->qtestSettings()->limitResultOutput && output.length() > outputLimit) output = output.left(outputLimit).append(QLatin1String("...")); diff --git a/plugins/autotest/testresultspane.cpp b/plugins/autotest/testresultspane.cpp index e53af910da..149d988a19 100644 --- a/plugins/autotest/testresultspane.cpp +++ b/plugins/autotest/testresultspane.cpp @@ -291,7 +291,7 @@ void TestResultsPane::onRunSelectedTriggered() void TestResultsPane::initializeFilterMenu() { - const bool omitIntern = AutotestPlugin::instance()->settings()->omitInternalMssg; + const bool omitIntern = AutotestPlugin::instance()->qtestSettings()->omitInternalMssg; // FilterModel has all messages enabled by default if (omitIntern) m_filterModel->toggleTestResultType(Result::MESSAGE_INTERNAL); diff --git a/plugins/autotest/testrunner.cpp b/plugins/autotest/testrunner.cpp index 07f90a56ad..368897a929 100644 --- a/plugins/autotest/testrunner.cpp +++ b/plugins/autotest/testrunner.cpp @@ -186,7 +186,7 @@ void performTestRun(QFutureInterface &futureInterface, void TestRunner::runTests() { - const QSharedPointer settings = AutotestPlugin::instance()->settings(); + const QSharedPointer settings = AutotestPlugin::instance()->qtestSettings(); const int timeout = settings->timeout; const QString metricsOption = TestSettings::metricsTypeToOption(settings->metrics); const bool displayRunConfigWarnings = !settings->omitRunConfigWarn; diff --git a/plugins/autotest/testsettings.cpp b/plugins/autotest/testsettings.cpp index 3a11b8c66b..276c2c9a79 100644 --- a/plugins/autotest/testsettings.cpp +++ b/plugins/autotest/testsettings.cpp @@ -24,7 +24,7 @@ namespace Autotest { namespace Internal { -static const char group[] = "Autotest"; +static const char group[] = "QTest"; static const char timeoutKey[] = "Timeout"; static const char metricsKey[] = "Metrics"; static const char omitInternalKey[] = "OmitInternal"; diff --git a/plugins/autotest/testsettingspage.cpp b/plugins/autotest/testsettingspage.cpp index e65bff754a..a0b218cb27 100644 --- a/plugins/autotest/testsettingspage.cpp +++ b/plugins/autotest/testsettingspage.cpp @@ -89,8 +89,8 @@ TestSettings TestSettingsWidget::settings() const TestSettingsPage::TestSettingsPage(const QSharedPointer &settings) : m_settings(settings), m_widget(0) { - setId("A.General"); - setDisplayName(tr("General")); + setId("A.QTest"); + setDisplayName(tr("QTest")); setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY); setDisplayCategory(tr("Test Settings")); setCategoryIcon(QLatin1String(":/images/autotest.png")); diff --git a/plugins/autotest/testsettingspage.h b/plugins/autotest/testsettingspage.h index 3e98c8413d..61a8ea678a 100644 --- a/plugins/autotest/testsettingspage.h +++ b/plugins/autotest/testsettingspage.h @@ -25,6 +25,7 @@ #include #include +#include namespace Autotest { namespace Internal { -- cgit v1.2.1