2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2014-12-04 14:05:19 +01:00
|
|
|
|
2020-10-09 13:07:55 +02:00
|
|
|
#include "testsettingspage.h"
|
|
|
|
|
|
2014-12-04 14:05:19 +01:00
|
|
|
#include "autotestconstants.h"
|
2020-10-09 13:07:55 +02:00
|
|
|
#include "autotestplugin.h"
|
2022-07-13 18:31:56 +02:00
|
|
|
#include "autotesttr.h"
|
2016-06-06 15:35:00 +02:00
|
|
|
#include "testframeworkmanager.h"
|
2014-12-04 14:05:19 +01:00
|
|
|
#include "testsettings.h"
|
2016-02-01 15:12:10 +01:00
|
|
|
#include "testtreemodel.h"
|
2014-12-04 14:05:19 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2020-10-09 13:07:55 +02:00
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
#include <utils/id.h>
|
2022-07-13 18:15:55 +02:00
|
|
|
#include <utils/infolabel.h>
|
|
|
|
|
#include <utils/layoutbuilder.h>
|
2017-01-06 07:20:25 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2016-08-03 17:55:54 +02:00
|
|
|
#include <utils/utilsicons.h>
|
2014-12-04 14:05:19 +01:00
|
|
|
|
2022-07-13 18:15:55 +02:00
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QGroupBox>
|
|
|
|
|
#include <QHeaderView>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QSpacerItem>
|
|
|
|
|
#include <QSpinBox>
|
|
|
|
|
#include <QTreeWidget>
|
|
|
|
|
|
2023-01-16 15:00:15 +01:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2023-04-20 09:55:15 +02:00
|
|
|
namespace Autotest::Internal {
|
2014-12-04 14:05:19 +01:00
|
|
|
|
2023-04-20 09:55:15 +02:00
|
|
|
class TestSettingsWidget : public Core::IOptionsPageWidget
|
2022-07-13 18:15:55 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2023-04-20 09:55:15 +02:00
|
|
|
explicit TestSettingsWidget(TestSettings *settings);
|
|
|
|
|
|
|
|
|
|
void apply() final;
|
2022-07-13 18:15:55 +02:00
|
|
|
|
|
|
|
|
TestSettings settings() const;
|
|
|
|
|
|
|
|
|
|
private:
|
2023-01-16 15:00:15 +01:00
|
|
|
void populateFrameworksListWidget(const QHash<Id, bool> &frameworks,
|
|
|
|
|
const QHash<Id, bool> &testTools);
|
2022-07-13 18:15:55 +02:00
|
|
|
void testSettings(TestSettings &settings) const;
|
|
|
|
|
void testToolsSettings(TestSettings &settings) const;
|
|
|
|
|
void onFrameworkItemChanged();
|
|
|
|
|
|
2023-04-20 09:55:15 +02:00
|
|
|
TestSettings *m_settings;
|
2022-07-13 18:15:55 +02:00
|
|
|
QCheckBox *m_omitInternalMsgCB;
|
|
|
|
|
QCheckBox *m_omitRunConfigWarnCB;
|
|
|
|
|
QCheckBox *m_limitResultOutputCB;
|
|
|
|
|
QCheckBox *m_limitResultDescriptionCb;
|
|
|
|
|
QSpinBox *m_limitResultDescriptionSpinBox;
|
|
|
|
|
QCheckBox *m_openResultsOnStartCB;
|
|
|
|
|
QCheckBox *m_openResultsOnFinishCB;
|
|
|
|
|
QCheckBox *m_openResultsOnFailCB;
|
|
|
|
|
QCheckBox *m_autoScrollCB;
|
|
|
|
|
QCheckBox *m_displayAppCB;
|
|
|
|
|
QCheckBox *m_processArgsCB;
|
|
|
|
|
QComboBox *m_runAfterBuildCB;
|
|
|
|
|
QSpinBox *m_timeoutSpin;
|
|
|
|
|
QTreeWidget *m_frameworkTreeWidget;
|
2023-01-16 15:00:15 +01:00
|
|
|
InfoLabel *m_frameworksWarn;
|
2022-07-13 18:15:55 +02:00
|
|
|
};
|
|
|
|
|
|
2023-04-20 09:55:15 +02:00
|
|
|
TestSettingsWidget::TestSettingsWidget(TestSettings *settings)
|
|
|
|
|
: m_settings(settings)
|
2014-12-04 14:05:19 +01:00
|
|
|
{
|
2022-07-13 18:31:56 +02:00
|
|
|
m_omitInternalMsgCB = new QCheckBox(Tr::tr("Omit internal messages"));
|
2022-07-13 18:15:55 +02:00
|
|
|
m_omitInternalMsgCB->setChecked(true);
|
2022-07-13 18:31:56 +02:00
|
|
|
m_omitInternalMsgCB->setToolTip(Tr::tr("Hides internal messages by default. "
|
2022-07-13 18:15:55 +02:00
|
|
|
"You can still enable them by using the test results filter."));
|
|
|
|
|
|
2022-07-13 18:31:56 +02:00
|
|
|
m_omitRunConfigWarnCB = new QCheckBox(Tr::tr("Omit run configuration warnings"));
|
|
|
|
|
m_omitRunConfigWarnCB->setToolTip(Tr::tr("Hides warnings related to a deduced run configuration."));
|
2022-07-13 18:15:55 +02:00
|
|
|
|
2022-07-13 18:31:56 +02:00
|
|
|
m_limitResultOutputCB = new QCheckBox(Tr::tr("Limit result output"));
|
2022-07-13 18:15:55 +02:00
|
|
|
m_limitResultOutputCB->setChecked(true);
|
2022-07-13 18:31:56 +02:00
|
|
|
m_limitResultOutputCB->setToolTip(Tr::tr("Limits result output to 100000 characters."));
|
2022-07-13 18:15:55 +02:00
|
|
|
|
2022-07-13 18:31:56 +02:00
|
|
|
m_limitResultDescriptionCb = new QCheckBox(Tr::tr("Limit result description:"));
|
2022-07-13 18:15:55 +02:00
|
|
|
m_limitResultDescriptionCb->setToolTip(
|
2022-07-13 18:31:56 +02:00
|
|
|
Tr::tr("Limit number of lines shown in test result tooltip and description."));
|
2022-07-13 18:15:55 +02:00
|
|
|
|
|
|
|
|
m_limitResultDescriptionSpinBox = new QSpinBox;
|
|
|
|
|
m_limitResultDescriptionSpinBox->setEnabled(false);
|
|
|
|
|
m_limitResultDescriptionSpinBox->setMinimum(1);
|
|
|
|
|
m_limitResultDescriptionSpinBox->setMaximum(1000000);
|
|
|
|
|
m_limitResultDescriptionSpinBox->setValue(10);
|
|
|
|
|
|
2022-07-13 18:31:56 +02:00
|
|
|
m_openResultsOnStartCB = new QCheckBox(Tr::tr("Open results when tests start"));
|
2022-07-13 18:15:55 +02:00
|
|
|
m_openResultsOnStartCB->setToolTip(
|
2022-07-13 18:31:56 +02:00
|
|
|
Tr::tr("Displays test results automatically when tests are started."));
|
2022-07-13 18:15:55 +02:00
|
|
|
|
2022-07-13 18:31:56 +02:00
|
|
|
m_openResultsOnFinishCB = new QCheckBox(Tr::tr("Open results when tests finish"));
|
2022-07-13 18:15:55 +02:00
|
|
|
m_openResultsOnFinishCB->setChecked(true);
|
|
|
|
|
m_openResultsOnFinishCB->setToolTip(
|
2022-07-13 18:31:56 +02:00
|
|
|
Tr::tr("Displays test results automatically when tests are finished."));
|
2022-07-13 18:15:55 +02:00
|
|
|
|
2022-07-13 18:31:56 +02:00
|
|
|
m_openResultsOnFailCB = new QCheckBox(Tr::tr("Only for unsuccessful test runs"));
|
2022-07-13 18:15:55 +02:00
|
|
|
m_openResultsOnFailCB->setToolTip(
|
2022-07-13 18:31:56 +02:00
|
|
|
Tr::tr("Displays test results only if the test run contains failed, fatal or unexpectedly passed tests."));
|
2022-07-13 18:15:55 +02:00
|
|
|
|
2022-07-13 18:31:56 +02:00
|
|
|
m_autoScrollCB = new QCheckBox(Tr::tr("Automatically scroll results"));
|
2022-07-13 18:15:55 +02:00
|
|
|
m_autoScrollCB->setChecked(true);
|
2022-07-13 18:31:56 +02:00
|
|
|
m_autoScrollCB->setToolTip(Tr::tr("Automatically scrolls down when new items are added and scrollbar is at bottom."));
|
2016-02-23 17:40:10 +01:00
|
|
|
|
2022-07-13 18:31:56 +02:00
|
|
|
m_displayAppCB = new QCheckBox(Tr::tr("Group results by application"));
|
2022-07-13 18:15:55 +02:00
|
|
|
|
2022-07-13 18:31:56 +02:00
|
|
|
m_processArgsCB = new QCheckBox(Tr::tr("Process arguments"));
|
2022-07-13 18:15:55 +02:00
|
|
|
m_processArgsCB->setToolTip(
|
2022-07-13 18:31:56 +02:00
|
|
|
Tr::tr("Allow passing arguments specified on the respective run configuration.\n"
|
2022-07-13 18:15:55 +02:00
|
|
|
"Warning: this is an experimental feature and might lead to failing to execute the test executable."));
|
|
|
|
|
|
|
|
|
|
m_runAfterBuildCB = new QComboBox;
|
2022-07-13 18:31:56 +02:00
|
|
|
m_runAfterBuildCB->setToolTip(Tr::tr("Runs chosen tests automatically if a build succeeded."));
|
|
|
|
|
m_runAfterBuildCB->addItem(Tr::tr("None"));
|
|
|
|
|
m_runAfterBuildCB->addItem(Tr::tr("All"));
|
|
|
|
|
m_runAfterBuildCB->addItem(Tr::tr("Selected"));
|
2022-07-13 18:15:55 +02:00
|
|
|
|
2022-07-13 18:31:56 +02:00
|
|
|
auto timeoutLabel = new QLabel(Tr::tr("Timeout:"));
|
|
|
|
|
timeoutLabel->setToolTip(Tr::tr("Timeout used when executing each test case."));
|
2022-07-13 18:15:55 +02:00
|
|
|
|
|
|
|
|
m_timeoutSpin = new QSpinBox;
|
|
|
|
|
m_timeoutSpin->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
|
m_timeoutSpin->setRange(5, 36000);
|
|
|
|
|
m_timeoutSpin->setValue(60);
|
2022-07-13 18:31:56 +02:00
|
|
|
m_timeoutSpin->setSuffix(Tr::tr(" s"));
|
2022-07-13 18:15:55 +02:00
|
|
|
m_timeoutSpin->setToolTip(
|
2022-07-13 18:31:56 +02:00
|
|
|
Tr::tr("Timeout used when executing test cases. This will apply "
|
|
|
|
|
"for each test case on its own, not the whole project."));
|
2022-07-13 18:15:55 +02:00
|
|
|
|
|
|
|
|
m_frameworkTreeWidget = new QTreeWidget;
|
|
|
|
|
m_frameworkTreeWidget->setRootIsDecorated(false);
|
|
|
|
|
m_frameworkTreeWidget->setHeaderHidden(false);
|
|
|
|
|
m_frameworkTreeWidget->setColumnCount(2);
|
|
|
|
|
m_frameworkTreeWidget->header()->setDefaultSectionSize(150);
|
2022-07-13 18:31:56 +02:00
|
|
|
m_frameworkTreeWidget->setToolTip(Tr::tr("Selects the test frameworks to be handled by the AutoTest plugin."));
|
2022-07-13 18:15:55 +02:00
|
|
|
|
|
|
|
|
QTreeWidgetItem *item = m_frameworkTreeWidget->headerItem();
|
2022-07-13 18:31:56 +02:00
|
|
|
item->setText(0, Tr::tr("Framework"));
|
|
|
|
|
item->setToolTip(0, Tr::tr("Selects the test frameworks to be handled by the AutoTest plugin."));
|
|
|
|
|
item->setText(1, Tr::tr("Group"));
|
|
|
|
|
item->setToolTip(1, Tr::tr("Enables grouping of test cases."));
|
2022-07-13 18:15:55 +02:00
|
|
|
|
2023-01-16 15:00:15 +01:00
|
|
|
m_frameworksWarn = new InfoLabel;
|
2022-07-13 18:15:55 +02:00
|
|
|
m_frameworksWarn->setVisible(false);
|
|
|
|
|
m_frameworksWarn->setElideMode(Qt::ElideNone);
|
2023-01-16 15:00:15 +01:00
|
|
|
m_frameworksWarn->setType(InfoLabel::Warning);
|
2022-07-13 18:15:55 +02:00
|
|
|
|
2023-01-16 15:00:15 +01:00
|
|
|
using namespace Layouting;
|
2022-07-13 18:15:55 +02:00
|
|
|
|
2022-08-01 18:18:02 +02:00
|
|
|
PushButton resetChoicesButton {
|
|
|
|
|
text(Tr::tr("Reset Cached Choices")),
|
|
|
|
|
tooltip(Tr::tr("Clear all cached choices of run configurations for "
|
|
|
|
|
"tests where the executable could not be deduced.")),
|
|
|
|
|
onClicked([] { AutotestPlugin::clearChoiceCache(); }, this)
|
|
|
|
|
};
|
|
|
|
|
|
2022-07-13 18:15:55 +02:00
|
|
|
Group generalGroup {
|
2022-07-13 18:31:56 +02:00
|
|
|
title(Tr::tr("General")),
|
2022-07-13 18:15:55 +02:00
|
|
|
Column {
|
|
|
|
|
m_omitInternalMsgCB,
|
|
|
|
|
m_omitRunConfigWarnCB,
|
|
|
|
|
m_limitResultOutputCB,
|
2022-07-22 18:54:04 +02:00
|
|
|
Row { m_limitResultDescriptionCb, m_limitResultDescriptionSpinBox, st },
|
2022-07-13 18:15:55 +02:00
|
|
|
m_openResultsOnStartCB,
|
|
|
|
|
m_openResultsOnFinishCB,
|
|
|
|
|
Row { Space(20), m_openResultsOnFailCB },
|
|
|
|
|
m_autoScrollCB,
|
|
|
|
|
m_displayAppCB,
|
|
|
|
|
m_processArgsCB,
|
2022-07-13 18:31:56 +02:00
|
|
|
Row { Tr::tr("Automatically run"), m_runAfterBuildCB, st },
|
2022-07-22 18:54:04 +02:00
|
|
|
Row { timeoutLabel, m_timeoutSpin, st },
|
|
|
|
|
Row { resetChoicesButton, st }
|
2022-07-13 18:15:55 +02:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Group activeFrameworks {
|
2022-07-13 18:31:56 +02:00
|
|
|
title(Tr::tr("Active Test Frameworks")),
|
2022-07-13 18:15:55 +02:00
|
|
|
Column {
|
|
|
|
|
m_frameworkTreeWidget,
|
|
|
|
|
m_frameworksWarn,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
Row {
|
2022-07-22 18:54:04 +02:00
|
|
|
Column { generalGroup, st },
|
|
|
|
|
Column { activeFrameworks, st }
|
2022-07-13 18:15:55 +02:00
|
|
|
},
|
2022-07-22 18:54:04 +02:00
|
|
|
st
|
2022-07-13 18:15:55 +02:00
|
|
|
}.attachTo(this);
|
|
|
|
|
|
|
|
|
|
connect(m_frameworkTreeWidget, &QTreeWidget::itemChanged,
|
2016-06-08 12:56:25 +02:00
|
|
|
this, &TestSettingsWidget::onFrameworkItemChanged);
|
2022-07-13 18:15:55 +02:00
|
|
|
connect(m_openResultsOnFinishCB, &QCheckBox::toggled,
|
|
|
|
|
m_openResultsOnFailCB, &QCheckBox::setEnabled);
|
|
|
|
|
connect(m_limitResultDescriptionCb, &QCheckBox::toggled,
|
|
|
|
|
m_limitResultDescriptionSpinBox, &QSpinBox::setEnabled);
|
2014-12-04 14:05:19 +01:00
|
|
|
|
2023-04-20 09:55:15 +02:00
|
|
|
|
|
|
|
|
m_timeoutSpin->setValue(settings->timeout / 1000); // we store milliseconds
|
|
|
|
|
m_omitInternalMsgCB->setChecked(settings->omitInternalMssg);
|
|
|
|
|
m_omitRunConfigWarnCB->setChecked(settings->omitRunConfigWarn);
|
|
|
|
|
m_limitResultOutputCB->setChecked(settings->limitResultOutput);
|
|
|
|
|
m_limitResultDescriptionCb->setChecked(settings->limitResultDescription);
|
|
|
|
|
m_limitResultDescriptionSpinBox->setEnabled(settings->limitResultDescription);
|
|
|
|
|
m_limitResultDescriptionSpinBox->setValue(settings->resultDescriptionMaxSize);
|
|
|
|
|
m_autoScrollCB->setChecked(settings->autoScroll);
|
|
|
|
|
m_processArgsCB->setChecked(settings->processArgs);
|
|
|
|
|
m_displayAppCB->setChecked(settings->displayApplication);
|
|
|
|
|
m_openResultsOnStartCB->setChecked(settings->popupOnStart);
|
|
|
|
|
m_openResultsOnFinishCB->setChecked(settings->popupOnFinish);
|
|
|
|
|
m_openResultsOnFailCB->setChecked(settings->popupOnFail);
|
|
|
|
|
m_runAfterBuildCB->setCurrentIndex(int(settings->runAfterBuild));
|
|
|
|
|
populateFrameworksListWidget(settings->frameworks, settings->tools);
|
2014-12-04 14:05:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TestSettings TestSettingsWidget::settings() const
|
|
|
|
|
{
|
|
|
|
|
TestSettings result;
|
2022-07-13 18:15:55 +02:00
|
|
|
result.timeout = m_timeoutSpin->value() * 1000; // we display seconds
|
|
|
|
|
result.omitInternalMssg = m_omitInternalMsgCB->isChecked();
|
|
|
|
|
result.omitRunConfigWarn = m_omitRunConfigWarnCB->isChecked();
|
|
|
|
|
result.limitResultOutput = m_limitResultOutputCB->isChecked();
|
|
|
|
|
result.limitResultDescription = m_limitResultDescriptionCb->isChecked();
|
|
|
|
|
result.resultDescriptionMaxSize = m_limitResultDescriptionSpinBox->value();
|
|
|
|
|
result.autoScroll = m_autoScrollCB->isChecked();
|
|
|
|
|
result.processArgs = m_processArgsCB->isChecked();
|
|
|
|
|
result.displayApplication = m_displayAppCB->isChecked();
|
|
|
|
|
result.popupOnStart = m_openResultsOnStartCB->isChecked();
|
|
|
|
|
result.popupOnFinish = m_openResultsOnFinishCB->isChecked();
|
|
|
|
|
result.popupOnFail = m_openResultsOnFailCB->isChecked();
|
|
|
|
|
result.runAfterBuild = RunAfterBuildMode(m_runAfterBuildCB->currentIndex());
|
2020-10-06 14:31:31 +02:00
|
|
|
testSettings(result);
|
2020-10-19 14:46:21 +02:00
|
|
|
testToolsSettings(result);
|
2014-12-04 14:05:19 +01:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-19 14:46:21 +02:00
|
|
|
enum TestBaseInfo
|
|
|
|
|
{
|
|
|
|
|
BaseId = Qt::UserRole,
|
|
|
|
|
BaseType
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-16 15:00:15 +01:00
|
|
|
void TestSettingsWidget::populateFrameworksListWidget(const QHash<Id, bool> &frameworks,
|
|
|
|
|
const QHash<Id, bool> &testTools)
|
2016-06-06 15:35:00 +02:00
|
|
|
{
|
2020-03-26 12:01:59 +01:00
|
|
|
const TestFrameworks ®istered = TestFrameworkManager::registeredFrameworks();
|
2022-07-13 18:15:55 +02:00
|
|
|
m_frameworkTreeWidget->clear();
|
2020-03-13 13:54:33 +01:00
|
|
|
for (const ITestFramework *framework : registered) {
|
2023-01-16 15:00:15 +01:00
|
|
|
const Id id = framework->id();
|
2022-07-13 18:15:55 +02:00
|
|
|
auto item = new QTreeWidgetItem(m_frameworkTreeWidget, {framework->displayName()});
|
2016-06-06 15:35:00 +02:00
|
|
|
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
|
2018-01-09 13:15:11 +01:00
|
|
|
item->setCheckState(0, frameworks.value(id) ? Qt::Checked : Qt::Unchecked);
|
2020-10-19 14:46:21 +02:00
|
|
|
item->setData(0, BaseId, id.toSetting());
|
|
|
|
|
item->setData(0, BaseType, ITestBase::Framework);
|
2020-03-13 13:54:33 +01:00
|
|
|
item->setData(1, Qt::CheckStateRole, framework->grouping() ? Qt::Checked : Qt::Unchecked);
|
2022-07-13 18:31:56 +02:00
|
|
|
item->setToolTip(0, Tr::tr("Enable or disable test frameworks to be handled by the "
|
|
|
|
|
"AutoTest plugin."));
|
2020-03-13 13:54:33 +01:00
|
|
|
QString toolTip = framework->groupingToolTip();
|
2018-03-13 10:04:46 +01:00
|
|
|
if (toolTip.isEmpty())
|
2022-07-13 18:31:56 +02:00
|
|
|
toolTip = Tr::tr("Enable or disable grouping of test cases by folder.");
|
2018-03-13 10:04:46 +01:00
|
|
|
item->setToolTip(1, toolTip);
|
2016-06-06 15:35:00 +02:00
|
|
|
}
|
2020-10-19 14:46:21 +02:00
|
|
|
// ...and now the test tools
|
|
|
|
|
const TestTools ®isteredTools = TestFrameworkManager::registeredTestTools();
|
|
|
|
|
for (const ITestTool *testTool : registeredTools) {
|
2023-01-16 15:00:15 +01:00
|
|
|
const Id id = testTool->id();
|
2022-07-13 18:15:55 +02:00
|
|
|
auto item = new QTreeWidgetItem(m_frameworkTreeWidget, {testTool->displayName()});
|
2020-10-19 14:46:21 +02:00
|
|
|
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
|
|
|
|
|
item->setCheckState(0, testTools.value(id) ? Qt::Checked : Qt::Unchecked);
|
|
|
|
|
item->setData(0, BaseId, id.toSetting());
|
|
|
|
|
item->setData(0, BaseType, ITestBase::Tool);
|
|
|
|
|
}
|
2016-06-06 15:35:00 +02:00
|
|
|
}
|
|
|
|
|
|
2020-10-06 14:31:31 +02:00
|
|
|
void TestSettingsWidget::testSettings(TestSettings &settings) const
|
2016-06-06 15:35:00 +02:00
|
|
|
{
|
2022-07-13 18:15:55 +02:00
|
|
|
const QAbstractItemModel *model = m_frameworkTreeWidget->model();
|
2017-12-06 08:45:36 +01:00
|
|
|
QTC_ASSERT(model, return);
|
2020-10-19 14:46:21 +02:00
|
|
|
const int itemCount = TestFrameworkManager::registeredFrameworks().size();
|
|
|
|
|
QTC_ASSERT(itemCount <= model->rowCount(), return);
|
2016-06-06 15:35:00 +02:00
|
|
|
for (int row = 0; row < itemCount; ++row) {
|
2017-12-06 08:45:36 +01:00
|
|
|
QModelIndex idx = model->index(row, 0);
|
2023-01-16 15:00:15 +01:00
|
|
|
const Id id = Id::fromSetting(idx.data(BaseId));
|
2017-12-06 08:45:36 +01:00
|
|
|
settings.frameworks.insert(id, idx.data(Qt::CheckStateRole) == Qt::Checked);
|
|
|
|
|
idx = model->index(row, 1);
|
|
|
|
|
settings.frameworksGrouping.insert(id, idx.data(Qt::CheckStateRole) == Qt::Checked);
|
2016-06-06 15:35:00 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-19 14:46:21 +02:00
|
|
|
void TestSettingsWidget::testToolsSettings(TestSettings &settings) const
|
|
|
|
|
{
|
2022-07-13 18:15:55 +02:00
|
|
|
const QAbstractItemModel *model = m_frameworkTreeWidget->model();
|
2020-10-19 14:46:21 +02:00
|
|
|
QTC_ASSERT(model, return);
|
|
|
|
|
// frameworks are listed before tools
|
|
|
|
|
int row = TestFrameworkManager::registeredFrameworks().size();
|
|
|
|
|
const int end = model->rowCount();
|
|
|
|
|
QTC_ASSERT(row <= end, return);
|
|
|
|
|
for ( ; row < end; ++row) {
|
|
|
|
|
const QModelIndex idx = model->index(row, 0);
|
2023-01-16 15:00:15 +01:00
|
|
|
const Id id = Id::fromSetting(idx.data(BaseId));
|
2020-10-19 14:46:21 +02:00
|
|
|
settings.tools.insert(id, idx.data(Qt::CheckStateRole) == Qt::Checked);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-08 12:56:25 +02:00
|
|
|
void TestSettingsWidget::onFrameworkItemChanged()
|
|
|
|
|
{
|
2020-10-19 14:46:21 +02:00
|
|
|
bool atLeastOneEnabled = false;
|
|
|
|
|
int mixed = ITestBase::None;
|
2022-07-13 18:15:55 +02:00
|
|
|
if (QAbstractItemModel *model = m_frameworkTreeWidget->model()) {
|
2018-01-09 13:15:11 +01:00
|
|
|
for (int row = 0, count = model->rowCount(); row < count; ++row) {
|
2020-10-19 14:46:21 +02:00
|
|
|
const QModelIndex idx = model->index(row, 0);
|
|
|
|
|
if (idx.data(Qt::CheckStateRole) == Qt::Checked) {
|
|
|
|
|
atLeastOneEnabled = true;
|
|
|
|
|
mixed |= idx.data(BaseType).toInt();
|
2018-01-09 13:15:11 +01:00
|
|
|
}
|
2016-06-08 12:56:25 +02:00
|
|
|
}
|
|
|
|
|
}
|
2020-10-19 14:46:21 +02:00
|
|
|
|
|
|
|
|
if (!atLeastOneEnabled || (mixed == (ITestBase::Framework | ITestBase::Tool))) {
|
|
|
|
|
if (!atLeastOneEnabled) {
|
2022-07-13 18:31:56 +02:00
|
|
|
m_frameworksWarn->setText(Tr::tr("No active test frameworks or tools."));
|
|
|
|
|
m_frameworksWarn->setToolTip(Tr::tr("You will not be able to use the AutoTest plugin "
|
|
|
|
|
"without having at least one active test framework."));
|
2020-10-19 14:46:21 +02:00
|
|
|
} else {
|
2022-07-13 18:31:56 +02:00
|
|
|
m_frameworksWarn->setText(Tr::tr("Mixing test frameworks and test tools."));
|
|
|
|
|
m_frameworksWarn->setToolTip(Tr::tr("Mixing test frameworks and test tools can lead "
|
|
|
|
|
"to duplicating run information when using "
|
2021-03-18 11:02:24 +01:00
|
|
|
"\"Run All Tests\", for example."));
|
2020-10-19 14:46:21 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-07-13 18:15:55 +02:00
|
|
|
m_frameworksWarn->setVisible(!atLeastOneEnabled
|
2020-10-19 14:46:21 +02:00
|
|
|
|| (mixed == (ITestBase::Framework | ITestBase::Tool)));
|
2016-06-08 12:56:25 +02:00
|
|
|
}
|
|
|
|
|
|
2023-04-20 09:55:15 +02:00
|
|
|
void TestSettingsWidget::apply()
|
2014-12-04 14:05:19 +01:00
|
|
|
{
|
2023-04-20 09:55:15 +02:00
|
|
|
const TestSettings newSettings = settings();
|
2023-01-16 15:00:15 +01:00
|
|
|
const QList<Id> changedIds = Utils::filtered(newSettings.frameworksGrouping.keys(),
|
|
|
|
|
[newSettings, this](const Id &id) {
|
2017-12-06 08:45:36 +01:00
|
|
|
return newSettings.frameworksGrouping[id] != m_settings->frameworksGrouping[id];
|
|
|
|
|
});
|
2016-09-16 07:46:05 +02:00
|
|
|
*m_settings = newSettings;
|
|
|
|
|
m_settings->toSettings(Core::ICore::settings());
|
2020-03-26 12:01:59 +01:00
|
|
|
|
|
|
|
|
for (ITestFramework *framework : TestFrameworkManager::registeredFrameworks()) {
|
|
|
|
|
framework->setActive(m_settings->frameworks.value(framework->id(), false));
|
|
|
|
|
framework->setGrouping(m_settings->frameworksGrouping.value(framework->id(), false));
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-19 14:46:21 +02:00
|
|
|
for (ITestTool *testTool : TestFrameworkManager::registeredTestTools())
|
|
|
|
|
testTool->setActive(m_settings->tools.value(testTool->id(), false));
|
|
|
|
|
|
2019-09-05 10:42:01 +02:00
|
|
|
TestTreeModel::instance()->synchronizeTestFrameworks();
|
2020-10-19 14:46:21 +02:00
|
|
|
TestTreeModel::instance()->synchronizeTestTools();
|
2019-08-05 15:47:10 +02:00
|
|
|
if (!changedIds.isEmpty())
|
2017-12-06 08:45:36 +01:00
|
|
|
TestTreeModel::instance()->rebuild(changedIds);
|
2014-12-04 14:05:19 +01:00
|
|
|
}
|
|
|
|
|
|
2023-04-20 09:55:15 +02:00
|
|
|
// TestSettingsPage
|
|
|
|
|
|
|
|
|
|
TestSettingsPage::TestSettingsPage(TestSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
setId(Constants::AUTOTEST_SETTINGS_ID);
|
|
|
|
|
setDisplayName(Tr::tr("General"));
|
|
|
|
|
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
|
|
|
|
setDisplayCategory(Tr::tr("Testing"));
|
|
|
|
|
setCategoryIconPath(":/autotest/images/settingscategory_autotest.png");
|
|
|
|
|
setWidgetCreator([settings] { return new TestSettingsWidget(settings); });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // Autotest::Internal
|