• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 2.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 2.0 Test Case Wrapper.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "tes2TestCaseWrapper.hpp"
25 #include "tcuTestLog.hpp"
26 #include "gluDefs.hpp"
27 #include "gluStateReset.hpp"
28 #include "glwEnums.hpp"
29 #include "glwFunctions.hpp"
30 
31 namespace deqp
32 {
33 namespace gles2
34 {
35 
36 using tcu::TestLog;
37 
TestCaseWrapper(tcu::TestContext & testCtx,glu::RenderContext & renderCtx)38 TestCaseWrapper::TestCaseWrapper (tcu::TestContext& testCtx, glu::RenderContext& renderCtx)
39 	: tcu::TestCaseWrapper	(testCtx)
40 	, m_renderCtx			(renderCtx)
41 {
42 	TCU_CHECK(contextSupports(renderCtx.getType(), glu::ApiType::es(2,0)));
43 }
44 
~TestCaseWrapper(void)45 TestCaseWrapper::~TestCaseWrapper (void)
46 {
47 }
48 
initTestCase(tcu::TestCase * testCase)49 bool TestCaseWrapper::initTestCase (tcu::TestCase* testCase)
50 {
51 	return tcu::TestCaseWrapper::initTestCase(testCase);
52 }
53 
deinitTestCase(tcu::TestCase * testCase)54 bool TestCaseWrapper::deinitTestCase (tcu::TestCase* testCase)
55 {
56 	TestLog& log = m_testCtx.getLog();
57 
58 	if (!tcu::TestCaseWrapper::deinitTestCase(testCase))
59 		return false;
60 
61 	try
62 	{
63 		// Reset state
64 		glu::resetState(m_renderCtx);
65 	}
66 	catch (const std::exception& e)
67 	{
68 		log << e;
69 		log << TestLog::Message << "Error in state reset, test program will terminate." << TestLog::EndMessage;
70 		return false;
71 	}
72 
73 	return true;
74 }
75 
iterateTestCase(tcu::TestCase * testCase)76 tcu::TestNode::IterateResult TestCaseWrapper::iterateTestCase (tcu::TestCase* testCase)
77 {
78 	TestLog&						log		= m_testCtx.getLog();
79 	const glw::Functions&			gl		= m_renderCtx.getFunctions();
80 	tcu::TestCase::IterateResult	result	= tcu::TestNode::STOP;
81 
82 	// Clear to surrender-blue
83 	gl.clearColor(0.125f, 0.25f, 0.5f, 1.f);
84 	gl.clear(GL_COLOR_BUFFER_BIT);
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 		m_testCtx.setTerminateAfter(true);
99 		return tcu::TestNode::STOP;
100 	}
101 	catch (const std::exception& e)
102 	{
103 		log << e;
104 		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
105 		return tcu::TestNode::STOP;
106 	}
107 }
108 
109 } // gles2
110 } // deqp
111