1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
7 ** This file is part of the test suite of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include <QXmlContentHandler>
45 #include "XMLWriter.h"
47 #include "TestSuiteResult.h"
49 using namespace QPatternistSDK;
51 TestSuiteResult::TestSuiteResult(const QString &testSuiteVersion,
53 const TestResult::List &results) : m_testSuiteVersion(testSuiteVersion),
59 TestSuiteResult::~TestSuiteResult()
61 qDeleteAll(m_results);
64 void TestSuiteResult::toXML(XMLWriter &receiver) const
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.
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."));
82 /* Not currently serialized:
83 * - <implementation-defined-items>
85 * - <context-properties>
88 receiver.startDocument();
89 /* <test-suite-result> */
90 receiver.startPrefixMapping(QString(), Global::xqtsResultNS);
91 receiver.startElement(QLatin1String("test-suite-result"));
92 receiver.endPrefixMapping(QString());
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);
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);
110 /* </organization> */
111 receiver.endElement(QLatin1String("organization"));
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);
120 receiver.endElement(QLatin1String("submittor"));
123 receiver.startElement(QLatin1String("description"));
126 receiver.startElement(QLatin1String("p"));
127 receiver.characters(implementationDescription);
130 receiver.endElement(QLatin1String("p"));
132 receiver.endElement(QLatin1String("description"));
134 /* </implementation> */
135 receiver.endElement(QLatin1String("implementation"));
138 receiver.startElement(QLatin1String("syntax"));
139 receiver.characters(QLatin1String(QLatin1String("XQuery")));
142 receiver.endElement(QLatin1String("syntax"));
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);
150 QXmlAttributes test_suiteAtts;
151 test_suiteAtts.append(QLatin1String("version"), QString(), QLatin1String("version"), m_testSuiteVersion);
152 receiver.startElement(QLatin1String("test-suite"), test_suiteAtts);
155 receiver.endElement(QLatin1String("test-suite"));
158 receiver.endElement(QLatin1String("test-run"));
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());
164 for(; it != end; ++it)
165 (*it)->toXML(receiver);
167 /* </test-suite-result> */
168 receiver.endElement(QLatin1String("test-suite-result"));
169 receiver.endDocument();
172 // vim: et:ts=4:sw=4:sts=4