1 /*------------------------------------------------------------------------- 2 * drawElements Quality Program OpenGL ES 3.0 Module 3 * ------------------------------------------------- 4 * 5 * Copyright 2014 The Android Open Source Project 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 * 19 *//*! 20 * \file 21 * \brief OpenGL ES 3.0 Test Case Wrapper. 22 *//*--------------------------------------------------------------------*/ 23 24 #include "tes3TestCaseWrapper.hpp" 25 #include "gluStateReset.hpp" 26 #include "tcuTestLog.hpp" 27 #include "glwEnums.hpp" 28 #include "glwFunctions.hpp" 29 30 namespace deqp 31 { 32 namespace gles3 33 { 34 35 using tcu::TestLog; 36 37 TestCaseWrapper::TestCaseWrapper (tcu::TestContext& testCtx, glu::RenderContext& renderCtx) 38 : tcu::TestCaseWrapper (testCtx) 39 , m_renderCtx (renderCtx) 40 { 41 TCU_CHECK(contextSupports(renderCtx.getType(), glu::ApiType::es(3,0))); 42 } 43 44 TestCaseWrapper::~TestCaseWrapper (void) 45 { 46 } 47 48 bool TestCaseWrapper::initTestCase (tcu::TestCase* testCase) 49 { 50 return tcu::TestCaseWrapper::initTestCase(testCase); 51 } 52 53 bool TestCaseWrapper::deinitTestCase (tcu::TestCase* testCase) 54 { 55 TestLog& log = m_testCtx.getLog(); 56 57 if (!tcu::TestCaseWrapper::deinitTestCase(testCase)) 58 return false; 59 60 try 61 { 62 // Reset state 63 glu::resetState(m_renderCtx); 64 } 65 catch (const std::exception& e) 66 { 67 log << e; 68 log << TestLog::Message << "Error in state reset, test program will terminate." << TestLog::EndMessage; 69 return false; 70 } 71 72 return true; 73 } 74 75 tcu::TestNode::IterateResult TestCaseWrapper::iterateTestCase (tcu::TestCase* testCase) 76 { 77 tcu::TestCase::IterateResult result = tcu::TestNode::STOP; 78 79 // Clear to surrender-blue 80 { 81 const glw::Functions& gl = m_renderCtx.getFunctions(); 82 gl.clearColor(0.125f, 0.25f, 0.5f, 1.f); 83 gl.clear(GL_COLOR_BUFFER_BIT); 84 } 85 86 result = tcu::TestCaseWrapper::iterateTestCase(testCase); 87 88 // Call implementation specific post-iterate routine (usually handles native events and swaps buffers) 89 try 90 { 91 m_renderCtx.postIterate(); 92 return result; 93 } 94 catch (const tcu::ResourceError& e) 95 { 96 m_testCtx.getLog() << e; 97 m_testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine"); 98 return tcu::TestNode::STOP; 99 } 100 catch (const std::exception& e) 101 { 102 m_testCtx.getLog() << e; 103 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine"); 104 return tcu::TestNode::STOP; 105 } 106 } 107 108 } // gles3 109 } // deqp 110