1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
5 * Copyright (c) 2016 Google Inc.
6 * Copyright (c) 2016 The Khronos Group Inc.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 * \brief OpenGL Test Case Wrapper.
23 */ /*-------------------------------------------------------------------*/
25 #include "glcTestCaseWrapper.hpp"
26 #include "gluStateReset.hpp"
27 #include "glwEnums.hpp"
28 #include "glwFunctions.hpp"
29 #include "tcuTestLog.hpp"
36 TestCaseWrapper::TestCaseWrapper(Context& context) : m_testCtx(context.getTestContext()), m_context(context)
40 TestCaseWrapper::~TestCaseWrapper(void)
44 bool TestCaseWrapper::initTestCase(tcu::TestCase* testCase)
46 TestLog& log = m_testCtx.getLog();
51 // Clear state to defaults
52 glu::resetState(m_context.getRenderContext(), m_context.getContextInfo());
54 catch (const std::exception& e)
57 log << TestLog::Message << "Error in state reset, test program will terminate." << TestLog::EndMessage;
66 catch (const std::bad_alloc&)
69 m_testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Failed to allocate memory in test case init");
71 catch (const tcu::ResourceError& e)
74 m_testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in test case init");
77 catch (const tcu::NotSupportedError& e)
80 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not supported");
83 catch (const tcu::InternalError& e)
86 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Internal error in test case init");
89 catch (const tcu::Exception& e)
97 if (m_testCtx.getTestResult() == QP_TEST_RESULT_LAST)
98 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in test case init");
105 bool TestCaseWrapper::deinitTestCase(tcu::TestCase* testCase)
107 TestLog& log = m_testCtx.getLog();
113 catch (const tcu::Exception& e)
116 log << TestLog::Message << "Error in test case deinit, test program will terminate." << TestLog::EndMessage;
122 // Clear state to defaults
123 glu::resetState(m_context.getRenderContext(), m_context.getContextInfo());
125 catch (const std::exception& e)
128 log << TestLog::Message << "Error in state reset, test program will terminate." << TestLog::EndMessage;
135 tcu::TestNode::IterateResult TestCaseWrapper::iterateTestCase(tcu::TestCase* testCase)
137 // Iterate the sub-case.
138 TestLog& log = m_testCtx.getLog();
139 tcu::TestCase::IterateResult iterateResult = tcu::TestCase::STOP;
143 iterateResult = testCase->iterate();
145 catch (const std::bad_alloc&)
147 m_testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Failed to allocate memory during test execution");
149 catch (const tcu::ResourceError& e)
152 m_testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error during test execution");
154 catch (const tcu::NotSupportedError& e)
157 m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not supported");
159 catch (const tcu::InternalError& e)
162 m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Internal error in test execution");
164 catch (const tcu::Exception& e)
167 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in test execution");
171 const glw::Functions& gl = m_context.getRenderContext().getFunctions();
172 gl.clearColor(0.f, 0.f, 0.f, 1.f);
173 gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
175 tcu::TestCase::IterateResult result = iterateResult;
177 // Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
180 m_context.getRenderContext().postIterate();
182 catch (const std::exception& e)
184 m_testCtx.getLog() << e;
185 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
186 return tcu::TestNode::STOP;