1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the test suite of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | #include <QPair> |
30 | #include <QtDebug> |
31 | |
32 | #include "TestContainer.h" |
33 | |
34 | using namespace QPatternistSDK; |
35 | |
36 | TestContainer::TestContainer() : m_deleteChildren(true) |
37 | { |
38 | } |
39 | |
40 | TestContainer::~TestContainer() |
41 | { |
42 | if(m_deleteChildren) |
43 | qDeleteAll(c: m_children); |
44 | } |
45 | |
46 | TestResult::List TestContainer::execute(const ExecutionStage stage, |
47 | TestSuite *ts) |
48 | { |
49 | Q_ASSERT(ts); |
50 | const unsigned int c = m_children.count(); |
51 | TestResult::List result; |
52 | |
53 | for(unsigned int i = 0; i != c; ++i) |
54 | result += static_cast<TestItem *>(child(row: i))->execute(stage, ts); |
55 | |
56 | return result; |
57 | } |
58 | |
59 | TestItem::ResultSummary TestContainer::resultSummary() const |
60 | { |
61 | const int c = childCount(); |
62 | int total = 0; |
63 | int pass = 0; |
64 | |
65 | for(int i = 0; i != c; ++i) |
66 | { |
67 | TestItem *t = static_cast<TestItem *>(child(row: i)); |
68 | const ResultSummary sum(t->resultSummary()); |
69 | pass += sum.first; |
70 | total += sum.second; |
71 | } |
72 | |
73 | return ResultSummary(pass, total); |
74 | } |
75 | |
76 | TreeItem::List TestContainer::children() const |
77 | { |
78 | return m_children; |
79 | } |
80 | |
81 | void TestContainer::appendChild(TreeItem *item) |
82 | { |
83 | /* When one of our children changes, we changes. */ |
84 | connect(asender: item, SIGNAL(changed(TreeItem *)), SIGNAL(changed(TreeItem *))); |
85 | m_children.append(t: item); |
86 | } |
87 | |
88 | TreeItem *TestContainer::child(const unsigned int rowP) const |
89 | { |
90 | return m_children.value(i: rowP); |
91 | } |
92 | |
93 | unsigned int TestContainer::childCount() const |
94 | { |
95 | return m_children.count(); |
96 | } |
97 | |
98 | void TestContainer::setTitle(const QString &titleP) |
99 | { |
100 | m_title = titleP; |
101 | } |
102 | |
103 | QString TestContainer::title() const |
104 | { |
105 | return m_title; |
106 | } |
107 | |
108 | bool TestContainer::isFinalNode() const |
109 | { |
110 | return false; |
111 | } |
112 | |
113 | int TestContainer::columnCount() const |
114 | { |
115 | return 4; |
116 | } |
117 | |
118 | QString TestContainer::description() const |
119 | { |
120 | return m_description; |
121 | } |
122 | |
123 | void TestContainer::setDescription(const QString &desc) |
124 | { |
125 | m_description = desc; |
126 | } |
127 | |
128 | void TestContainer::setDeleteChildren(const bool val) |
129 | { |
130 | m_deleteChildren = val; |
131 | } |
132 | |
133 | void TestContainer::removeLast() |
134 | { |
135 | m_children.removeLast(); |
136 | } |
137 | |
138 | // vim: et:ts=4:sw=4:sts=4 |
139 |