• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 API test case.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es3fApiCase.hpp"
25 #include "gluStrUtil.hpp"
26 #include "gluRenderContext.hpp"
27 
28 #include <algorithm>
29 
30 using std::string;
31 using std::vector;
32 
33 namespace deqp
34 {
35 namespace gles3
36 {
37 namespace Functional
38 {
39 
40 using tcu::TestLog;
41 
ApiCase(Context & context,const char * name,const char * description)42 ApiCase::ApiCase (Context& context, const char* name, const char* description)
43 	: TestCase		(context, name, description)
44 	, CallLogWrapper(context.getRenderContext().getFunctions(), context.getTestContext().getLog())
45 	, m_log			(getLog())
46 {
47 }
48 
~ApiCase(void)49 ApiCase::~ApiCase (void)
50 {
51 }
52 
iterate(void)53 ApiCase::IterateResult ApiCase::iterate (void)
54 {
55 	// Initialize result to pass.
56 	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
57 
58 	// Enable call logging.
59 	enableLogging(true);
60 
61 	// Run test.
62 	test();
63 
64 	return STOP;
65 }
66 
expectError(deUint32 expected)67 void ApiCase::expectError (deUint32 expected)
68 {
69 	deUint32 err = glGetError();
70 	if (err != expected)
71 	{
72 		m_log << TestLog::Message << "// ERROR: expected " << glu::getErrorStr(expected) << TestLog::EndMessage;
73 		if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
74 			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid error");
75 	}
76 }
77 
expectError(deUint32 expected0,deUint32 expected1)78 void ApiCase::expectError (deUint32 expected0, deUint32 expected1)
79 {
80 	deUint32 err = glGetError();
81 	if (err != expected0 && err != expected1)
82 	{
83 		m_log << TestLog::Message << "// ERROR: expected " << glu::getErrorStr(expected0) << " or " << glu::getErrorStr(expected1) << TestLog::EndMessage;
84 		if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
85 			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid error");
86 	}
87 }
88 
checkBooleans(deUint8 value,deUint8 expected)89 void ApiCase::checkBooleans (deUint8 value, deUint8 expected)
90 {
91 	checkBooleans((deInt32)value, expected);
92 }
93 
checkBooleans(deInt32 value,deUint8 expected)94 void ApiCase::checkBooleans (deInt32 value, deUint8 expected)
95 {
96 	if (value != (deInt32)expected)
97 	{
98 		m_log << TestLog::Message << "// ERROR: expected " << (expected	? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
99 		if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
100 			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
101 	}
102 }
103 
getSupportedExtensions(const deUint32 numSupportedValues,const deUint32 extension,std::vector<int> & values)104 void ApiCase::getSupportedExtensions (const deUint32 numSupportedValues, const deUint32 extension, std::vector<int>& values)
105 {
106 	deInt32 numFormats;
107 	GLU_CHECK_CALL(glGetIntegerv(numSupportedValues, &numFormats));
108 	if (numFormats == 0)
109 	{
110 		m_log << TestLog::Message << "// No supported extensions available." << TestLog::EndMessage;
111 		return;
112 	}
113 	values.resize(numFormats);
114 	GLU_CHECK_CALL(glGetIntegerv(extension, &values[0]));
115 }
116 
117 } // Functional
118 } // gles3
119 } // deqp
120