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 <QtDebug>
30
31#include "Global.h"
32
33#include "TestResultHandler.h"
34
35using namespace QPatternistSDK;
36
37TestResultHandler::TestResultHandler()
38{
39 /* Fifteen thousand. When finished, we squeeze them. */
40 m_result.reserve(asize: 15000);
41 m_comments.reserve(asize: 1000); /* Comments are only used for stuff that crash, more or less. */
42}
43
44bool TestResultHandler::startElement(const QStringRef &namespaceURI, const QStringRef &localName,
45 const QStringRef &, const QXmlStreamAttributes &atts)
46{
47 /* We only care about 'test-case', ignore everything else. */
48 if(localName != QLatin1String("test-case") ||
49 namespaceURI != Global::xqtsResultNS)
50 return true;
51
52 /* The 'comments' attribute is optional. */
53 Q_ASSERT_X(atts.count() == 2 || atts.count() == 3, Q_FUNC_INFO,
54 "The input appears to not conform to XQTSResult.xsd");
55
56 Q_ASSERT_X(!m_result.contains(atts.value(QLatin1String("name")).toString()), Q_FUNC_INFO,
57 qPrintable(QString::fromLatin1("A test result for test case %1 has "
58 "already been read(duplicate entry it seems).")
59 .arg(atts.value(QLatin1String("name")))));
60
61 m_result.insert(akey: atts.at(i: 0).value().toString(),
62 avalue: TestResult::statusFromString(string: atts.value(qualifiedName: QLatin1String("result")).toString()));
63
64 return true;
65}
66
67bool TestResultHandler::endDocument()
68{
69 m_result.squeeze();
70 m_comments.squeeze();
71 return true;
72}
73
74TestResultHandler::Hash TestResultHandler::result() const
75{
76 return m_result;
77}
78
79TestResultHandler::CommentHash TestResultHandler::comments() const
80{
81 return m_comments;
82}
83
84// vim: et:ts=4:sw=4:sts=4
85

source code of qtxmlpatterns/tests/auto/xmlpatternssdk/TestResultHandler.cpp