es3fNegativeFragmentApiTests.js (15884B)
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 Negative Fragment Pipe API tests. 22 *//*--------------------------------------------------------------------*/ 23 'use strict'; 24 goog.provide('functional.gles3.es3fNegativeFragmentApiTests'); 25 goog.require('framework.common.tcuTestCase'); 26 goog.require('functional.gles3.es3fApiCase'); 27 28 goog.scope(function() { 29 30 var es3fNegativeFragmentApiTests = functional.gles3.es3fNegativeFragmentApiTests; 31 var es3fApiCase = functional.gles3.es3fApiCase; 32 var tcuTestCase = framework.common.tcuTestCase; 33 34 /** 35 * @param {WebGL2RenderingContext} gl 36 */ 37 es3fNegativeFragmentApiTests.init = function(gl) { 38 39 var testGroup = tcuTestCase.runner.testCases; 40 41 testGroup.addChild(new es3fApiCase.ApiCaseCallback('scissor', 'Invalid gl.scissor() usage', gl, function() { 42 bufferedLogToConsole('gl.INVALID_VALUE is generated if either width or height is negative.'); 43 gl.scissor(0, 0, -1, 0); 44 this.expectError(gl.INVALID_VALUE); 45 gl.scissor(0, 0, 0, -1); 46 this.expectError(gl.INVALID_VALUE); 47 gl.scissor(0, 0, -1, -1); 48 this.expectError(gl.INVALID_VALUE); 49 50 })); 51 52 testGroup.addChild(new es3fApiCase.ApiCaseCallback('depth_func', 'Invalid gl.depthFunc() usage', gl, function() { 53 bufferedLogToConsole('gl.INVALID_ENUM is generated if func is not an accepted value.'); 54 gl.depthFunc(-1); 55 this.expectError(gl.INVALID_ENUM); 56 57 })); 58 59 testGroup.addChild(new es3fApiCase.ApiCaseCallback('viewport', 'Invalid gl.viewport() usage', gl, function() { 60 bufferedLogToConsole('gl.INVALID_VALUE is generated if either width or height is negative.'); 61 gl.viewport(0, 0, -1, 1); 62 this.expectError(gl.INVALID_VALUE); 63 gl.viewport(0, 0, 1, -1); 64 this.expectError(gl.INVALID_VALUE); 65 gl.viewport(0, 0, -1, -1); 66 this.expectError(gl.INVALID_VALUE); 67 68 })); 69 70 // Stencil functions 71 72 testGroup.addChild(new es3fApiCase.ApiCaseCallback('stencil_func', 'Invalid gl.stencilFunc() usage', gl, function() { 73 bufferedLogToConsole('gl.INVALID_ENUM is generated if func is not one of the eight accepted values.'); 74 gl.stencilFunc(-1, 0, 1); 75 this.expectError(gl.INVALID_ENUM); 76 77 })); 78 79 testGroup.addChild(new es3fApiCase.ApiCaseCallback('stencil_func_separate', 'Invalid gl.stencilFuncSeparate() usage', gl, function() { 80 bufferedLogToConsole('gl.INVALID_ENUM is generated if face is not gl.FRONT, gl.BACK, or gl.FRONT_AND_BACK.'); 81 gl.stencilFuncSeparate(-1, gl.NEVER, 0, 1); 82 this.expectError(gl.INVALID_ENUM); 83 84 bufferedLogToConsole('gl.INVALID_ENUM is generated if func is not one of the eight accepted values.'); 85 gl.stencilFuncSeparate(gl.FRONT, -1, 0, 1); 86 this.expectError(gl.INVALID_ENUM); 87 88 })); 89 90 testGroup.addChild(new es3fApiCase.ApiCaseCallback('stencil_op', 'Invalid gl.stencilOp() usage', gl, function() { 91 bufferedLogToConsole('gl.INVALID_ENUM is generated if sfail, dpfail, or dppass is any value other than the defined symbolic constant values.'); 92 gl.stencilOp(-1, gl.ZERO, gl.REPLACE); 93 this.expectError(gl.INVALID_ENUM); 94 gl.stencilOp(gl.KEEP, -1, gl.REPLACE); 95 this.expectError(gl.INVALID_ENUM); 96 gl.stencilOp(gl.KEEP, gl.ZERO, -1); 97 this.expectError(gl.INVALID_ENUM); 98 99 })); 100 101 testGroup.addChild(new es3fApiCase.ApiCaseCallback('stencil_op_separate', 'Invalid gl.stencilOpSeparate() usage', gl, function() { 102 bufferedLogToConsole('gl.INVALID_ENUM is generated if face is any value other than gl.FRONT, gl.BACK, or gl.FRONT_AND_BACK.'); 103 gl.stencilOpSeparate(-1, gl.KEEP, gl.ZERO, gl.REPLACE); 104 this.expectError(gl.INVALID_ENUM); 105 106 bufferedLogToConsole('gl.INVALID_ENUM is generated if sfail, dpfail, or dppass is any value other than the eight defined symbolic constant values.'); 107 gl.stencilOpSeparate(gl.FRONT, -1, gl.ZERO, gl.REPLACE); 108 this.expectError(gl.INVALID_ENUM); 109 gl.stencilOpSeparate(gl.FRONT, gl.KEEP, -1, gl.REPLACE); 110 this.expectError(gl.INVALID_ENUM); 111 gl.stencilOpSeparate(gl.FRONT, gl.KEEP, gl.ZERO, -1); 112 this.expectError(gl.INVALID_ENUM); 113 114 })); 115 116 testGroup.addChild(new es3fApiCase.ApiCaseCallback('stencil_mask_separate', 'Invalid gl.stencilMaskSeparate() usage', gl, function() { 117 bufferedLogToConsole('gl.INVALID_ENUM is generated if face is not gl.FRONT, gl.BACK, or gl.FRONT_AND_BACK.'); 118 gl.stencilMaskSeparate(-1, 0); 119 this.expectError(gl.INVALID_ENUM); 120 121 })); 122 123 // Blend functions 124 125 testGroup.addChild(new es3fApiCase.ApiCaseCallback('blend_equation', 'Invalid gl.blendEquation() usage', gl, function() { 126 bufferedLogToConsole('gl.INVALID_ENUM is generated if mode is not gl.FUNC_ADD, gl.FUNC_SUBTRACT, gl.FUNC_REVERSE_SUBTRACT, gl.MAX or gl.MIN.'); 127 gl.blendEquation(-1); 128 this.expectError(gl.INVALID_ENUM); 129 130 })); 131 132 testGroup.addChild(new es3fApiCase.ApiCaseCallback('blend_equation_separate', 'Invalid gl.blendEquationSeparate() usage', gl, function() { 133 bufferedLogToConsole('gl.INVALID_ENUM is generated if modeRGB is not gl.FUNC_ADD, gl.FUNC_SUBTRACT, gl.FUNC_REVERSE_SUBTRACT, gl.MAX or gl.MIN.'); 134 gl.blendEquationSeparate(-1, gl.FUNC_ADD); 135 this.expectError(gl.INVALID_ENUM); 136 137 bufferedLogToConsole('gl.INVALID_ENUM is generated if modeAlpha is not gl.FUNC_ADD, gl.FUNC_SUBTRACT, gl.FUNC_REVERSE_SUBTRACT, gl.MAX or gl.MIN.'); 138 gl.blendEquationSeparate(gl.FUNC_ADD, -1); 139 this.expectError(gl.INVALID_ENUM); 140 141 })); 142 143 testGroup.addChild(new es3fApiCase.ApiCaseCallback('blend_func', 'Invalid gl.blendFunc() usage', gl, function() { 144 bufferedLogToConsole('gl.INVALID_ENUM is generated if either sfactor or dfactor is not an accepted value.'); 145 gl.blendFunc(-1, gl.ONE); 146 this.expectError(gl.INVALID_ENUM); 147 gl.blendFunc(gl.ONE, -1); 148 this.expectError(gl.INVALID_ENUM); 149 150 })); 151 152 testGroup.addChild(new es3fApiCase.ApiCaseCallback('blend_func_separate', 'Invalid gl.blendFuncSeparate() usage', gl, function() { 153 bufferedLogToConsole('gl.INVALID_ENUM is generated if srcRGB, dstRGB, srcAlpha, or dstAlpha is not an accepted value.'); 154 gl.blendFuncSeparate(-1, gl.ONE, gl.SRC_COLOR, gl.ONE_MINUS_SRC_COLOR); 155 this.expectError(gl.INVALID_ENUM); 156 gl.blendFuncSeparate(gl.ZERO, -1, gl.SRC_COLOR, gl.ONE_MINUS_SRC_COLOR); 157 this.expectError(gl.INVALID_ENUM); 158 gl.blendFuncSeparate(gl.ZERO, gl.ONE, -1, gl.ONE_MINUS_SRC_COLOR); 159 this.expectError(gl.INVALID_ENUM); 160 gl.blendFuncSeparate(gl.ZERO, gl.ONE, gl.SRC_COLOR, -1); 161 this.expectError(gl.INVALID_ENUM); 162 163 })); 164 165 // Rasterization API functions 166 167 testGroup.addChild(new es3fApiCase.ApiCaseCallback('cull_face', 'Invalid gl.cullFace() usage', gl, function() { 168 bufferedLogToConsole('gl.INVALID_ENUM is generated if mode is not an accepted value.'); 169 gl.cullFace(-1); 170 this.expectError(gl.INVALID_ENUM); 171 172 })); 173 174 testGroup.addChild(new es3fApiCase.ApiCaseCallback('front_face', 'Invalid gl.frontFace() usage', gl, function() { 175 bufferedLogToConsole('gl.INVALID_ENUM is generated if mode is not an accepted value.'); 176 gl.frontFace(-1); 177 this.expectError(gl.INVALID_ENUM); 178 179 })); 180 181 testGroup.addChild(new es3fApiCase.ApiCaseCallback('line_width', 'Invalid gl.lineWidth() usage', gl, function() { 182 bufferedLogToConsole('gl.INVALID_VALUE is generated if width is less than or equal to 0.'); 183 gl.lineWidth(0); 184 this.expectError(gl.INVALID_VALUE); 185 gl.lineWidth(-1); 186 this.expectError(gl.INVALID_VALUE); 187 188 })); 189 190 testGroup.addChild(new es3fApiCase.ApiCaseCallback('begin_query', 'Invalid gl.beginQuery() usage', gl, function() { 191 /** @type{Array<WebGLQuery>} */ var ids = []; 192 ids[0] = gl.createQuery(); 193 ids[1] = gl.createQuery(); 194 ids[2] = gl.createQuery(); 195 196 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not one of the accepted tokens.'); 197 gl.beginQuery(-1, ids[0]); 198 this.expectError(gl.INVALID_ENUM); 199 200 bufferedLogToConsole('gl.INVALID_OPERATION is generated if gl.beginQuery is executed while a query object of the same target is already active.'); 201 gl.beginQuery(gl.ANY_SAMPLES_PASSED, ids[0]); 202 this.expectError(gl.NO_ERROR); 203 gl.beginQuery(gl.ANY_SAMPLES_PASSED, ids[1]); 204 this.expectError(gl.INVALID_OPERATION); 205 // \note gl.ANY_SAMPLES_PASSED and gl.ANY_SAMPLES_PASSED_CONSERVATIVE alias to the same target for the purposes of this error. 206 gl.beginQuery(gl.ANY_SAMPLES_PASSED_CONSERVATIVE, ids[1]); 207 this.expectError(gl.INVALID_OPERATION); 208 gl.beginQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[1]); 209 this.expectError(gl.NO_ERROR); 210 gl.beginQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[2]); 211 this.expectError(gl.INVALID_OPERATION); 212 gl.endQuery(gl.ANY_SAMPLES_PASSED); 213 gl.endQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN); 214 this.expectError(gl.NO_ERROR); 215 216 bufferedLogToConsole('An exception is thrown if the name is null.'); 217 this.expectThrowNoError(function() { 218 gl.beginQuery(gl.ANY_SAMPLES_PASSED, null); 219 }); 220 221 bufferedLogToConsole('gl.INVALID_OPERATION is generated if the name has since been deleted with gl.deleteQuery.'); 222 gl.deleteQuery(ids[2]); 223 this.expectError(gl.NO_ERROR); 224 gl.beginQuery(gl.ANY_SAMPLES_PASSED, ids[2]); 225 this.expectError(gl.INVALID_OPERATION); 226 227 bufferedLogToConsole('gl.INVALID_OPERATION is generated if id is the name of an already active query object.'); 228 gl.beginQuery(gl.ANY_SAMPLES_PASSED, ids[0]); 229 this.expectError(gl.NO_ERROR); 230 gl.beginQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[0]); 231 this.expectError(gl.INVALID_OPERATION); 232 233 bufferedLogToConsole('gl.INVALID_OPERATION is generated if id refers to an existing query object whose type does not does not match target.'); 234 gl.endQuery(gl.ANY_SAMPLES_PASSED); 235 this.expectError(gl.NO_ERROR); 236 gl.beginQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, ids[0]); 237 this.expectError(gl.INVALID_OPERATION); 238 239 gl.deleteQuery(ids[0]); 240 gl.deleteQuery(ids[1]); 241 gl.deleteQuery(ids[2]); 242 this.expectError(gl.NO_ERROR); 243 })); 244 245 testGroup.addChild(new es3fApiCase.ApiCaseCallback('end_query', 'Invalid gl.endQuery() usage', gl, function() { 246 /** @type{WebGLQuery} */ var id; 247 id = gl.createQuery(); 248 249 bufferedLogToConsole('gl.INVALID_ENUM is generated if target is not one of the accepted tokens.'); 250 gl.endQuery(-1); 251 this.expectError(gl.INVALID_ENUM); 252 253 bufferedLogToConsole('gl.INVALID_OPERATION is generated if gl.endQuery is executed when a query object of the same target is not active.'); 254 gl.endQuery(gl.ANY_SAMPLES_PASSED); 255 this.expectError(gl.INVALID_OPERATION); 256 gl.beginQuery(gl.ANY_SAMPLES_PASSED, id); 257 this.expectError(gl.NO_ERROR); 258 gl.endQuery(gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN); 259 this.expectError(gl.INVALID_OPERATION); 260 gl.endQuery(gl.ANY_SAMPLES_PASSED); 261 this.expectError(gl.NO_ERROR); 262 263 gl.deleteQuery(id); 264 this.expectError(gl.NO_ERROR); 265 })); 266 267 // Sync objects 268 269 testGroup.addChild(new es3fApiCase.ApiCaseCallback('fence_sync', 'Invalid gl.fenceSync() usage', gl, function() { 270 bufferedLogToConsole('gl.INVALID_ENUM is generated if condition is not gl.SYNC_GPU_COMMANDS_COMPLETE.'); 271 gl.fenceSync(-1, 0); 272 this.expectError(gl.INVALID_ENUM); 273 274 bufferedLogToConsole('gl.INVALID_VALUE is generated if flags is not zero.'); 275 gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0x0010); 276 this.expectError(gl.INVALID_VALUE); 277 278 })); 279 280 testGroup.addChild(new es3fApiCase.ApiCaseCallback('wait_sync', 'Invalid gl.waitSync() usage', gl, function() { 281 /** @type{WebGLSync} */ var sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0); 282 283 bufferedLogToConsole('An exception is thrown if sync is null.'); 284 this.expectThrowNoError(function() { 285 gl.waitSync(null, 0, gl.TIMEOUT_IGNORED); 286 }); 287 288 bufferedLogToConsole('gl.INVALID_VALUE is generated if flags is not zero.'); 289 gl.waitSync(sync, 0x0010, gl.TIMEOUT_IGNORED); 290 this.expectError(gl.INVALID_VALUE); 291 292 bufferedLogToConsole('gl.INVALID_VALUE is generated if timeout is not gl.TIMEOUT_IGNORED.'); 293 gl.waitSync(sync, 0, 0); 294 this.expectError(gl.INVALID_VALUE); 295 296 gl.deleteSync(sync); 297 })); 298 299 testGroup.addChild(new es3fApiCase.ApiCaseCallback('client_wait_sync', 'Invalid gl.clientWaitSync() usage', gl, function() { 300 /** @type{WebGLSync} */ var sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0); 301 302 bufferedLogToConsole('An exception is thrown if sync is null.'); 303 this.expectThrowNoError(function() { 304 gl.clientWaitSync (null, 0, 0); 305 }); 306 307 bufferedLogToConsole('gl.INVALID_VALUE is generated if flags contains any unsupported flag.'); 308 gl.clientWaitSync(sync, 0x00000004, 0); 309 this.expectError(gl.INVALID_VALUE); 310 311 gl.deleteSync(sync); 312 })); 313 314 }; 315 316 /** 317 * @param {WebGL2RenderingContext} gl 318 */ 319 es3fNegativeFragmentApiTests.run = function(gl) { 320 var testName = 'negativeFragmentApi'; 321 var testDescription = 'Negative Fragment API tests'; 322 var state = tcuTestCase.runner; 323 324 state.testName = testName; 325 state.testCases = tcuTestCase.newTest(testName, testDescription, null); 326 327 //Set up name and description of this test series. 328 setCurrentTestName(testName); 329 description(testDescription); 330 try { 331 es3fNegativeFragmentApiTests.init(gl); 332 tcuTestCase.runner.runCallback(tcuTestCase.runTestCases); 333 } catch (err) { 334 bufferedLogToConsole(err); 335 tcuTestCase.runner.terminate(); 336 } 337 }; 338 339 });