Home | History | Annotate | Download | only in functional
      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 "tcuResultCollector.hpp"
     27 
     28 #include "gluContextInfo.hpp"
     29 #include "gluRenderContext.hpp"
     30 #include "glwFunctions.hpp"
     31 
     32 namespace deqp
     33 {
     34 namespace gles31
     35 {
     36 namespace Functional
     37 {
     38 namespace NegativeTestShared
     39 {
     40 
     41 using glw::GLenum;
     42 using tcu::TestLog;
     43 using std::string;
     44 
     45 ErrorCase::ErrorCase (Context& ctx, const char* name, const char* desc)
     46 	: TestCase(ctx, name, desc)
     47 {
     48 }
     49 
     50 NegativeTestContext::NegativeTestContext (ErrorCase&				host,
     51 										  glu::RenderContext&		renderCtx,
     52 										  const glu::ContextInfo&	ctxInfo,
     53 										  tcu::TestLog&				log,
     54 										  tcu::ResultCollector&		results,
     55 										  bool						enableLogging_)
     56 	: glu::CallLogWrapper	(renderCtx.getFunctions(), log)
     57 	, m_host				(host)
     58 	, m_renderCtx			(renderCtx)
     59 	, m_ctxInfo				(ctxInfo)
     60 	, m_results				(results)
     61 	, m_openSections		(0)
     62 {
     63 	enableLogging(enableLogging_);
     64 }
     65 
     66 NegativeTestContext::~NegativeTestContext ()
     67 {
     68 	while (m_openSections--)
     69 		getLog() << TestLog::EndSection;
     70 }
     71 
     72 void NegativeTestContext::fail (const string& msg)
     73 {
     74 	m_results.addResult(QP_TEST_RESULT_FAIL, msg);
     75 }
     76 
     77 int NegativeTestContext::getInteger (GLenum pname) const
     78 {
     79 	int retval = 0;
     80 	m_renderCtx.getFunctions().getIntegerv(pname, &retval);
     81 	return retval;
     82 }
     83 
     84 void NegativeTestContext::beginSection (const string& desc)
     85 {
     86 	if (isLoggingEnabled())
     87 	{
     88 		getLog() << TestLog::Section("callstream", desc);
     89 		m_openSections++;
     90 	}
     91 }
     92 
     93 void NegativeTestContext::endSection (void)
     94 {
     95 	if (isLoggingEnabled())
     96 	{
     97 		DE_ASSERT (m_openSections > 0);
     98 		getLog() << TestLog::EndSection;
     99 		m_openSections--;
    100 	}
    101 }
    102 
    103 void NegativeTestContext::expectError (GLenum error)
    104 {
    105 	m_host.expectError(error, error);
    106 }
    107 
    108 void NegativeTestContext::expectError (GLenum error0, GLenum error1)
    109 {
    110 	m_host.expectError(error0, error1);
    111 }
    112 
    113 bool NegativeTestContext::isShaderSupported (glu::ShaderType shaderType)
    114 {
    115 	if (contextSupports(getRenderContext().getType(), glu::ApiType::es(3, 2)))
    116 		return true;
    117 
    118 	switch (shaderType)
    119 	{
    120 		case glu::SHADERTYPE_GEOMETRY:
    121 			return getContextInfo().isExtensionSupported("GL_EXT_geometry_shader");
    122 		case glu::SHADERTYPE_TESSELLATION_CONTROL:
    123 		case glu::SHADERTYPE_TESSELLATION_EVALUATION:
    124 			return getContextInfo().isExtensionSupported("GL_EXT_tessellation_shader");
    125 		default:
    126 			return true;
    127 	}
    128 }
    129 
    130 bool NegativeTestContext::isExtensionSupported (std::string extension)
    131 {
    132 	return getContextInfo().isExtensionSupported(extension.c_str());
    133 }
    134 
    135 } // NegativeTestShared
    136 } // Functional
    137 } // gles31
    138 } // deqp
    139