AutoTest: Add a itestframework.cpp

To get a few things out-of-line in itestframework.h.

Change-Id: Iae6f702b789c98b17a4d255008736377030e3b6c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2020-04-17 17:04:35 +02:00
parent 90fd6870c5
commit 6285696091
6 changed files with 87 additions and 36 deletions

View File

@@ -0,0 +1,78 @@
/****************************************************************************
**
** Copyright (C) 2020 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 "itestframework.h"
#include "itestparser.h"
namespace Autotest {
ITestFramework::ITestFramework(bool activeByDefault)
: m_active(activeByDefault)
{}
ITestFramework::~ITestFramework()
{
delete m_testParser;
}
TestTreeItem *ITestFramework::rootNode()
{
if (!m_rootNode)
m_rootNode = createRootNode();
// These are stored in the TestTreeModel and destroyed on shutdown there.
return m_rootNode;
}
ITestParser *ITestFramework::testParser()
{
if (!m_testParser)
m_testParser = createTestParser();
return m_testParser;
}
Core::Id ITestFramework::settingsId() const
{
return Core::Id(Constants::SETTINGSPAGE_PREFIX)
.withSuffix(QString("%1.%2").arg(priority()).arg(QLatin1String(name())));
}
Core::Id ITestFramework::id() const
{
return Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(name());
}
void ITestFramework::resetRootNode()
{
if (!m_rootNode)
return;
if (m_rootNode->model())
static_cast<TestTreeModel *>(m_rootNode->model())->takeItem(m_rootNode);
delete m_rootNode;
m_rootNode = nullptr;
}
} // namespace Autotest