• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import hilog from '@ohos.hilog';
17import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType, Level, Size } from '@ohos/hypium';
18
19import {checkError, createProgram, getColorUint8Array} from './WebGL1';
20
21
22export default function webgl1_attribute() {
23
24	describe('webgl1_attribute', function () {
25        let gl = global.gl;
26        // Defines a test suite. Two parameters are supported: test suite name and test suite function.
27        beforeAll(function () {
28            hilog.info(0x0000, 'testTag', '%{public}s', 'webgl1_test_01 start');
29            // Presets an action, which is performed only once before all test cases of the test suite start.
30            // This API supports only one parameter: preset action function.
31        })
32        beforeEach(function () {
33            // Presets an action, which is performed before each unit test case starts.
34            // The number of execution times is the same as the number of test cases defined by **it**.
35            // This API supports only one parameter: preset action function.
36            checkError(gl);
37        })
38        afterEach(function () {
39            // Presets a clear action, which is performed after each unit test case ends.
40            // The number of execution times is the same as the number of test cases defined by **it**.
41            // This API supports only one parameter: clear action function.
42            checkError(gl);
43        })
44        afterAll(function () {
45            // Presets a clear action, which is performed after all test cases of the test suite end.
46            // This API supports only one parameter: clear action function.
47            hilog.info(0x0000, 'testTag', '%{public}s', 'webgl1_test_01 end');
48        })
49
50        let getVertexAttribDesc = (attrib) => {
51            // 返回当前绑定的 WebGLBuffer。
52            let bufferBinding = gl.getVertexAttrib(attrib, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
53            // 返回一个 GLint,指示顶点数组元素的大小。
54            let size = gl.getVertexAttrib(attrib, gl.VERTEX_ATTRIB_ARRAY_SIZE);
55            // 返回一个 GLboolean,如果在此索引处启用了顶点属性,则该 GLboolean 为 true。 否则为假。
56            let enable = gl.getVertexAttrib(attrib, gl.VERTEX_ATTRIB_ARRAY_ENABLED);
57            // 返回一个 GLint,指示数组中连续元素之间的字节数。 0 表示元素是连续的。
58            let stride = gl.getVertexAttrib(attrib, gl.VERTEX_ATTRIB_ARRAY_STRIDE);
59            // 返回表示数组类型的 GLenum。 其中之一 gl.BYTE  gl.UNSIGNED_BYTE gl.SHORT,gl.UNSIGNED_SHORT gl.FLOAT
60            let type = gl.getVertexAttrib(attrib, gl.VERTEX_ATTRIB_ARRAY_TYPE);
61            // 返回一个 GLboolean,如果对给定索引处的顶点属性数组规范化定点数据类型,则该 GLboolean 为 true。
62            let normalized = gl.getVertexAttrib(attrib, gl.VERTEX_ATTRIB_ARRAY_NORMALIZED)
63            // 返回一个 Float32Array(包含 4 个元素),表示给定索引处顶点属性的当前值。
64            let vertex = gl.getVertexAttrib(attrib, gl.CURRENT_VERTEX_ATTRIB);
65            return {bufferBinding, size, enable, stride, type, normalized, vertex}
66        }
67
68        function getAttribLocationTemp(callback, finish) {
69            let vSource = `
70            attribute vec4 a_Position;
71            attribute float a_PointSize;
72            void main(){
73                gl_Position = a_Position;
74                gl_PointSize = a_PointSize;
75            }
76        `;
77            let fSource = `
78            precision mediump float;
79            uniform vec4 u_FragColor;
80            void main(){
81                gl_FragColor = u_FragColor;
82            }
83        `
84            let p = createProgram(gl, vSource, fSource);
85            callback(p);
86            gl.deleteShader(p.vertexShader);
87            gl.deleteShader(p.fragmentShader);
88            gl.deleteProgram(p.program);
89            if (finish) finish();
90        }
91
92        /**
93         * 验证此方法是否返回了给定WebGLProgram对象中某属性的下标指向位置
94         */
95
96        /**
97         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0001
98         * @tc.name webgl_test_getAttribLocation
99         * @tc.desc Test getAttribLocation.
100         */
101        it('webgl_test_getAttribLocation', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
102            console.info("webgltest [webgl_test_getAttribLocation] getAttribLocation");
103            let vSource = `
104            attribute vec4 a_Position;
105            attribute float a_PointSize;
106            void main(){
107                gl_Position = a_Position;
108                gl_PointSize = a_PointSize;
109            }
110        `;
111            let fSource = `
112            precision mediump float;
113            uniform vec4 u_FragColor;
114            void main(){
115                gl_FragColor = u_FragColor;
116            }
117        `
118            let p = createProgram(gl, vSource, fSource);
119            let a_Position = gl.getAttribLocation(p.program, "a_Position");
120            console.info("webgltest vertexShader source :", vSource);
121            console.info("webgltest attribute a_Position:", a_Position);
122            expect(a_Position >= 0).assertTrue();
123            let a_PositionErr = gl.getAttribLocation(p.program, "a_Position_Err");
124            console.info("webgltest attribute a_PositionErr:", a_PositionErr);
125            expect(a_PositionErr).assertEqual(-1);
126            gl.deleteShader(p.vertexShader);
127            gl.deleteShader(p.fragmentShader);
128            gl.deleteProgram(p.program);
129            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
130            done();
131        })
132
133        /**
134         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0002
135         * @tc.name webgl_test_getAttribLocation_1
136         * @tc.desc Test getAttribLocation.
137         */
138        it('webgl_test_getAttribLocation_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
139            async function (done) {
140            console.info("webgltest [webgl_test_getAttribLocation_1] getAttribLocation");
141            getAttribLocationTemp((p) => {
142                let attr = gl.getAttribLocation(p.program, 0);
143                console.info("webgltest ", attr);
144                expect(attr).assertEqual(-1);
145                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
146            });
147            done();
148        })
149
150        /**
151         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0003
152         * @tc.name webgl_test_getAttribLocation_2
153         * @tc.desc Test getAttribLocation.
154         */
155        it('webgl_test_getAttribLocation_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
156            async function (done) {
157            console.info("webgltest [webgl_test_getAttribLocation_1] getAttribLocation");
158            getAttribLocationTemp((p) => {
159                let attr = gl.getAttribLocation(p.program, undefined);
160                console.info("webgltest ", attr);
161                expect(attr).assertEqual(-1);
162                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
163            });
164            done();
165        })
166
167        /**
168         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0004
169         * @tc.name webgl_test_getAttribLocation_3
170         * @tc.desc Test getAttribLocation.
171         */
172        it('webgl_test_getAttribLocation_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
173            async function (done) {
174            console.info("webgltest [webgl_test_getAttribLocation_1] getAttribLocation");
175            getAttribLocationTemp((p) => {
176                let attr = gl.getAttribLocation(p.program, null);
177                console.info("webgltest ", attr);
178                expect(attr).assertEqual(-1);
179                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
180            });
181            done();
182        })
183
184        /**
185         * 验证getActiveAttrib方法是否返回一个WebGLActiveInfo对象,
186         * 并包含在WebGLProgram中给到位置的一个顶点属性的尺寸、类型和名称。
187         */
188        function getActiveAttrib(callback, finish) {
189            let vSource = `
190            attribute vec4 a_Position;
191            void main(){
192                gl_Position = a_Position;
193                gl_PointSize = 10.0;
194            }
195        `;
196            let fSource = `
197            precision mediump float;
198            uniform vec4 u_FragColor;
199            void main(){
200                gl_FragColor = u_FragColor;
201            }
202        `
203            let p = createProgram(gl, vSource, fSource);
204            callback(p);
205            gl.deleteShader(p.vertexShader);
206            gl.deleteShader(p.fragmentShader);
207            gl.deleteProgram(p.program);
208            if (finish) finish();
209        }
210
211
212        /**
213         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0005
214         * @tc.name webgl_test_getActiveAttrib
215         * @tc.desc Test getActiveAttrib.
216         */
217        it('webgl_test_getActiveAttrib', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
218            console.info("webgltest [webgl_test_getActiveAttrib] getActiveAttrib");
219            let vSource = `
220            attribute vec4 a_Position;
221            void main(){
222                gl_Position = a_Position;
223                gl_PointSize = 10.0;
224            }
225        `;
226            let fSource = `
227            precision mediump float;
228            uniform vec4 u_FragColor;
229            void main(){
230                gl_FragColor = u_FragColor;
231            }
232        `
233            let p = createProgram(gl, vSource, fSource);
234
235            console.info("webgltest vertex shader source:", vSource);
236            let attribCount = gl.getProgramParameter(p.program, gl.ACTIVE_ATTRIBUTES);
237            console.info("webgltest attribCount:", attribCount);
238            let activeAttrib = gl.getActiveAttrib(p.program, 0);
239            console.info("webgltest ", activeAttrib);
240            expect(activeAttrib.name).assertEqual("a_Position");
241            expect(activeAttrib.type).assertEqual(gl.FLOAT_VEC4);
242            gl.deleteShader(p.vertexShader);
243            gl.deleteShader(p.fragmentShader);
244            gl.deleteProgram(p.program);
245            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
246            done();
247        })
248
249        /**
250         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0006
251         * @tc.name webgl_test_getActiveAttrib_1
252         * @tc.desc Test getActiveAttrib.
253         */
254        it('webgl_test_getActiveAttrib_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
255            console.info("webgltest [webgl_test_getActiveAttrib_1] getActiveAttrib");
256            getActiveAttrib((p) => {
257                let activeAttrib = gl.getActiveAttrib(p.program, 10);
258                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
259                console.info("webgltest ", activeAttrib);
260                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
261            });
262            done();
263        })
264
265
266        /**
267         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0007
268         * @tc.name webgl_test_getActiveAttrib_2
269         * @tc.desc Test getActiveAttrib.
270         */
271        it('webgl_test_getActiveAttrib_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
272            console.info("webgltest [webgl_test_getActiveAttrib_2] getActiveAttrib");
273            getActiveAttrib((p) => {
274                let activeAttrib = gl.getActiveAttrib(p.program, null);
275                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
276                console.info("webgltest ", activeAttrib);
277                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
278            });
279            done();
280        })
281
282
283        /**
284         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0008
285         * @tc.name webgl_test_getActiveAttrib_3
286         * @tc.desc Test getActiveAttrib.
287         */
288        it('webgl_test_getActiveAttrib_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
289            console.info("webgltest [webgl_test_getActiveAttrib_3] getActiveAttrib");
290            getActiveAttrib((p) => {
291                let activeAttrib = gl.getActiveAttrib(p.program, -1);
292                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
293                console.info("webgltest ", activeAttrib);
294                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
295            });
296            done();
297        })
298
299        /**
300         * 验证vertexAttrib1f方法是否可以给顶点 attibute 变量的1个分量赋值
301         */
302        function vertexAttrib1f(callback, finish) {
303            let vSource = `
304            attribute float a_PointSize;
305            void main(){
306                gl_Position = vec4(0.5, 0.5, 1, 1.0);
307                gl_PointSize = a_PointSize;
308            }
309        `;
310            let fSource = `
311            precision mediump float;
312            uniform vec4 u_FragColor;
313            void main(){
314                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
315            }
316        `
317            let p = createProgram(gl, vSource, fSource);
318            callback(p);
319            gl.deleteShader(p.vertexShader);
320            gl.deleteShader(p.fragmentShader);
321            gl.deleteProgram(p.program);
322            if (finish) finish();
323        }
324
325
326        /**
327         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0009
328         * @tc.name webgl_test_vertexAttrib1f
329         * @tc.desc Test vertexAttrib1f.
330         */
331        it('webgl_test_vertexAttrib1f', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
332            console.info("webgltest [webgl_test_vertexAttrib1f] vertexAttrib1f");
333            let vSource = `
334            attribute float a_PointSize;
335            void main(){
336                gl_Position = vec4(0.5, 0.5, 1, 1.0);
337                gl_PointSize = a_PointSize;
338            }
339        `;
340            let fSource = `
341            precision mediump float;
342            uniform vec4 u_FragColor;
343            void main(){
344                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
345            }
346        `
347            let p = createProgram(gl, vSource, fSource);
348            console.info("webgltest vertex shader source:", vSource);
349            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
350            console.info("webgltest vertexAttrib1f( 100.0) ");
351            gl.vertexAttrib1f(a_PointSize, 100.0);
352            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
353            console.log(vertexAttrib);
354            console.info("webgltest a_PointSize value: ", vertexAttrib[0]);
355            expect(vertexAttrib[0]).assertEqual(100);
356            gl.deleteShader(p.vertexShader);
357            gl.deleteShader(p.fragmentShader);
358            gl.deleteProgram(p.program);
359            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
360            done();
361        })
362
363
364        /**
365         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0010
366         * @tc.name webgl_test_vertexAttrib1f_1
367         * @tc.desc Test vertexAttrib1f.
368         */
369        it('webgl_test_vertexAttrib1f_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
370            console.info("webgltest [webgl_test_vertexAttrib1f_1] vertexAttrib1f");
371            vertexAttrib1f((p) => {
372                let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
373                gl.vertexAttrib1f(a_PointSize, 100);
374                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
375            })
376            done();
377        })
378
379
380        /**
381         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0011
382         * @tc.name webgl_test_vertexAttrib1f_2
383         * @tc.desc Test vertexAttrib1f.
384         */
385        it('webgl_test_vertexAttrib1f_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
386            console.info("webgltest [webgl_test_vertexAttrib1f_1] vertexAttrib1f");
387            vertexAttrib1f((p) => {
388                let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
389                gl.vertexAttrib1f(a_PointSize, null);
390                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
391            })
392            done();
393        })
394
395
396        /**
397         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0012
398         * @tc.name webgl_test_vertexAttrib1f_3
399         * @tc.desc Test vertexAttrib1f.
400         */
401        it('webgl_test_vertexAttrib1f_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
402            console.info("webgltest [webgl_test_vertexAttrib1f_1] vertexAttrib1f");
403            vertexAttrib1f((p) => {
404                let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
405                gl.vertexAttrib1f(a_PointSize, -100);
406                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
407            })
408            done();
409        })
410
411
412        /**
413         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0013
414         * @tc.name webgl_test_vertexAttrib1f_4
415         * @tc.desc Test vertexAttrib1f.
416         */
417        it('webgl_test_vertexAttrib1f_4', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
418            console.info("webgltest [webgl_test_vertexAttrib1f_4] vertexAttrib1f");
419            vertexAttrib1f((p) => {
420                let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
421                gl.vertexAttrib1f(null, null);
422                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
423            })
424            done();
425        })
426
427        /**
428         * 验证vertexAttrib2f方法是否可以给顶点 attibute 变量的2个分量赋值
429         */
430        function vertexAttrib2f(callback, verify) {
431            let vSource = `
432            attribute float a_PointSize;
433            void main(){
434                gl_Position = vec4(0.5, 0.5, 1, 1.0);
435                gl_PointSize = a_PointSize;
436            }
437        `;
438            let fSource = `
439            precision mediump float;
440            uniform vec4 u_FragColor;
441            void main(){
442                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
443            }
444        `
445            let p = createProgram(gl, vSource, fSource);
446            console.info("webgltest vertex shader source:", vSource);
447            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
448            callback(a_PointSize);
449            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
450            console.info("webgltest a_PointSize value: ", vertexAttrib);
451            verify(vertexAttrib);
452            gl.deleteShader(p.vertexShader);
453            gl.deleteShader(p.fragmentShader);
454            gl.deleteProgram(p.program);
455        }
456
457
458        /**
459         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0014
460         * @tc.name webgl_test_vertexAttrib2f
461         * @tc.desc Test vertexAttrib2f.
462         */
463        it('webgl_test_vertexAttrib2f', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
464            console.info("webgltest [webgl_test_vertexAttrib2f] vertexAttrib2f");
465            let vSource = `
466            attribute float a_PointSize;
467            void main(){
468                gl_Position = vec4(0.5, 0.5, 1, 1.0);
469                gl_PointSize = a_PointSize;
470            }
471        `;
472            let fSource = `
473            precision mediump float;
474            uniform vec4 u_FragColor;
475            void main(){
476                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
477            }
478        `
479            let p = createProgram(gl, vSource, fSource);
480            console.info("webgltest vertex shader source:", vSource);
481            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
482            console.info("webgltest vertexAttrib2f( 100.0, 100.0) ");
483            gl.vertexAttrib2f(a_PointSize, 100.0, 100);
484            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
485            console.info("webgltest a_PointSize value: ", vertexAttrib);
486            expect(vertexAttrib[0]).assertEqual(100);
487            expect(vertexAttrib[1]).assertEqual(100);
488            gl.deleteShader(p.vertexShader);
489            gl.deleteShader(p.fragmentShader);
490            gl.deleteProgram(p.program);
491            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
492            done();
493        })
494
495
496        /**
497         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0015
498         * @tc.name webgl_test_vertexAttrib2f_1
499         * @tc.desc Test vertexAttrib2f.
500         */
501        it('webgl_test_vertexAttrib2f_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
502            console.info("webgltest [webgl_test_vertexAttrib2f_1] vertexAttrib2f");
503            vertexAttrib2f((attrib) => {
504                gl.vertexAttrib2f(attrib, null, null);
505            }, (attrib) => {
506                expect(attrib[0]).assertEqual(0);
507                expect(attrib[1]).assertEqual(0);
508                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
509            });
510            done();
511        })
512
513
514        /**
515         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0016
516         * @tc.name webgl_test_vertexAttrib2f_2
517         * @tc.desc Test vertexAttrib2f.
518         */
519        it('webgl_test_vertexAttrib2f_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
520            console.info("webgltest [webgl_test_vertexAttrib2f_2] vertexAttrib2f");
521            vertexAttrib2f((attrib) => {
522                gl.vertexAttrib2f(attrib, -100, -100);
523            }, (attrib) => {
524                expect(attrib[0]).assertEqual(-100);
525                expect(attrib[1]).assertEqual(-100);
526                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
527            });
528            done();
529        })
530
531
532        /**
533         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0017
534         * @tc.name webgl_test_vertexAttrib2f_3
535         * @tc.desc Test vertexAttrib2f.
536         */
537        it('webgl_test_vertexAttrib2f_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
538            console.info("webgltest [webgl_test_vertexAttrib2f_3] vertexAttrib2f");
539            vertexAttrib2f((attrib) => {
540                gl.vertexAttrib2f(-1, -200, -100);
541                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
542            }, (attrib) => {
543                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
544            });
545            done();
546        })
547
548        /**
549         * 验证vertexAttrib3f方法是否可以给顶点 attibute 变量的3个分量赋值
550         */
551        function vertexAttrib3f(callback, finish) {
552            let vSource = `
553            attribute float a_PointSize;
554            void main(){
555                gl_Position = vec4(0.5, 0.5, 1, 1.0);
556                gl_PointSize = a_PointSize;
557            }
558        `;
559            let fSource = `
560            precision mediump float;
561            uniform vec4 u_FragColor;
562            void main(){
563                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
564            }
565        `
566            let p = createProgram(gl, vSource, fSource);
567            console.info("webgltest vertex shader source:", vSource);
568            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
569            callback(a_PointSize);
570            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
571            finish(vertexAttrib);
572            gl.deleteShader(p.vertexShader);
573            gl.deleteShader(p.fragmentShader);
574            gl.deleteProgram(p.program);
575        }
576
577
578        /**
579         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0018
580         * @tc.name webgl_test_vertexAttrib3f
581         * @tc.desc Test vertexAttrib3f.
582         */
583        it('webgl_test_vertexAttrib3f', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
584            console.info("webgltest [webgl_test_vertexAttrib3f] vertexAttrib3f");
585            let vSource = `
586            attribute float a_PointSize;
587            void main(){
588                gl_Position = vec4(0.5, 0.5, 1, 1.0);
589                gl_PointSize = a_PointSize;
590            }
591        `;
592            let fSource = `
593            precision mediump float;
594            uniform vec4 u_FragColor;
595            void main(){
596                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
597            }
598        `
599            let p = createProgram(gl, vSource, fSource);
600            console.info("webgltest vertex shader source:", vSource);
601            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
602            console.info("webgltest vertexAttrib3f( 100.0, 100.0, 100.0) ");
603            gl.vertexAttrib3f(a_PointSize, 100.0, 100.0, 100.0);
604            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
605            console.info("webgltest a_PointSize value: ", vertexAttrib);
606            expect(vertexAttrib[0]).assertEqual(100);
607            expect(vertexAttrib[1]).assertEqual(100);
608            expect(vertexAttrib[2]).assertEqual(100);
609            gl.deleteShader(p.vertexShader);
610            gl.deleteShader(p.fragmentShader);
611            gl.deleteProgram(p.program);
612            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
613            done();
614        })
615
616
617        /**
618         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0019
619         * @tc.name webgl_test_vertexAttrib3f_1
620         * @tc.desc Test vertexAttrib3f.
621         */
622        it('webgl_test_vertexAttrib3f_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
623            console.info("webgltest [webgl_test_vertexAttrib3f_1] vertexAttrib3f");
624            vertexAttrib3f((attrib) => {
625                gl.vertexAttrib3f(attrib, null, null, null);
626                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
627            }, (attrib) => {
628                expect(attrib[0]).assertEqual(0);
629                expect(attrib[1]).assertEqual(0);
630                expect(attrib[2]).assertEqual(0);
631                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
632            })
633            done();
634        })
635
636
637        /**
638         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0020
639         * @tc.name webgl_test_vertexAttrib3f_2
640         * @tc.desc Test vertexAttrib3f.
641         */
642        it('webgl_test_vertexAttrib3f_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
643            console.info("webgltest [webgl_test_vertexAttrib3f_2] vertexAttrib3f");
644            vertexAttrib3f((attrib) => {
645                gl.vertexAttrib3f(attrib, -1, -1, -1);
646                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
647            }, (attrib) => {
648                expect(attrib[0]).assertEqual(-1);
649                expect(attrib[1]).assertEqual(-1);
650                expect(attrib[2]).assertEqual(-1);
651                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
652            })
653            done();
654        })
655
656
657        /**
658         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0021
659         * @tc.name webgl_test_vertexAttrib3f_3
660         * @tc.desc Test vertexAttrib3f.
661         */
662        it('webgl_test_vertexAttrib3f_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
663            console.info("webgltest [webgl_test_vertexAttrib3f_3] vertexAttrib3f");
664            vertexAttrib3f((attrib) => {
665                gl.vertexAttrib3f(attrib, undefined, undefined, undefined);
666                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
667            }, (attrib) => {
668                expect(attrib[0].toString()).assertEqual("NaN");
669                expect(attrib[1].toString()).assertEqual("NaN");
670                expect(attrib[2].toString()).assertEqual("NaN");
671                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
672            })
673            done();
674        })
675
676
677        /**
678         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0022
679         * @tc.name webgl_test_vertexAttrib3f_4
680         * @tc.desc Test vertexAttrib3f.
681         */
682        it('webgl_test_vertexAttrib3f_4', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
683            console.info("webgltest [webgl_test_vertexAttrib3f_4] vertexAttrib3f");
684            vertexAttrib3f((attrib) => {
685                gl.vertexAttrib3f(-1, null, null, null);
686                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
687            }, (attrib) => {
688                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
689            })
690            done();
691        })
692
693        /**
694         * 验证vertexAttrib4f方法是否可以给顶点 attibute 变量的4个分量赋值
695         */
696        function vertexAttrib4f(callback, finish) {
697            let vSource = `
698            attribute float a_PointSize;
699            void main(){
700                gl_Position = vec4(0.5, 0.5, 1, 1.0);
701                gl_PointSize = a_PointSize;
702            }
703        `;
704            let fSource = `
705            precision mediump float;
706            uniform vec4 u_FragColor;
707            void main(){
708                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
709            }
710        `
711            let p = createProgram(gl, vSource, fSource);
712            console.info("webgltest vertex shader source:", vSource);
713            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
714            callback(a_PointSize);
715            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
716            finish(vertexAttrib);
717            gl.deleteShader(p.vertexShader);
718            gl.deleteShader(p.fragmentShader);
719            gl.deleteProgram(p.program);
720        }
721
722
723        /**
724         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0023
725         * @tc.name webgl_test_vertexAttrib4f
726         * @tc.desc Test vertexAttrib4f.
727         */
728        it('webgl_test_vertexAttrib4f', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
729            console.info("webgltest [webgl_test_vertexAttrib4f] vertexAttrib4f");
730            let vSource = `
731            attribute float a_PointSize;
732            void main(){
733                gl_Position = vec4(0.5, 0.5, 1, 1.0);
734                gl_PointSize = a_PointSize;
735            }
736        `;
737            let fSource = `
738            precision mediump float;
739            uniform vec4 u_FragColor;
740            void main(){
741                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
742            }
743        `
744            let p = createProgram(gl, vSource, fSource);
745            console.info("webgltest vertex shader source:", vSource);
746            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
747            console.info("webgltest vertexAttrib4f( 100.0, 100.0, 100.0,100.0) ");
748            gl.vertexAttrib4f(a_PointSize, 100.0, 100.0, 100.0, 100.0);
749            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
750            console.info("webgltest a_PointSize value: ", vertexAttrib);
751            expect(vertexAttrib[0]).assertEqual(100);
752            expect(vertexAttrib[1]).assertEqual(100);
753            expect(vertexAttrib[2]).assertEqual(100);
754            expect(vertexAttrib[3]).assertEqual(100);
755            gl.deleteShader(p.vertexShader);
756            gl.deleteShader(p.fragmentShader);
757            gl.deleteProgram(p.program);
758            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
759            done();
760        })
761
762
763        /**
764         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0024
765         * @tc.name webgl_test_vertexAttrib4f_1
766         * @tc.desc Test vertexAttrib4f.
767         */
768        it('webgl_test_vertexAttrib4f_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
769            console.info("webgltest [webgl_test_vertexAttrib4f_1] vertexAttrib4f");
770            vertexAttrib4f((attrib) => {
771                gl.vertexAttrib4f(attrib, null, null, null, null);
772                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
773            }, (attrib) => {
774                expect(attrib[0]).assertEqual(0);
775                expect(attrib[1]).assertEqual(0);
776                expect(attrib[2]).assertEqual(0);
777                expect(attrib[3]).assertEqual(0);
778                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
779            })
780            done();
781        })
782
783
784        /**
785         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0025
786         * @tc.name webgl_test_vertexAttrib4f_2
787         * @tc.desc Test vertexAttrib4f.
788         */
789        it('webgl_test_vertexAttrib4f_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
790            console.info("webgltest [webgl_test_vertexAttrib4f_2] vertexAttrib4f");
791            vertexAttrib4f((attrib) => {
792                gl.vertexAttrib4f(attrib, -1, -1, -1, -1);
793                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
794            }, (attrib) => {
795                expect(attrib[0]).assertEqual(-1);
796                expect(attrib[1]).assertEqual(-1);
797                expect(attrib[2]).assertEqual(-1);
798                expect(attrib[3]).assertEqual(-1);
799                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
800            })
801            done();
802        })
803
804
805        /**
806         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0026
807         * @tc.name webgl_test_vertexAttrib4f_3
808         * @tc.desc Test vertexAttrib4f.
809         */
810        it('webgl_test_vertexAttrib4f_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
811            console.info("webgltest [webgl_test_vertexAttrib4f_3] vertexAttrib4f");
812            vertexAttrib4f((attrib) => {
813                gl.vertexAttrib4f(attrib, undefined, undefined, undefined, undefined);
814                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
815            }, (attrib) => {
816                expect(attrib[0].toString()).assertEqual("NaN");
817                expect(attrib[1].toString()).assertEqual("NaN");
818                expect(attrib[2].toString()).assertEqual("NaN");
819                expect(attrib[3].toString()).assertEqual("NaN");
820                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
821            })
822            done();
823        })
824
825
826        /**
827         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0027
828         * @tc.name webgl_test_vertexAttrib4f_4
829         * @tc.desc Test vertexAttrib4f.
830         */
831        it('webgl_test_vertexAttrib4f_4', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
832            console.info("webgltest [webgl_test_vertexAttrib4f_4] vertexAttrib4f");
833            vertexAttrib4f((attrib) => {
834                gl.vertexAttrib4f(-1, 0, 0, 0, 0);
835                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
836            }, (attrib) => {
837                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
838            })
839            done();
840        })
841
842        /**
843         * 验证vertexAttrib1fv方法是否可以给顶点 attibute 变量的第一个向量值
844         */
845        function vertexAttrib1fv(callback, finish) {
846            let vSource = `
847            attribute float a_PointSize;
848            void main(){
849                gl_Position = vec4(0.5, 0.5, 1, 1.0);
850                gl_PointSize = a_PointSize;
851            }
852        `;
853            let fSource = `
854            precision mediump float;
855            uniform vec4 u_FragColor;
856            void main(){
857                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
858            }
859        `
860            let p = createProgram(gl, vSource, fSource);
861            console.info("webgltest vertex shader source:", vSource);
862            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
863            callback(a_PointSize);
864            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
865            finish(vertexAttrib);
866            gl.deleteShader(p.vertexShader);
867            gl.deleteShader(p.fragmentShader);
868            gl.deleteProgram(p.program);
869        }
870
871
872        /**
873         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0028
874         * @tc.name webgl_test_vertexAttrib1fv
875         * @tc.desc Test vertexAttrib1fv.
876         */
877        it('webgl_test_vertexAttrib1fv', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
878            console.info("webgltest [webgl_test_vertexAttrib1fv] vertexAttrib1fv");
879            let vSource = `
880            attribute float a_PointSize;
881            void main(){
882                gl_Position = vec4(0.5, 0.5, 1, 1.0);
883                gl_PointSize = a_PointSize;
884            }
885        `;
886            let fSource = `
887            precision mediump float;
888            uniform vec4 u_FragColor;
889            void main(){
890                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
891            }
892        `
893            let p = createProgram(gl, vSource, fSource);
894            console.info("webgltest vertex shader source:", vSource);
895            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
896            console.info("webgltest vertexAttrib1fv(a_PointSize,new Float32Array([100.0, 100.0, 100.0, 100.0])) ");
897            gl.vertexAttrib1fv(a_PointSize, new Float32Array([100.0, 100.0, 100.0, 100.0]));
898            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
899            console.info("webgltest a_PointSize value: ", vertexAttrib);
900            expect(vertexAttrib[0]).assertEqual(100);
901            expect(vertexAttrib[1] != 100).assertTrue();
902            expect(vertexAttrib[2] != 100).assertTrue();
903            expect(vertexAttrib[3] != 100).assertTrue();
904            gl.deleteShader(p.vertexShader);
905            gl.deleteShader(p.fragmentShader);
906            gl.deleteProgram(p.program);
907            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
908            done();
909        })
910
911
912        /**
913         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0029
914         * @tc.name webgl_test_vertexAttrib1fv_1
915         * @tc.desc Test vertexAttrib1fv.
916         */
917        it('webgl_test_vertexAttrib1fv_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
918            console.info("webgltest [webgl_test_vertexAttrib1fv_1] vertexAttrib1fv");
919            vertexAttrib1fv((attrib) => {
920                gl.vertexAttrib1fv(attrib, new Float32Array([-100.0]));
921                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
922            }, (attrib) => {
923                expect(attrib[0]).assertEqual(-100);
924                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
925            })
926            done();
927        })
928
929        /**
930         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0030
931         * @tc.name webgl_test_vertexAttrib1fv_2
932         * @tc.desc Test vertexAttrib1fv.
933         */
934        it('webgl_test_vertexAttrib1fv_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
935            console.info("webgltest [webgl_test_vertexAttrib1fv_2] vertexAttrib1fv");
936            vertexAttrib1fv((attrib) => {
937                gl.vertexAttrib1fv(attrib, new Float32Array([undefined]));
938                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
939            }, (attrib) => {
940                expect(attrib[0].toString()).assertEqual("NaN");
941                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
942            })
943            done();
944        })
945
946        /**
947         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0031
948         * @tc.name webgl_test_vertexAttrib1fv_3
949         * @tc.desc Test vertexAttrib1fv.
950         */
951        it('webgl_test_vertexAttrib1fv_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
952            console.info("webgltest [webgl_test_vertexAttrib1fv_3] vertexAttrib1fv");
953            vertexAttrib1fv((attrib) => {
954                gl.vertexAttrib1fv(attrib, new Float32Array([null]));
955                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
956            }, (attrib) => {
957                expect(attrib[0]).assertEqual(0);
958                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
959            })
960            done();
961        })
962
963
964        /**
965         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0032
966         * @tc.name webgl_test_vertexAttrib1fv_4
967         * @tc.desc Test vertexAttrib1fv.
968         */
969        it('webgl_test_vertexAttrib1fv_4', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
970            console.info("webgltest [webgl_test_vertexAttrib1fv_4] vertexAttrib1fv");
971            vertexAttrib1fv((attrib) => {
972                gl.vertexAttrib1fv(attrib, new Float32Array([-100]));
973                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
974            }, (attrib) => {
975                expect(attrib[0]).assertEqual(-100);
976                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
977            })
978            done();
979        })
980
981        /**
982         * 验证vertexAttrib2fv方法是否可以给顶点 attibute 变量的第2个向量值
983         */
984        function vertexAttrib2fv(callback, finish) {
985            let vSource = `
986            attribute float a_PointSize;
987            void main(){
988                gl_Position = vec4(0.5, 0.5, 1, 1.0);
989                gl_PointSize = a_PointSize;
990            }
991        `;
992            let fSource = `
993            precision mediump float;
994            uniform vec4 u_FragColor;
995            void main(){
996                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
997            }
998        `
999            let p = createProgram(gl, vSource, fSource);
1000            console.info("webgltest vertex shader source:", vSource);
1001            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
1002            callback(a_PointSize);
1003            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
1004            finish(vertexAttrib);
1005            gl.deleteShader(p.vertexShader);
1006            gl.deleteShader(p.fragmentShader);
1007            gl.deleteProgram(p.program);
1008        }
1009
1010
1011        /**
1012         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0033
1013         * @tc.name webgl_test_vertexAttrib2fv
1014         * @tc.desc Test vertexAttrib2fv.
1015         */
1016        it('webgl_test_vertexAttrib2fv', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1017            console.info("webgltest [webgl_test_vertexAttrib2fv] vertexAttrib2fv");
1018            let vSource = `
1019            attribute float a_PointSize;
1020            void main(){
1021                gl_Position = vec4(0.5, 0.5, 1, 1.0);
1022                gl_PointSize = a_PointSize;
1023            }
1024        `;
1025            let fSource = `
1026            precision mediump float;
1027            uniform vec4 u_FragColor;
1028            void main(){
1029                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
1030            }
1031        `
1032            let p = createProgram(gl, vSource, fSource);
1033            console.info("webgltest vertex shader source:", vSource);
1034            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
1035            console.info("webgltest vertexAttrib2fv(a_PointSize,new Float32Array([100.0, 100.0, 100.0, 100.0])) ");
1036            gl.vertexAttrib2fv(a_PointSize, new Float32Array([100.0, 100.0, 100.0, 100.0]));
1037            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
1038            console.info("webgltest a_PointSize value: ", vertexAttrib);
1039            expect(vertexAttrib[0]).assertEqual(100);
1040            expect(vertexAttrib[1]).assertEqual(100);
1041            expect(vertexAttrib[2] != 100).assertTrue();
1042            expect(vertexAttrib[3] != 100).assertTrue();
1043            gl.deleteShader(p.vertexShader);
1044            gl.deleteShader(p.fragmentShader);
1045            gl.deleteProgram(p.program);
1046            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1047            done();
1048        })
1049
1050        /**
1051         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0034
1052         * @tc.name webgl_test_vertexAttrib2fv_1
1053         * @tc.desc Test vertexAttrib2fv.
1054         */
1055        it('webgl_test_vertexAttrib2fv_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1056            console.info("webgltest [webgl_test_vertexAttrib2fv_1] vertexAttrib2fv");
1057            vertexAttrib2fv((attrib) => {
1058                gl.vertexAttrib2fv(attrib, new Float32Array([-100.0, -100.0]));
1059                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1060            }, (attrib) => {
1061                expect(attrib[0]).assertEqual(-100);
1062                expect(attrib[1]).assertEqual(-100);
1063                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1064            })
1065            done();
1066        })
1067
1068        /**
1069         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0035
1070         * @tc.name webgl_test_vertexAttrib2fv_2
1071         * @tc.desc Test vertexAttrib2fv.
1072         */
1073        it('webgl_test_vertexAttrib2fv_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1074            console.info("webgltest [webgl_test_vertexAttrib2fv_2] vertexAttrib2fv");
1075            vertexAttrib2fv((attrib) => {
1076                gl.vertexAttrib2fv(attrib, new Float32Array([undefined, undefined]));
1077                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1078            }, (attrib) => {
1079                expect(attrib[0].toString()).assertEqual("NaN");
1080                expect(attrib[1].toString()).assertEqual("NaN");
1081                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1082            })
1083            done();
1084        })
1085
1086
1087        /**
1088         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0036
1089         * @tc.name webgl_test_vertexAttrib2fv_3
1090         * @tc.desc Test vertexAttrib2fv.
1091         */
1092        it('webgl_test_vertexAttrib2fv_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1093            console.info("webgltest [webgl_test_vertexAttrib2fv_3] vertexAttrib2fv");
1094            vertexAttrib2fv((attrib) => {
1095                gl.vertexAttrib2fv(attrib, new Float32Array([null, null]));
1096                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1097            }, (attrib) => {
1098                expect(attrib[0]).assertEqual(0);
1099                expect(attrib[1]).assertEqual(0);
1100                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1101            })
1102            done();
1103        })
1104
1105
1106        /**
1107         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0037
1108         * @tc.name webgl_test_vertexAttrib2fv_4
1109         * @tc.desc Test vertexAttrib2fv.
1110         */
1111        it('webgl_test_vertexAttrib2fv_4', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1112            console.info("webgltest [webgl_test_vertexAttrib2fv_4] vertexAttrib2fv");
1113            vertexAttrib2fv((attrib) => {
1114                gl.vertexAttrib2fv(attrib, new Float32Array([-100, 100]));
1115                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1116            }, (attrib) => {
1117                expect(attrib[0]).assertEqual(-100);
1118                expect(attrib[1]).assertEqual(100);
1119                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1120            })
1121            done();
1122        })
1123
1124        /**
1125         * 验证vertexAttrib3fv方法是否可以给顶点 attibute 变量的第3个向量值
1126         */
1127        function vertexAttrib3fv(callback, finish) {
1128            let vSource = `
1129            attribute float a_PointSize;
1130            void main(){
1131                gl_Position = vec4(0.5, 0.5, 1, 1.0);
1132                gl_PointSize = a_PointSize;
1133            }
1134        `;
1135            let fSource = `
1136            precision mediump float;
1137            uniform vec4 u_FragColor;
1138            void main(){
1139                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
1140            }
1141        `
1142            let p = createProgram(gl, vSource, fSource);
1143            console.info("webgltest vertex shader source:", vSource);
1144            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
1145            callback(a_PointSize);
1146            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
1147            finish(vertexAttrib);
1148            gl.deleteShader(p.vertexShader);
1149            gl.deleteShader(p.fragmentShader);
1150            gl.deleteProgram(p.program);
1151        }
1152
1153
1154        /**
1155         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0038
1156         * @tc.name webgl_test_vertexAttrib3fv
1157         * @tc.desc Test vertexAttrib3fv.
1158         */
1159        it('webgl_test_vertexAttrib3fv', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1160            console.info("webgltest [webgl_test_vertexAttrib3fv] vertexAttrib3fv");
1161            let vSource = `
1162            attribute float a_PointSize;
1163            void main(){
1164                gl_Position = vec4(0.5, 0.5, 1, 1.0);
1165                gl_PointSize = a_PointSize;
1166            }
1167        `;
1168            let fSource = `
1169            precision mediump float;
1170            uniform vec4 u_FragColor;
1171            void main(){
1172                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
1173            }
1174        `
1175            let p = createProgram(gl, vSource, fSource);
1176            console.info("webgltest vertex shader source:", vSource);
1177            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
1178            console.info("webgltest vertexAttrib3fv(a_PointSize,new Float32Array([100.0, 100.0, 100.0, 100.0])) ");
1179            gl.vertexAttrib3fv(a_PointSize, new Float32Array([100.0, 100.0, 100.0, 100.0]));
1180            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
1181            console.info("webgltest a_PointSize value: ", vertexAttrib);
1182            expect(vertexAttrib[0]).assertEqual(100);
1183            expect(vertexAttrib[1]).assertEqual(100);
1184            expect(vertexAttrib[2]).assertEqual(100);
1185            expect(vertexAttrib[3] != 100).assertTrue();
1186            gl.deleteShader(p.vertexShader);
1187            gl.deleteShader(p.fragmentShader);
1188            gl.deleteProgram(p.program);
1189            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1190            done();
1191        })
1192
1193
1194        /**
1195         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0039
1196         * @tc.name webgl_test_vertexAttrib3fv_1
1197         * @tc.desc Test vertexAttrib3fv.
1198         */
1199        it('webgl_test_vertexAttrib3fv_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1200            console.info("webgltest [webgl_test_vertexAttrib3fv_1] vertexAttrib3fv");
1201            vertexAttrib3fv((attrib) => {
1202                gl.vertexAttrib3fv(attrib, new Float32Array([-100.0, -100.0, -100.0]));
1203                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1204            }, (attrib) => {
1205                expect(attrib[0]).assertEqual(-100);
1206                expect(attrib[1]).assertEqual(-100);
1207                expect(attrib[2]).assertEqual(-100);
1208                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1209            })
1210            done();
1211        })
1212
1213
1214        /**
1215         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0040
1216         * @tc.name webgl_test_vertexAttrib3fv_2
1217         * @tc.desc Test vertexAttrib3fv.
1218         */
1219        it('webgl_test_vertexAttrib3fv_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1220            console.info("webgltest [webgl_test_vertexAttrib3fv_2] vertexAttrib3fv");
1221            vertexAttrib3fv((attrib) => {
1222                gl.vertexAttrib3fv(attrib, new Float32Array([undefined, undefined, undefined]));
1223                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1224            }, (attrib) => {
1225                expect(attrib[0].toString()).assertEqual("NaN");
1226                expect(attrib[1].toString()).assertEqual("NaN");
1227                expect(attrib[2].toString()).assertEqual("NaN");
1228                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1229            })
1230            done();
1231        })
1232
1233
1234        /**
1235         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0041
1236         * @tc.name webgl_test_vertexAttrib3fv_3
1237         * @tc.desc Test vertexAttrib3fv.
1238         */
1239        it('webgl_test_vertexAttrib3fv_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1240            console.info("webgltest [webgl_test_vertexAttrib3fv_3] vertexAttrib3fv");
1241            vertexAttrib3fv((attrib) => {
1242                gl.vertexAttrib3fv(attrib, new Float32Array([null, null, null]));
1243                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1244            }, (attrib) => {
1245                expect(attrib[0]).assertEqual(0);
1246                expect(attrib[1]).assertEqual(0);
1247                expect(attrib[2]).assertEqual(0);
1248                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1249            })
1250            done();
1251        })
1252
1253
1254        /**
1255         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0042
1256         * @tc.name webgl_test_vertexAttrib3fv_4
1257         * @tc.desc Test vertexAttrib3fv.
1258         */
1259        it('webgl_test_vertexAttrib3fv_4', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1260            console.info("webgltest [webgl_test_vertexAttrib3fv_4] vertexAttrib3fv");
1261            vertexAttrib3fv((attrib) => {
1262                gl.vertexAttrib3fv(-1, new Float32Array([-100, 100, 100]));
1263                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
1264            }, (attrib) => {
1265                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1266            })
1267            done();
1268        })
1269
1270        /**
1271         * 验证vertexAttrib4fv方法是否可以给顶点 attibute 变量的第4个向量值
1272         */
1273        function vertexAttrib4fv(callback, finish) {
1274            let vSource = `
1275            attribute float a_PointSize;
1276            void main(){
1277                gl_Position = vec4(0.5, 0.5, 1, 1.0);
1278                gl_PointSize = a_PointSize;
1279            }
1280        `;
1281            let fSource = `
1282            precision mediump float;
1283            uniform vec4 u_FragColor;
1284            void main(){
1285                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
1286            }
1287        `
1288            let p = createProgram(gl, vSource, fSource);
1289            console.info("webgltest vertex shader source:", vSource);
1290            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
1291            callback(a_PointSize);
1292            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
1293            finish(vertexAttrib);
1294            gl.deleteShader(p.vertexShader);
1295            gl.deleteShader(p.fragmentShader);
1296            gl.deleteProgram(p.program);
1297        }
1298
1299
1300        /**
1301         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0043
1302         * @tc.name webgl_test_vertexAttrib4fv
1303         * @tc.desc Test vertexAttrib4fv.
1304         */
1305        it('webgl_test_vertexAttrib4fv', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1306            console.info("webgltest [webgl_test_vertexAttrib4fv] vertexAttrib4fv");
1307            let vSource = `
1308            attribute float a_PointSize;
1309            void main(){
1310                gl_Position = vec4(0.5, 0.5, 1, 1.0);
1311                gl_PointSize = a_PointSize;
1312            }
1313        `;
1314            let fSource = `
1315            precision mediump float;
1316            uniform vec4 u_FragColor;
1317            void main(){
1318                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
1319            }
1320        `
1321            let p = createProgram(gl, vSource, fSource);
1322            console.info("webgltest vertex shader source:", vSource);
1323            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
1324            console.info("webgltest vertexAttrib4fv(a_PointSize,new Float32Array([100.0, 100.0, 100.0, 100.0])) ");
1325            gl.vertexAttrib4fv(a_PointSize, new Float32Array([100.0, 100.0, 100.0, 100.0]));
1326            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
1327            console.info("webgltest a_PointSize value: ", vertexAttrib);
1328            expect(vertexAttrib[0]).assertEqual(100);
1329            expect(vertexAttrib[1]).assertEqual(100);
1330            expect(vertexAttrib[2]).assertEqual(100);
1331            expect(vertexAttrib[3]).assertEqual(100);
1332            gl.deleteShader(p.vertexShader);
1333            gl.deleteShader(p.fragmentShader);
1334            gl.deleteProgram(p.program);
1335            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1336            done();
1337        })
1338
1339
1340        /**
1341         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0044
1342         * @tc.name webgl_test_vertexAttrib4fv_1
1343         * @tc.desc Test vertexAttrib4fv.
1344         */
1345        it('webgl_test_vertexAttrib4fv_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1346            console.info("webgltest [webgl_test_vertexAttrib4fv_1] vertexAttrib4fv");
1347            vertexAttrib4fv((attrib) => {
1348                gl.vertexAttrib4fv(attrib, new Float32Array([-100.0, -100.0, -100.0, -100.0]));
1349                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1350            }, (attrib) => {
1351                expect(attrib[0]).assertEqual(-100);
1352                expect(attrib[1]).assertEqual(-100);
1353                expect(attrib[2]).assertEqual(-100);
1354                expect(attrib[3]).assertEqual(-100);
1355                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1356            })
1357            done();
1358        })
1359
1360
1361        /**
1362         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0045
1363         * @tc.name webgl_test_vertexAttrib4fv_2
1364         * @tc.desc Test vertexAttrib4fv.
1365         */
1366        it('webgl_test_vertexAttrib4fv_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1367            console.info("webgltest [webgl_test_vertexAttrib4fv_2] vertexAttrib4fv");
1368            vertexAttrib4fv((attrib) => {
1369                gl.vertexAttrib4fv(attrib, new Float32Array([undefined, undefined, undefined, undefined]));
1370                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1371            }, (attrib) => {
1372                expect(attrib[0].toString()).assertEqual("NaN");
1373                expect(attrib[1].toString()).assertEqual("NaN");
1374                expect(attrib[2].toString()).assertEqual("NaN");
1375                expect(attrib[3].toString()).assertEqual("NaN");
1376                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1377            })
1378            done();
1379        })
1380
1381
1382        /**
1383         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0046
1384         * @tc.name webgl_test_vertexAttrib4fv_3
1385         * @tc.desc Test vertexAttrib4fv.
1386         */
1387        it('webgl_test_vertexAttrib4fv_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1388            console.info("webgltest [webgl_test_vertexAttrib4fv_3] vertexAttrib4fv");
1389            vertexAttrib4fv((attrib) => {
1390                gl.vertexAttrib4fv(attrib, new Float32Array([null, null, null, null]));
1391                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1392            }, (attrib) => {
1393                expect(attrib[0]).assertEqual(0);
1394                expect(attrib[1]).assertEqual(0);
1395                expect(attrib[2]).assertEqual(0);
1396                expect(attrib[3]).assertEqual(0);
1397                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1398            })
1399            done();
1400        })
1401
1402
1403        /**
1404         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0047
1405         * @tc.name webgl_test_vertexAttrib4fv_4
1406         * @tc.desc Test vertexAttrib4fv.
1407         */
1408        it('webgl_test_vertexAttrib4fv_4', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1409            console.info("webgltest [webgl_test_vertexAttrib4fv_4] vertexAttrib4fv");
1410            vertexAttrib4fv((attrib) => {
1411                gl.vertexAttrib4fv(-1, new Float32Array([-100, 100, 100, 100]));
1412                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
1413            }, (attrib) => {
1414                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1415            })
1416            done();
1417        })
1418
1419        /**
1420         * 验证getVertexAttrib方法 是否能够返回关于给定位置顶点属性的信息。
1421         */
1422        function getVertexAttrib(callback, finish) {
1423            let vSource = `
1424            attribute float a_PointSize;
1425            void main(){
1426                gl_Position = vec4(0.5, 0.5, 1, 1.0);
1427                gl_PointSize = a_PointSize;
1428            }
1429        `;
1430            let fSource = `
1431            precision mediump float;
1432            uniform vec4 u_FragColor;
1433            void main(){
1434                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
1435            }
1436        `
1437            let p = createProgram(gl, vSource, fSource);
1438            console.info("webgltest vertex shader source:", vSource);
1439            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
1440            callback(a_PointSize);
1441            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
1442            finish(vertexAttrib);
1443            gl.deleteShader(p.vertexShader);
1444            gl.deleteShader(p.fragmentShader);
1445            gl.deleteProgram(p.program);
1446        }
1447
1448
1449        /**
1450         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0048
1451         * @tc.name webgl_test_getVertexAttrib
1452         * @tc.desc Test getVertexAttrib.
1453         */
1454        it('webgl_test_getVertexAttrib', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1455            console.info("webgltest [webgl_test_getVertexAttrib] getVertexAttrib");
1456            let vSource = `
1457            attribute float a_PointSize;
1458            void main(){
1459                gl_Position = vec4(0.5, 0.5, 1, 1.0);
1460                gl_PointSize = a_PointSize;
1461            }
1462        `;
1463            let fSource = `
1464            precision mediump float;
1465            uniform vec4 u_FragColor;
1466            void main(){
1467                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
1468            }
1469        `
1470            let p = createProgram(gl, vSource, fSource);
1471            console.info("webgltest vertex shader source:", vSource);
1472            let a_PointSize = gl.getAttribLocation(p.program, "a_PointSize");
1473            console.info("webgltest vertexAttrib4fv(a_PointSize,new Float32Array([100.0, 100.0, 100.0, 100.0]));");
1474            gl.vertexAttrib4fv(a_PointSize, new Float32Array([100.0, 100.0, 100.0, 100.0]));
1475            console.info("webgltest gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);");
1476            let vertexAttrib = gl.getVertexAttrib(a_PointSize, gl.CURRENT_VERTEX_ATTRIB);
1477            console.info("webgltest a_PointSize value: ", vertexAttrib);
1478            expect(vertexAttrib[0]).assertEqual(100);
1479            expect(vertexAttrib[1]).assertEqual(100);
1480            expect(vertexAttrib[2]).assertEqual(100);
1481            expect(vertexAttrib[3]).assertEqual(100);
1482            gl.deleteShader(p.vertexShader);
1483            gl.deleteShader(p.fragmentShader);
1484            gl.deleteProgram(p.program);
1485            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1486            done();
1487        })
1488
1489
1490        /**
1491         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0049
1492         * @tc.name webgl_test_getVertexAttrib_1
1493         * @tc.desc Test getVertexAttrib.
1494         */
1495        it('webgl_test_getVertexAttrib_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1496            console.info("webgltest [webgl_test_getVertexAttrib_1] getVertexAttrib");
1497            getVertexAttrib((attrib) => {
1498                gl.vertexAttrib4fv(attrib, new Float32Array([-100.0, -100.0, -100.0, -100.0]));
1499                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1500            }, (attrib) => {
1501                expect(attrib[0]).assertEqual(-100);
1502                expect(attrib[1]).assertEqual(-100);
1503                expect(attrib[2]).assertEqual(-100);
1504                expect(attrib[3]).assertEqual(-100);
1505                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1506            })
1507            done();
1508        });
1509
1510
1511        /**
1512         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0050
1513         * @tc.name webgl_test_getVertexAttrib_2
1514         * @tc.desc Test getVertexAttrib.
1515         */
1516        it('webgl_test_getVertexAttrib_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1517            console.info("webgltest [webgl_test_getVertexAttrib_2] getVertexAttrib");
1518            getVertexAttrib((attrib) => {
1519                gl.vertexAttrib4fv(attrib, new Float32Array([undefined, undefined, undefined, undefined]));
1520                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1521            }, (attrib) => {
1522                expect(attrib[0].toString()).assertEqual("NaN");
1523                expect(attrib[1].toString()).assertEqual("NaN");
1524                expect(attrib[2].toString()).assertEqual("NaN");
1525                expect(attrib[3].toString()).assertEqual("NaN");
1526                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1527            })
1528            done();
1529        })
1530
1531
1532        /**
1533         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0051
1534         * @tc.name webgl_test_getVertexAttrib_3
1535         * @tc.desc Test getVertexAttrib.
1536         */
1537        it('webgl_test_getVertexAttrib_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1538            console.info("webgltest [webgl_test_getVertexAttrib_3] getVertexAttrib");
1539            getVertexAttrib((attrib) => {
1540                gl.vertexAttrib4fv(attrib, new Float32Array([null, null, null, null]));
1541                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1542            }, (attrib) => {
1543                expect(attrib[0]).assertEqual(0);
1544                expect(attrib[1]).assertEqual(0);
1545                expect(attrib[2]).assertEqual(0);
1546                expect(attrib[3]).assertEqual(0);
1547                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1548            })
1549            done();
1550        })
1551
1552
1553        /**
1554         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0052
1555         * @tc.name webgl_test_getVertexAttrib_4
1556         * @tc.desc Test getVertexAttrib.
1557         */
1558        it('webgl_test_getVertexAttrib_4', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
1559            console.info("webgltest [webgl_test_getVertexAttrib_4] getVertexAttrib");
1560            getVertexAttrib((attrib) => {
1561                gl.vertexAttrib4fv(-1, new Float32Array([-100, 100, 100, 100]));
1562                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
1563            }, (attrib) => {
1564                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1565            })
1566            done();
1567        })
1568
1569        /**
1570         * WebGL API 的 WebGLRenderingContext.vertexAttribPointer()
1571         * 方法绑定了当前绑定到 gl 的缓冲区。
1572         * ARRAY_BUFFER到当前顶点缓冲区对象的通用顶点属性并指定其布局。
1573         */
1574        function vertexAttribPointer(callback, finish) {
1575            let vSource = `
1576            attribute vec4 a_Position;
1577            attribute vec4 a_Color;
1578            uniform mat4 u_ModelViewMatrix;
1579            varying vec4 v_Color;
1580            void main() {
1581                gl_Position = u_ModelViewMatrix * a_Position;
1582                v_Color = a_Color;
1583            }
1584        `;
1585            let fSource = `
1586            precision mediump float;
1587            varying vec4 v_Color;
1588            void main() {
1589                gl_FragColor = v_Color;
1590            }
1591        `
1592            let p = createProgram(gl, vSource, fSource);
1593            console.info("webgltest vertex shader source:", vSource);
1594
1595            let arr = new Float32Array([
1596                0.0, 0.5, -0.4, 0.4, 1.0, 0.4,
1597                -0.5, -0.5, -0.4, 0.4, 1.0, 0.4,
1598                0.5, -0.5, -0.4, 1.0, 0.4, 0.4,
1599
1600                0.5, 0.4, -0.2, 1.0, 0.4, 0.4,
1601                -0.5, 0.4, -0.2, 1.0, 1.0, 0.4,
1602                0.0, -0.6, -0.2, 1.0, 1.0, 0.4,
1603
1604                0.0, 0.5, 0.0, 0.4, 0.4, 1.0,
1605                -0.5, -0.5, 0.0, 0.4, 0.4, 1.0,
1606                0.5, -0.5, 0.0, 1.0, 0.4, 0.4,
1607            ]);
1608            let FSIZE = arr.BYTES_PER_ELEMENT;
1609            let buffer = gl.createBuffer(); // 创建缓冲区
1610            gl.bindBuffer(gl.ARRAY_BUFFER, buffer); // 绑定缓冲区
1611            gl.bufferData(gl.ARRAY_BUFFER, arr, gl.STATIC_DRAW); // 将数据写入缓冲区对象
1612            let a_Position = gl.getAttribLocation(p.program, 'a_Position'); // 获取attribute变量地址
1613            let info = getVertexAttribDesc(a_Position);
1614            callback(a_Position);
1615            gl.enableVertexAttribArray(a_Position); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
1616            info = getVertexAttribDesc(a_Position);
1617            finish(info);
1618            gl.disableVertexAttribArray(a_Position);
1619            gl.deleteBuffer(buffer);
1620            gl.deleteShader(p.vertexShader);
1621            gl.deleteShader(p.fragmentShader);
1622            gl.deleteProgram(p.program);
1623        }
1624
1625
1626        /**
1627         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0053
1628         * @tc.name webgl_test_vertexAttribPointer
1629         * @tc.desc Test vertexAttribPointer.
1630         */
1631        it('webgl_test_vertexAttribPointer', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
1632            async function (done) {
1633            console.info("webgltest [webgl_test_vertexAttribPointer] vertexAttribPointer");
1634            let vSource = `
1635            attribute vec4 a_Position;
1636            attribute vec4 a_Color;
1637            uniform mat4 u_ModelViewMatrix;
1638            varying vec4 v_Color;
1639            void main() {
1640                gl_Position = u_ModelViewMatrix * a_Position;
1641                v_Color = a_Color;
1642            }
1643        `;
1644            let fSource = `
1645            precision mediump float;
1646            varying vec4 v_Color;
1647            void main() {
1648                gl_FragColor = v_Color;
1649            }
1650        `
1651            let p = createProgram(gl, vSource, fSource);
1652            console.info("webgltest vertex shader source:", vSource);
1653
1654            let arr = new Float32Array([
1655                0.0, 0.5, -0.4, 0.4, 1.0, 0.4,
1656                -0.5, -0.5, -0.4, 0.4, 1.0, 0.4,
1657                0.5, -0.5, -0.4, 1.0, 0.4, 0.4,
1658
1659                0.5, 0.4, -0.2, 1.0, 0.4, 0.4,
1660                -0.5, 0.4, -0.2, 1.0, 1.0, 0.4,
1661                0.0, -0.6, -0.2, 1.0, 1.0, 0.4,
1662
1663                0.0, 0.5, 0.0, 0.4, 0.4, 1.0,
1664                -0.5, -0.5, 0.0, 0.4, 0.4, 1.0,
1665                0.5, -0.5, 0.0, 1.0, 0.4, 0.4,
1666            ]);
1667            let FSIZE = arr.BYTES_PER_ELEMENT;
1668            let buffer = gl.createBuffer(); // 创建缓冲区
1669            gl.bindBuffer(gl.ARRAY_BUFFER, buffer); // 绑定缓冲区
1670            gl.bufferData(gl.ARRAY_BUFFER, arr, gl.STATIC_DRAW); // 将数据写入缓冲区对象
1671
1672            let a_Position = gl.getAttribLocation(p.program, 'a_Position'); // 获取attribute变量地址
1673            let info = getVertexAttribDesc(a_Position);
1674            console.info("webgltest ", JSON.stringify(info));
1675            expect(info.bufferBinding).assertEqual(null);
1676            console.info("webgltest gl.vertexAttribPointer(a_Position, 3, gl.FLOAT, false, FSIZE * 6, 0); ");
1677            gl.vertexAttribPointer(a_Position, 3, gl.FLOAT, false, FSIZE * 6, 0); // 将缓冲区对象分配给一个attribute变量
1678            gl.enableVertexAttribArray(a_Position); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
1679            info = getVertexAttribDesc(a_Position);
1680            console.info("webgltest ", JSON.stringify(info));
1681            expect(info.bufferBinding).assertEqual(buffer);
1682            expect(info.size).assertEqual(3);
1683            expect(info.type).assertEqual(gl.FLOAT);
1684            expect(info.normalized).assertEqual(false);
1685            expect(info.stride).assertEqual(FSIZE * 6);
1686            gl.disableVertexAttribArray(a_Position);
1687            gl.deleteBuffer(buffer);
1688            gl.deleteShader(p.vertexShader);
1689            gl.deleteShader(p.fragmentShader);
1690            gl.deleteProgram(p.program);
1691            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1692            done();
1693        })
1694
1695
1696        /**
1697         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0054
1698         * @tc.name webgl_test_vertexAttribPointer_1
1699         * @tc.desc Test vertexAttribPointer.
1700         */
1701        it('webgl_test_vertexAttribPointer_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
1702            async function (done) {
1703            console.info("webgltest [webgl_test_vertexAttribPointer_1] vertexAttribPointer");
1704            vertexAttribPointer((attrib) => {
1705                gl.vertexAttribPointer(attrib, 2, gl.FLOAT, false, 0, 0);
1706                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1707            }, (info) => {
1708                expect(info.size).assertEqual(2);
1709                expect(info.type).assertEqual(gl.FLOAT);
1710                expect(info.normalized).assertEqual(false);
1711                expect(info.stride).assertEqual(0);
1712                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1713            })
1714            done();
1715        })
1716
1717
1718        /**
1719         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0055
1720         * @tc.name webgl_test_vertexAttribPointer_2
1721         * @tc.desc Test vertexAttribPointer.
1722         */
1723        it('webgl_test_vertexAttribPointer_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
1724            async function (done) {
1725            console.info("webgltest [webgl_test_vertexAttribPointer_2] vertexAttribPointer");
1726            vertexAttribPointer((attrib) => {
1727                gl.vertexAttribPointer(-1, 2, gl.FLOAT, false, 0, 0);
1728                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
1729            }, (info) => {
1730                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1731            })
1732            done();
1733        })
1734
1735
1736        /**
1737         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0056
1738         * @tc.name webgl_test_vertexAttribPointer_3
1739         * @tc.desc Test vertexAttribPointer.
1740         */
1741        it('webgl_test_vertexAttribPointer_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
1742            async function (done) {
1743            console.info("webgltest [webgl_test_vertexAttribPointer_3] vertexAttribPointer");
1744            vertexAttribPointer((attrib) => {
1745                gl.vertexAttribPointer(attrib, 2, gl.BYTE, false, 0, 0);
1746                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1747            }, (info) => {
1748                expect(info.size).assertEqual(2);
1749                expect(info.type).assertEqual(gl.BYTE);
1750                expect(info.normalized).assertEqual(false);
1751                expect(info.stride).assertEqual(0);
1752                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1753            })
1754            done();
1755        })
1756
1757
1758        /**
1759         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0057
1760         * @tc.name webgl_test_vertexAttribPointer_4
1761         * @tc.desc Test vertexAttribPointer.
1762         */
1763        it('webgl_test_vertexAttribPointer_4', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
1764            async function (done) {
1765            console.info("webgltest [webgl_test_vertexAttribPointer_4] vertexAttribPointer");
1766            vertexAttribPointer((attrib) => {
1767                gl.vertexAttribPointer(attrib, 3, gl.SHORT, false, 0, 0);
1768                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1769            }, (info) => {
1770                expect(info.size).assertEqual(3);
1771                expect(info.type).assertEqual(gl.SHORT);
1772                expect(info.normalized).assertEqual(false);
1773                expect(info.stride).assertEqual(0);
1774                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1775            })
1776            done();
1777        })
1778
1779
1780        /**
1781         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0058
1782         * @tc.name webgl_test_vertexAttribPointer_5
1783         * @tc.desc Test vertexAttribPointer.
1784         */
1785        it('webgl_test_vertexAttribPointer_5', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
1786            async function (done) {
1787            console.info("webgltest [webgl_test_vertexAttribPointer_5] vertexAttribPointer");
1788            vertexAttribPointer((attrib) => {
1789                gl.vertexAttribPointer(attrib, 3, gl.UNSIGNED_BYTE, false, 0, 0);
1790                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1791            }, (info) => {
1792                expect(info.size).assertEqual(3);
1793                expect(info.type).assertEqual(gl.UNSIGNED_BYTE);
1794                expect(info.normalized).assertEqual(false);
1795                expect(info.stride).assertEqual(0);
1796                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1797            })
1798            done();
1799        })
1800
1801
1802        /**
1803         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0059
1804         * @tc.name webgl_test_vertexAttribPointer_6
1805         * @tc.desc Test vertexAttribPointer.
1806         */
1807        it('webgl_test_vertexAttribPointer_6', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
1808            async function (done) {
1809            console.info("webgltest [webgl_test_vertexAttribPointer_6] vertexAttribPointer");
1810            vertexAttribPointer((attrib) => {
1811                gl.vertexAttribPointer(attrib, 3, gl.UNSIGNED_SHORT, false, 0, 0);
1812                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1813            }, (info) => {
1814                expect(info.size).assertEqual(3);
1815                expect(info.type).assertEqual(gl.UNSIGNED_SHORT);
1816                expect(info.normalized).assertEqual(false);
1817                expect(info.stride).assertEqual(0);
1818                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1819            })
1820            done();
1821        })
1822
1823
1824        /**
1825         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0060
1826         * @tc.name webgl_test_vertexAttribPointer_7
1827         * @tc.desc Test vertexAttribPointer.
1828         */
1829        it('webgl_test_vertexAttribPointer_7', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
1830            async function (done) {
1831            console.info("webgltest [webgl_test_vertexAttribPointer_7] vertexAttribPointer");
1832            vertexAttribPointer((attrib) => {
1833                gl.vertexAttribPointer(attrib, 3, gl.UNSIGNED_SHORT, true, 0, 0);
1834                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1835            }, (info) => {
1836                expect(info.size).assertEqual(3);
1837                expect(info.type).assertEqual(gl.UNSIGNED_SHORT);
1838                expect(info.normalized).assertEqual(true);
1839                expect(info.stride).assertEqual(0);
1840                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1841            })
1842            done();
1843        })
1844
1845
1846        /**
1847         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0061
1848         * @tc.name webgl_test_vertexAttribPointer_8
1849         * @tc.desc Test vertexAttribPointer.
1850         */
1851        it('webgl_test_vertexAttribPointer_8', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
1852            async function (done) {
1853            console.info("webgltest [webgl_test_vertexAttribPointer_8] vertexAttribPointer");
1854            vertexAttribPointer((attrib) => {
1855                gl.vertexAttribPointer(attrib, 3, gl.UNSIGNED_SHORT, true, 2, 0);
1856                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1857            }, (info) => {
1858                console.log(info);
1859                expect(info.size).assertEqual(3);
1860                expect(info.type).assertEqual(gl.UNSIGNED_SHORT);
1861                expect(info.normalized).assertEqual(true);
1862                expect(info.stride).assertEqual(2);
1863                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1864            })
1865            done();
1866        })
1867
1868        /**
1869         * enableVertexAttribArray方法再给定的索引位置打开通用顶点数组。
1870         */
1871        function enableVertexAttribArray(callback, finish) {
1872            let vSource = `
1873            attribute vec4 a_Position;
1874            attribute vec4 a_Color;
1875            uniform mat4 u_ModelViewMatrix;
1876            varying vec4 v_Color;
1877            void main() {
1878                gl_Position = u_ModelViewMatrix * a_Position;
1879                v_Color = a_Color;
1880            }
1881        `;
1882            let fSource = `
1883            precision mediump float;
1884            varying vec4 v_Color;
1885            void main() {
1886                gl_FragColor = v_Color;
1887            }
1888        `
1889            let p = createProgram(gl, vSource, fSource);
1890            console.info("webgltest vertex shader source:", vSource);
1891
1892            let arr = new Float32Array([
1893                0.0, 0.5, -0.4, 0.4, 1.0, 0.4,
1894                -0.5, -0.5, -0.4, 0.4, 1.0, 0.4,
1895                0.5, -0.5, -0.4, 1.0, 0.4, 0.4,
1896
1897                0.5, 0.4, -0.2, 1.0, 0.4, 0.4,
1898                -0.5, 0.4, -0.2, 1.0, 1.0, 0.4,
1899                0.0, -0.6, -0.2, 1.0, 1.0, 0.4,
1900
1901                0.0, 0.5, 0.0, 0.4, 0.4, 1.0,
1902                -0.5, -0.5, 0.0, 0.4, 0.4, 1.0,
1903                0.5, -0.5, 0.0, 1.0, 0.4, 0.4,
1904            ]);
1905            let FSIZE = arr.BYTES_PER_ELEMENT;
1906            let buffer = gl.createBuffer(); // 创建缓冲区
1907            gl.bindBuffer(gl.ARRAY_BUFFER, buffer); // 绑定缓冲区
1908            gl.bufferData(gl.ARRAY_BUFFER, arr, gl.STATIC_DRAW); // 将数据写入缓冲区对象
1909            let a_Position = gl.getAttribLocation(p.program, 'a_Position'); // 获取attribute变量地址
1910            let info = getVertexAttribDesc(a_Position);
1911            console.info("webgltest enable:", info.enable);
1912            gl.vertexAttribPointer(a_Position, 3, gl.FLOAT, false, FSIZE * 6, 0); // 将缓冲区对象分配给一个attribute变量
1913            callback(a_Position);
1914            info = getVertexAttribDesc(a_Position);
1915            finish(info);
1916            gl.disableVertexAttribArray(a_Position); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
1917            gl.deleteBuffer(buffer);
1918            gl.deleteShader(p.vertexShader);
1919            gl.deleteShader(p.fragmentShader);
1920            gl.deleteProgram(p.program);
1921        }
1922
1923
1924        /**
1925         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0062
1926         * @tc.name webgl_test_enableVertexAttribArray
1927         * @tc.desc Test enableVertexAttribArray.
1928         */
1929        it('webgl_test_enableVertexAttribArray', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
1930            async function (done) {
1931            console.info("webgltest [webgl_test_enableVertexAttribArray] enableVertexAttribArray");
1932            let vSource = `
1933            attribute vec4 a_Position;
1934            attribute vec4 a_Color;
1935            uniform mat4 u_ModelViewMatrix;
1936            varying vec4 v_Color;
1937            void main() {
1938                gl_Position = u_ModelViewMatrix * a_Position;
1939                v_Color = a_Color;
1940            }
1941        `;
1942            let fSource = `
1943            precision mediump float;
1944            varying vec4 v_Color;
1945            void main() {
1946                gl_FragColor = v_Color;
1947            }
1948        `
1949            let p = createProgram(gl, vSource, fSource);
1950            console.info("webgltest vertex shader source:", vSource);
1951
1952            let arr = new Float32Array([
1953                0.0, 0.5, -0.4, 0.4, 1.0, 0.4,
1954                -0.5, -0.5, -0.4, 0.4, 1.0, 0.4,
1955                0.5, -0.5, -0.4, 1.0, 0.4, 0.4,
1956
1957                0.5, 0.4, -0.2, 1.0, 0.4, 0.4,
1958                -0.5, 0.4, -0.2, 1.0, 1.0, 0.4,
1959                0.0, -0.6, -0.2, 1.0, 1.0, 0.4,
1960
1961                0.0, 0.5, 0.0, 0.4, 0.4, 1.0,
1962                -0.5, -0.5, 0.0, 0.4, 0.4, 1.0,
1963                0.5, -0.5, 0.0, 1.0, 0.4, 0.4,
1964            ]);
1965            let FSIZE = arr.BYTES_PER_ELEMENT;
1966            let buffer = gl.createBuffer();
1967            gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
1968            gl.bufferData(gl.ARRAY_BUFFER, arr, gl.STATIC_DRAW);
1969
1970            let a_Position = gl.getAttribLocation(p.program, 'a_Position');
1971            let info = getVertexAttribDesc(a_Position);
1972            console.info("webgltest enable:", info.enable);
1973            gl.vertexAttribPointer(a_Position, 3, gl.FLOAT, false, FSIZE * 6, 0);
1974            expect(info.enable).assertEqual(false);
1975            console.info("webgltest gl.enableVertexAttribArray(a_Position);");
1976            gl.enableVertexAttribArray(a_Position);
1977            info = getVertexAttribDesc(a_Position);
1978            console.info("webgltest enable:", info.enable);
1979            expect(info.enable).assertEqual(true);
1980            gl.disableVertexAttribArray(a_Position);
1981            gl.deleteBuffer(buffer);
1982            gl.deleteShader(p.vertexShader);
1983            gl.deleteShader(p.fragmentShader);
1984            gl.deleteProgram(p.program);
1985            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
1986            done();
1987        })
1988
1989
1990        /**
1991         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0063
1992         * @tc.name webgl_test_enableVertexAttribArray_1
1993         * @tc.desc Test enableVertexAttribArray.
1994         */
1995        it('webgl_test_enableVertexAttribArray_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
1996            async function (done) {
1997            console.info("webgltest [webgl_test_enableVertexAttribArray_1] enableVertexAttribArray");
1998            enableVertexAttribArray((attrib) => {
1999                gl.enableVertexAttribArray(attrib);
2000                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2001            }, (info) => {
2002                expect(info.enable).assertEqual(true);
2003                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2004            })
2005            done();
2006        })
2007
2008
2009        /**
2010         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0064
2011         * @tc.name webgl_test_enableVertexAttribArray_2
2012         * @tc.desc Test enableVertexAttribArray.
2013         */
2014        it('webgl_test_enableVertexAttribArray_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
2015            async function (done) {
2016            console.info("webgltest [webgl_test_enableVertexAttribArray_2] enableVertexAttribArray");
2017            enableVertexAttribArray((attrib) => {
2018                gl.enableVertexAttribArray(-1);
2019                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
2020            }, (info) => {
2021                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2022            })
2023            done();
2024        })
2025
2026        /**
2027         * enableVertexAttribArray方法再给定的索引位置关闭通用顶点数组。
2028         */
2029
2030        function disableVertexAttribArray(callback, finish) {
2031            let vSource = `
2032            attribute vec4 a_Position;
2033            attribute vec4 a_Color;
2034            uniform mat4 u_ModelViewMatrix;
2035            varying vec4 v_Color;
2036            void main() {
2037                gl_Position = u_ModelViewMatrix * a_Position;
2038                v_Color = a_Color;
2039            }
2040        `;
2041            let fSource = `
2042            precision mediump float;
2043            varying vec4 v_Color;
2044            void main() {
2045                gl_FragColor = v_Color;
2046            }
2047        `
2048            let p = createProgram(gl, vSource, fSource);
2049            console.info("webgltest vertex shader source:", vSource);
2050
2051            let arr = new Float32Array([
2052                0.0, 0.5, -0.4, 0.4, 1.0, 0.4,
2053                -0.5, -0.5, -0.4, 0.4, 1.0, 0.4,
2054                0.5, -0.5, -0.4, 1.0, 0.4, 0.4,
2055
2056                0.5, 0.4, -0.2, 1.0, 0.4, 0.4,
2057                -0.5, 0.4, -0.2, 1.0, 1.0, 0.4,
2058                0.0, -0.6, -0.2, 1.0, 1.0, 0.4,
2059
2060                0.0, 0.5, 0.0, 0.4, 0.4, 1.0,
2061                -0.5, -0.5, 0.0, 0.4, 0.4, 1.0,
2062                0.5, -0.5, 0.0, 1.0, 0.4, 0.4,
2063            ]);
2064
2065            let FSIZE = arr.BYTES_PER_ELEMENT;
2066            let buffer = gl.createBuffer();
2067            gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
2068            gl.bufferData(gl.ARRAY_BUFFER, arr, gl.STATIC_DRAW);
2069
2070            let a_Position = gl.getAttribLocation(p.program, 'a_Position');
2071            let info = getVertexAttribDesc(a_Position);
2072            console.info("webgltest enable:", info.enable);
2073            gl.vertexAttribPointer(a_Position, 3, gl.FLOAT, false, FSIZE * 6, 0);
2074            gl.enableVertexAttribArray(a_Position);
2075            info = getVertexAttribDesc(a_Position);
2076            callback(a_Position);
2077            info = getVertexAttribDesc(a_Position);
2078            finish(info);
2079            gl.deleteBuffer(buffer);
2080            gl.deleteShader(p.vertexShader);
2081            gl.deleteShader(p.fragmentShader);
2082            gl.deleteProgram(p.program);
2083        }
2084
2085
2086        /**
2087         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0065
2088         * @tc.name webgl_test_disableVertexAttribArray
2089         * @tc.desc Test disableVertexAttribArray.
2090         */
2091        it('webgl_test_disableVertexAttribArray', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
2092            async function (done) {
2093            console.info("webgltest [webgl_test_disableVertexAttribArray] disableVertexAttribArray");
2094            let vSource = `
2095            attribute vec4 a_Position;
2096            attribute vec4 a_Color;
2097            uniform mat4 u_ModelViewMatrix;
2098            varying vec4 v_Color;
2099            void main() {
2100                gl_Position = u_ModelViewMatrix * a_Position;
2101                v_Color = a_Color;
2102            }
2103        `;
2104            let fSource = `
2105            precision mediump float;
2106            varying vec4 v_Color;
2107            void main() {
2108                gl_FragColor = v_Color;
2109            }
2110        `
2111            let p = createProgram(gl, vSource, fSource);
2112            console.info("webgltest vertex shader source:", vSource);
2113
2114            let arr = new Float32Array([
2115                0.0, 0.5, -0.4, 0.4, 1.0, 0.4,
2116                -0.5, -0.5, -0.4, 0.4, 1.0, 0.4,
2117                0.5, -0.5, -0.4, 1.0, 0.4, 0.4,
2118
2119                0.5, 0.4, -0.2, 1.0, 0.4, 0.4,
2120                -0.5, 0.4, -0.2, 1.0, 1.0, 0.4,
2121                0.0, -0.6, -0.2, 1.0, 1.0, 0.4,
2122
2123                0.0, 0.5, 0.0, 0.4, 0.4, 1.0,
2124                -0.5, -0.5, 0.0, 0.4, 0.4, 1.0,
2125                0.5, -0.5, 0.0, 1.0, 0.4, 0.4,
2126            ]);
2127
2128            let FSIZE = arr.BYTES_PER_ELEMENT;
2129            let buffer = gl.createBuffer(); // 创建缓冲区
2130            gl.bindBuffer(gl.ARRAY_BUFFER, buffer); // 绑定缓冲区
2131            gl.bufferData(gl.ARRAY_BUFFER, arr, gl.STATIC_DRAW); // 将数据写入缓冲区对象
2132
2133            let a_Position = gl.getAttribLocation(p.program, 'a_Position'); // 获取attribute变量地址
2134            let info = getVertexAttribDesc(a_Position);
2135            console.info("webgltest enable:", info.enable);
2136            gl.vertexAttribPointer(a_Position, 3, gl.FLOAT, false, FSIZE * 6, 0); // 将缓冲区对象分配给一个attribute变量
2137            expect(info.enable).assertEqual(false);
2138            console.info("webgltest gl.enableVertexAttribArray(a_Position);");
2139            gl.enableVertexAttribArray(a_Position); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
2140            info = getVertexAttribDesc(a_Position);
2141            console.info("webgltest enable:", info.enable);
2142            expect(info.enable).assertEqual(true);
2143            console.info("webgltest gl.disableVertexAttribArray(a_Position);");
2144            gl.disableVertexAttribArray(a_Position);
2145            info = getVertexAttribDesc(a_Position);
2146            console.info("webgltest enable:", info.enable);
2147            expect(info.enable).assertEqual(false);
2148            gl.deleteBuffer(buffer);
2149            gl.deleteShader(p.vertexShader);
2150            gl.deleteShader(p.fragmentShader);
2151            gl.deleteProgram(p.program);
2152            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2153            done();
2154        })
2155
2156
2157        /**
2158         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0066
2159         * @tc.name webgl_test_disableVertexAttribArray_1
2160         * @tc.desc Test disableVertexAttribArray.
2161         */
2162        it('webgl_test_disableVertexAttribArray_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
2163            async function (done) {
2164            console.info("webgltest [webgl_test_disableVertexAttribArray_1] disableVertexAttribArray");
2165            disableVertexAttribArray((attrib) => {
2166                gl.disableVertexAttribArray(attrib);
2167                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2168            }, (info) => {
2169                expect(info.enable).assertEqual(false);
2170                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2171            })
2172            done();
2173        })
2174
2175
2176        /**
2177         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0067
2178         * @tc.name webgl_test_disableVertexAttribArray_2
2179         * @tc.desc Test disableVertexAttribArray.
2180         */
2181        it('webgl_test_disableVertexAttribArray_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
2182            async function (done) {
2183            console.info("webgltest [webgl_test_disableVertexAttribArray_2] disableVertexAttribArray");
2184            disableVertexAttribArray((attrib) => {
2185                gl.disableVertexAttribArray(-1);
2186                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
2187                gl.disableVertexAttribArray(attrib);
2188            }, (info) => {
2189                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2190            })
2191            done();
2192        })
2193
2194
2195        /**
2196         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0068
2197         * @tc.name webgl_test_disableVertexAttribArray_3
2198         * @tc.desc Test disableVertexAttribArray.
2199         */
2200        it('webgl_test_disableVertexAttribArray_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
2201            async function (done) {
2202            console.info("webgltest [webgl_test_disableVertexAttribArray_3] disableVertexAttribArray");
2203            disableVertexAttribArray((attrib) => {
2204                gl.disableVertexAttribArray(null);
2205                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2206                gl.disableVertexAttribArray(attrib);
2207            }, (info) => {
2208                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2209            })
2210            done();
2211        })
2212
2213        /**
2214         * bindAttribLocation方法将通用顶点索引绑定到属性变量
2215         */
2216        function bindAttribLocation(callback, finish) {
2217            let vSource = `
2218            attribute vec4 a_Position;
2219            attribute vec4 a_Color;
2220            varying vec4 v_Color;
2221            void main() {
2222                gl_Position = a_Position;
2223                v_Color = a_Color;
2224            }
2225        `;
2226            let fSource = `
2227            precision mediump float;
2228            varying vec4 v_Color;
2229            void main() {
2230                gl_FragColor = v_Color;
2231            }
2232        `
2233            let p = createProgram(gl, vSource, fSource, (it) => {
2234                gl.bindAttribLocation(it, 11, "a_Position");
2235            });
2236            let a_Position = gl.getAttribLocation(p.program, "a_Position");
2237            callback(p.program, a_Position);
2238            gl.linkProgram(p.program);
2239            a_Position = gl.getAttribLocation(p.program, "a_Position");
2240            finish(a_Position)
2241            gl.bindAttribLocation(p.program, 0, "a_Position");
2242            gl.deleteShader(p.vertexShader);
2243            gl.deleteShader(p.fragmentShader);
2244            gl.deleteProgram(p.program);
2245        }
2246
2247        /**
2248         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0069
2249         * @tc.name webgl_test_bindAttribLocation
2250         * @tc.desc Test bindAttribLocation.
2251         */
2252        it('webgl_test_bindAttribLocation', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
2253            async function (done) {
2254            console.info("webgltest [webgl_test_bindAttribLocation] bindAttribLocation");
2255            let vSource = `
2256            attribute vec4 a_Position;
2257            attribute vec4 a_Color;
2258            varying vec4 v_Color;
2259            void main() {
2260                gl_Position = a_Position;
2261                v_Color = a_Color;
2262            }
2263        `;
2264            let fSource = `
2265            precision mediump float;
2266            varying vec4 v_Color;
2267            void main() {
2268                gl_FragColor = v_Color;
2269            }
2270        `
2271            let p = createProgram(gl, vSource, fSource, (it) => {
2272                console.info("webgltest gl.bindAttribLocation(it, 11, 'a_Position');");
2273                gl.bindAttribLocation(it, 11, "a_Position");
2274            });
2275            let a_Position = gl.getAttribLocation(p.program, "a_Position");
2276            console.info("webgltest a_Position:", a_Position);
2277            expect(a_Position).assertEqual(11);
2278            console.info("webgltest gl.bindAttribLocation(p.program, 12, 'a_Position');");
2279            gl.bindAttribLocation(p.program, 12, "a_Position");
2280            console.info("webgltest gl.linkProgram(p.program);");
2281            gl.linkProgram(p.program);
2282            a_Position = gl.getAttribLocation(p.program, "a_Position");
2283            console.info("webgltest a_Position:", a_Position);
2284            expect(a_Position).assertEqual(12);
2285            gl.bindAttribLocation(p.program, 0, "a_Position");
2286            gl.deleteShader(p.vertexShader);
2287            gl.deleteShader(p.fragmentShader);
2288            gl.deleteProgram(p.program);
2289            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2290            done();
2291        })
2292
2293
2294        /**
2295         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0070
2296         * @tc.name webgl_test_bindAttribLocation_1
2297         * @tc.desc Test bindAttribLocation.
2298         */
2299        it('webgl_test_bindAttribLocation_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
2300            async function (done) {
2301            console.info("webgltest [webgl_test_bindAttribLocation_1] bindAttribLocation");
2302            bindAttribLocation((program, attrib) => {
2303                gl.bindAttribLocation(program, 12, "a_Position");
2304                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2305            }, (attrib) => {
2306                expect(attrib).assertEqual(12);
2307                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2308            })
2309            done();
2310        })
2311
2312
2313        /**
2314         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0071
2315         * @tc.name webgl_test_bindAttribLocation_2
2316         * @tc.desc Test bindAttribLocation.
2317         */
2318        it('webgl_test_bindAttribLocation_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
2319            async function (done) {
2320            console.info("webgltest [webgl_test_bindAttribLocation_2] bindAttribLocation");
2321            bindAttribLocation((program, attrib) => {
2322                gl.bindAttribLocation(program, 12, "a");
2323                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2324            }, (attrib) => {
2325                expect(attrib).assertEqual(11);
2326                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2327            })
2328            done();
2329        })
2330
2331
2332        /**
2333         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0072
2334         * @tc.name webgl_test_bindAttribLocation_3
2335         * @tc.desc Test bindAttribLocation.
2336         */
2337        it('webgl_test_bindAttribLocation_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
2338            async function (done) {
2339            console.info("webgltest [webgl_test_bindAttribLocation_3] bindAttribLocation");
2340            bindAttribLocation((program, attrib) => {
2341                gl.bindAttribLocation(program, null, null);
2342                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2343            }, (attrib) => {
2344                expect(attrib).assertEqual(11);
2345                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2346            })
2347            done();
2348        })
2349
2350
2351        /**
2352         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0073
2353         * @tc.name webgl_test_bindAttribLocation_4
2354         * @tc.desc Test bindAttribLocation.
2355         */
2356        it('webgl_test_bindAttribLocation_4', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
2357            async function (done) {
2358            console.info("webgltest [webgl_test_bindAttribLocation_4] bindAttribLocation");
2359            bindAttribLocation((program, attrib) => {
2360                gl.bindAttribLocation(program, -1, attrib);
2361                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
2362            }, (attrib) => {
2363                expect(attrib).assertEqual(11);
2364                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2365            })
2366            done();
2367        })
2368
2369        /**
2370         * 返回指定顶点属性的地址
2371         */
2372        function getVertexAttribOffset(callback, finish) {
2373            let vSource = `
2374            attribute vec4 a_Position;
2375            attribute vec4 a_Color;
2376            uniform mat4 u_ModelViewMatrix;
2377            varying vec4 v_Color;
2378            void main() {
2379                gl_Position = u_ModelViewMatrix * a_Position;
2380                v_Color = a_Color;
2381            }
2382        `;
2383            let fSource = `
2384            precision mediump float;
2385            varying vec4 v_Color;
2386            void main() {
2387                gl_FragColor = v_Color;
2388            }
2389        `
2390            let p = createProgram(gl, vSource, fSource);
2391            console.info("webgltest vertex shader source:", vSource);
2392            let arr = new Float32Array([
2393                0.0, 0.5, -0.4, 0.4, 1.0, 0.4,
2394                -0.5, -0.5, -0.4, 0.4, 1.0, 0.4,
2395                0.5, -0.5, -0.4, 1.0, 0.4, 0.4,
2396
2397                0.5, 0.4, -0.2, 1.0, 0.4, 0.4,
2398                -0.5, 0.4, -0.2, 1.0, 1.0, 0.4,
2399                0.0, -0.6, -0.2, 1.0, 1.0, 0.4,
2400
2401                0.0, 0.5, 0.0, 0.4, 0.4, 1.0,
2402                -0.5, -0.5, 0.0, 0.4, 0.4, 1.0,
2403                0.5, -0.5, 0.0, 1.0, 0.4, 0.4,
2404            ]);
2405
2406            let FSIZE = arr.BYTES_PER_ELEMENT;
2407            let buffer = gl.createBuffer(); // 创建缓冲区
2408            gl.bindBuffer(gl.ARRAY_BUFFER, buffer); // 绑定缓冲区
2409            gl.bufferData(gl.ARRAY_BUFFER, arr, gl.STATIC_DRAW); // 将数据写入缓冲区对象
2410            let a_Position = gl.getAttribLocation(p.program, 'a_Position'); // 获取attribute变量地址
2411            gl.vertexAttribPointer(a_Position, 3, gl.FLOAT, false, FSIZE * 6, 0); // 将缓冲区对象分配给一个attribute变量
2412            gl.enableVertexAttribArray(a_Position); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
2413            let positionOffset = gl.getVertexAttribOffset(a_Position, gl.VERTEX_ATTRIB_ARRAY_POINTER);
2414            let a_Color = gl.getAttribLocation(gl.program, 'a_Color'); // 获取attribute变量地址
2415            callback(a_Color, FSIZE);
2416            let colorOffset = gl.getVertexAttribOffset(a_Color, gl.VERTEX_ATTRIB_ARRAY_POINTER);
2417            finish(colorOffset, FSIZE);
2418            gl.enableVertexAttribArray(a_Color); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
2419            gl.disableVertexAttribArray(a_Position);
2420            gl.disableVertexAttribArray(a_Color);
2421            gl.deleteBuffer(buffer)
2422            gl.deleteShader(p.vertexShader);
2423            gl.deleteShader(p.fragmentShader);
2424            gl.deleteProgram(p.program);
2425        }
2426
2427        /**
2428         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0074
2429         * @tc.name webgl_test_getVertexAttribOffset
2430         * @tc.desc Test getVertexAttribOffset.
2431         */
2432        it('webgl_test_getVertexAttribOffset', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
2433            async function (done) {
2434            console.info("webgltest [webgl_test_getVertexAttribOffset] getVertexAttribOffset");
2435            let vSource = `
2436            attribute vec4 a_Position;
2437            attribute vec4 a_Color;
2438            uniform mat4 u_ModelViewMatrix;
2439            varying vec4 v_Color;
2440            void main() {
2441                gl_Position = u_ModelViewMatrix * a_Position;
2442                v_Color = a_Color;
2443            }
2444        `;
2445            let fSource = `
2446            precision mediump float;
2447            varying vec4 v_Color;
2448            void main() {
2449                gl_FragColor = v_Color;
2450            }
2451        `
2452            let p = createProgram(gl, vSource, fSource);
2453            console.info("webgltest vertex shader source:", vSource);
2454
2455            let arr = new Float32Array([
2456                0.0, 0.5, -0.4, 0.4, 1.0, 0.4,
2457                -0.5, -0.5, -0.4, 0.4, 1.0, 0.4,
2458                0.5, -0.5, -0.4, 1.0, 0.4, 0.4,
2459
2460                0.5, 0.4, -0.2, 1.0, 0.4, 0.4,
2461                -0.5, 0.4, -0.2, 1.0, 1.0, 0.4,
2462                0.0, -0.6, -0.2, 1.0, 1.0, 0.4,
2463
2464                0.0, 0.5, 0.0, 0.4, 0.4, 1.0,
2465                -0.5, -0.5, 0.0, 0.4, 0.4, 1.0,
2466                0.5, -0.5, 0.0, 1.0, 0.4, 0.4,
2467            ]);
2468
2469            let FSIZE = arr.BYTES_PER_ELEMENT;
2470            let buffer = gl.createBuffer(); // 创建缓冲区
2471            gl.bindBuffer(gl.ARRAY_BUFFER, buffer); // 绑定缓冲区
2472            gl.bufferData(gl.ARRAY_BUFFER, arr, gl.STATIC_DRAW); // 将数据写入缓冲区对象
2473
2474            let a_Position = gl.getAttribLocation(p.program, 'a_Position'); // 获取attribute变量地址
2475            console.info("webgltest gl.vertexAttribPointer(a_Position, 3, gl.FLOAT, false, FSIZE * 6, 0);");
2476            gl.vertexAttribPointer(a_Position, 3, gl.FLOAT, false, FSIZE * 6, 0); // 将缓冲区对象分配给一个attribute变量
2477            gl.enableVertexAttribArray(a_Position); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
2478            let positionOffset = gl.getVertexAttribOffset(a_Position, gl.VERTEX_ATTRIB_ARRAY_POINTER);
2479            console.info("webgltest positionOffset:", positionOffset);
2480            let a_Color = gl.getAttribLocation(gl.program, 'a_Color'); // 获取attribute变量地址
2481            console.info("webgltest gl.vertexAttribPointer(a_Color, 3, gl.FLOAT, false, FSIZE * 6, FSIZE * 3);");
2482            gl.vertexAttribPointer(a_Color, 3, gl.FLOAT, false, FSIZE * 6, FSIZE * 3); // 将缓冲区对象分配给一个attribute变量
2483            let colorOffset = gl.getVertexAttribOffset(a_Color, gl.VERTEX_ATTRIB_ARRAY_POINTER);
2484            gl.enableVertexAttribArray(a_Color); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
2485            console.info("webgltest colorOffset:", colorOffset);
2486            console.info("webgltest FSIZE:", FSIZE);
2487            expect(positionOffset).assertEqual(0);
2488            expect(colorOffset).assertEqual(FSIZE * 3);
2489            gl.disableVertexAttribArray(a_Position);
2490            gl.disableVertexAttribArray(a_Color);
2491            gl.deleteBuffer(buffer)
2492            gl.deleteShader(p.vertexShader);
2493            gl.deleteShader(p.fragmentShader);
2494            gl.deleteProgram(p.program);
2495            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2496            done();
2497        })
2498
2499
2500        /**
2501         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0075
2502         * @tc.name webgl_test_getVertexAttribOffset_1
2503         * @tc.desc Test getVertexAttribOffset.
2504         */
2505        it('webgl_test_getVertexAttribOffset_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
2506            async function (done) {
2507            console.info("webgltest [webgl_test_getVertexAttribOffset_1] getVertexAttribOffset");
2508            getVertexAttribOffset((val, FSIZE) => {
2509                gl.vertexAttribPointer(val, 3, gl.FLOAT, false, FSIZE * 6, FSIZE * 3);
2510                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2511            }, (val, FSIZE) => {
2512                expect(val).assertEqual(FSIZE * 3);
2513                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2514            })
2515            done();
2516        })
2517
2518
2519        /**
2520         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0076
2521         * @tc.name webgl_test_getVertexAttribOffset_2
2522         * @tc.desc Test getVertexAttribOffset.
2523         */
2524        it('webgl_test_getVertexAttribOffset_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
2525            async function (done) {
2526            console.info("webgltest [webgl_test_getVertexAttribOffset_2] getVertexAttribOffset");
2527            getVertexAttribOffset((val, FSIZE) => {
2528                gl.vertexAttribPointer(val, 3, gl.FLOAT, false, FSIZE * 6, -FSIZE * 3);
2529                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
2530            }, (val, FSIZE) => {
2531                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2532            })
2533            done();
2534        })
2535
2536
2537        /**
2538         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0077
2539         * @tc.name webgl_test_getVertexAttribOffset_3
2540         * @tc.desc Test getVertexAttribOffset.
2541         */
2542        it('webgl_test_getVertexAttribOffset_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
2543            async function (done) {
2544            console.info("webgltest [webgl_test_getVertexAttribOffset_3] getVertexAttribOffset");
2545            getVertexAttribOffset((val, FSIZE) => {
2546                gl.vertexAttribPointer(val, 3, gl.FLOAT, false, FSIZE * 6, null);
2547                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2548            }, (val, FSIZE) => {
2549                expect(val).assertEqual(0);
2550                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2551            })
2552            done();
2553        })
2554
2555
2556        /**
2557         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0078
2558         * @tc.name webgl_test_getVertexAttribOffset_4
2559         * @tc.desc Test getVertexAttribOffset.
2560         */
2561        it('webgl_test_getVertexAttribOffset_4', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0,
2562            async function (done) {
2563            console.info("webgltest [webgl_test_getVertexAttribOffset_4] getVertexAttribOffset");
2564            getVertexAttribOffset((val, FSIZE) => {
2565                gl.vertexAttribPointer(val, 3, gl.FLOAT, false, FSIZE * 6, undefined);
2566                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2567            }, (val, FSIZE) => {
2568                expect(val).assertEqual(0);
2569                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2570            })
2571            done();
2572        })
2573
2574        /**
2575         * drawArrays 用于从向量数组中绘制图元
2576         */
2577        function drawArrays(callback, finish) {
2578            let srcViewport = gl.getParameter(gl.VIEWPORT);
2579            let {program, vertexShader, fragmentShader} = createProgram(gl, `
2580                attribute vec4 a_Position;
2581                attribute float a_PointSize;
2582                attribute vec4 a_Color;
2583                varying vec4 v_Color;
2584                void main(){
2585                    gl_Position = a_Position;
2586                    gl_PointSize = a_PointSize;
2587                    v_Color = a_Color;
2588                }
2589            `, `
2590                precision mediump float;
2591                varying vec4 v_Color;
2592                void main(){
2593                    gl_FragColor = v_Color;
2594                }
2595            `);
2596            gl.clearColor(0.92, 0.92, 0.92, 1);
2597            gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
2598            let arr = new Float32Array([
2599                0.0, 0.5, 20.0, 1.0, 0.0, 0.0,
2600                -0.5, -0.5, 40.0, 0.0, 1.0, 0.0,
2601                0.5, -0.5, 60.0, 0.0, 0.0, 1.0,
2602            ]);
2603            let FSIZE = arr.BYTES_PER_ELEMENT;
2604            let buffer = gl.createBuffer(); // 创建缓冲区
2605            gl.bindBuffer(gl.ARRAY_BUFFER, buffer); // 绑定缓冲区
2606            gl.bufferData(gl.ARRAY_BUFFER, arr, gl.STATIC_DRAW); // 将数据写入缓冲区对象
2607
2608            let a_Position = gl.getAttribLocation(gl.program, 'a_Position'); // 获取attribute变量地址
2609            gl.vertexAttribPointer(a_Position, 2, gl.FLOAT, false, FSIZE * 6, 0); // 将缓冲区对象分配给一个attribute变量
2610            gl.enableVertexAttribArray(a_Position); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
2611
2612            let a_PointSize = gl.getAttribLocation(gl.program, 'a_PointSize');
2613            gl.vertexAttribPointer(a_PointSize, 1, gl.FLOAT, false, FSIZE * 6, FSIZE * 2);
2614            gl.enableVertexAttribArray(a_PointSize); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
2615
2616            let a_Color = gl.getAttribLocation(gl.program, 'a_Color');
2617            gl.vertexAttribPointer(a_Color, 3, gl.FLOAT, false, FSIZE * 6, FSIZE * 3);
2618            gl.enableVertexAttribArray(a_Color); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
2619
2620            let n = arr.length / 6;
2621            gl.viewport(0, 0, 800, 800);
2622            callback(n)
2623            finish()
2624            gl.viewport(srcViewport[0],srcViewport[1],srcViewport[2],srcViewport[3]);
2625            gl.disableVertexAttribArray(a_Position);
2626            gl.disableVertexAttribArray(a_PointSize);
2627            gl.disableVertexAttribArray(a_Color);
2628            gl.deleteBuffer(buffer);
2629            gl.detachShader(program, vertexShader);
2630            gl.deleteShader(vertexShader);
2631            gl.detachShader(program, fragmentShader);
2632            gl.deleteShader(fragmentShader);
2633            gl.deleteProgram(program);
2634            gl.flush();
2635        }
2636
2637        /**
2638         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0079
2639         * @tc.name webgl_test_drawArrays
2640         * @tc.desc Test drawArrays.
2641         */
2642        it('webgl_test_drawArrays', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
2643            console.info("webgltest [webgl_test_drawArrays] drawArrays");
2644            let srcViewport = gl.getParameter(gl.VIEWPORT);
2645            let {program, vertexShader, fragmentShader} = createProgram(gl, `
2646                attribute vec4 a_Position;
2647                attribute float a_PointSize;
2648                attribute vec4 a_Color;
2649                varying vec4 v_Color;
2650                void main(){
2651                    gl_Position = a_Position;
2652                    gl_PointSize = a_PointSize;
2653                    v_Color = a_Color;
2654                }
2655            `, `
2656                precision mediump float;
2657                varying vec4 v_Color;
2658                void main(){
2659                    gl_FragColor = v_Color;
2660                }
2661            `);
2662            gl.clearColor(0.92, 0.92, 0.92, 1);
2663            gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
2664            let arr = new Float32Array([
2665                0.0, 0.5, 20.0, 1.0, 0.0, 0.0,
2666                -0.5, -0.5, 40.0, 0.0, 1.0, 0.0,
2667                0.5, -0.5, 60.0, 0.0, 0.0, 1.0,
2668            ]);
2669            let FSIZE = arr.BYTES_PER_ELEMENT;
2670            let buffer = gl.createBuffer(); // 创建缓冲区
2671            gl.bindBuffer(gl.ARRAY_BUFFER, buffer); // 绑定缓冲区
2672            gl.bufferData(gl.ARRAY_BUFFER, arr, gl.STATIC_DRAW); // 将数据写入缓冲区对象
2673
2674            let a_Position = gl.getAttribLocation(gl.program, 'a_Position'); // 获取attribute变量地址
2675            gl.vertexAttribPointer(a_Position, 2, gl.FLOAT, false, FSIZE * 6, 0); // 将缓冲区对象分配给一个attribute变量
2676            gl.enableVertexAttribArray(a_Position); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
2677
2678            let a_PointSize = gl.getAttribLocation(gl.program, 'a_PointSize');
2679            gl.vertexAttribPointer(a_PointSize, 1, gl.FLOAT, false, FSIZE * 6, FSIZE * 2);
2680            gl.enableVertexAttribArray(a_PointSize); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
2681
2682            let a_Color = gl.getAttribLocation(gl.program, 'a_Color');
2683            gl.vertexAttribPointer(a_Color, 3, gl.FLOAT, false, FSIZE * 6, FSIZE * 3);
2684            gl.enableVertexAttribArray(a_Color); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
2685
2686            let n = arr.length / 6;
2687            gl.viewport(0, 0, 800, 800);
2688            gl.drawArrays(gl.TRIANGLES, 0, n);
2689            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2690            gl.disableVertexAttribArray(a_Position);
2691            gl.disableVertexAttribArray(a_PointSize);
2692            gl.disableVertexAttribArray(a_Color);
2693            gl.deleteBuffer(buffer);
2694            gl.detachShader(program, vertexShader);
2695            gl.deleteShader(vertexShader);
2696            gl.detachShader(program, fragmentShader);
2697            gl.deleteShader(fragmentShader);
2698            gl.deleteProgram(program);
2699            gl.flush();
2700            gl.viewport(srcViewport[0],srcViewport[1],srcViewport[2],srcViewport[3]);
2701            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2702            done();
2703        })
2704
2705
2706        /**
2707         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0080
2708         * @tc.name webgl_test_drawArrays_1
2709         * @tc.desc Test drawArrays.
2710         */
2711        it('webgl_test_drawArrays_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
2712            console.info("webgltest [webgl_test_drawArrays_1] drawArrays");
2713            drawArrays((n) => {
2714                gl.drawArrays(gl.TRIANGLES, 0, -1);
2715                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
2716            }, () => {
2717                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2718            })
2719            done();
2720        })
2721
2722
2723        /**
2724         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0081
2725         * @tc.name webgl_test_drawArrays_2
2726         * @tc.desc Test drawArrays.
2727         */
2728        it('webgl_test_drawArrays_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
2729            console.info("webgltest [webgl_test_drawArrays_2] drawArrays");
2730            drawArrays((n) => {
2731                gl.drawArrays(gl.TRIANGLES, 0, null);
2732                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2733            }, () => {
2734                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2735            })
2736            done();
2737        })
2738
2739
2740        /**
2741         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0082
2742         * @tc.name webgl_test_drawArrays_3
2743         * @tc.desc Test drawArrays.
2744         */
2745        it('webgl_test_drawArrays_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
2746            console.info("webgltest [webgl_test_drawArrays_3] drawArrays");
2747            drawArrays((n) => {
2748                gl.drawArrays(gl.TRIANGLES, -1, null);
2749                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
2750            }, () => {
2751                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2752            })
2753            done();
2754        })
2755
2756
2757        /**
2758         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0083
2759         * @tc.name webgl_test_drawArrays_4
2760         * @tc.desc Test drawArrays.
2761         */
2762        it('webgl_test_drawArrays_4', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
2763            console.info("webgltest [webgl_test_drawArrays_4] drawArrays");
2764            drawArrays((n) => {
2765                gl.drawArrays(gl.POINTS, 0, n);
2766                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2767            }, () => {
2768                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2769            })
2770            done();
2771        })
2772
2773
2774        /**
2775         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0084
2776         * @tc.name webgl_test_drawArrays_5
2777         * @tc.desc Test drawArrays.
2778         */
2779        it('webgl_test_drawArrays_5', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
2780            console.info("webgltest [webgl_test_drawArrays_5] drawArrays");
2781            drawArrays((n) => {
2782                gl.drawArrays(gl.LINE_STRIP, 0, n);
2783                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2784            }, () => {
2785                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2786            })
2787            done();
2788        })
2789
2790
2791        /**
2792         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0085
2793         * @tc.name webgl_test_drawArrays_6
2794         * @tc.desc Test drawArrays.
2795         */
2796        it('webgl_test_drawArrays_6', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
2797            console.info("webgltest [webgl_test_drawArrays_6] drawArrays");
2798            drawArrays((n) => {
2799                gl.drawArrays(gl.LINE_LOOP, 0, n);
2800                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2801            }, () => {
2802                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2803            })
2804            done();
2805        })
2806
2807
2808        /**
2809         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0086
2810         * @tc.name webgl_test_drawArrays_7
2811         * @tc.desc Test drawArrays.
2812         */
2813        it('webgl_test_drawArrays_7', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
2814            console.info("webgltest [webgl_test_drawArrays_7] drawArrays");
2815            drawArrays((n) => {
2816                gl.drawArrays(gl.LINES, 0, n);
2817                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2818            }, () => {
2819                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2820            })
2821            done();
2822        })
2823
2824
2825        /**
2826         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0087
2827         * @tc.name webgl_test_drawArrays_8
2828         * @tc.desc Test drawArrays.
2829         */
2830        it('webgl_test_drawArrays_8', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
2831            console.info("webgltest [webgl_test_drawArrays_8] drawArrays");
2832            drawArrays((n) => {
2833                gl.drawArrays(gl.TRIANGLE_STRIP, 0, n);
2834                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2835            }, () => {
2836                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2837            })
2838            done();
2839        })
2840
2841
2842        /**
2843         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0088
2844         * @tc.name webgl_test_drawArrays_9
2845         * @tc.desc Test drawArrays.
2846         */
2847        it('webgl_test_drawArrays_9', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
2848            console.info("webgltest [webgl_test_drawArrays_9] drawArrays");
2849            drawArrays((n) => {
2850                gl.drawArrays(gl.TRIANGLE_FAN, 0, n);
2851                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2852            }, () => {
2853                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
2854            })
2855            done();
2856        })
2857
2858        /**
2859         * drawElements 从数组数据渲染图元
2860         */
2861        function drawElements(callback, finish) {
2862            let srcViewport = gl.getParameter(gl.VIEWPORT);
2863            let {program, vertexShader, fragmentShader} = createProgram(gl, `
2864                attribute vec4 a_Position;
2865                attribute vec4 a_Color;
2866                uniform mat4 u_MvpMatrix;
2867                varying vec4 v_Color;
2868                void main() {
2869                    gl_Position = u_MvpMatrix * a_Position;
2870                    v_Color = a_Color;
2871                }
2872            `, `
2873                precision mediump float;
2874                varying vec4 v_Color;
2875                void main() {
2876                    gl_FragColor = v_Color;
2877                }
2878            `);
2879            let arr = new Float32Array([
2880                1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
2881                -1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
2882                -1.0, -1.0, 1.0, 1.0, 0.0, 0.0,
2883                1.0, -1.0, 1.0, 1.0, 1.0, 0.0,
2884
2885                1.0, -1.0, -1.0, 0.0, 1.0, 0.0,
2886                1.0, 1.0, -1.0, 0.0, 1.0, 1.0,
2887                -1.0, 1.0, -1.0, 0.0, 0.0, 1.0,
2888                -1.0, -1.0, -1.0, 0.0, 0.0, 0.0,
2889            ]);
2890            let indices = new Uint8Array([
2891                0, 1, 2, 0, 2, 3,
2892                0, 3, 4, 0, 4, 5,
2893                0, 5, 6, 0, 6, 1,
2894                1, 6, 7, 1, 7, 2,
2895                7, 4, 3, 7, 3, 2,
2896                4, 7, 6, 4, 6, 5,
2897            ]);
2898            let FSIZE = arr.BYTES_PER_ELEMENT;
2899            let buffer = gl.createBuffer(); // 创建缓冲区
2900            gl.bindBuffer(gl.ARRAY_BUFFER, buffer); // 绑定缓冲区
2901            gl.bufferData(gl.ARRAY_BUFFER, arr, gl.STATIC_DRAW); // 将数据写入缓冲区对象
2902
2903            let a_Position = gl.getAttribLocation(gl.program, 'a_Position'); // 获取attribute变量地址
2904            gl.vertexAttribPointer(a_Position, 3, gl.FLOAT, false, FSIZE * 6, 0); // 将缓冲区对象分配给一个attribute变量
2905            gl.enableVertexAttribArray(a_Position); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
2906
2907            let a_Color = gl.getAttribLocation(gl.program, 'a_Color'); // 获取attribute变量地址
2908            gl.vertexAttribPointer(a_Color, 3, gl.FLOAT, false, FSIZE * 6, FSIZE * 3); // 将缓冲区对象分配给一个attribute变量
2909            gl.enableVertexAttribArray(a_Color); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
2910
2911            let indexBuffer = gl.createBuffer();
2912            gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
2913            gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
2914
2915            let u_MvpMatrix = gl.getUniformLocation(gl.program, 'u_MvpMatrix');
2916            gl.clearColor(0.92, 0.92, 0.92, 1);
2917            gl.clear(gl.COLOR_BUFFER_BIT);
2918            let srcEnable = gl.isEnabled(gl.DEPTH_TEST);
2919            gl.enable(gl.DEPTH_TEST);
2920            gl.enable(gl.POLYGON_OFFSET_FILL);
2921            gl.polygonOffset(1.0, 1.0);
2922            gl.uniformMatrix4fv(u_MvpMatrix, false, new Float32Array([
2923                3.4, -0.5, -0.3, -0.3,
2924                0, 3.4, -0.3, -0.3,
2925                -1.4, -1.2, -0.8, -0.8,
2926                -0.4, -0.5, 6.3, 8.1,
2927            ]));
2928            gl.viewport(0, 0, 800, 800);
2929            callback(indices.length);
2930            finish();
2931            gl.viewport(srcViewport[0],srcViewport[1],srcViewport[2],srcViewport[3]);
2932            gl.disableVertexAttribArray(a_Position);
2933            gl.disableVertexAttribArray(a_Color);
2934            gl.bindBuffer(gl.ARRAY_BUFFER, null);
2935            gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
2936            gl.deleteBuffer(buffer);
2937            gl.deleteBuffer(indexBuffer);
2938            gl.deleteShader(vertexShader);
2939            gl.deleteShader(fragmentShader);
2940            gl.deleteProgram(program);
2941            if (srcEnable) {
2942                gl.enable(gl.DEPTH_TEST);
2943            } else {
2944                gl.disable(gl.DEPTH_TEST);
2945            }
2946            gl.disable(gl.POLYGON_OFFSET_FILL);
2947            gl.flush();
2948        }
2949
2950        /**
2951         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0089
2952         * @tc.name webgl_test_drawElements
2953         * @tc.desc Test drawElements.
2954         */
2955        it('webgl_test_drawElements', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
2956            console.info("webgltest [webgl_test_drawElements] drawElements");
2957            let srcViewport = gl.getParameter(gl.VIEWPORT);
2958            let {program, vertexShader, fragmentShader} = createProgram(gl, `
2959                attribute vec4 a_Position;
2960                attribute vec4 a_Color;
2961                uniform mat4 u_MvpMatrix;
2962                varying vec4 v_Color;
2963                void main() {
2964                    gl_Position = u_MvpMatrix * a_Position;
2965                    v_Color = a_Color;
2966                }
2967            `, `
2968                precision mediump float;
2969                varying vec4 v_Color;
2970                void main() {
2971                    gl_FragColor = v_Color;
2972                }
2973            `);
2974            let arr = new Float32Array([
2975                1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
2976                -1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
2977                -1.0, -1.0, 1.0, 1.0, 0.0, 0.0,
2978                1.0, -1.0, 1.0, 1.0, 1.0, 0.0,
2979
2980                1.0, -1.0, -1.0, 0.0, 1.0, 0.0,
2981                1.0, 1.0, -1.0, 0.0, 1.0, 1.0,
2982                -1.0, 1.0, -1.0, 0.0, 0.0, 1.0,
2983                -1.0, -1.0, -1.0, 0.0, 0.0, 0.0,
2984            ]);
2985            let indices = new Uint8Array([
2986                0, 1, 2, 0, 2, 3,
2987                0, 3, 4, 0, 4, 5,
2988                0, 5, 6, 0, 6, 1,
2989                1, 6, 7, 1, 7, 2,
2990                7, 4, 3, 7, 3, 2,
2991                4, 7, 6, 4, 6, 5,
2992            ]);
2993            let FSIZE = arr.BYTES_PER_ELEMENT;
2994            let buffer = gl.createBuffer(); // 创建缓冲区
2995            gl.bindBuffer(gl.ARRAY_BUFFER, buffer); // 绑定缓冲区
2996            gl.bufferData(gl.ARRAY_BUFFER, arr, gl.STATIC_DRAW); // 将数据写入缓冲区对象
2997
2998            let a_Position = gl.getAttribLocation(gl.program, 'a_Position'); // 获取attribute变量地址
2999            gl.vertexAttribPointer(a_Position, 3, gl.FLOAT, false, FSIZE * 6, 0); // 将缓冲区对象分配给一个attribute变量
3000            gl.enableVertexAttribArray(a_Position); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
3001
3002            let a_Color = gl.getAttribLocation(gl.program, 'a_Color'); // 获取attribute变量地址
3003            gl.vertexAttribPointer(a_Color, 3, gl.FLOAT, false, FSIZE * 6, FSIZE * 3); // 将缓冲区对象分配给一个attribute变量
3004            gl.enableVertexAttribArray(a_Color); // 开启attribute变量(连接a_Position变量与分配给它的缓冲区对象)
3005
3006            let indexBuffer = gl.createBuffer();
3007            gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
3008            gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
3009
3010            let u_MvpMatrix = gl.getUniformLocation(gl.program, 'u_MvpMatrix');
3011
3012            gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
3013            gl.clearColor(0.92, 0.92, 0.92, 1);
3014            gl.clear(gl.COLOR_BUFFER_BIT);
3015            let srcEnable = gl.isEnabled(gl.DEPTH_TEST);
3016            gl.enable(gl.DEPTH_TEST);
3017            gl.enable(gl.POLYGON_OFFSET_FILL);
3018            gl.polygonOffset(1.0, 1.0);
3019            gl.uniformMatrix4fv(u_MvpMatrix, false, new Float32Array([
3020                3.4, -0.5, -0.3, -0.3,
3021                0, 3.4, -0.3, -0.3,
3022                -1.4, -1.2, -0.8, -0.8,
3023                -0.4, -0.5, 6.3, 8.1,
3024            ]));
3025            gl.drawElements(gl.TRIANGLES, indices.length, gl.UNSIGNED_BYTE, 0);
3026            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3027            gl.viewport(srcViewport[0],srcViewport[1],srcViewport[2],srcViewport[3]);
3028            gl.disableVertexAttribArray(a_Position);
3029            gl.disableVertexAttribArray(a_Color);
3030            gl.bindBuffer(gl.ARRAY_BUFFER, null);
3031            gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
3032            gl.deleteBuffer(buffer);
3033            gl.deleteBuffer(indexBuffer);
3034            gl.deleteShader(vertexShader);
3035            gl.deleteShader(fragmentShader);
3036            gl.deleteProgram(program);
3037            if (srcEnable) {
3038                gl.enable(gl.DEPTH_TEST);
3039            } else {
3040                gl.disable(gl.DEPTH_TEST);
3041            }
3042            gl.disable(gl.POLYGON_OFFSET_FILL);
3043            gl.flush();
3044            expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3045            done();
3046        })
3047
3048
3049        /**
3050         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0090
3051         * @tc.name webgl_test_drawElements_1
3052         * @tc.desc Test drawElements.
3053         */
3054        it('webgl_test_drawElements_1', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
3055            console.info("webgltest [webgl_test_drawElements_1] drawElements");
3056            drawElements((n) => {
3057                gl.drawElements(gl.TRIANGLES, n, gl.UNSIGNED_BYTE, 0);
3058                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3059            }, () => {
3060                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3061            })
3062            done();
3063        })
3064
3065
3066        /**
3067         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0091
3068         * @tc.name webgl_test_drawElements_2
3069         * @tc.desc Test drawElements.
3070         */
3071        it('webgl_test_drawElements_2', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
3072            console.info("webgltest [webgl_test_drawElements_2] drawElements");
3073            drawElements((n) => {
3074                gl.drawElements(gl.POINTS, n, gl.UNSIGNED_BYTE, 0);
3075                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3076            }, () => {
3077                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3078            })
3079            done();
3080        })
3081
3082
3083        /**
3084         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0092
3085         * @tc.name webgl_test_drawElements_3
3086         * @tc.desc Test drawElements.
3087         */
3088        it('webgl_test_drawElements_3', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
3089            console.info("webgltest [webgl_test_drawElements_3] drawElements");
3090            drawElements((n) => {
3091                gl.drawElements(gl.LINE_STRIP, n, gl.UNSIGNED_BYTE, 0);
3092                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3093            }, () => {
3094                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3095            })
3096            done();
3097        })
3098
3099
3100        /**
3101         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0093
3102         * @tc.name webgl_test_drawElements_4
3103         * @tc.desc Test drawElements.
3104         */
3105        it('webgl_test_drawElements_4', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
3106            console.info("webgltest [webgl_test_drawElements_4] drawElements");
3107            drawElements((n) => {
3108                gl.drawElements(gl.LINE_LOOP, n, gl.UNSIGNED_BYTE, 0);
3109                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3110            }, () => {
3111                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3112            })
3113            done();
3114        })
3115
3116
3117        /**
3118         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0094
3119         * @tc.name webgl_test_drawElements_5
3120         * @tc.desc Test drawElements.
3121         */
3122        it('webgl_test_drawElements_5', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
3123            console.info("webgltest [webgl_test_drawElements_5] drawElements");
3124            drawElements((n) => {
3125                gl.drawElements(gl.LINES, n, gl.UNSIGNED_BYTE, 0);
3126                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3127            }, () => {
3128                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3129            })
3130            done();
3131        })
3132
3133
3134        /**
3135         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0095
3136         * @tc.name webgl_test_drawElements_6
3137         * @tc.desc Test drawElements.
3138         */
3139        it('webgl_test_drawElements_6', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
3140            console.info("webgltest [webgl_test_drawElements_6] drawElements");
3141            drawElements((n) => {
3142                gl.drawElements(gl.TRIANGLE_STRIP, n, gl.UNSIGNED_BYTE, 0);
3143                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3144            }, () => {
3145                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3146            })
3147            done();
3148        })
3149
3150
3151        /**
3152         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0096
3153         * @tc.name webgl_test_drawElements_7
3154         * @tc.desc Test drawElements.
3155         */
3156        it('webgl_test_drawElements_7', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
3157            console.info("webgltest [webgl_test_drawElements_7] drawElements");
3158            drawElements((n) => {
3159                gl.drawElements(gl.TRIANGLE_FAN, n, gl.UNSIGNED_BYTE, 0);
3160                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3161            }, () => {
3162                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3163            })
3164            done();
3165        })
3166
3167
3168        /**
3169         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0097
3170         * @tc.name webgl_test_drawElements_8
3171         * @tc.desc Test drawElements.
3172         */
3173        it('webgl_test_drawElements_8', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
3174            console.info("webgltest [webgl_test_drawElements_8] drawElements");
3175            drawElements((n) => {
3176                gl.drawElements(gl.TRIANGLES, n, gl.UNSIGNED_SHORT, 0);
3177                expect(checkError(gl)).assertEqual(gl.INVALID_OPERATION);
3178            }, () => {
3179                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3180            })
3181            done();
3182        })
3183
3184
3185        /**
3186         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0098
3187         * @tc.name webgl_test_drawElements_9
3188         * @tc.desc Test drawElements.
3189         */
3190        it('webgl_test_drawElements_9', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
3191            console.info("webgltest [webgl_test_drawElements_9] drawElements");
3192            drawElements((n) => {
3193                gl.drawElements(gl.TRIANGLES, n, gl.UNSIGNED_INT, 0);
3194                expect(checkError(gl)).assertEqual(gl.INVALID_ENUM);
3195            }, () => {
3196                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3197            })
3198            done();
3199        })
3200
3201
3202        /**
3203         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0099
3204         * @tc.name webgl_test_drawElements_10
3205         * @tc.desc Test drawElements.
3206         */
3207        it('webgl_test_drawElements_10', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
3208            console.info("webgltest [webgl_test_drawElements_10] drawElements");
3209            drawElements((n) => {
3210                gl.drawElements(gl.TRIANGLES, n, gl.UNSIGNED_BYTE, -1);
3211                expect(checkError(gl)).assertEqual(gl.INVALID_VALUE);
3212            }, () => {
3213                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3214            })
3215            done();
3216        })
3217
3218
3219        /**
3220         * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_ATTRIBUTE_0100
3221         * @tc.name webgl_test_drawElements_11
3222         * @tc.desc Test drawElements.
3223         */
3224        it('webgl_test_drawElements_11', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL0, async function (done) {
3225            console.info("webgltest [webgl_test_drawElements_11] drawElements");
3226            drawElements((n) => {
3227                gl.drawElements(gl.TRIANGLES, n, gl.UNSIGNED_BYTE, null);
3228                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3229            }, () => {
3230                expect(checkError(gl)).assertEqual(gl.NO_ERROR);
3231            })
3232            done();
3233        })
3234    })
3235}
3236