• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.1 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.1 Test Package
22  *//*--------------------------------------------------------------------*/
23 
24 #include "tes31TestPackage.hpp"
25 #include "tes31InfoTests.hpp"
26 #include "es31fFunctionalTests.hpp"
27 #include "es31sStressTests.hpp"
28 #include "gluStateReset.hpp"
29 #include "gluRenderContext.hpp"
30 #include "tcuTestLog.hpp"
31 
32 namespace deqp
33 {
34 namespace gles31
35 {
36 
37 class TestCaseWrapper : public tcu::TestCaseExecutor
38 {
39 public:
40 									TestCaseWrapper		(TestPackage& package);
41 									~TestCaseWrapper	(void);
42 
43 	void							init				(tcu::TestCase* testCase, const std::string& path);
44 	void							deinit				(tcu::TestCase* testCase);
45 	tcu::TestNode::IterateResult	iterate				(tcu::TestCase* testCase);
46 
47 private:
48 	TestPackage&					m_testPackage;
49 };
50 
TestCaseWrapper(TestPackage & package)51 TestCaseWrapper::TestCaseWrapper (TestPackage& package)
52 	: m_testPackage(package)
53 {
54 }
55 
~TestCaseWrapper(void)56 TestCaseWrapper::~TestCaseWrapper (void)
57 {
58 }
59 
init(tcu::TestCase * testCase,const std::string &)60 void TestCaseWrapper::init (tcu::TestCase* testCase, const std::string&)
61 {
62 	testCase->init();
63 }
64 
deinit(tcu::TestCase * testCase)65 void TestCaseWrapper::deinit (tcu::TestCase* testCase)
66 {
67 	testCase->deinit();
68 
69 	DE_ASSERT(m_testPackage.getContext());
70 	glu::resetState(m_testPackage.getContext()->getRenderContext(), m_testPackage.getContext()->getContextInfo());
71 }
72 
iterate(tcu::TestCase * testCase)73 tcu::TestNode::IterateResult TestCaseWrapper::iterate (tcu::TestCase* testCase)
74 {
75 	tcu::TestContext&					testCtx	= m_testPackage.getContext()->getTestContext();
76 	const tcu::TestCase::IterateResult	result	= testCase->iterate();
77 
78 	// Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
79 	try
80 	{
81 		m_testPackage.getContext()->getRenderContext().postIterate();
82 		return result;
83 	}
84 	catch (const tcu::ResourceError& e)
85 	{
86 		testCtx.getLog() << e;
87 		testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
88 		testCtx.setTerminateAfter(true);
89 		return tcu::TestNode::STOP;
90 	}
91 	catch (const std::exception& e)
92 	{
93 		testCtx.getLog() << e;
94 		testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
95 		return tcu::TestNode::STOP;
96 	}
97 }
98 
TestPackage(tcu::TestContext & testCtx)99 TestPackage::TestPackage (tcu::TestContext& testCtx)
100 	: tcu::TestPackage	(testCtx, "dEQP-GLES31", "dEQP OpenGL ES 3.1 Tests")
101 	, m_archive			(testCtx.getRootArchive(), "gles31/")
102 	, m_context			(DE_NULL)
103 {
104 }
105 
~TestPackage(void)106 TestPackage::~TestPackage (void)
107 {
108 	// Destroy children first since destructors may access context.
109 	TestNode::deinit();
110 	delete m_context;
111 }
112 
init(void)113 void TestPackage::init (void)
114 {
115 	try
116 	{
117 		// Create context
118 		m_context = new Context(m_testCtx);
119 
120 		// Add main test groups
121 		addChild(new InfoTests						(*m_context));
122 		addChild(new Functional::FunctionalTests	(*m_context));
123 		addChild(new Stress::StressTests			(*m_context));
124 	}
125 	catch (...)
126 	{
127 		delete m_context;
128 		m_context = DE_NULL;
129 
130 		throw;
131 	}
132 }
133 
deinit(void)134 void TestPackage::deinit (void)
135 {
136 	TestNode::deinit();
137 	delete m_context;
138 	m_context = DE_NULL;
139 }
140 
createExecutor(void) const141 tcu::TestCaseExecutor* TestPackage::createExecutor (void) const
142 {
143 	return new TestCaseWrapper(const_cast<TestPackage&>(*this));
144 }
145 
146 } // gles31
147 } // deqp
148