1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <QtTest/private/qtestelement_p.h>
5
6QT_BEGIN_NAMESPACE
7
8QTestElement::QTestElement(QTest::LogElementType type)
9 : QTestCoreElement<QTestElement>(type)
10{
11}
12
13QTestElement::~QTestElement()
14{
15 for (auto *child : listOfChildren)
16 delete child;
17}
18
19bool QTestElement::addChild(QTestElement *element)
20{
21 if (!element)
22 return false;
23
24 if (element->elementType() != QTest::LET_Undefined) {
25 listOfChildren.push_back(x: element);
26 element->setParent(this);
27 return true;
28 }
29
30 return false;
31}
32
33const std::vector<QTestElement*> &QTestElement::childElements() const
34{
35 return listOfChildren;
36}
37
38const QTestElement *QTestElement::parentElement() const
39{
40 return parent;
41}
42
43void QTestElement::setParent(const QTestElement *p)
44{
45 parent = p;
46}
47
48QT_END_NAMESPACE
49
50

source code of qtbase/src/testlib/qtestelement.cpp