1*35238bceSAndroid Build Coastguard Worker #ifndef _TCUTESTCONTEXT_HPP 2*35238bceSAndroid Build Coastguard Worker #define _TCUTESTCONTEXT_HPP 3*35238bceSAndroid Build Coastguard Worker /*------------------------------------------------------------------------- 4*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program Tester Core 5*35238bceSAndroid Build Coastguard Worker * ---------------------------------------- 6*35238bceSAndroid Build Coastguard Worker * 7*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project 8*35238bceSAndroid Build Coastguard Worker * 9*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 10*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 11*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at 12*35238bceSAndroid Build Coastguard Worker * 13*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 14*35238bceSAndroid Build Coastguard Worker * 15*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 16*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 17*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 19*35238bceSAndroid Build Coastguard Worker * limitations under the License. 20*35238bceSAndroid Build Coastguard Worker * 21*35238bceSAndroid Build Coastguard Worker *//*! 22*35238bceSAndroid Build Coastguard Worker * \file 23*35238bceSAndroid Build Coastguard Worker * \brief Context shared between test cases. 24*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 25*35238bceSAndroid Build Coastguard Worker 26*35238bceSAndroid Build Coastguard Worker #include "tcuDefs.hpp" 27*35238bceSAndroid Build Coastguard Worker #include "qpWatchDog.h" 28*35238bceSAndroid Build Coastguard Worker #include "qpTestLog.h" 29*35238bceSAndroid Build Coastguard Worker 30*35238bceSAndroid Build Coastguard Worker #include <string> 31*35238bceSAndroid Build Coastguard Worker 32*35238bceSAndroid Build Coastguard Worker namespace tcu 33*35238bceSAndroid Build Coastguard Worker { 34*35238bceSAndroid Build Coastguard Worker 35*35238bceSAndroid Build Coastguard Worker class Archive; 36*35238bceSAndroid Build Coastguard Worker class Platform; 37*35238bceSAndroid Build Coastguard Worker class CommandLine; 38*35238bceSAndroid Build Coastguard Worker class TestLog; 39*35238bceSAndroid Build Coastguard Worker 40*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*! 41*35238bceSAndroid Build Coastguard Worker * \brief Test context 42*35238bceSAndroid Build Coastguard Worker * 43*35238bceSAndroid Build Coastguard Worker * Test context holds common resources that are available to test cases. 44*35238bceSAndroid Build Coastguard Worker * This includes test log and resource archive. 45*35238bceSAndroid Build Coastguard Worker * 46*35238bceSAndroid Build Coastguard Worker * Test case can write to test log and must set test result to test context. 47*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 48*35238bceSAndroid Build Coastguard Worker class TestContext 49*35238bceSAndroid Build Coastguard Worker { 50*35238bceSAndroid Build Coastguard Worker public: 51*35238bceSAndroid Build Coastguard Worker TestContext(Platform &platform, Archive &rootArchive, TestLog &log, const CommandLine &cmdLine, 52*35238bceSAndroid Build Coastguard Worker qpWatchDog *watchDog); ~TestContext(void)53*35238bceSAndroid Build Coastguard Worker ~TestContext(void) 54*35238bceSAndroid Build Coastguard Worker { 55*35238bceSAndroid Build Coastguard Worker } 56*35238bceSAndroid Build Coastguard Worker 57*35238bceSAndroid Build Coastguard Worker void writeSessionInfo(void); 58*35238bceSAndroid Build Coastguard Worker 59*35238bceSAndroid Build Coastguard Worker // API for test cases getLog(void)60*35238bceSAndroid Build Coastguard Worker TestLog &getLog(void) 61*35238bceSAndroid Build Coastguard Worker { 62*35238bceSAndroid Build Coastguard Worker return m_log; 63*35238bceSAndroid Build Coastguard Worker } getArchive(void)64*35238bceSAndroid Build Coastguard Worker Archive &getArchive(void) 65*35238bceSAndroid Build Coastguard Worker { 66*35238bceSAndroid Build Coastguard Worker return *m_curArchive; 67*35238bceSAndroid Build Coastguard Worker } //!< \note Do not access in TestNode constructors. getPlatform(void)68*35238bceSAndroid Build Coastguard Worker Platform &getPlatform(void) 69*35238bceSAndroid Build Coastguard Worker { 70*35238bceSAndroid Build Coastguard Worker return m_platform; 71*35238bceSAndroid Build Coastguard Worker } 72*35238bceSAndroid Build Coastguard Worker void setTestResult(qpTestResult result, const char *description); 73*35238bceSAndroid Build Coastguard Worker void touchWatchdog(void); 74*35238bceSAndroid Build Coastguard Worker void touchWatchdogAndDisableIntervalTimeLimit(void); 75*35238bceSAndroid Build Coastguard Worker void touchWatchdogAndEnableIntervalTimeLimit(void); getCommandLine(void) const76*35238bceSAndroid Build Coastguard Worker const CommandLine &getCommandLine(void) const 77*35238bceSAndroid Build Coastguard Worker { 78*35238bceSAndroid Build Coastguard Worker return m_cmdLine; 79*35238bceSAndroid Build Coastguard Worker } 80*35238bceSAndroid Build Coastguard Worker 81*35238bceSAndroid Build Coastguard Worker // API for test framework getTestResult(void) const82*35238bceSAndroid Build Coastguard Worker qpTestResult getTestResult(void) const 83*35238bceSAndroid Build Coastguard Worker { 84*35238bceSAndroid Build Coastguard Worker return m_testResult; 85*35238bceSAndroid Build Coastguard Worker } getTestResultDesc(void) const86*35238bceSAndroid Build Coastguard Worker const char *getTestResultDesc(void) const 87*35238bceSAndroid Build Coastguard Worker { 88*35238bceSAndroid Build Coastguard Worker return m_testResultDesc.c_str(); 89*35238bceSAndroid Build Coastguard Worker } getWatchDog(void)90*35238bceSAndroid Build Coastguard Worker qpWatchDog *getWatchDog(void) 91*35238bceSAndroid Build Coastguard Worker { 92*35238bceSAndroid Build Coastguard Worker return m_watchDog; 93*35238bceSAndroid Build Coastguard Worker } 94*35238bceSAndroid Build Coastguard Worker getRootArchive(void) const95*35238bceSAndroid Build Coastguard Worker Archive &getRootArchive(void) const 96*35238bceSAndroid Build Coastguard Worker { 97*35238bceSAndroid Build Coastguard Worker return m_rootArchive; 98*35238bceSAndroid Build Coastguard Worker } setCurrentArchive(Archive & archive)99*35238bceSAndroid Build Coastguard Worker void setCurrentArchive(Archive &archive) 100*35238bceSAndroid Build Coastguard Worker { 101*35238bceSAndroid Build Coastguard Worker m_curArchive = &archive; 102*35238bceSAndroid Build Coastguard Worker } 103*35238bceSAndroid Build Coastguard Worker setTerminateAfter(bool terminate)104*35238bceSAndroid Build Coastguard Worker void setTerminateAfter(bool terminate) 105*35238bceSAndroid Build Coastguard Worker { 106*35238bceSAndroid Build Coastguard Worker m_terminateAfter = terminate; 107*35238bceSAndroid Build Coastguard Worker } getTerminateAfter(void) const108*35238bceSAndroid Build Coastguard Worker bool getTerminateAfter(void) const 109*35238bceSAndroid Build Coastguard Worker { 110*35238bceSAndroid Build Coastguard Worker return m_terminateAfter; 111*35238bceSAndroid Build Coastguard Worker } 112*35238bceSAndroid Build Coastguard Worker 113*35238bceSAndroid Build Coastguard Worker protected: 114*35238bceSAndroid Build Coastguard Worker TestContext(const TestContext &); 115*35238bceSAndroid Build Coastguard Worker TestContext &operator=(const TestContext &); 116*35238bceSAndroid Build Coastguard Worker 117*35238bceSAndroid Build Coastguard Worker Platform &m_platform; //!< Platform port implementation. 118*35238bceSAndroid Build Coastguard Worker Archive &m_rootArchive; //!< Root archive. 119*35238bceSAndroid Build Coastguard Worker TestLog &m_log; //!< Test log. 120*35238bceSAndroid Build Coastguard Worker const CommandLine &m_cmdLine; //!< Command line. 121*35238bceSAndroid Build Coastguard Worker qpWatchDog *m_watchDog; //!< Watchdog (can be null). 122*35238bceSAndroid Build Coastguard Worker 123*35238bceSAndroid Build Coastguard Worker Archive *m_curArchive; //!< Current archive for test cases. 124*35238bceSAndroid Build Coastguard Worker qpTestResult m_testResult; //!< Latest test result. 125*35238bceSAndroid Build Coastguard Worker std::string m_testResultDesc; //!< Latest test result description. 126*35238bceSAndroid Build Coastguard Worker bool m_terminateAfter; //!< Should tester terminate after execution of the current test 127*35238bceSAndroid Build Coastguard Worker }; 128*35238bceSAndroid Build Coastguard Worker 129*35238bceSAndroid Build Coastguard Worker } // namespace tcu 130*35238bceSAndroid Build Coastguard Worker 131*35238bceSAndroid Build Coastguard Worker #endif // _TCUTESTCONTEXT_HPP 132