2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2020 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2020-04-17 17:04:35 +02:00
|
|
|
|
|
|
|
|
#include "itestframework.h"
|
|
|
|
|
|
2020-10-09 13:07:55 +02:00
|
|
|
#include "autotestconstants.h"
|
|
|
|
|
#include "itestparser.h"
|
|
|
|
|
#include "testtreeitem.h"
|
|
|
|
|
#include "testtreemodel.h"
|
|
|
|
|
|
2020-04-17 17:04:35 +02:00
|
|
|
namespace Autotest {
|
|
|
|
|
|
2020-11-25 08:18:55 +01:00
|
|
|
ITestBase::ITestBase(bool activeByDefault, const ITestBase::TestBaseType type)
|
2020-04-17 17:04:35 +02:00
|
|
|
: m_active(activeByDefault)
|
2020-11-25 08:18:55 +01:00
|
|
|
, m_type(type)
|
2020-04-17 17:04:35 +02:00
|
|
|
{}
|
|
|
|
|
|
2020-10-06 14:02:29 +02:00
|
|
|
Utils::Id ITestBase::settingsId() const
|
2020-04-17 17:04:35 +02:00
|
|
|
{
|
2020-06-26 13:59:38 +02:00
|
|
|
return Utils::Id(Constants::SETTINGSPAGE_PREFIX)
|
2020-04-17 17:04:35 +02:00
|
|
|
.withSuffix(QString("%1.%2").arg(priority()).arg(QLatin1String(name())));
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-06 14:02:29 +02:00
|
|
|
Utils::Id ITestBase::id() const
|
2020-04-17 17:04:35 +02:00
|
|
|
{
|
2020-06-26 13:59:38 +02:00
|
|
|
return Utils::Id(Constants::FRAMEWORK_PREFIX).withSuffix(name());
|
2020-04-17 17:04:35 +02:00
|
|
|
}
|
|
|
|
|
|
2020-10-06 14:02:29 +02:00
|
|
|
void ITestBase::resetRootNode()
|
2020-04-17 17:04:35 +02:00
|
|
|
{
|
|
|
|
|
if (!m_rootNode)
|
|
|
|
|
return;
|
|
|
|
|
if (m_rootNode->model())
|
|
|
|
|
static_cast<TestTreeModel *>(m_rootNode->model())->takeItem(m_rootNode);
|
|
|
|
|
delete m_rootNode;
|
|
|
|
|
m_rootNode = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-06 14:02:29 +02:00
|
|
|
|
|
|
|
|
ITestFramework::ITestFramework(bool activeByDefault)
|
2020-11-25 08:18:55 +01:00
|
|
|
: ITestBase(activeByDefault, ITestBase::Framework)
|
2020-10-06 14:02:29 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
ITestFramework::~ITestFramework()
|
|
|
|
|
{
|
|
|
|
|
delete m_testParser;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-19 13:56:19 +02:00
|
|
|
TestTreeItem *ITestFramework::rootNode()
|
|
|
|
|
{
|
|
|
|
|
if (!m_rootNode)
|
|
|
|
|
m_rootNode = createRootNode();
|
|
|
|
|
// These are stored in the TestTreeModel and destroyed on shutdown there.
|
|
|
|
|
return static_cast<TestTreeItem *>(m_rootNode);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-06 14:02:29 +02:00
|
|
|
ITestParser *ITestFramework::testParser()
|
|
|
|
|
{
|
|
|
|
|
if (!m_testParser)
|
|
|
|
|
m_testParser = createTestParser();
|
|
|
|
|
return m_testParser;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-25 08:18:55 +01:00
|
|
|
ITestTool::ITestTool(bool activeByDefault)
|
|
|
|
|
: ITestBase(activeByDefault, ITestBase::Tool)
|
|
|
|
|
{}
|
|
|
|
|
|
2020-10-19 13:56:19 +02:00
|
|
|
ITestTreeItem *ITestTool::rootNode()
|
|
|
|
|
{
|
|
|
|
|
if (!m_rootNode)
|
|
|
|
|
m_rootNode = createRootNode();
|
|
|
|
|
// These are stored in the TestTreeModel and destroyed on shutdown there.
|
|
|
|
|
return m_rootNode;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-17 17:04:35 +02:00
|
|
|
} // namespace Autotest
|