author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 12 Mar 2010 15:46:37 +0200 | |
branch | RCL_3 |
changeset 5 | d3bac044e0f0 |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include <QXmlAttributes> |
|
43 |
#include <QtDebug> |
|
44 |
||
45 |
#include "qdebug_p.h" |
|
46 |
#include "Global.h" |
|
47 |
#include "XMLWriter.h" |
|
48 |
||
49 |
#include "TestResult.h" |
|
50 |
||
51 |
using namespace QPatternistSDK; |
|
52 |
using namespace QPatternist; |
|
53 |
||
54 |
QString TestResult::displayName(const TestResult::Status stat) |
|
55 |
{ |
|
56 |
switch(stat) |
|
57 |
{ |
|
58 |
case Pass: |
|
59 |
return QLatin1String("pass"); |
|
60 |
case Fail: |
|
61 |
return QLatin1String("fail"); |
|
62 |
case NotTested: |
|
63 |
return QLatin1String("not tested"); |
|
64 |
case Unknown: |
|
65 |
Q_ASSERT(false); |
|
66 |
} |
|
67 |
||
68 |
Q_ASSERT(false); |
|
69 |
return QString(); |
|
70 |
} |
|
71 |
||
72 |
TestResult::Status TestResult::statusFromString(const QString &string) |
|
73 |
{ |
|
74 |
if(string == QLatin1String("pass")) |
|
75 |
return Pass; |
|
76 |
else if(string == QLatin1String("fail")) |
|
77 |
return Fail; |
|
78 |
else if(string == QLatin1String("not tested")) |
|
79 |
return NotTested; |
|
80 |
else |
|
81 |
{ |
|
82 |
Q_ASSERT(false); |
|
83 |
return Fail; |
|
84 |
} |
|
85 |
} |
|
86 |
||
87 |
TestResult::TestResult(const QString &n, |
|
88 |
const Status s, |
|
89 |
ASTItem *tree, |
|
90 |
const ErrorHandler::Message::List &ers, |
|
91 |
const QPatternist::Item::List &itemsP, |
|
92 |
const QString &serialized) : m_status(s), |
|
93 |
m_messages(ers), |
|
94 |
m_astTree(tree), |
|
95 |
m_testName(n), |
|
96 |
m_items(itemsP), |
|
97 |
m_asSerialized(serialized) |
|
98 |
{ |
|
99 |
Q_ASSERT(!n.isEmpty()); |
|
100 |
Q_ASSERT(s != 0); |
|
101 |
} |
|
102 |
||
103 |
TestResult::~TestResult() |
|
104 |
{ |
|
105 |
delete m_astTree; |
|
106 |
} |
|
107 |
||
108 |
void TestResult::toXML(XMLWriter &receiver) const |
|
109 |
{ |
|
110 |
QXmlAttributes atts; |
|
111 |
atts.append(QLatin1String("name"), QString(), QLatin1String("name"), m_testName); |
|
112 |
atts.append(QLatin1String("result"), QString(), QLatin1String("result"), displayName(m_status)); |
|
113 |
||
114 |
if(!m_comment.isEmpty()) |
|
115 |
atts.append(QLatin1String("comment"), QString(), QLatin1String("comment"), m_comment); |
|
116 |
||
117 |
receiver.startElement(QLatin1String("test-case"), atts); |
|
118 |
receiver.endElement(QLatin1String("test-case")); |
|
119 |
} |
|
120 |
||
121 |
void TestResult::setComment(const QString &comm) |
|
122 |
{ |
|
123 |
m_comment = comm; |
|
124 |
} |
|
125 |
||
126 |
TestResult::Status TestResult::status() const |
|
127 |
{ |
|
128 |
return m_status; |
|
129 |
} |
|
130 |
||
131 |
QString TestResult::comment() const |
|
132 |
{ |
|
133 |
return m_comment; |
|
134 |
} |
|
135 |
||
136 |
ASTItem *TestResult::astTree() const |
|
137 |
{ |
|
138 |
return m_astTree; |
|
139 |
} |
|
140 |
||
141 |
ErrorHandler::Message::List TestResult::messages() const |
|
142 |
{ |
|
143 |
return m_messages; |
|
144 |
} |
|
145 |
||
146 |
QPatternist::Item::List TestResult::items() const |
|
147 |
{ |
|
148 |
return m_items; |
|
149 |
} |
|
150 |
||
151 |
QString TestResult::asSerialized() const |
|
152 |
{ |
|
153 |
pDebug() << "asSerialized: " << m_asSerialized; |
|
154 |
return m_asSerialized; |
|
155 |
} |
|
156 |
||
157 |
// vim: et:ts=4:sw=4:sts=4 |
|
158 |