1 #ifndef _TES31TESTCASEWRAPPER_HPP
2 #define _TES31TESTCASEWRAPPER_HPP
3 /*-------------------------------------------------------------------------
4 * OpenGL Conformance Test Suite
5 * -----------------------------
7 * Copyright (c) 2019 The Khronos Group Inc.
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * \brief OpenGL ES 3.1 Test Package that runs on GL4.5 context
24 *//*--------------------------------------------------------------------*/
26 #include "tcuTestLog.hpp"
27 #include "tes31Context.hpp"
28 #include "tcuWaiverUtil.hpp"
29 #include "gluStateReset.hpp"
36 template <typename TEST_PACKAGE>
37 class TestCaseWrapper : public tcu::TestCaseExecutor
40 TestCaseWrapper (TEST_PACKAGE& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism);
41 ~TestCaseWrapper (void);
43 void init (tcu::TestCase* testCase, const std::string& path);
44 void deinit (tcu::TestCase* testCase);
45 tcu::TestNode::IterateResult iterate (tcu::TestCase* testCase);
48 TEST_PACKAGE& m_testPackage;
49 de::SharedPtr<tcu::WaiverUtil> m_waiverMechanism;
52 template <typename TEST_PACKAGE>
53 TestCaseWrapper<TEST_PACKAGE>::TestCaseWrapper (TEST_PACKAGE& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism)
54 : m_testPackage(package)
55 , m_waiverMechanism (waiverMechanism)
59 template <typename TEST_PACKAGE>
60 TestCaseWrapper<TEST_PACKAGE>::~TestCaseWrapper (void)
64 template <typename TEST_PACKAGE>
65 void TestCaseWrapper<TEST_PACKAGE>::init (tcu::TestCase* testCase, const std::string& path)
67 if (m_waiverMechanism->isOnWaiverList(path))
68 throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
73 template <typename TEST_PACKAGE>
74 void TestCaseWrapper<TEST_PACKAGE>::deinit (tcu::TestCase* testCase)
78 DE_ASSERT(m_testPackage.getContext());
79 glu::resetState(m_testPackage.getContext()->getRenderContext(), m_testPackage.getContext()->getContextInfo());
82 template <typename TEST_PACKAGE>
83 tcu::TestNode::IterateResult TestCaseWrapper<TEST_PACKAGE>::iterate (tcu::TestCase* testCase)
85 tcu::TestContext& testCtx = m_testPackage.getContext()->getTestContext();
86 const tcu::TestCase::IterateResult result = testCase->iterate();
88 // Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
91 m_testPackage.getContext()->getRenderContext().postIterate();
94 catch (const tcu::ResourceError& e)
96 testCtx.getLog() << e;
97 testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
98 testCtx.setTerminateAfter(true);
99 return tcu::TestNode::STOP;
101 catch (const std::exception& e)
103 testCtx.getLog() << e;
104 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
105 return tcu::TestNode::STOP;
112 #endif // _TES31TESTCASEWRAPPER_HPP