From 3d90a9a0e8009119a7217aad4b9a8f4926d803fa Mon Sep 17 00:00:00 2001 From: zleoyu Date: Fri, 22 Jul 2022 18:09:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A6=86=E7=9B=96=E7=94=A8=E4=BE=8B=20WebGLCon?= =?UTF-8?q?textAttributes=E7=B1=BB=E4=B8=AD=E7=9A=84alpha=20depth=20stenci?= =?UTF-8?q?l=20powerPreference=20WebGLRenderingContextBase=E7=B1=BB?= =?UTF-8?q?=E4=B8=AD=E7=9A=84VIEWPORT=20BOOL=20SAMPLER=5FCUBE=20WebGL2Rend?= =?UTF-8?q?eringContextBase=E7=B1=BB=E4=B8=AD=E7=9A=84OBJECT=5FTYPE=20WebG?= =?UTF-8?q?LRenderingContextBase=E7=B1=BB=E4=B8=AD=E7=9A=84canvas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zleoyu Change-Id: Id4b9bf353be581367717c7b4b57b003656f009b3 --- .../src/main/js/default/test/WebGL.test01.js | 16 ++- .../src/main/js/default/test/WebGL.test14.js | 3 + .../src/main/js/default/test/WebGL.test15.js | 134 ++++++++++++++++++ .../src/main/js/default/test/webGL.test.js | 29 +++- 4 files changed, 170 insertions(+), 12 deletions(-) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test01.js b/graphic/webGL/src/main/js/default/test/WebGL.test01.js index 96a9f3028..c789ca97e 100644 --- a/graphic/webGL/src/main/js/default/test/WebGL.test01.js +++ b/graphic/webGL/src/main/js/default/test/WebGL.test01.js @@ -248,14 +248,14 @@ describe('webgl1Test_webgl2', function() { function initContext() { console.info('initContext start'); // 获取canvas元素 - const el = global.el; - const el2 = global.el2; + const canvas = global.el; + const canvas2 = global.el2; // 获取webgl上下文 - gl = el.getContext('webgl'); + gl = canvas.getContext('webgl'); if (!gl) { console.log('webgltest Failed to get the rendering context for WebGL'); } - gl2 = el2.getContext('webgl2'); + gl2 = canvas2.getContext('webgl2'); if (!gl) { console.log('webgltest Failed to get the rendering context for WebGL2'); } @@ -2004,8 +2004,14 @@ describe('webgl1Test_webgl2', function() { gl.STATIC_DRAW ); - var viewPortParameter = gl.getParameter(gl.MAX_VIEWPORT_DIMS); + var maxViewPortDimsParameter = gl.getParameter(gl.MAX_VIEWPORT_DIMS); + console.log('maxViewPortDimsParameter: ' + maxViewPortDimsParameter); + var viewPortParameter = gl.getParameter(gl.VIEWPORT); console.log('viewPortParameter: ' + viewPortParameter); + var boolParameter = gl.getParameter(gl.BOOL); + console.log('boolParameter: ' + boolParameter); + var SamplerCubeParameter = gl.getParameter(gl.SAMPLER_CUBE); + console.log('SamplerCubeParameter: ' + SamplerCubeParameter); const isContextLostValue = gl.isContextLost(); console.info("isContextLostValue: " + isContextLostValue); diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test14.js b/graphic/webGL/src/main/js/default/test/WebGL.test14.js index 786d7438e..5571eb900 100644 --- a/graphic/webGL/src/main/js/default/test/WebGL.test14.js +++ b/graphic/webGL/src/main/js/default/test/WebGL.test14.js @@ -947,6 +947,9 @@ describe('webgl1Test_webgl15', function() { var x8 = gl2.SYNC_FLAGS; expect(x8).assertEqual(37141); + var x9 = gl2.OBJECT_TYPE; + expect(x9).assertEqual(37138); + done(); }); }) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test15.js b/graphic/webGL/src/main/js/default/test/WebGL.test15.js index c87ab989c..502f1e177 100644 --- a/graphic/webGL/src/main/js/default/test/WebGL.test15.js +++ b/graphic/webGL/src/main/js/default/test/WebGL.test15.js @@ -380,4 +380,138 @@ describe('webgl1Test_webgl16', function() { expect(stencilMaskSeparateParameter).assertEqual(110101); done(); }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1338 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_0', 0, async function(done) { + console.info("webgltest into webglContextAttributes"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.alpha = true; + const alphaValue = ContextAttributesValue.alpha; + console.info("webgltest webglContextAttributes: " + alphaValue); + expect(alphaValue).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1339 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_1', 0, async function(done) { + console.info("webgltest into webglContextAttributes_1"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.antialias = true; + const antialiasValue = ContextAttributesValue.antialias; + console.info("webgltest webglContextAttributes_1: " + antialiasValue); + expect(antialiasValue).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1341 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_2', 0, async function(done) { + console.info("webgltest into webglContextAttributes_2"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.depth = true; + const depthValue = ContextAttributesValue.depth; + console.info("webgltest webglContextAttributes_2: " + depthValue); + expect(depthValue).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1342 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_3', 0, async function(done) { + console.info("webgltest into webglContextAttributes_3"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.failIfMajorPerformanceCaveat = false; + const failIfMajorPerformanceCaveatValue = ContextAttributesValue.failIfMajorPerformanceCaveat; + console.info("webgltest webglContextAttributes_3: " + failIfMajorPerformanceCaveatValue); + expect(failIfMajorPerformanceCaveatValue).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1343 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_4', 0, async function(done) { + console.info("webgltest into webglContextAttributes_4"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.desynchronized = false; + const desynchronizedValue = ContextAttributesValue.desynchronized; + console.info("webgltest webglContextAttributes_4: " + desynchronizedValue); + expect(desynchronizedValue).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1344 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_5', 0, async function(done) { + console.info("webgltest into webglContextAttributes_5"); + const ContextAttributesValue = gl.getContextAttributes(); + const powerPreferenceValue = ContextAttributesValue.powerPreference; + console.info("webgltest webglContextAttributes_5: " + powerPreferenceValue); + expect(powerPreferenceValue).assertEqual("default"); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1345 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_6', 0, async function(done) { + console.info("webgltest into webglContextAttributes_6"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.premultipliedAlpha = true; + const premultipliedAlphaValue = ContextAttributesValue.premultipliedAlpha; + console.info("webgltest webglContextAttributes_6: " + premultipliedAlphaValue); + expect(premultipliedAlphaValue).assertEqual(true); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1346 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_7', 0, async function(done) { + console.info("webgltest into webglContextAttributes_7"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.preserveDrawingBuffer = false; + const preserveDrawingBufferValue = ContextAttributesValue.preserveDrawingBuffer; + console.info("webgltest webglContextAttributes_7: " + preserveDrawingBufferValue); + expect(preserveDrawingBufferValue).assertEqual(false); + done(); + }) + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1347 + * @tc.name webgl_test_webglContextAttributes + * @tc.desc Test webglContextAttributes. + */ + it('webgl_test_webglContextAttributes_8', 0, async function(done) { + console.info("webgltest into webglContextAttributes_8"); + const ContextAttributesValue = gl.getContextAttributes(); + ContextAttributesValue.stencil = false; + const stencilValue = ContextAttributesValue.stencil; + console.info("webgltest webglContextAttributes_8: " + stencilValue); + expect(stencilValue).assertEqual(false); + done(); + }) }) diff --git a/graphic/webGL/src/main/js/default/test/webGL.test.js b/graphic/webGL/src/main/js/default/test/webGL.test.js index b3e9c2ee1..a9e84e943 100644 --- a/graphic/webGL/src/main/js/default/test/webGL.test.js +++ b/graphic/webGL/src/main/js/default/test/webGL.test.js @@ -1996,8 +1996,14 @@ describe('webgl1Test_webgl1', function() { return; } - var viewPortParameter = gl.getParameter(gl.MAX_VIEWPORT_DIMS); + var maxViewPortDimsParameter = gl.getParameter(gl.MAX_VIEWPORT_DIMS); + console.log('maxViewPortDimsParameter: ' + maxViewPortDimsParameter); + var viewPortParameter = gl.getParameter(gl.VIEWPORT); console.log('viewPortParameter: ' + viewPortParameter); + var boolParameter = gl.getParameter(gl.BOOL); + console.log('boolParameter: ' + boolParameter); + var SamplerCubeParameter = gl.getParameter(gl.SAMPLER_CUBE); + console.log('SamplerCubeParameter: ' + SamplerCubeParameter); const isContextLostValue = gl.isContextLost(); console.info("isContextLostValue: " + isContextLostValue); @@ -27024,9 +27030,11 @@ describe('webgl1Test_webgl1', function() { gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_INT).rangeMin; const min = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_INT).rangeMin; const max = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT).rangeMax; + const precision = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT).precision; expect(min).assertEqual(24); expect(max).assertEqual(127); - done(); + expect(precision).assertEqual(23); + done(); }); /** @@ -27152,6 +27160,9 @@ describe('webgl1Test_webgl1', function() { var x8 = gl2.SYNC_FLAGS; expect(x8).assertEqual(37141); + + var x9 = gl2.OBJECT_TYPE; + expect(x9).assertEqual(37138); done(); @@ -27165,11 +27176,15 @@ describe('webgl1Test_webgl1', function() { it('testAttributeBase', 0, async function(done) { console.info('jsWebGL testAttributeBase test start'); var attribute = gl.getContextAttributes(); - expect(atttribute.desynchronized).assertEqual(false); - expect(atttribute.antialias).assertEqual(true); - expect(atttribute.premultipliedAlpha).assertEqual(true); - expect(atttribute.preserveDrawingBuffer).assertEqual(false); - expect(atttribute.failIfMajorPerformanceCaveat).assertEqual(false); + expect(attribute.alpha).assertEqual(true); + expect(attribute.antialias).assertEqual(true); + expect(attribute.depth).assertEqual(true); + expect(attribute.failIfMajorPerformanceCaveat).assertEqual(false); + expect(attribute.desynchronized).assertEqual(false); + expect(attribute.premultipliedAlpha).assertEqual(true); + expect(attribute.preserveDrawingBuffer).assertEqual(false); + expect(attribute.powerPreference).assertEqual("default"); + expect(attribute.stencil).assertEqual(false); done() }); }) -- GitLab