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