2016-06-01 16:22:50 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** 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 "testframeworkmanager.h"
|
|
|
|
|
#include "autotestconstants.h"
|
2016-10-05 12:39:23 +02:00
|
|
|
#include "autotestplugin.h"
|
2020-10-06 14:31:31 +02:00
|
|
|
#include "itestsettings.h"
|
2016-06-06 15:35:00 +02:00
|
|
|
#include "testsettings.h"
|
2020-01-10 12:00:37 +01:00
|
|
|
|
2016-06-01 16:22:50 +02:00
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2016-10-05 13:34:57 +02:00
|
|
|
#include <QSettings>
|
2016-06-01 16:22:50 +02:00
|
|
|
|
2019-08-19 14:46:20 +02:00
|
|
|
using namespace Core;
|
2020-06-26 13:59:38 +02:00
|
|
|
using namespace Utils;
|
2019-08-19 14:46:20 +02:00
|
|
|
|
2016-06-01 16:22:50 +02:00
|
|
|
namespace Autotest {
|
|
|
|
|
|
2017-09-27 15:00:11 +02:00
|
|
|
static TestFrameworkManager *s_instance = nullptr;
|
2016-06-01 16:22:50 +02:00
|
|
|
|
|
|
|
|
TestFrameworkManager::TestFrameworkManager()
|
|
|
|
|
{
|
|
|
|
|
s_instance = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TestFrameworkManager::~TestFrameworkManager()
|
|
|
|
|
{
|
2020-03-19 16:59:59 +01:00
|
|
|
qDeleteAll(m_registeredFrameworks);
|
2020-03-26 09:21:25 +01:00
|
|
|
s_instance = nullptr;
|
2016-06-01 16:22:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TestFrameworkManager::registerTestFramework(ITestFramework *framework)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(framework, return false);
|
2020-03-19 16:59:59 +01:00
|
|
|
QTC_ASSERT(!m_registeredFrameworks.contains(framework), return false);
|
2016-06-06 15:35:00 +02:00
|
|
|
// TODO check for unique priority before registering
|
2020-03-19 16:59:59 +01:00
|
|
|
m_registeredFrameworks.append(framework);
|
2020-03-26 12:01:59 +01:00
|
|
|
Utils::sort(m_registeredFrameworks, &ITestFramework::priority);
|
2016-06-01 16:22:50 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-28 12:27:13 +01:00
|
|
|
void TestFrameworkManager::activateFrameworksFromSettings(const Internal::TestSettings *settings)
|
2016-06-06 15:35:00 +02:00
|
|
|
{
|
2020-03-26 12:01:59 +01:00
|
|
|
for (ITestFramework *framework : qAsConst(s_instance->m_registeredFrameworks)) {
|
2020-03-19 16:59:59 +01:00
|
|
|
framework->setActive(settings->frameworks.value(framework->id(), false));
|
|
|
|
|
framework->setGrouping(settings->frameworksGrouping.value(framework->id(), false));
|
2017-12-06 08:45:36 +01:00
|
|
|
}
|
2016-06-06 15:35:00 +02:00
|
|
|
}
|
|
|
|
|
|
2020-03-26 12:01:59 +01:00
|
|
|
TestFrameworks TestFrameworkManager::registeredFrameworks()
|
2016-06-06 15:35:00 +02:00
|
|
|
{
|
2020-03-26 12:01:59 +01:00
|
|
|
return s_instance->m_registeredFrameworks;
|
2016-06-01 16:22:50 +02:00
|
|
|
}
|
|
|
|
|
|
2020-03-13 12:16:26 +01:00
|
|
|
ITestFramework *TestFrameworkManager::frameworkForId(Id frameworkId)
|
|
|
|
|
{
|
2020-03-19 16:59:59 +01:00
|
|
|
return Utils::findOrDefault(s_instance->m_registeredFrameworks,
|
|
|
|
|
[frameworkId](ITestFramework *framework) {
|
|
|
|
|
return framework->id() == frameworkId;
|
|
|
|
|
});
|
2020-03-13 12:16:26 +01:00
|
|
|
}
|
|
|
|
|
|
2016-10-05 12:39:23 +02:00
|
|
|
void TestFrameworkManager::synchronizeSettings(QSettings *s)
|
|
|
|
|
{
|
2019-08-19 10:55:32 +02:00
|
|
|
Internal::AutotestPlugin::settings()->fromSettings(s);
|
2020-03-19 16:59:59 +01:00
|
|
|
for (ITestFramework *framework : qAsConst(m_registeredFrameworks)) {
|
2020-10-06 14:31:31 +02:00
|
|
|
if (ITestSettings *fSettings = framework->testSettings())
|
2016-10-05 12:39:23 +02:00
|
|
|
fSettings->fromSettings(s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-01 16:22:50 +02:00
|
|
|
} // namespace Autotest
|