es3fStringQueryTests.js (4685B)
1 /*------------------------------------------------------------------------- 2 * drawElements Quality Program OpenGL ES Utilities 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 21 'use strict'; 22 goog.provide('functional.gles3.es3fStringQueryTests'); 23 goog.require('framework.common.tcuTestCase'); 24 goog.require('functional.gles3.es3fApiCase'); 25 26 goog.scope(function() { 27 var es3fStringQueryTests = functional.gles3.es3fStringQueryTests; 28 var tcuTestCase = framework.common.tcuTestCase; 29 var es3fApiCase = functional.gles3.es3fApiCase; 30 31 /** 32 * @constructor 33 * @extends {tcuTestCase.DeqpTest} 34 */ 35 es3fStringQueryTests.StringQueryTests = function() { 36 tcuTestCase.DeqpTest.call(this, 'string', 'String Query tests'); 37 }; 38 39 es3fStringQueryTests.StringQueryTests.prototype = Object.create(tcuTestCase.DeqpTest.prototype); 40 es3fStringQueryTests.StringQueryTests.prototype.constructor = es3fStringQueryTests.StringQueryTests; 41 42 es3fStringQueryTests.StringQueryTests.prototype.init = function() { 43 this.addChild(new es3fApiCase.ApiCaseCallback('renderer', 'RENDERER', gl, function() { 44 var string = /** @type {string} */ (gl.getParameter(gl.RENDERER)); 45 this.check(string !== null, 46 'Got invalid string: ' + string); 47 })); 48 49 this.addChild(new es3fApiCase.ApiCaseCallback('vendor', 'VENDOR', gl, function() { 50 var string = /** @type {string} */ (gl.getParameter(gl.VENDOR)); 51 this.check(string !== null, 52 'Got invalid string: ' + string); 53 })); 54 55 this.addChild(new es3fApiCase.ApiCaseCallback('version', 'VERSION', gl, function() { 56 var string = /** @type {string} */ (gl.getParameter(gl.VERSION)); 57 /** @type {string} */ var referenceString = 'WebGL 2.0'; 58 59 this.check(string !== null && string.indexOf(referenceString) === 0, 60 'Got invalid string prefix: ' + string + ' expected: ' + referenceString); 61 })); 62 63 this.addChild(new es3fApiCase.ApiCaseCallback('shading_language_version', 'SHADING_LANGUAGE_VERSION', gl, function() { 64 var string = /** @type {string} */ (gl.getParameter(gl.SHADING_LANGUAGE_VERSION)); 65 /** @type {string} */ var referenceString = 'WebGL GLSL ES 3.00'; 66 67 this.check(string !== null, 'Got invalid string'); 68 this.check(string.indexOf(referenceString) === 0, 'Got invalid string prefix'); 69 })); 70 71 this.addChild(new es3fApiCase.ApiCaseCallback('extensions', 'EXTENSIONS', gl, function() { 72 /** @type {Array<string>} */ var extensions = gl.getSupportedExtensions(); 73 this.check(extensions !== null, 'Got invalid string'); 74 75 // [dag] check that all extensions from gl.getSupportedExtensions() are found using gl.getExtension() 76 for (var i in extensions) { 77 /** @type {Object} */ var extension = gl.getExtension(extensions[i]); 78 this.check(extension !== null, 'Advertised extension ' + extensions[i] + ' not found'); 79 } 80 81 // [dag] check that gl.getExtension() returns null for items not in gl.getSupportedExtensions() 82 this.check(gl.getExtension('Random_String') === null, 'Extension query methods are not consistent.'); 83 })); 84 85 }; 86 87 /** 88 * Run test 89 * @param {WebGL2RenderingContext} context 90 */ 91 es3fStringQueryTests.run = function(context) { 92 gl = context; 93 //Set up Test Root parameters 94 var state = tcuTestCase.runner; 95 state.setRoot(new es3fStringQueryTests.StringQueryTests()); 96 97 //Set up name and description of this test series. 98 setCurrentTestName(state.testCases.fullName()); 99 description(state.testCases.getDescription()); 100 101 try { 102 //Run test cases 103 tcuTestCase.runTestCases(); 104 } 105 catch (err) { 106 testFailedOptions('Failed to es3fStringQueryTests.run tests', false); 107 tcuTestCase.runner.terminate(); 108 } 109 }; 110 111 });