author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
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 <QXmlContentHandler> |
|
43 |
||
44 |
#include "Global.h" |
|
45 |
#include "XMLWriter.h" |
|
46 |
||
47 |
#include "TestSuiteResult.h" |
|
48 |
||
49 |
using namespace QPatternistSDK; |
|
50 |
||
51 |
TestSuiteResult::TestSuiteResult(const QString &testSuiteVersion, |
|
52 |
const QDate &runDate, |
|
53 |
const TestResult::List &results) : m_testSuiteVersion(testSuiteVersion), |
|
54 |
m_runDate(runDate), |
|
55 |
m_results(results) |
|
56 |
{ |
|
57 |
} |
|
58 |
||
59 |
TestSuiteResult::~TestSuiteResult() |
|
60 |
{ |
|
61 |
qDeleteAll(m_results); |
|
62 |
} |
|
63 |
||
64 |
void TestSuiteResult::toXML(XMLWriter &receiver) const |
|
65 |
{ |
|
66 |
/* If this data needs to be configurable in someway(say, another |
|
67 |
* XML format is supported), then break out the info into getters(alternatively, combined |
|
68 |
* with setters, or that the class is subclassed), and access the getters instead. |
|
69 |
*/ |
|
70 |
const QString organizationName (QLatin1String("K Desktop Environment(KDE)")); |
|
71 |
const QString organizationWebsite (QLatin1String("http://www.kde.org/")); |
|
72 |
const QString submittorName (QLatin1String("Frans Englich")); |
|
73 |
const QString submittorEmail (QLatin1String("frans.englich@nokia.com")); |
|
74 |
const QString implementationVersion (QLatin1String("0.1")); |
|
75 |
const QString implementationName (QLatin1String("Patternist")); |
|
76 |
const QString implementationDescription (QLatin1String( |
|
77 |
"Patternist is an implementation written in C++ " |
|
78 |
"and with the Qt/KDE libraries. " |
|
79 |
"It is licensed under GNU LGPL and part of KDE, " |
|
80 |
"the K Desktop Environment.")); |
|
81 |
||
82 |
/* Not currently serialized: |
|
83 |
* - <implementation-defined-items> |
|
84 |
* - <features> |
|
85 |
* - <context-properties> |
|
86 |
*/ |
|
87 |
||
88 |
receiver.startDocument(); |
|
89 |
/* <test-suite-result> */ |
|
90 |
receiver.startPrefixMapping(QString(), Global::xqtsResultNS); |
|
91 |
receiver.startElement(QLatin1String("test-suite-result")); |
|
92 |
receiver.endPrefixMapping(QString()); |
|
93 |
||
94 |
/* <implementation> */ |
|
95 |
QXmlAttributes implementationAtts; |
|
96 |
implementationAtts.append(QLatin1String("name"), QString(), |
|
97 |
QLatin1String("name"), implementationName); |
|
98 |
implementationAtts.append(QLatin1String("version"), QString(), |
|
99 |
QLatin1String("version"), implementationVersion); |
|
100 |
receiver.startElement(QLatin1String("implementation"), implementationAtts); |
|
101 |
||
102 |
/* <organization> */ |
|
103 |
QXmlAttributes organizationAtts; |
|
104 |
organizationAtts.append(QLatin1String("name"), QString(), |
|
105 |
QLatin1String("name"), organizationName); |
|
106 |
organizationAtts.append(QLatin1String("website"), QString(), |
|
107 |
QLatin1String("website"), organizationWebsite); |
|
108 |
receiver.startElement(QLatin1String("organization"), organizationAtts); |
|
109 |
||
110 |
/* </organization> */ |
|
111 |
receiver.endElement(QLatin1String("organization")); |
|
112 |
||
113 |
/* <submittor> */ |
|
114 |
QXmlAttributes submittorAtts; |
|
115 |
submittorAtts.append(QLatin1String("name"), QString(), QLatin1String("name"), submittorName); |
|
116 |
submittorAtts.append(QLatin1String("email"), QString(), QLatin1String("email"), submittorEmail); |
|
117 |
receiver.startElement(QLatin1String("submittor"), submittorAtts); |
|
118 |
||
119 |
/* </submittor> */ |
|
120 |
receiver.endElement(QLatin1String("submittor")); |
|
121 |
||
122 |
/* <description> */ |
|
123 |
receiver.startElement(QLatin1String("description")); |
|
124 |
||
125 |
/* <p> */ |
|
126 |
receiver.startElement(QLatin1String("p")); |
|
127 |
receiver.characters(implementationDescription); |
|
128 |
||
129 |
/* </p> */ |
|
130 |
receiver.endElement(QLatin1String("p")); |
|
131 |
/* </description> */ |
|
132 |
receiver.endElement(QLatin1String("description")); |
|
133 |
||
134 |
/* </implementation> */ |
|
135 |
receiver.endElement(QLatin1String("implementation")); |
|
136 |
||
137 |
/* <syntax> */ |
|
138 |
receiver.startElement(QLatin1String("syntax")); |
|
139 |
receiver.characters(QLatin1String(QLatin1String("XQuery"))); |
|
140 |
||
141 |
/* </syntax> */ |
|
142 |
receiver.endElement(QLatin1String("syntax")); |
|
143 |
||
144 |
/* <test-run> */ |
|
145 |
QXmlAttributes test_runAtts; |
|
146 |
test_runAtts.append(QLatin1String("dateRun"), QString(), QLatin1String("dateRun"), m_runDate.toString(QLatin1String("yyyy-MM-dd"))); |
|
147 |
receiver.startElement(QLatin1String("test-run"), test_runAtts); |
|
148 |
||
149 |
/* <test-suite> */ |
|
150 |
QXmlAttributes test_suiteAtts; |
|
151 |
test_suiteAtts.append(QLatin1String("version"), QString(), QLatin1String("version"), m_testSuiteVersion); |
|
152 |
receiver.startElement(QLatin1String("test-suite"), test_suiteAtts); |
|
153 |
||
154 |
/* </test-suite> */ |
|
155 |
receiver.endElement(QLatin1String("test-suite")); |
|
156 |
||
157 |
/* </test-run> */ |
|
158 |
receiver.endElement(QLatin1String("test-run")); |
|
159 |
||
160 |
/* Serialize the TestResults: tons of test-case elements. */ |
|
161 |
const TestResult::List::const_iterator end(m_results.constEnd()); |
|
162 |
TestResult::List::const_iterator it(m_results.constBegin()); |
|
163 |
||
164 |
for(; it != end; ++it) |
|
165 |
(*it)->toXML(receiver); |
|
166 |
||
167 |
/* </test-suite-result> */ |
|
168 |
receiver.endElement(QLatin1String("test-suite-result")); |
|
169 |
receiver.endDocument(); |
|
170 |
} |
|
171 |
||
172 |
// vim: et:ts=4:sw=4:sts=4 |
|
173 |