1 /* KDevelop xUnit plugin
3 * Copyright 2006 Ernst Huber <qxrunner@systest.ch>
4 * Copyright 2008 Manuel Breugelmans <mbr.nxi@gmail.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #include "veritas/test.h"
23 #include "internal/test_p.h"
27 using Veritas::TestState
;
28 using Veritas::TestResult
;
30 Test
* Test::createRoot()
32 QList
<QVariant
> rootData
;
33 // 4 blank column data to make sure children also get that much columns
34 return new Test(rootData
<< "" << "" << "" << "");
37 Test::Test(const QList
<QVariant
>& data
, Test
* parent
)
41 d
->result
= new TestResult
;
43 // Make sure this item has as many columns as the parent.
44 for (int i
= d
->itemData
.count(); i
< Internal::columnCount
; i
++) {
48 d
->name
= data
.value(0).toString();
53 d
->needVerboseToggle
= false;
54 d
->needSelectionToggle
= false;
57 Test::Test(const QString
& name
, Test
* parent
)
62 d
->result
= new TestResult
;
63 // Make sure this item has as many columns as the parent.
64 for (int i
=0; i
< Internal::columnCount
; i
++) {
65 d
->itemData
<< QString();
68 d
->needVerboseToggle
= false;
69 d
->needSelectionToggle
= false;
72 QString
Test::name() const
80 bool Test::needVerboseToggle() const
82 return d
->needVerboseToggle
;
85 void Test::setVerboseToggle(bool enabled
)
87 d
->needVerboseToggle
= enabled
;
90 bool Test::needSelectionToggle() const
92 return d
->needSelectionToggle
;
95 void Test::setSelectionToggle(bool enabled
)
97 d
->needSelectionToggle
= enabled
;
103 qDeleteAll(d
->children
);
112 bool Test::shouldRun() const
117 Test
* Test::parent() const
119 return qobject_cast
<Test
*>(QObject::parent());
122 Test
* Test::child(int row
) const
124 return d
->children
.value(row
);
127 Test
* Test::childNamed(const QString
& name
) const
129 if (!d
->childMap
.contains(name
))
131 return d
->childMap
[name
];
134 void Test::addChild(Test
* item
)
136 Test
* t
= qobject_cast
<Test
*>(item
);
137 d
->children
.append(t
);
138 d
->childMap
[t
->name()] = t
;
141 int Test::childCount() const
143 return d
->children
.count();
146 int Test::row() const
149 return parent()->d
->children
.indexOf(const_cast<Test
*>(this));
154 TestState
Test::state() const
156 return d
->result
->state();
159 TestResult
* Test::result() const
164 void Test::setResult(TestResult
* res
)
166 if (d
->result
) delete d
->result
;
169 d
->setData(1, res
->message());
170 d
->setData(2, res
->file().pathOrUrl());
171 d
->setData(3, res
->line());
172 d
->result
->setOwner(this);
176 QList
<Test
*> Test::leafs() const
179 foreach(Test
* t
, d
->children
) {
180 if (t
->childCount() == 0) {
189 void Test::signalStarted()
191 emit
started(d
->index());
194 void Test::signalFinished()
196 emit
finished(d
->index());
200 Veritas::Test::Internal
* Test::internal()