1// The increased timeout is especially needed with larger binaries 2// like in the debug/gpu build 3jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000; 4 5describe('Debugger\'s Playback Behavior', function() { 6 const container = document.createElement('div'); 7 document.body.appendChild(container); 8 9 beforeEach(function() { 10 container.innerHTML = `<canvas id=debugger_view width=720 height=1280></canvas>`; 11 }); 12 13 afterEach(function() { 14 container.innerHTML = ''; 15 }); 16 17 it('can switch to the second frame of an animated skp', function(done) { 18 const filename = '/debugger/anim.mskp' 19 const fetchSkpPromise = fetch(filename); 20 21 Promise.all([LoadDebugger, fetchSkpPromise]).then((values) => { 22 23 const response = values[1]; 24 if (!response.ok) { 25 throw new Error("HTTP error, status = " + response.status); 26 } 27 response.arrayBuffer().then((buffer) => { 28 catchException(done, () => { 29 const canvasElement = document.getElementById('debugger_view'); 30 const fileContents = new Uint8Array(buffer); 31 console.log('fetched '+filename); 32 const player = Debugger.SkpFilePlayer(fileContents); 33 const bounds = player.getBounds(); 34 canvasElement.width = bounds.fRight - bounds.fLeft; 35 canvasElement.height = bounds.fBottom - bounds.fTop; 36 expect(canvasElement.width).toBe(1080); 37 expect(canvasElement.height).toBe(1920); 38 const surface = Debugger.MakeWebGLCanvasSurface(canvasElement); 39 expect(surface).toBeTruthy(); 40 const numFrames = player.getFrameCount(); 41 expect(numFrames).toBe(10); 42 43 let cmd = JSON.parse(player.jsonCommandList(surface)); 44 expect(cmd).toBeTruthy(); 45 46 // Move to last command in first frame 47 player.drawTo(surface, cmd.commands.length); 48 surface.flush(); 49 50 // Move to frame two 51 player.changeFrame(1); 52 cmd = JSON.parse(player.jsonCommandList(surface)); 53 expect(cmd).toBeTruthy(); 54 // move to command 100 in frame 2 55 player.drawTo(surface, 100); 56 surface.flush(); 57 58 console.log('drew picture to canvas element'); 59 surface.dispose(); 60 done(); 61 })(); 62 }); 63 }); 64 }); 65}); 66