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 | #ifndef PatternistSDK_TestResultHandler_H |
30 | #define PatternistSDK_TestResultHandler_H |
31 | |
32 | #include <QHash> |
33 | #include <QString> |
34 | |
35 | #include "TestResult.h" |
36 | #include "XmlParseHelper.h" |
37 | |
38 | QT_BEGIN_NAMESPACE |
39 | |
40 | namespace QPatternistSDK |
41 | { |
42 | /** |
43 | * @short Reads XML in the @c XQTSResult.xsd format, and provides access to |
44 | * the reported results. |
45 | * |
46 | * @author Frans Englich <frans.englich@nokia.com> |
47 | * @ingroup PatternistSDK |
48 | */ |
49 | class TestResultHandler : public XmlParseHelper |
50 | { |
51 | public: |
52 | /** |
53 | * A hash where the key is the class's name, that is <tt>test-case/@@name</tt>, |
54 | * and the value the test's result status. |
55 | */ |
56 | typedef QHash<QString, TestResult::Status> Hash; |
57 | |
58 | /** |
59 | * A hash mapping test-case names to their' comments. |
60 | */ |
61 | typedef QHash<QString, QString> CommentHash; |
62 | |
63 | /** |
64 | * Creates a TestResultHandler that will read @p file when run() is called. |
65 | */ |
66 | TestResultHandler(); |
67 | |
68 | /** |
69 | * Performs finalization. |
70 | */ |
71 | bool endDocument() override; |
72 | |
73 | /** |
74 | * Reads the <tt>test-case</tt> element and its attributes, everything else is ignored. |
75 | */ |
76 | bool startElement(const QStringRef &namespaceURI, const QStringRef &localName, |
77 | const QStringRef &qName, const QXmlStreamAttributes &atts) override; |
78 | /** |
79 | * @note Do not reimplement this function. |
80 | * @returns the result obtained from reading the XML file. |
81 | */ |
82 | Hash result() const; |
83 | |
84 | CommentHash comments() const; |
85 | |
86 | private: |
87 | Q_DISABLE_COPY(TestResultHandler) |
88 | Hash m_result; |
89 | CommentHash m_comments; |
90 | }; |
91 | } |
92 | |
93 | QT_END_NAMESPACE |
94 | |
95 | #endif |
96 | // vim: et:ts=4:sw=4:sts=4 |
97 | |