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 Shared structures for ES 3.1 negative API tests
22 *//*--------------------------------------------------------------------*/
23
24#include "es31fNegativeTestShared.hpp"
25
26#include "gluRenderContext.hpp"
27#include "glwFunctions.hpp"
28
29namespace deqp
30{
31namespace gles31
32{
33namespace Functional
34{
35namespace NegativeTestShared
36{
37
38using glw::GLenum;
39using tcu::TestLog;
40using std::string;
41
42ErrorCase::ErrorCase (Context& ctx, const char* name, const char* desc)
43	: TestCase(ctx, name, desc)
44{
45}
46
47NegativeTestContext::NegativeTestContext (ErrorCase&				host,
48										  glu::RenderContext&		renderCtx,
49										  const glu::ContextInfo&	ctxInfo,
50										  tcu::TestLog&				log,
51										  tcu::ResultCollector&		results,
52										  bool						enableLogging_)
53	: glu::CallLogWrapper	(renderCtx.getFunctions(), log)
54	, m_renderCtx			(renderCtx)
55	, m_ctxInfo				(ctxInfo)
56	, m_host				(host)
57	, m_results				(results)
58	, m_openSections		(0)
59{
60	enableLogging(enableLogging_);
61}
62
63NegativeTestContext::~NegativeTestContext ()
64{
65	while (m_openSections--)
66		getLog() << TestLog::EndSection;
67}
68
69void NegativeTestContext::fail (const string& msg)
70{
71	m_results.addResult(QP_TEST_RESULT_FAIL, msg);
72}
73
74int NegativeTestContext::getInteger (GLenum pname) const
75{
76	int retval = 0;
77	m_renderCtx.getFunctions().getIntegerv(pname, &retval);
78	return retval;
79}
80
81void NegativeTestContext::beginSection (const string& desc)
82{
83	if (isLoggingEnabled())
84	{
85		getLog() << TestLog::Section("callstream", desc);
86		m_openSections++;
87	}
88}
89
90void NegativeTestContext::endSection (void)
91{
92	if (isLoggingEnabled())
93	{
94		DE_ASSERT (m_openSections > 0);
95		getLog() << TestLog::EndSection;
96		m_openSections--;
97	}
98}
99
100void NegativeTestContext::expectMessage (GLenum source, GLenum type)
101{
102	m_host.expectMessage(source, type);
103}
104
105void NegativeTestContext::expectError (GLenum error)
106{
107	m_host.expectError(error, error);
108}
109
110void NegativeTestContext::expectError (GLenum error0, GLenum error1)
111{
112	m_host.expectError(error0, error1);
113}
114
115} // NegativeTestShared
116} // Functional
117} // gles31
118} // deqp
119