import _ol_render_webgl_TextureReplay_ from '../../../../../src/ol/render/webgl/TextureReplay.js'; import _ol_render_webgl_texturereplay_defaultshader_ from '../../../../../src/ol/render/webgl/texturereplay/defaultshader.js'; import _ol_render_webgl_texturereplay_defaultshader_Locations_ from '../../../../../src/ol/render/webgl/texturereplay/defaultshader/Locations.js'; describe('ol.render.webgl.TextureReplay', function() { var replay; beforeEach(function() { var tolerance = 0.1; var maxExtent = [-10000, -20000, 10000, 20000]; replay = new _ol_render_webgl_TextureReplay_(tolerance, maxExtent); }); describe('#setUpProgram', function() { var context, gl; beforeEach(function() { context = { getProgram: function() {}, useProgram: function() {} }; gl = { enableVertexAttribArray: function() {}, vertexAttribPointer: function() {}, uniform1f: function() {}, uniform2fv: function() {}, getUniformLocation: function() {}, getAttribLocation: function() {} }; }); it('returns the locations used by the shaders', function() { var locations = replay.setUpProgram(gl, context, [2, 2], 1); expect(locations).to.be.a( _ol_render_webgl_texturereplay_defaultshader_Locations_); }); it('gets and compiles the shaders', function() { sinon.spy(context, 'getProgram'); sinon.spy(context, 'useProgram'); replay.setUpProgram(gl, context, [2, 2], 1); expect(context.getProgram.calledWithExactly( _ol_render_webgl_texturereplay_defaultshader_.fragment, _ol_render_webgl_texturereplay_defaultshader_.vertex)).to.be(true); expect(context.useProgram.calledOnce).to.be(true); }); it('initializes the attrib pointers', function() { sinon.spy(gl, 'getAttribLocation'); sinon.spy(gl, 'vertexAttribPointer'); sinon.spy(gl, 'enableVertexAttribArray'); replay.setUpProgram(gl, context, [2, 2], 1); expect(gl.vertexAttribPointer.callCount).to.be(gl.getAttribLocation.callCount); expect(gl.enableVertexAttribArray.callCount).to.be( gl.getAttribLocation.callCount); }); }); describe('#shutDownProgram', function() { var context, gl; beforeEach(function() { context = { getProgram: function() {}, useProgram: function() {} }; gl = { enableVertexAttribArray: function() {}, disableVertexAttribArray: function() {}, vertexAttribPointer: function() {}, uniform1f: function() {}, uniform2fv: function() {}, getUniformLocation: function() {}, getAttribLocation: function() {} }; }); it('disables the attrib pointers', function() { sinon.spy(gl, 'getAttribLocation'); sinon.spy(gl, 'disableVertexAttribArray'); var locations = replay.setUpProgram(gl, context, [2, 2], 1); replay.shutDownProgram(gl, locations); expect(gl.disableVertexAttribArray.callCount).to.be( gl.getAttribLocation.callCount); }); }); });