1 #ifndef _TCUTESTCONTEXT_HPP 2 #define _TCUTESTCONTEXT_HPP 3 /*------------------------------------------------------------------------- 4 * drawElements Quality Program Tester Core 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 Context shared between test cases. 24 *//*--------------------------------------------------------------------*/ 25 26 #include "tcuDefs.hpp" 27 #include "qpWatchDog.h" 28 #include "qpTestLog.h" 29 30 #include <string> 31 32 namespace tcu 33 { 34 35 class Archive; 36 class Platform; 37 class CommandLine; 38 class TestLog; 39 40 /*--------------------------------------------------------------------*//*! 41 * \brief Test context 42 * 43 * Test context holds common resources that are available to test cases. 44 * This includes test log and resource archive. 45 * 46 * Test case can write to test log and must set test result to test context. 47 *//*--------------------------------------------------------------------*/ 48 class TestContext 49 { 50 public: 51 TestContext(Platform &platform, Archive &rootArchive, TestLog &log, const CommandLine &cmdLine, 52 qpWatchDog *watchDog); ~TestContext(void)53 ~TestContext(void) 54 { 55 } 56 57 void writeSessionInfo(void); 58 59 // API for test cases getLog(void)60 TestLog &getLog(void) 61 { 62 return m_log; 63 } getArchive(void)64 Archive &getArchive(void) 65 { 66 return *m_curArchive; 67 } //!< \note Do not access in TestNode constructors. getPlatform(void)68 Platform &getPlatform(void) 69 { 70 return m_platform; 71 } 72 void setTestResult(qpTestResult result, const char *description); 73 void touchWatchdog(void); 74 void touchWatchdogAndDisableIntervalTimeLimit(void); 75 void touchWatchdogAndEnableIntervalTimeLimit(void); getCommandLine(void) const76 const CommandLine &getCommandLine(void) const 77 { 78 return m_cmdLine; 79 } 80 81 // API for test framework getTestResult(void) const82 qpTestResult getTestResult(void) const 83 { 84 return m_testResult; 85 } getTestResultDesc(void) const86 const char *getTestResultDesc(void) const 87 { 88 return m_testResultDesc.c_str(); 89 } getWatchDog(void)90 qpWatchDog *getWatchDog(void) 91 { 92 return m_watchDog; 93 } 94 getRootArchive(void) const95 Archive &getRootArchive(void) const 96 { 97 return m_rootArchive; 98 } setCurrentArchive(Archive & archive)99 void setCurrentArchive(Archive &archive) 100 { 101 m_curArchive = &archive; 102 } 103 setTerminateAfter(bool terminate)104 void setTerminateAfter(bool terminate) 105 { 106 m_terminateAfter = terminate; 107 } getTerminateAfter(void) const108 bool getTerminateAfter(void) const 109 { 110 return m_terminateAfter; 111 } 112 113 protected: 114 TestContext(const TestContext &); 115 TestContext &operator=(const TestContext &); 116 117 Platform &m_platform; //!< Platform port implementation. 118 Archive &m_rootArchive; //!< Root archive. 119 TestLog &m_log; //!< Test log. 120 const CommandLine &m_cmdLine; //!< Command line. 121 qpWatchDog *m_watchDog; //!< Watchdog (can be null). 122 123 Archive *m_curArchive; //!< Current archive for test cases. 124 qpTestResult m_testResult; //!< Latest test result. 125 std::string m_testResultDesc; //!< Latest test result description. 126 bool m_terminateAfter; //!< Should tester terminate after execution of the current test 127 }; 128 129 } // namespace tcu 130 131 #endif // _TCUTESTCONTEXT_HPP 132