Home | History | Annotate | Download | only in functional
      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 Negative Fragment Pipe API tests.
     22  *//*--------------------------------------------------------------------*/
     23 
     24 #include "es2fNegativeFragmentApiTests.hpp"
     25 #include "es2fApiCase.hpp"
     26 
     27 #include "glwEnums.hpp"
     28 #include "glwDefs.hpp"
     29 
     30 using namespace glw; // GL types
     31 
     32 namespace deqp
     33 {
     34 namespace gles2
     35 {
     36 namespace Functional
     37 {
     38 
     39 using tcu::TestLog;
     40 
     41 NegativeFragmentApiTests::NegativeFragmentApiTests (Context& context)
     42 	: TestCaseGroup(context, "fragment", "Negative Fragment API Cases")
     43 {
     44 }
     45 
     46 NegativeFragmentApiTests::~NegativeFragmentApiTests (void)
     47 {
     48 }
     49 
     50 void NegativeFragmentApiTests::init (void)
     51 {
     52 	ES2F_ADD_API_CASE(scissor, "Invalid glScissor() usage",
     53 		{
     54 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if either width or height is negative.");
     55 			glScissor(0, 0, -1, 0);
     56 			expectError(GL_INVALID_VALUE);
     57 			glScissor(0, 0, 0, -1);
     58 			expectError(GL_INVALID_VALUE);
     59 			glScissor(0, 0, -1, -1);
     60 			expectError(GL_INVALID_VALUE);
     61 			m_log << TestLog::EndSection;
     62 		});
     63 	ES2F_ADD_API_CASE(depth_func, "Invalid glDepthFunc() usage",
     64 		{
     65 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if func is not an accepted value.");
     66 			glDepthFunc(-1);
     67 			expectError(GL_INVALID_ENUM);
     68 			m_log << TestLog::EndSection;
     69 		});
     70 	ES2F_ADD_API_CASE(viewport, "Invalid glViewport() usage",
     71 		{
     72 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if either width or height is negative.");
     73 			glViewport(0, 0, -1, 1);
     74 			expectError(GL_INVALID_VALUE);
     75 			glViewport(0, 0, 1, -1);
     76 			expectError(GL_INVALID_VALUE);
     77 			glViewport(0, 0, -1, -1);
     78 			expectError(GL_INVALID_VALUE);
     79 			m_log << TestLog::EndSection;
     80 		});
     81 
     82 	// Stencil functions
     83 
     84 	ES2F_ADD_API_CASE(stencil_func, "Invalid glStencilFunc() usage",
     85 		{
     86 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if func is not one of the eight accepted values.");
     87 			glStencilFunc(-1, 0, 1);
     88 			expectError(GL_INVALID_ENUM);
     89 			m_log << TestLog::EndSection;
     90 		});
     91 	ES2F_ADD_API_CASE(stencil_func_separate, "Invalid glStencilFuncSeparate() usage",
     92 		{
     93 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if face is not GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.");
     94 			glStencilFuncSeparate(-1, GL_NEVER, 0, 1);
     95 			expectError(GL_INVALID_ENUM);
     96 			m_log << TestLog::EndSection;
     97 
     98 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if func is not one of the eight accepted values.");
     99 			glStencilFuncSeparate(GL_FRONT, -1, 0, 1);
    100 			expectError(GL_INVALID_ENUM);
    101 			m_log << TestLog::EndSection;
    102 		});
    103 	ES2F_ADD_API_CASE(stencil_op, "Invalid glStencilOp() usage",
    104 		{
    105 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if sfail, dpfail, or dppass is any value other than the eight defined symbolic constant values.");
    106 			glStencilOp(-1, GL_ZERO, GL_REPLACE);
    107 			expectError(GL_INVALID_ENUM);
    108 			glStencilOp(GL_KEEP, -1, GL_REPLACE);
    109 			expectError(GL_INVALID_ENUM);
    110 			glStencilOp(GL_KEEP, GL_ZERO, -1);
    111 			expectError(GL_INVALID_ENUM);
    112 			m_log << TestLog::EndSection;
    113 		});
    114 	ES2F_ADD_API_CASE(stencil_op_separate, "Invalid glStencilOpSeparate() usage",
    115 		{
    116 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if face is any value other than GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.");
    117 			glStencilOpSeparate(-1, GL_KEEP, GL_ZERO, GL_REPLACE);
    118 			expectError(GL_INVALID_ENUM);
    119 			m_log << TestLog::EndSection;
    120 
    121 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if sfail, dpfail, or dppass is any value other than the eight defined symbolic constant values.");
    122 			glStencilOpSeparate(GL_FRONT, -1, GL_ZERO, GL_REPLACE);
    123 			expectError(GL_INVALID_ENUM);
    124 			glStencilOpSeparate(GL_FRONT, GL_KEEP, -1, GL_REPLACE);
    125 			expectError(GL_INVALID_ENUM);
    126 			glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_ZERO, -1);
    127 			expectError(GL_INVALID_ENUM);
    128 			m_log << TestLog::EndSection;
    129 		});
    130 	ES2F_ADD_API_CASE(stencil_mask_separate, "Invalid glStencilMaskSeparate() usage",
    131 		{
    132 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if face is not GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.");
    133 			glStencilMaskSeparate(-1, 0);
    134 			expectError(GL_INVALID_ENUM);
    135 			m_log << TestLog::EndSection;
    136 		});
    137 
    138 	// Blend functions
    139 
    140 	ES2F_ADD_API_CASE(blend_equation, "Invalid glBlendEquation() usage",
    141 		{
    142 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if mode is not one of GL_FUNC_ADD, GL_FUNC_SUBTRACT, or GL_FUNC_REVERSE_SUBTRACT.");
    143 			glBlendEquation(-1);
    144 			expectError(GL_INVALID_ENUM);
    145 			m_log << TestLog::EndSection;
    146 		});
    147 	ES2F_ADD_API_CASE(blend_equation_separate, "Invalid glBlendEquationSeparate() usage",
    148 		{
    149 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if either modeRGB or modeAlpha is not one of GL_FUNC_ADD, GL_FUNC_SUBTRACT, or GL_FUNC_REVERSE_SUBTRACT.");
    150 			glBlendEquationSeparate(-1, GL_FUNC_ADD);
    151 			expectError(GL_INVALID_ENUM);
    152 			glBlendEquationSeparate(GL_FUNC_ADD, -1);
    153 			expectError(GL_INVALID_ENUM);
    154 			m_log << TestLog::EndSection;
    155 		});
    156 	ES2F_ADD_API_CASE(blend_func_separate, "Invalid glBlendFuncSeparate() usage",
    157 		{
    158 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if srcRGB, dstRGB, srcAlpha, or dstAlpha is not an accepted value.");
    159 			glBlendFuncSeparate(-1, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
    160 			expectError(GL_INVALID_ENUM);
    161 			glBlendFuncSeparate(GL_ZERO, -1, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
    162 			expectError(GL_INVALID_ENUM);
    163 			glBlendFuncSeparate(GL_ZERO, GL_ONE, -1, GL_ONE_MINUS_SRC_COLOR);
    164 			expectError(GL_INVALID_ENUM);
    165 			glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, -1);
    166 			expectError(GL_INVALID_ENUM);
    167 			m_log << TestLog::EndSection;
    168 		});
    169 	ES2F_ADD_API_CASE(blend_func, "Invalid glBlendFunc() usage",
    170 		{
    171 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if either sfactor or dfactor is not an accepted value.");
    172 			glBlendFunc(-1, GL_ONE);
    173 			expectError(GL_INVALID_ENUM);
    174 			glBlendFunc(GL_ONE, -1);
    175 			expectError(GL_INVALID_ENUM);
    176 			m_log << TestLog::EndSection;
    177 		});
    178 
    179 	// Rasterization API functions
    180 
    181 	ES2F_ADD_API_CASE(cull_face, "Invalid glCullFace() usage",
    182 		{
    183 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if mode is not an accepted value.");
    184 			glCullFace(-1);
    185 			expectError(GL_INVALID_ENUM);
    186 			m_log << TestLog::EndSection;
    187 		});
    188 
    189 	ES2F_ADD_API_CASE(front_face, "Invalid glFrontFace() usage",
    190 		{
    191 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if mode is not an accepted value.");
    192 			glFrontFace(-1);
    193 			expectError(GL_INVALID_ENUM);
    194 			m_log << TestLog::EndSection;
    195 		});
    196 
    197 	ES2F_ADD_API_CASE(line_width, "Invalid glLineWidth() usage",
    198 		{
    199 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width is less than or equal to 0.");
    200 			glLineWidth(0);
    201 			expectError(GL_INVALID_VALUE);
    202 			glLineWidth(-1);
    203 			expectError(GL_INVALID_VALUE);
    204 			m_log << TestLog::EndSection;
    205 		});
    206 }
    207 
    208 } // Functional
    209 } // gles2
    210 } // deqp
    211