blob: 3068baaee5853ab57c019026b4179c4b50fb2e76 [file] [log] [blame]
Jarkko Poyry3c827362014-09-02 11:48:52 +03001#ifndef _XETESTRESULTPARSER_HPP
2#define _XETESTRESULTPARSER_HPP
3/*-------------------------------------------------------------------------
4 * drawElements Quality Program Test Executor
5 * ------------------------------------------
6 *
7 * Copyright 2014 The Android Open Source Project
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *
21 *//*!
22 * \file
23 * \brief Test case result parser.
24 *//*--------------------------------------------------------------------*/
25
26#include "xeDefs.hpp"
27#include "xeXMLParser.hpp"
28#include "xeTestCaseResult.hpp"
29
30#include <vector>
31
32namespace xe
33{
34
35enum TestLogVersion
36{
37 TESTLOGVERSION_0_2_0 = 0,
38 TESTLOGVERSION_0_3_0,
39 TESTLOGVERSION_0_3_1,
40 TESTLOGVERSION_0_3_2,
41 TESTLOGVERSION_0_3_3,
Mika Isojärvi352d99d2016-02-11 15:35:19 -080042 TESTLOGVERSION_0_3_4,
Jarkko Poyry3c827362014-09-02 11:48:52 +030043
44 TESTLOGVERSION_LAST
45};
46
47class TestResultParseError : public ParseError
48{
49public:
50 TestResultParseError (const std::string& message) : ParseError(message) {}
51};
52
53class TestResultParser
54{
55public:
56 enum ParseResult
57 {
58 PARSERESULT_NOT_CHANGED,
59 PARSERESULT_CHANGED,
60 PARSERESULT_COMPLETE,
61 PARSERESULT_ERROR,
62
63 PARSERESULT_LAST
64 };
65
66 TestResultParser (void);
67 ~TestResultParser (void);
68
69 void init (TestCaseResult* dstResult);
70 ParseResult parse (const deUint8* bytes, int numBytes);
71
72private:
73 TestResultParser (const TestResultParser& other);
74 TestResultParser& operator= (const TestResultParser& other);
75
76 void clear (void);
77
78 void handleElementStart (void);
79 void handleElementEnd (void);
80 void handleData (void);
81
82 const char* getAttribute (const char* name);
83
84 ri::Item* getCurrentItem (void);
85 ri::List* getCurrentItemList (void);
86 void pushItem (ri::Item* item);
87 void popItem (void);
88 void updateCurrentItemList (void);
89
90 enum State
91 {
92 STATE_NOT_INITIALIZED = 0,
93 STATE_INITIALIZED,
94 STATE_IN_TEST_CASE_RESULT,
95 STATE_TEST_CASE_RESULT_ENDED,
96
97 STATE_LAST
98 };
99
100 xml::Parser m_xmlParser;
101 TestCaseResult* m_result;
102
103 State m_state;
104 TestLogVersion m_logVersion; //!< Only valid in STATE_IN_TEST_CASE_RESULT.
105
106 std::vector<ri::Item*> m_itemStack;
107 ri::List* m_curItemList;
108
109 int m_base64DecodeOffset;
110
111 std::string m_curNumValue;
112};
113
114// Helpers exposed to other parsers.
115TestStatusCode getTestStatusCode (const char* statusCode);
116
117// Parsing helpers.
118
119class TestCaseResultData;
120
121void parseTestCaseResultFromData (TestResultParser* parser, TestCaseResult* result, const TestCaseResultData& data);
122
123} // xe
124
125#endif // _XETESTRESULTPARSER_HPP