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
30using std::string;
31using std::vector;
32
33namespace deqp
34{
35namespace gles3
36{
37namespace Functional
38{
39
40using tcu::TestLog;
41
42ApiCase::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
49ApiCase::~ApiCase (void)
50{
51}
52
53ApiCase::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
67void 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
78void 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
89void ApiCase::checkBooleans (deUint8 value, deUint8 expected)
90{
91	if (value != expected)
92	{
93		m_log << TestLog::Message << "// ERROR: expected " << (expected	? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
94		if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
95			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
96	}
97}
98
99void ApiCase::getSupportedExtensions (const deUint32 numSupportedValues, const deUint32 extension, std::vector<int>& values)
100{
101	deInt32 numFormats;
102	GLU_CHECK_CALL(glGetIntegerv(numSupportedValues, &numFormats));
103	if (numFormats == 0)
104	{
105		m_log << TestLog::Message << "// No supported extensions available." << TestLog::EndMessage;
106		return;
107	}
108	values.resize(numFormats);
109	GLU_CHECK_CALL(glGetIntegerv(extension, &values[0]));
110}
111
112} // Functional
113} // gles3
114} // deqp
115