2014-12-04 14:05:19 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-12-04 14:05:19 +01:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** This file is part of Qt Creator.
|
2014-12-04 14:05:19 +01:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
2014-12-04 14:05:19 +01:00
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-22 10:37:55 +01:00
|
|
|
** 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.
|
2014-12-04 14:05:19 +01:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** 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.
|
2014-12-04 14:05:19 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "autotestconstants.h"
|
2017-01-06 07:20:25 +01:00
|
|
|
#include "testcodeparser.h"
|
2016-06-06 15:35:00 +02:00
|
|
|
#include "testframeworkmanager.h"
|
2014-12-04 14:05:19 +01:00
|
|
|
#include "testsettingspage.h"
|
|
|
|
|
#include "testsettings.h"
|
2016-02-01 15:12:10 +01:00
|
|
|
#include "testtreemodel.h"
|
2018-08-08 12:40:03 +02:00
|
|
|
#include "autotestplugin.h"
|
2014-12-04 14:05:19 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.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
|
|
|
|
|
|
|
|
namespace Autotest {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
TestSettingsWidget::TestSettingsWidget(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
m_ui.setupUi(this);
|
2016-02-23 17:40:10 +01:00
|
|
|
|
2016-06-08 12:56:25 +02:00
|
|
|
m_ui.frameworksWarnIcon->setVisible(false);
|
2016-08-03 17:55:54 +02:00
|
|
|
m_ui.frameworksWarnIcon->setPixmap(Utils::Icons::WARNING.pixmap());
|
2016-06-08 12:56:25 +02:00
|
|
|
m_ui.frameworksWarn->setVisible(false);
|
|
|
|
|
m_ui.frameworksWarn->setText(tr("No active test frameworks."));
|
|
|
|
|
m_ui.frameworksWarn->setToolTip(tr("You will not be able to use the AutoTest plugin without "
|
|
|
|
|
"having at least one active test framework."));
|
2018-01-09 13:15:11 +01:00
|
|
|
connect(m_ui.frameworkTreeWidget, &QTreeWidget::itemChanged,
|
2016-06-08 12:56:25 +02:00
|
|
|
this, &TestSettingsWidget::onFrameworkItemChanged);
|
2018-08-08 12:40:03 +02:00
|
|
|
connect(m_ui.resetChoicesButton, &QPushButton::clicked,
|
|
|
|
|
this, [] { AutotestPlugin::clearChoiceCache(); });
|
2014-12-04 14:05:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestSettingsWidget::setSettings(const TestSettings &settings)
|
|
|
|
|
{
|
|
|
|
|
m_ui.timeoutSpin->setValue(settings.timeout / 1000); // we store milliseconds
|
|
|
|
|
m_ui.omitInternalMsgCB->setChecked(settings.omitInternalMssg);
|
2015-02-17 10:33:35 +01:00
|
|
|
m_ui.omitRunConfigWarnCB->setChecked(settings.omitRunConfigWarn);
|
2015-04-09 15:51:42 +02:00
|
|
|
m_ui.limitResultOutputCB->setChecked(settings.limitResultOutput);
|
2015-04-16 08:54:41 +02:00
|
|
|
m_ui.autoScrollCB->setChecked(settings.autoScroll);
|
2017-09-01 14:59:39 +02:00
|
|
|
m_ui.processArgsCB->setChecked(settings.processArgs);
|
2019-02-01 12:24:56 +01:00
|
|
|
m_ui.displayAppCB->setChecked(settings.displayApplication);
|
2016-09-13 09:30:59 +02:00
|
|
|
populateFrameworksListWidget(settings.frameworks);
|
2014-12-04 14:05:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TestSettings TestSettingsWidget::settings() const
|
|
|
|
|
{
|
|
|
|
|
TestSettings result;
|
|
|
|
|
result.timeout = m_ui.timeoutSpin->value() * 1000; // we display seconds
|
|
|
|
|
result.omitInternalMssg = m_ui.omitInternalMsgCB->isChecked();
|
2015-02-17 10:33:35 +01:00
|
|
|
result.omitRunConfigWarn = m_ui.omitRunConfigWarnCB->isChecked();
|
2015-04-09 15:51:42 +02:00
|
|
|
result.limitResultOutput = m_ui.limitResultOutputCB->isChecked();
|
2015-04-16 08:54:41 +02:00
|
|
|
result.autoScroll = m_ui.autoScrollCB->isChecked();
|
2017-09-01 14:59:39 +02:00
|
|
|
result.processArgs = m_ui.processArgsCB->isChecked();
|
2019-02-01 12:24:56 +01:00
|
|
|
result.displayApplication = m_ui.displayAppCB->isChecked();
|
2017-12-06 08:45:36 +01:00
|
|
|
frameworkSettings(result);
|
2014-12-04 14:05:19 +01:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-06 15:35:00 +02:00
|
|
|
void TestSettingsWidget::populateFrameworksListWidget(const QHash<Core::Id, bool> &frameworks)
|
|
|
|
|
{
|
|
|
|
|
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
|
|
|
|
|
const QList<Core::Id> ®istered = frameworkManager->sortedRegisteredFrameworkIds();
|
2018-01-09 13:15:11 +01:00
|
|
|
m_ui.frameworkTreeWidget->clear();
|
2016-06-06 15:35:00 +02:00
|
|
|
for (const Core::Id &id : registered) {
|
2018-01-09 13:15:11 +01:00
|
|
|
auto *item = new QTreeWidgetItem(m_ui.frameworkTreeWidget,
|
|
|
|
|
QStringList(frameworkManager->frameworkNameForId(id)));
|
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);
|
|
|
|
|
item->setData(0, Qt::UserRole, id.toSetting());
|
2017-12-06 08:45:36 +01:00
|
|
|
item->setData(1, Qt::CheckStateRole, frameworkManager->groupingEnabled(id) ? Qt::Checked
|
|
|
|
|
: Qt::Unchecked);
|
|
|
|
|
item->setToolTip(0, tr("Enable or disable test frameworks to be handled by the AutoTest "
|
|
|
|
|
"plugin."));
|
2018-03-13 10:04:46 +01:00
|
|
|
QString toolTip = frameworkManager->groupingToolTip(id);
|
|
|
|
|
if (toolTip.isEmpty())
|
|
|
|
|
toolTip = tr("Enable or disable grouping of test cases by folder.");
|
|
|
|
|
item->setToolTip(1, toolTip);
|
2016-06-06 15:35:00 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-06 08:45:36 +01:00
|
|
|
void TestSettingsWidget::frameworkSettings(TestSettings &settings) const
|
2016-06-06 15:35:00 +02:00
|
|
|
{
|
2018-01-09 13:15:11 +01:00
|
|
|
const QAbstractItemModel *model = m_ui.frameworkTreeWidget->model();
|
2017-12-06 08:45:36 +01:00
|
|
|
QTC_ASSERT(model, return);
|
2018-01-09 13:15:11 +01:00
|
|
|
const int itemCount = model->rowCount();
|
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);
|
|
|
|
|
const Core::Id id = Core::Id::fromSetting(idx.data(Qt::UserRole));
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-08 12:56:25 +02:00
|
|
|
void TestSettingsWidget::onFrameworkItemChanged()
|
|
|
|
|
{
|
2018-01-09 13:15:11 +01:00
|
|
|
if (QAbstractItemModel *model = m_ui.frameworkTreeWidget->model()) {
|
|
|
|
|
for (int row = 0, count = model->rowCount(); row < count; ++row) {
|
|
|
|
|
if (model->index(row, 0).data(Qt::CheckStateRole) == Qt::Checked) {
|
|
|
|
|
m_ui.frameworksWarn->setVisible(false);
|
|
|
|
|
m_ui.frameworksWarnIcon->setVisible(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-06-08 12:56:25 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_ui.frameworksWarn->setVisible(true);
|
|
|
|
|
m_ui.frameworksWarnIcon->setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-04 14:05:19 +01:00
|
|
|
TestSettingsPage::TestSettingsPage(const QSharedPointer<TestSettings> &settings)
|
2018-05-31 07:38:04 +02:00
|
|
|
: m_settings(settings)
|
2014-12-04 14:05:19 +01:00
|
|
|
{
|
2016-10-05 13:34:57 +02:00
|
|
|
setId("A.AutoTest.0.General");
|
2014-12-04 14:05:19 +01:00
|
|
|
setDisplayName(tr("General"));
|
|
|
|
|
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
|
2016-10-05 13:34:57 +02:00
|
|
|
setDisplayCategory(QCoreApplication::translate("AutoTest", Constants::AUTOTEST_SETTINGS_TR));
|
2018-04-23 19:06:13 +02:00
|
|
|
setCategoryIcon(Utils::Icon({{":/autotest/images/settingscategory_autotest.png",
|
|
|
|
|
Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint));
|
2014-12-04 14:05:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *TestSettingsPage::widget()
|
|
|
|
|
{
|
|
|
|
|
if (!m_widget) {
|
|
|
|
|
m_widget = new TestSettingsWidget;
|
|
|
|
|
m_widget->setSettings(*m_settings);
|
|
|
|
|
}
|
|
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestSettingsPage::apply()
|
|
|
|
|
{
|
|
|
|
|
if (!m_widget) // page was not shown at all
|
|
|
|
|
return;
|
|
|
|
|
const TestSettings newSettings = m_widget->settings();
|
2016-09-16 07:46:05 +02:00
|
|
|
bool frameworkSyncNecessary = newSettings.frameworks != m_settings->frameworks;
|
2017-12-06 08:45:36 +01:00
|
|
|
const QList<Core::Id> changedIds = Utils::filtered(newSettings.frameworksGrouping.keys(),
|
|
|
|
|
[newSettings, this] (const Core::Id &id) {
|
|
|
|
|
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());
|
2017-12-06 08:45:36 +01:00
|
|
|
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
|
|
|
|
|
frameworkManager->activateFrameworksFromSettings(m_settings);
|
2016-09-16 07:46:05 +02:00
|
|
|
if (frameworkSyncNecessary)
|
|
|
|
|
TestTreeModel::instance()->syncTestFrameworks();
|
2017-12-06 08:45:36 +01:00
|
|
|
else if (!changedIds.isEmpty())
|
|
|
|
|
TestTreeModel::instance()->rebuild(changedIds);
|
2014-12-04 14:05:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Autotest
|