diff --git a/src/plugins/autotest/CMakeLists.txt b/src/plugins/autotest/CMakeLists.txt index fedb6b7fe73..7b1438ab01b 100644 --- a/src/plugins/autotest/CMakeLists.txt +++ b/src/plugins/autotest/CMakeLists.txt @@ -35,7 +35,6 @@ add_qtc_plugin(AutoTest gtest/gtestparser.cpp gtest/gtestparser.h gtest/gtestresult.cpp gtest/gtestresult.h gtest/gtestsettings.cpp gtest/gtestsettings.h - gtest/gtestsettingspage.cpp gtest/gtestsettingspage.h gtest/gtestsettingspage.ui gtest/gtesttreeitem.cpp gtest/gtesttreeitem.h gtest/gtestvisitors.cpp gtest/gtestvisitors.h itemdatacache.h diff --git a/src/plugins/autotest/autotest.pro b/src/plugins/autotest/autotest.pro index bd7535658f1..6bfd57bbe1a 100644 --- a/src/plugins/autotest/autotest.pro +++ b/src/plugins/autotest/autotest.pro @@ -48,7 +48,6 @@ SOURCES += \ gtest/gtestvisitors.cpp \ gtest/gtestframework.cpp \ gtest/gtestsettings.cpp \ - gtest/gtestsettingspage.cpp \ gtest/gtest_utils.cpp \ qtest/qttesttreeitem.cpp \ qtest/qttestvisitors.cpp \ @@ -123,7 +122,6 @@ HEADERS += \ gtest/gtestvisitors.h \ gtest/gtestframework.h \ gtest/gtestsettings.h \ - gtest/gtestsettingspage.h \ gtest/gtestconstants.h \ qtest/qttesttreeitem.h \ qtest/qttest_utils.h \ @@ -155,8 +153,7 @@ RESOURCES += \ autotest.qrc FORMS += \ - testsettingspage.ui \ - gtest/gtestsettingspage.ui + testsettingspage.ui equals(TEST, 1) { HEADERS += autotestunittests.h diff --git a/src/plugins/autotest/gtest/gtestframework.cpp b/src/plugins/autotest/gtest/gtestframework.cpp index 72aed152122..10bad2a2634 100644 --- a/src/plugins/autotest/gtest/gtestframework.cpp +++ b/src/plugins/autotest/gtest/gtestframework.cpp @@ -77,7 +77,7 @@ QString GTestFramework::groupingToolTip() const GTest::Constants::GroupMode GTestFramework::groupMode() { - return GTest::Constants::GroupMode(g_settings->groupMode.value()); + return GTest::Constants::GroupMode(g_settings->groupMode.itemValue().toInt()); } } // namespace Internal diff --git a/src/plugins/autotest/gtest/gtestframework.h b/src/plugins/autotest/gtest/gtestframework.h index 1bdfd682411..c7504d28e36 100644 --- a/src/plugins/autotest/gtest/gtestframework.h +++ b/src/plugins/autotest/gtest/gtestframework.h @@ -28,7 +28,6 @@ #include "../itestframework.h" #include "gtestconstants.h" #include "gtestsettings.h" -#include "gtestsettingspage.h" namespace Autotest { namespace Internal { diff --git a/src/plugins/autotest/gtest/gtestsettings.cpp b/src/plugins/autotest/gtest/gtestsettings.cpp index 13ff8577213..e6eabe35a15 100644 --- a/src/plugins/autotest/gtest/gtestsettings.cpp +++ b/src/plugins/autotest/gtest/gtestsettings.cpp @@ -24,7 +24,16 @@ ****************************************************************************/ #include "gtestsettings.h" + #include "gtest_utils.h" +#include "gtestconstants.h" +#include "../autotestconstants.h" +#include "../testframeworkmanager.h" +#include "../testtreemodel.h" + +#include + +using namespace Utils; namespace Autotest { namespace Internal { @@ -37,38 +46,65 @@ GTestSettings::GTestSettings() registerAspect(&iterations); iterations.setSettingsKey("Iterations"); iterations.setDefaultValue(1); + iterations.setEnabled(false); + iterations.setLabelText(tr("Iterations:")); + iterations.setEnabler(&repeat); registerAspect(&seed); seed.setSettingsKey("Seed"); + seed.setSpecialValueText(QString()); + seed.setEnabled(false); + seed.setLabelText(tr("Seed:")); + seed.setToolTip(tr("A seed of 0 generates a seed based on the current timestamp.")); + seed.setEnabler(&shuffle); registerAspect(&runDisabled); runDisabled.setSettingsKey("RunDisabled"); + runDisabled.setLabelText(tr("Run disabled tests")); + runDisabled.setToolTip(tr("Executes disabled tests when performing a test run.")); registerAspect(&shuffle); shuffle.setSettingsKey("Shuffle"); + shuffle.setLabelText(tr("Shuffle tests")); + shuffle.setToolTip(tr("Shuffles tests automatically on every iteration by the given seed.")); registerAspect(&repeat); repeat.setSettingsKey("Repeat"); + repeat.setLabelText(tr("Repeat tests")); + repeat.setToolTip(tr("Repeats a test run (you might be required to increase the timeout to avoid canceling the tests).")); registerAspect(&throwOnFailure); throwOnFailure.setSettingsKey("ThrowOnFailure"); + throwOnFailure.setLabelText(tr("Throw on failure")); + throwOnFailure.setToolTip(tr("Turns assertion failures into C++ exceptions.")); registerAspect(&breakOnFailure); breakOnFailure.setSettingsKey("BreakOnFailure"); breakOnFailure.setDefaultValue(true); + breakOnFailure.setLabelText(tr("Break on failure while debugging")); + breakOnFailure.setToolTip(tr("Turns failures into debugger breakpoints.")); registerAspect(&groupMode); - groupMode.setDefaultValue(GTest::Constants::Directory); groupMode.setSettingsKey("GroupMode"); - groupMode.setFromSettingsTransformation([](const QVariant &savedValue) -> QVariant { + groupMode.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox); + groupMode.setFromSettingsTransformation([this](const QVariant &savedValue) -> QVariant { // avoid problems if user messes around with the settings file bool ok = false; const int tmp = savedValue.toInt(&ok); - return ok ? static_cast(tmp) : GTest::Constants::Directory; + return ok ? groupMode.indexForItemValue(tmp) : GTest::Constants::Directory; }); + groupMode.setToSettingsTransformation([this](const QVariant &value) { + return groupMode.itemValueForIndex(value.toInt()); + }); + groupMode.addOption({tr("Directory"), {}, GTest::Constants::Directory}); + groupMode.addOption({tr("GTest Filter"), {}, GTest::Constants::GTestFilter}); + groupMode.setDefaultValue(GTest::Constants::Directory); + groupMode.setLabelText(tr("Group mode:")); + groupMode.setToolTip(tr("Select on what grouping the tests should be based.")); registerAspect(>estFilter); gtestFilter.setSettingsKey("GTestFilter"); + gtestFilter.setDisplayStyle(StringAspect::LineEditDisplay); gtestFilter.setDefaultValue(GTest::Constants::DEFAULT_FILTER); gtestFilter.setFromSettingsTransformation([](const QVariant &savedValue) -> QVariant { // avoid problems if user messes around with the settings file @@ -77,6 +113,52 @@ GTestSettings::GTestSettings() return tmp; return GTest::Constants::DEFAULT_FILTER; }); + gtestFilter.setEnabled(false); + gtestFilter.setLabelText(tr("Active filter:")); + gtestFilter.setToolTip(tr("Set the GTest filter to be used for grouping.\n" + "See Google Test documentation for further information on GTest filters.")); + + gtestFilter.setValidationFunction([](FancyLineEdit *edit, QString * /*error*/) { + return edit && GTestUtils::isValidGTestFilter(edit->text()); + }); + + QObject::connect(&groupMode, &SelectionAspect::volatileValueChanged, + >estFilter, [this](int val) { + gtestFilter.setEnabled(groupMode.itemValueForIndex(val) == GTest::Constants::GTestFilter); + }); +} + +GTestSettingsPage::GTestSettingsPage(GTestSettings *settings, Utils::Id settingsId) +{ + setId(settingsId); + setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY); + setDisplayName(QCoreApplication::translate("GTestFramework", + GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY)); + setSettings(settings); + QObject::connect(settings, &AspectContainer::applied, this, [] { + Id id = Id(Constants::FRAMEWORK_PREFIX).withSuffix(GTest::Constants::FRAMEWORK_NAME); + TestTreeModel::instance()->rebuild({id}); + }); + + setLayouter([settings](QWidget *widget) { + GTestSettings &s = *settings; + using namespace Layouting; + const Break nl; + + Grid grid { + s.runDisabled, nl, + s.breakOnFailure, nl, + s.repeat, s.iterations, nl, + s.shuffle, s.seed + }; + + Form form { + s.groupMode, + s.gtestFilter + }; + + Column { Row { Column { grid, form, Stretch() }, Stretch() } }.attachTo(widget); + }); } } // namespace Internal diff --git a/src/plugins/autotest/gtest/gtestsettings.h b/src/plugins/autotest/gtest/gtestsettings.h index d549ddcb1b5..ea9a7621f33 100644 --- a/src/plugins/autotest/gtest/gtestsettings.h +++ b/src/plugins/autotest/gtest/gtestsettings.h @@ -27,6 +27,8 @@ #include "gtestconstants.h" +#include + #include namespace Autotest { @@ -34,6 +36,8 @@ namespace Internal { class GTestSettings : public Utils::AspectContainer { + Q_DECLARE_TR_FUNCTIONS(Autotest::Internal::GTestSettings) + public: GTestSettings(); @@ -48,5 +52,13 @@ public: Utils::StringAspect gtestFilter; }; +class GTestSettingsPage final : public Core::IOptionsPage +{ + Q_DECLARE_TR_FUNCTIONS(Autotest::Internal::GTestSettings) + +public: + GTestSettingsPage(GTestSettings *settings, Utils::Id settingsId); +}; + } // namespace Internal } // namespace Autotest diff --git a/src/plugins/autotest/gtest/gtestsettingspage.cpp b/src/plugins/autotest/gtest/gtestsettingspage.cpp deleted file mode 100644 index 6924b1f59bc..00000000000 --- a/src/plugins/autotest/gtest/gtestsettingspage.cpp +++ /dev/null @@ -1,123 +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. -** -****************************************************************************/ - -#include "gtestconstants.h" -#include "gtestsettingspage.h" -#include "gtestsettings.h" -#include "gtest_utils.h" -#include "../autotestconstants.h" -#include "../testframeworkmanager.h" -#include "../testtreemodel.h" - -#include "ui_gtestsettingspage.h" -#include - -namespace Autotest { -namespace Internal { - -static bool validateFilter(Utils::FancyLineEdit *edit, QString * /*error*/) -{ - return edit && GTestUtils::isValidGTestFilter(edit->text()); -} - -class GTestSettingsWidget final : public Core::IOptionsPageWidget -{ - Q_DECLARE_TR_FUNCTIONS(Autotest::Internal::GTestSettingsWidget) - -public: - explicit GTestSettingsWidget(GTestSettings *settings); - -private: - void apply() final; - - Ui::GTestSettingsPage m_ui; - QString m_currentGTestFilter; - GTestSettings *m_settings; -}; - -GTestSettingsWidget::GTestSettingsWidget(GTestSettings *settings) - : m_settings(settings) -{ - m_ui.setupUi(this); - m_ui.filterLineEdit->setValidationFunction(&validateFilter); - m_ui.filterLineEdit->setEnabled(m_ui.groupModeCombo->currentIndex() == 1); - - connect(m_ui.groupModeCombo, &QComboBox::currentTextChanged, - this, [this] () { - m_ui.filterLineEdit->setEnabled(m_ui.groupModeCombo->currentIndex() == 1); - }); - connect(m_ui.repeatGTestsCB, &QCheckBox::toggled, m_ui.repetitionSpin, &QSpinBox::setEnabled); - connect(m_ui.shuffleGTestsCB, &QCheckBox::toggled, m_ui.seedSpin, &QSpinBox::setEnabled); - - m_ui.runDisabledGTestsCB->setChecked(m_settings->runDisabled.value()); - m_ui.repeatGTestsCB->setChecked(m_settings->repeat.value()); - m_ui.shuffleGTestsCB->setChecked(m_settings->shuffle.value()); - m_ui.repetitionSpin->setValue(m_settings->iterations.value()); - m_ui.seedSpin->setValue(m_settings->seed.value()); - m_ui.breakOnFailureCB->setChecked(m_settings->breakOnFailure.value()); - m_ui.throwOnFailureCB->setChecked(m_settings->throwOnFailure.value()); - m_ui.groupModeCombo->setCurrentIndex(m_settings->groupMode.value() - 1); // there's None for internal use - m_ui.filterLineEdit->setText(m_settings->gtestFilter.value()); - m_currentGTestFilter = m_settings->gtestFilter.value(); // store it temporarily (if edit is invalid) -} - -void GTestSettingsWidget::apply() -{ - GTest::Constants::GroupMode oldGroupMode = GTest::Constants::GroupMode(m_settings->groupMode.value()); - const QString oldFilter = m_settings->gtestFilter.value(); - - m_settings->runDisabled.setValue(m_ui.runDisabledGTestsCB->isChecked()); - m_settings->repeat.setValue(m_ui.repeatGTestsCB->isChecked()); - m_settings->shuffle.setValue(m_ui.shuffleGTestsCB->isChecked()); - m_settings->iterations.setValue(m_ui.repetitionSpin->value()); - m_settings->seed.setValue(m_ui.seedSpin->value()); - m_settings->breakOnFailure.setValue(m_ui.breakOnFailureCB->isChecked()); - m_settings->throwOnFailure.setValue(m_ui.throwOnFailureCB->isChecked()); - m_settings->groupMode.setValue(static_cast( - m_ui.groupModeCombo->currentIndex() + 1)); - if (m_ui.filterLineEdit->isValid()) - m_settings->gtestFilter.setValue(m_ui.filterLineEdit->text()); - else - m_settings->gtestFilter.setValue(m_currentGTestFilter); - - m_settings->writeSettings(Core::ICore::settings()); - if (m_settings->groupMode.value() == oldGroupMode && oldFilter == m_settings->gtestFilter.value()) - return; - - auto id = Utils::Id(Constants::FRAMEWORK_PREFIX).withSuffix(GTest::Constants::FRAMEWORK_NAME); - TestTreeModel::instance()->rebuild({id}); -} - -GTestSettingsPage::GTestSettingsPage(GTestSettings *settings, Utils::Id settingsId) -{ - setId(settingsId); - setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY); - setDisplayName(QCoreApplication::translate("GTestFramework", - GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY)); - setWidgetCreator([settings] { return new GTestSettingsWidget(settings); }); -} - -} // namespace Internal -} // namespace Autotest diff --git a/src/plugins/autotest/gtest/gtestsettingspage.h b/src/plugins/autotest/gtest/gtestsettingspage.h deleted file mode 100644 index acb3b3513c5..00000000000 --- a/src/plugins/autotest/gtest/gtestsettingspage.h +++ /dev/null @@ -1,42 +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 - -namespace Autotest { -namespace Internal { - -class GTestSettings; - -class GTestSettingsPage final : public Core::IOptionsPage -{ -public: - GTestSettingsPage(GTestSettings *settings, Utils::Id settingsId); -}; - -} // namespace Internal -} // namespace Autotest diff --git a/src/plugins/autotest/gtest/gtestsettingspage.ui b/src/plugins/autotest/gtest/gtestsettingspage.ui deleted file mode 100644 index e0a13196df0..00000000000 --- a/src/plugins/autotest/gtest/gtestsettingspage.ui +++ /dev/null @@ -1,229 +0,0 @@ - - - Autotest::Internal::GTestSettingsPage - - - - 0 - 0 - 449 - 232 - - - - - - - - - - - - - - Turns failures into debugger breakpoints. - - - Break on failure while debugging - - - true - - - - - - - Executes disabled tests when performing a test run. - - - Run disabled tests - - - - - - - Turns assertion failures into C++ exceptions. - - - Throw on failure - - - - - - - - 0 - 0 - - - - Iterations: - - - - - - - Shuffles tests automatically on every iteration by the given seed. - - - Shuffle tests - - - - - - - Repeats a test run (you might be required to increase the timeout to avoid canceling the tests). - - - Repeat tests - - - - - - - false - - - 1 - - - 9999 - - - - - - - - 0 - 0 - - - - Seed: - - - - - - - false - - - A seed of 0 generates a seed based on the current timestamp. - - - - - - 99999 - - - - - - - - - - - Group mode: - - - - - - - Active filter: - - - - - - - Select on what grouping the tests should be based. - - - - Directory - - - - - GTest Filter - - - - - - - - Set the GTest filter to be used for grouping. -See Google Test documentation for further information on GTest filters. - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 60 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - Utils::FancyLineEdit - QLineEdit -
utils/fancylineedit.h
-
-
- - -