1#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,
42
43	TESTLOGVERSION_LAST
44};
45
46class TestResultParseError : public ParseError
47{
48public:
49	TestResultParseError (const std::string& message) : ParseError(message) {}
50};
51
52class TestResultParser
53{
54public:
55	enum ParseResult
56	{
57		PARSERESULT_NOT_CHANGED,
58		PARSERESULT_CHANGED,
59		PARSERESULT_COMPLETE,
60		PARSERESULT_ERROR,
61
62		PARSERESULT_LAST
63	};
64
65							TestResultParser			(void);
66							~TestResultParser			(void);
67
68	void					init						(TestCaseResult* dstResult);
69	ParseResult				parse						(const deUint8* bytes, int numBytes);
70
71private:
72							TestResultParser			(const TestResultParser& other);
73	TestResultParser&		operator=					(const TestResultParser& other);
74
75	void					clear						(void);
76
77	void					handleElementStart			(void);
78	void					handleElementEnd			(void);
79	void					handleData					(void);
80
81	const char*				getAttribute				(const char* name);
82
83	ri::Item*				getCurrentItem				(void);
84	ri::List*				getCurrentItemList			(void);
85	void					pushItem					(ri::Item* item);
86	void					popItem						(void);
87	void					updateCurrentItemList		(void);
88
89	enum State
90	{
91		STATE_NOT_INITIALIZED = 0,
92		STATE_INITIALIZED,
93		STATE_IN_TEST_CASE_RESULT,
94		STATE_TEST_CASE_RESULT_ENDED,
95
96		STATE_LAST
97	};
98
99	xml::Parser				m_xmlParser;
100	TestCaseResult*			m_result;
101
102	State					m_state;
103	TestLogVersion			m_logVersion;		//!< Only valid in STATE_IN_TEST_CASE_RESULT.
104
105	std::vector<ri::Item*>	m_itemStack;
106	ri::List*				m_curItemList;
107
108	int						m_base64DecodeOffset;
109
110	std::string				m_curNumValue;
111};
112
113// Helpers exposed to other parsers.
114TestStatusCode	getTestStatusCode			(const char* statusCode);
115
116// Parsing helpers.
117
118class TestCaseResultData;
119
120void			parseTestCaseResultFromData	(TestResultParser* parser, TestCaseResult* result, const TestCaseResultData& data);
121
122} // xe
123
124#endif // _XETESTRESULTPARSER_HPP
125