Best JavaScript code snippet using appium-xcuitest-driver
Recorder.seek.test.js
Source:Recorder.seek.test.js
1// import {2// Point, // Transform,3// } from '../tools/g2';4import {5 round,6} from '../../tools/math';7// import * as tools from '../tools/tools';8import makeFigure from '../../__mocks__/makeFigure';9import Worker from '../../__mocks__/recorder.worker.mock';10// tools.isTouchDevice = jest.fn();11jest.mock('./recorder.worker');12// jest.useFakeTimers();13describe('Seek', () => {14 let figure;15 let recorder;16 let a;17 // let b;18 let transforms;19 let frameStep;20 let dissolveTester;21 beforeEach(() => {22 // Disable requestAnimationFrame calling draw as it does so at a time23 // interval and figure.mock.timeStep does it precisely24 jest.useFakeTimers();25 jest.spyOn(window, 'requestAnimationFrame').mockImplementation(() => {});26 figure = makeFigure();27 figure.timeKeeper.reset();28 jest.useFakeTimers();29 figure.add([30 {31 name: 'a',32 make: 'polygon',33 options: {34 radius: 1,35 sides: 4,36 rotation: Math.PI / 4,37 },38 },39 {40 name: 'b',41 make: 'polygon',42 },43 ]);44 a = figure.elements._a;45 // b = figure.elements._b;46 figure.initialize();47 figure.mock.timersBeforeDraw = false;48 ({ recorder } = figure);49 recorder.reset();50 recorder.worker = new Worker();51 recorder.worker.recorder = recorder;52 recorder.stateTimeStep = 0.5;53 // a.pulseSettings.progression = 'tools.math.triangle';54 const startPulse = () => {55 a.pulse({56 duration: 2, scale: 2, when: 'syncNow', progression: 'tools.math.triangle',57 });58 };59 recorder.addEventType('startPulse', startPulse.bind(this));60 const startAnimation = () => {61 a.animations.new()62 .position({ target: [2, 2], duration: 2, progression: 'linear' })63 .start('syncNow');64 };65 recorder.addEventType('startAnimation', startAnimation.bind(this));66 frameStep = 0.1;67 // setup68 figure.mock.timeStep(0, frameStep); // Ok69 recorder.startRecording();70 figure.mock.timeStep(0.5, frameStep); // 0.571 figure.mock.timeStep(0.5, frameStep); // 172 // Start animation at time 173 startAnimation();74 recorder.recordEvent('startAnimation');75 figure.mock.timeStep(0.5, frameStep); // 1.576 figure.mock.timeStep(0.5, frameStep); // 277 // Start pulse at time 278 startPulse();79 recorder.recordEvent('startPulse');80 // debugger;81 figure.mock.timeStep(0.5, frameStep); // 2.582 figure.mock.timeStep(0.5, frameStep); // 383 figure.mock.timeStep(0.5, frameStep); // 3.584 figure.mock.timeStep(0.5, frameStep); // 485 figure.mock.timeStep(0.5, frameStep); // 4.586 figure.mock.timeStep(0.5, frameStep); // 587 recorder.recordEvent('touch', ['up']);88 recorder.stopRecording();89 recorder.seek(0);90 transforms = () => [91 recorder.state,92 a.getPosition().round(3).x,93 a.pulseTransforms.map(t => t.s().round(3).x),94 a.frozenPulseTransforms.map(t => t.s().round(3).x),95 a.drawTransforms.map(t => t.s().round(3).x),96 round(figure.getRemainingAnimationTime(), 3),97 ];98 dissolveTester = (outState, inState, endState, remainingAnimTime) => {99 expect(transforms()).toEqual(['preparingToPlay', ...outState, 1]);100 expect(figure.elements.isShown).toBe(true);101 expect(round(figure.elements.opacity)).toBe(1);102 expect(a.isShown).toBe(true);103 expect(a.opacity).toBe(1);104 expect(round(a.lastDrawOpacity)).toBe(1);105 figure.mock.timeStep(0.4, frameStep);106 expect(transforms()).toEqual(['preparingToPlay', ...outState, 0.6]);107 expect(figure.elements.isShown).toBe(true);108 expect(round(figure.elements.opacity)).toBe(0.5005);109 expect(a.isShown).toBe(true);110 expect(a.opacity).toBe(1);111 expect(round(a.lastDrawOpacity)).toBe(0.5005);112 figure.mock.timeStep(0.4, frameStep);113 expect(transforms()).toEqual(['preparingToPlay', ...outState, 0.2]);114 expect(figure.elements.isShown).toBe(true);115 expect(round(figure.elements.opacity)).toBe(0.001);116 expect(a.isShown).toBe(false);117 expect(a.opacity).toBe(1);118 expect(round(a.lastDrawOpacity)).toBe(0.12588);119 figure.mock.timeStep(0.2, frameStep);120 expect(transforms()).toEqual(['preparingToPlay', ...inState, 0.8]);121 expect(figure.elements.isShown).toBe(true);122 expect(round(figure.elements.opacity)).toBe(0.001);123 expect(a.isShown).toBe(true);124 expect(a.opacity).toBe(0.001);125 expect(round(a.lastDrawOpacity)).toBe(0);126 figure.mock.timeStep(0.4, frameStep);127 expect(transforms()).toEqual(['preparingToPlay', ...inState, 0.4]);128 expect(figure.elements.isShown).toBe(true);129 expect(round(figure.elements.opacity)).toBe(0.5005);130 expect(a.isShown).toBe(true);131 expect(round(a.opacity)).toBe(0.5005);132 expect(round(a.lastDrawOpacity)).toBe(round(0.5005 * 0.5005));133 figure.mock.timeStep(0.4, frameStep);134 expect(transforms()).toEqual(['playing', ...endState, remainingAnimTime]);135 expect(figure.elements.isShown).toBe(true);136 expect(round(figure.elements.opacity)).toBe(1);137 expect(a.isShown).toBe(true);138 expect(a.opacity).toBe(1);139 expect(round(a.lastDrawOpacity)).toBe(1);140 };141 });142 afterEach(() => {143 figure.timeKeeper.reset();144 window.requestAnimationFrame.mockRestore();145 });146 test('Just playback', () => {147 // Note, the animation and pulse are starting on the frame after the desired148 // time. As the frame time is 0.1, then the animations will be 0.1s behind149 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);150 recorder.startPlayback();151 expect(transforms()).toEqual(['playing', 0, [], [], [1], 0]);152 figure.mock.timeStep(0.5, frameStep);153 expect(transforms()).toEqual(['playing', 0, [], [], [1], 0]);154 figure.mock.timeStep(0.5, frameStep);155 expect(transforms()).toEqual(['playing', 0, [], [], [1], 2]);156 figure.mock.timeStep(0.5, frameStep);157 expect(transforms()).toEqual(['playing', 0.5, [], [], [1], 1.5]);158 figure.mock.timeStep(0.5, frameStep);159 expect(transforms()).toEqual(['playing', 1, [], [], [1], 2]);160 figure.mock.timeStep(1, frameStep);161 expect(transforms()).toEqual(['playing', 2, [2], [], [2], 1]);162 figure.mock.timeStep(1, frameStep);163 expect(transforms()).toEqual(['playing', 2, [1], [], [1], 0]);164 figure.mock.timeStep(0.5, frameStep);165 expect(transforms()).toEqual(['playing', 2, [], [], [1], 0]);166 figure.mock.timeStep(0.5, frameStep);167 expect(transforms()).toEqual(['idle', 2, [], [], [1], 0]);168 });169 describe('Seek with no state change', () => {170 test('Seek to before animation', () => {171 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);172 recorder.seek(0.5);173 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);174 recorder.startPlayback();175 expect(transforms()).toEqual(['playing', 0, [], [], [1], 0]);176 figure.mock.timeStep(0.5, frameStep);177 expect(transforms()).toEqual(['playing', 0, [], [], [1], 2]);178 figure.mock.timeStep(0.5, frameStep);179 expect(transforms()).toEqual(['playing', 0.5, [], [], [1], 1.5]);180 });181 test('Seek to start of animation', () => {182 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);183 recorder.seek(1);184 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);185 recorder.startPlayback();186 expect(transforms()).toEqual(['playing', 0, [], [], [1], 2]);187 figure.mock.timeStep(0.5, frameStep);188 expect(transforms()).toEqual(['playing', 0.5, [], [], [1], 1.5]);189 });190 test('Seek to middle of animation, before pulse', () => {191 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);192 recorder.seek(1.5);193 expect(transforms()).toEqual(['idle', 0.5, [], [], [1], 0]);194 recorder.startPlayback();195 expect(transforms()).toEqual(['playing', 0.5, [], [], [1], 1.5]);196 figure.mock.timeStep(0.5, frameStep);197 expect(transforms()).toEqual(['playing', 1, [], [], [1], 2]);198 figure.mock.timeStep(0.5, frameStep);199 expect(transforms()).toEqual(['playing', 1.5, [1.5], [], [1.5], 1.5]);200 });201 test('Seek to end of animation, middle of pulse', () => {202 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);203 recorder.seek(3);204 expect(transforms()).toEqual(['idle', 2, [], [2], [1], 0]);205 recorder.startPlayback();206 expect(transforms()).toEqual(['playing', 2, [2], [], [1], 1]);207 figure.mock.timeStep(0, frameStep);208 expect(transforms()).toEqual(['playing', 2, [2], [], [2], 1]);209 figure.mock.timeStep(0.5, frameStep);210 expect(transforms()).toEqual(['playing', 2, [1.5], [], [1.5], 0.5]);211 figure.mock.timeStep(0.5, frameStep);212 expect(transforms()).toEqual(['playing', 2, [1], [], [1], 0]);213 });214 test('Seek to start of pulse', () => {215 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);216 recorder.seek(2);217 expect(transforms()).toEqual(['idle', 1, [], [], [1], 0]);218 recorder.startPlayback();219 expect(transforms()).toEqual(['playing', 1, [], [], [1], 2]);220 figure.mock.timeStep(0.5, frameStep);221 expect(transforms()).toEqual(['playing', 1.5, [1.5], [], [1.5], 1.5]);222 figure.mock.timeStep(0.5, frameStep);223 expect(transforms()).toEqual(['playing', 2, [2], [], [2], 1]);224 });225 test('Seek to end of pulse', () => {226 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);227 recorder.seek(4);228 expect(transforms()).toEqual(['idle', 2, [1], [], [1], 0]);229 recorder.startPlayback();230 expect(transforms()).toEqual(['playing', 2, [1], [], [1], 0]);231 figure.mock.timeStep(0.5, frameStep);232 expect(transforms()).toEqual(['playing', 2, [], [], [1], 0]);233 });234 test('Seek to after end of pulse', () => {235 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);236 recorder.seek(4.5);237 expect(transforms()).toEqual(['idle', 2, [], [], [1], 0]);238 recorder.startPlayback();239 expect(transforms()).toEqual(['playing', 2, [], [], [1], 0]);240 figure.mock.timeStep(0.5, frameStep);241 expect(transforms()).toEqual(['idle', 2, [], [], [1], 0]);242 });243 });244 describe('Seek to before animation', () => {245 beforeEach(() => {246 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);247 recorder.seek(0.5);248 });249 afterEach(() => {250 expect(transforms()).toEqual(['playing', 0, [], [], [1], 0]);251 figure.mock.timeStep(0.5, frameStep);252 expect(transforms()).toEqual(['playing', 0, [], [], [1], 2]);253 figure.mock.timeStep(0.5, frameStep);254 expect(transforms()).toEqual(['playing', 0.5, [], [], [1], 1.5]);255 figure.mock.timeStep(0.5, frameStep);256 expect(transforms()).toEqual(['playing', 1, [], [], [1], 2]);257 figure.mock.timeStep(1, frameStep);258 expect(transforms()).toEqual(['playing', 2, [2], [], [2], 1]);259 figure.mock.timeStep(1, frameStep);260 expect(transforms()).toEqual(['playing', 2, [1], [], [1], 0]);261 figure.mock.timeStep(0.5, frameStep);262 expect(transforms()).toEqual(['playing', 2, [], [], [1], 0]);263 figure.mock.timeStep(0.5, frameStep);264 expect(transforms()).toEqual(['idle', 2, [], [], [1], 0]);265 });266 test('No state change', () => {267 recorder.startPlayback();268 });269 describe('Position Change', () => {270 beforeEach(() => {271 a.setPosition(2, 2);272 figure.mock.timeStep(1, frameStep);273 expect(transforms()).toEqual(['idle', 2, [], [], [1], 0]);274 });275 test('Instant', () => {276 recorder.settings.play = 'instant';277 recorder.startPlayback();278 });279 test('Animate', () => {280 recorder.settings.play = {281 how: 'animate',282 velocity: {},283 };284 recorder.startPlayback();285 expect(transforms()).toEqual(['preparingToPlay', 2, [], [], [1], 1]);286 figure.mock.timeStep(0.5, frameStep);287 expect(transforms()).toEqual(['preparingToPlay', 1, [], [], [1], 0.5]);288 figure.mock.timeStep(0.5, frameStep);289 });290 test('Dissolve', () => {291 recorder.settings.play = 'dissolve';292 recorder.startPlayback();293 dissolveTester(294 [2, [], [], [1]],295 [0, [], [], [1]],296 [0, [], [], [1]],297 0,298 );299 // First animation is dissolve out for 0.8s, and delay for 0.2s300 // expect(transforms()).toEqual(['preparingToPlay', 2, [], [], [1], 1]);301 // expect(figure.elements.isShown).toBe(true);302 // expect(round(figure.elements.opacity)).toBe(1);303 // expect(a.isShown).toBe(true);304 // expect(a.opacity).toBe(1);305 // expect(round(a.lastDrawOpacity)).toBe(1);306 // figure.mock.timeStep(0.4, frameStep);307 // expect(transforms()).toEqual(['preparingToPlay', 2, [], [], [1], 0.6]);308 // expect(figure.elements.isShown).toBe(true);309 // expect(round(figure.elements.opacity)).toBe(0.5005);310 // expect(a.isShown).toBe(true);311 // expect(a.opacity).toBe(1);312 // expect(round(a.lastDrawOpacity)).toBe(0.5005);313 // figure.mock.timeStep(0.4, frameStep);314 // expect(transforms()).toEqual(['preparingToPlay', 2, [], [], [1], 0.2]);315 // expect(figure.elements.isShown).toBe(true);316 // expect(round(figure.elements.opacity)).toBe(1);317 // expect(a.isShown).toBe(false);318 // expect(a.opacity).toBe(1);319 // expect(round(a.lastDrawOpacity)).toBe(0.12587);320 // figure.mock.timeStep(0.2, frameStep);321 // expect(transforms()).toEqual(['preparingToPlay', 0, [], [], [1], 0.8]);322 // expect(figure.elements.isShown).toBe(true);323 // expect(round(figure.elements.opacity)).toBe(0.001);324 // expect(a.isShown).toBe(true);325 // expect(a.opacity).toBe(0.001);326 // expect(round(a.lastDrawOpacity)).toBe(0);327 // figure.mock.timeStep(0.4, frameStep);328 // expect(transforms()).toEqual(['preparingToPlay', 0, [], [], [1], 0.4]);329 // expect(figure.elements.isShown).toBe(true);330 // expect(round(figure.elements.opacity)).toBe(0.5005);331 // expect(a.isShown).toBe(true);332 // expect(round(a.opacity)).toBe(0.5005);333 // expect(round(a.lastDrawOpacity)).toBe(round(0.5005 * 0.5005));334 // figure.mock.timeStep(0.4, frameStep);335 // expect(transforms()).toEqual(['playing', 0, [], [], [1], 0]);336 // expect(figure.elements.isShown).toBe(true);337 // expect(round(figure.elements.opacity)).toBe(1);338 // expect(a.isShown).toBe(true);339 // expect(a.opacity).toBe(1);340 // expect(round(a.lastDrawOpacity)).toBe(1);341 });342 });343 describe('Pulse Change', () => {344 beforeEach(() => {345 figure.unpause();346 // a.pulseNow(2, 2);347 a.pulse({ duration: 2, scale: 2, when: 'syncNow' });348 figure.mock.timeStep(0);349 figure.mock.timeStep(0.5, frameStep);350 figure.mock.timeStep(0.5, frameStep);351 expect(transforms()).toEqual(['idle', 0, [2], [], [2], 1]);352 });353 test('Instant', () => {354 recorder.settings.play = 'instant';355 recorder.startPlayback();356 expect(transforms()).toEqual(['playing', 0, [], [], [2], 0]);357 // So let's update it so the afterEach works358 figure.mock.timeStep(0);359 expect(transforms()).toEqual(['playing', 0, [], [], [1], 0]);360 });361 test('Animate', () => {362 recorder.settings.play = {363 how: 'animate',364 velocity: {},365 };366 recorder.startPlayback();367 expect(transforms()).toEqual(['preparingToPlay', 0, [], [2], [2], 1]);368 figure.mock.timeStep(0.5, frameStep);369 expect(transforms()).toEqual(['preparingToPlay', 0, [], [1.5], [1.5], 0.5]);370 figure.mock.timeStep(0.5, frameStep);371 });372 test('Dissolve', () => {373 recorder.settings.play = 'dissolve';374 recorder.startPlayback();375 dissolveTester(376 [0, [], [2], [2]],377 [0, [], [], [1]],378 [0, [], [], [1]],379 0,380 );381 });382 });383 describe('Position and Pulse Change', () => {384 beforeEach(() => {385 figure.unpause();386 // a.pulseNow(2, 2);387 a.pulse({ duration: 2, scale: 2, when: 'syncNow' });388 a.setPosition(2, 2);389 figure.mock.timeStep(0);390 figure.mock.timeStep(0.5, frameStep);391 figure.mock.timeStep(0.5, frameStep);392 expect(transforms()).toEqual(['idle', 2, [2], [], [2], 1]);393 });394 test('Instant', () => {395 recorder.settings.play = 'instant';396 recorder.startPlayback();397 // The old drawTransform scale is not yet updated398 expect(transforms()).toEqual(['playing', 0, [], [], [2], 0]);399 // So let's update it so the afterEach works400 figure.mock.timeStep(0);401 expect(transforms()).toEqual(['playing', 0, [], [], [1], 0]);402 });403 test('Animate', () => {404 recorder.settings.play = {405 how: 'animate',406 velocity: {},407 };408 recorder.startPlayback();409 expect(transforms()).toEqual(['preparingToPlay', 2, [], [2], [2], 1]);410 figure.mock.timeStep(0.5, frameStep);411 expect(transforms()).toEqual(['preparingToPlay', 1, [], [1.5], [1.5], 0.5]);412 figure.mock.timeStep(0.5, frameStep);413 });414 test('Dissolve', () => {415 recorder.settings.play = 'dissolve';416 recorder.startPlayback();417 dissolveTester(418 [2, [], [2], [2]],419 [0, [], [], [1]],420 [0, [], [], [1]],421 0,422 );423 });424 });425 });426 describe('Seek to start of animation', () => {427 beforeEach(() => {428 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);429 recorder.seek(1);430 });431 afterEach(() => {432 expect(transforms()).toEqual(['playing', 0, [], [], [1], 2]);433 figure.mock.timeStep(0.5, frameStep);434 expect(transforms()).toEqual(['playing', 0.5, [], [], [1], 1.5]);435 figure.mock.timeStep(0.5, frameStep);436 expect(transforms()).toEqual(['playing', 1, [], [], [1], 2]);437 figure.mock.timeStep(1, frameStep);438 expect(transforms()).toEqual(['playing', 2, [2], [], [2], 1]);439 figure.mock.timeStep(1, frameStep);440 expect(transforms()).toEqual(['playing', 2, [1], [], [1], 0]);441 figure.mock.timeStep(0.5, frameStep);442 expect(transforms()).toEqual(['playing', 2, [], [], [1], 0]);443 figure.mock.timeStep(0.5, frameStep);444 expect(transforms()).toEqual(['idle', 2, [], [], [1], 0]);445 });446 test('No state change', () => {447 recorder.startPlayback();448 expect(transforms()).toEqual(['playing', 0, [], [], [1], 2]);449 });450 describe('Position Change', () => {451 beforeEach(() => {452 a.setPosition(2, 2);453 figure.mock.timeStep(1, frameStep);454 expect(transforms()).toEqual(['idle', 2, [], [], [1], 0]);455 });456 test('Instant', () => {457 recorder.settings.play = 'instant';458 recorder.startPlayback();459 });460 test('Animate', () => {461 recorder.settings.play = {462 how: 'animate',463 velocity: {},464 };465 recorder.startPlayback();466 expect(transforms()).toEqual(['preparingToPlay', 2, [], [], [1], 1]);467 figure.mock.timeStep(0.5, frameStep);468 expect(transforms()).toEqual(['preparingToPlay', 1, [], [], [1], 0.5]);469 figure.mock.timeStep(0.5, frameStep);470 });471 test('Dissolve', () => {472 recorder.settings.play = 'dissolve';473 recorder.startPlayback();474 dissolveTester(475 [2, [], [], [1]],476 [0, [], [], [1]],477 [0, [], [], [1]],478 2,479 );480 });481 });482 describe('Pulse Change', () => {483 beforeEach(() => {484 figure.unpause();485 // a.pulseNow(2, 2);486 a.pulse({ scale: 2, duration: 2, when: 'syncNow' });487 figure.mock.timeStep(0);488 figure.mock.timeStep(0.5, frameStep);489 figure.mock.timeStep(0.5, frameStep);490 expect(transforms()).toEqual(['idle', 0, [2], [], [2], 1]);491 });492 test('Instant', () => {493 recorder.settings.play = 'instant';494 recorder.startPlayback();495 // The old drawTransform scale will be updated on the next draw496 expect(transforms()).toEqual(['playing', 0, [], [], [2], 2]);497 figure.mock.timeStep(0);498 expect(transforms()).toEqual(['playing', 0, [], [], [1], 2]);499 });500 test('Animate', () => {501 recorder.settings.play = {502 how: 'animate',503 velocity: {},504 };505 recorder.startPlayback();506 expect(transforms()).toEqual(['preparingToPlay', 0, [], [2], [2], 1]);507 figure.mock.timeStep(0.5, frameStep);508 expect(transforms()).toEqual(['preparingToPlay', 0, [], [1.5], [1.5], 0.5]);509 figure.mock.timeStep(0.5, frameStep);510 // expect(transforms()).toEqual(['playing', 0, [], [], [1], 2]);511 });512 test('Dissolve', () => {513 recorder.settings.play = 'dissolve';514 recorder.startPlayback();515 dissolveTester(516 [0, [], [2], [2]],517 [0, [], [], [1]],518 [0, [], [], [1]],519 2,520 );521 // expect(transforms()).toEqual(['playing', 0, [], [], [1], 2]);522 });523 });524 describe('Position and Pulse Change', () => {525 beforeEach(() => {526 figure.unpause();527 // a.pulseNow(2, 2);528 a.pulse({ scale: 2, duration: 2, when: 'syncNow' });529 a.setPosition(2, 2);530 figure.mock.timeStep(0);531 figure.mock.timeStep(0.5, frameStep);532 figure.mock.timeStep(0.5, frameStep);533 expect(transforms()).toEqual(['idle', 2, [2], [], [2], 1]);534 });535 test('Instant', () => {536 recorder.settings.play = 'instant';537 recorder.startPlayback();538 // drawTransforms will update on next draw frame539 expect(transforms()).toEqual(['playing', 0, [], [], [2], 2]);540 figure.mock.timeStep(0);541 expect(transforms()).toEqual(['playing', 0, [], [], [1], 2]);542 });543 test('Animate', () => {544 recorder.settings.play = {545 how: 'animate',546 velocity: {},547 };548 recorder.startPlayback();549 expect(transforms()).toEqual(['preparingToPlay', 2, [], [2], [2], 1]);550 figure.mock.timeStep(0.5, frameStep);551 expect(transforms()).toEqual(['preparingToPlay', 1, [], [1.5], [1.5], 0.5]);552 figure.mock.timeStep(0.5, frameStep);553 // expect(transforms()).toEqual(['playing', 0, [], [], [1], 2]);554 });555 test('Dissolve', () => {556 recorder.settings.play = 'dissolve';557 recorder.startPlayback();558 dissolveTester(559 [2, [], [2], [2]],560 [0, [], [], [1]],561 [0, [], [], [1]],562 2,563 );564 // expect(transforms()).toEqual(['playing', 0, [], [], [1], 2]);565 });566 });567 });568 describe('Seek to middle of animation', () => {569 beforeEach(() => {570 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);571 recorder.seek(1.5);572 });573 afterEach(() => {574 // expect(transforms()).toEqual(['playing', 0.4, [], [], [1], 1.6]);575 expect(transforms()).toEqual(['playing', 0.5, [], [], [1], 1.5]);576 figure.mock.timeStep(0.5, frameStep);577 expect(transforms()).toEqual(['playing', 1, [], [], [1], 2]);578 figure.mock.timeStep(1, frameStep);579 expect(transforms()).toEqual(['playing', 2, [2], [], [2], 1]);580 figure.mock.timeStep(1, frameStep);581 expect(transforms()).toEqual(['playing', 2, [1], [], [1], 0]);582 figure.mock.timeStep(0.5, frameStep);583 expect(transforms()).toEqual(['playing', 2, [], [], [1], 0]);584 figure.mock.timeStep(0.5, frameStep);585 expect(transforms()).toEqual(['idle', 2, [], [], [1], 0]);586 });587 test('No state change', () => {588 recorder.startPlayback();589 expect(transforms()).toEqual(['playing', 0.5, [], [], [1], 1.5]);590 });591 describe('Position Change', () => {592 beforeEach(() => {593 a.setPosition(2.5, 2.5);594 figure.mock.timeStep(1, frameStep);595 });596 test('Instant', () => {597 recorder.settings.play = 'instant';598 recorder.startPlayback();599 });600 test('Animate', () => {601 recorder.settings.play = {602 how: 'animate',603 velocity: {},604 };605 recorder.startPlayback();606 expect(transforms()).toEqual(['preparingToPlay', 2.5, [], [], [1], 1]);607 figure.mock.timeStep(0.5, frameStep);608 expect(transforms()).toEqual(['preparingToPlay', 1.5, [], [], [1], 0.5]);609 figure.mock.timeStep(0.5, frameStep);610 });611 test('Dissolve', () => {612 recorder.settings.play = 'dissolve';613 recorder.startPlayback();614 dissolveTester(615 [2.5, [], [], [1]],616 [0.5, [], [], [1]],617 [0.5, [], [], [1]],618 1.5,619 );620 });621 });622 describe('Pulse Change', () => {623 beforeEach(() => {624 figure.unpause();625 a.pulse({ duration: 2, scale: 2, when: 'syncNow' });626 // figure.mock.timeStep(0);627 figure.mock.timeStep(0.5, frameStep);628 figure.mock.timeStep(0.5, frameStep);629 expect(transforms()).toEqual(['idle', 0.5, [2], [], [2], 1]);630 });631 test('Instant', () => {632 recorder.settings.play = 'instant';633 recorder.startPlayback();634 expect(transforms()).toEqual(['playing', 0.5, [], [], [2], 1.5]);635 figure.mock.timeStep(0);636 expect(transforms()).toEqual(['playing', 0.5, [], [], [1], 1.5]);637 });638 test('Animate', () => {639 recorder.settings.play = {640 how: 'animate',641 velocity: {},642 };643 recorder.startPlayback();644 expect(transforms()).toEqual(['preparingToPlay', 0.5, [], [2], [2], 1]);645 figure.mock.timeStep(0.5, frameStep);646 expect(transforms()).toEqual(['preparingToPlay', 0.5, [], [1.5], [1.5], 0.5]);647 figure.mock.timeStep(0.5, frameStep);648 expect(transforms()).toEqual(['playing', 0.5, [], [], [1], 1.5]);649 });650 test('Dissolve', () => {651 recorder.settings.play = 'dissolve';652 recorder.startPlayback();653 dissolveTester(654 [0.5, [], [2], [2]],655 [0.5, [], [], [1]],656 [0.5, [], [], [1]],657 1.5,658 );659 expect(transforms()).toEqual(['playing', 0.5, [], [], [1], 1.5]);660 });661 });662 describe('Position and Pulse Change', () => {663 beforeEach(() => {664 figure.unpause();665 // a.pulseNow(2, 2);666 a.pulse({ duration: 2, scale: 2, when: 'syncNow' });667 a.setPosition(2.5, 2.5);668 figure.mock.timeStep(0);669 figure.mock.timeStep(0.5, frameStep);670 figure.mock.timeStep(0.5, frameStep);671 expect(transforms()).toEqual(['idle', 2.5, [2], [], [2], 1]);672 });673 test('Instant', () => {674 recorder.settings.play = 'instant';675 recorder.startPlayback();676 expect(transforms()).toEqual(['playing', 0.5, [], [], [2], 1.5]);677 figure.mock.timeStep(0);678 expect(transforms()).toEqual(['playing', 0.5, [], [], [1], 1.5]);679 });680 test('Animate', () => {681 recorder.settings.play = {682 how: 'animate',683 velocity: {},684 };685 recorder.startPlayback();686 expect(transforms()).toEqual(['preparingToPlay', 2.5, [], [2], [2], 1]);687 figure.mock.timeStep(0.5, frameStep);688 expect(transforms()).toEqual(['preparingToPlay', 1.5, [], [1.5], [1.5], 0.5]);689 figure.mock.timeStep(0.5, frameStep);690 expect(transforms()).toEqual(['playing', 0.5, [], [], [1], 1.5]);691 });692 test('Dissolve', () => {693 recorder.settings.play = 'dissolve';694 recorder.startPlayback();695 dissolveTester(696 [2.5, [], [2], [2]],697 [0.5, [], [], [1]],698 [0.5, [], [], [1]],699 1.5,700 );701 expect(transforms()).toEqual(['playing', 0.5, [], [], [1], 1.5]);702 });703 });704 });705 describe('Seek to start of pulse', () => {706 beforeEach(() => {707 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);708 recorder.seek(2);709 expect(transforms()).toEqual(['idle', 1, [], [], [1], 0]);710 });711 afterEach(() => {712 figure.mock.timeStep(1, frameStep);713 expect(transforms()).toEqual(['playing', 2, [2], [], [2], 1]);714 figure.mock.timeStep(1, frameStep);715 expect(transforms()).toEqual(['playing', 2, [1], [], [1], 0]);716 figure.mock.timeStep(0.5, frameStep);717 expect(transforms()).toEqual(['playing', 2, [], [], [1], 0]);718 figure.mock.timeStep(0.5, frameStep);719 expect(transforms()).toEqual(['idle', 2, [], [], [1], 0]);720 });721 test('No state change', () => {722 recorder.startPlayback();723 expect(transforms()).toEqual(['playing', 1, [], [], [1], 2]);724 });725 describe('Position Change', () => {726 beforeEach(() => {727 a.setPosition(3, 3);728 figure.mock.timeStep(1, frameStep);729 expect(transforms()).toEqual(['idle', 3, [], [], [1], 0]);730 });731 test('Instant', () => {732 recorder.settings.play = 'instant';733 recorder.startPlayback();734 expect(transforms()).toEqual(['playing', 1, [], [], [1], 2]);735 });736 // only next737 test('Animate', () => {738 recorder.settings.play = {739 how: 'animate',740 velocity: {},741 };742 // debugger;743 recorder.startPlayback();744 expect(transforms()).toEqual(['preparingToPlay', 3, [], [], [1], 1]);745 figure.mock.timeStep(0.5, frameStep);746 expect(transforms()).toEqual(['preparingToPlay', 2, [], [], [1], 0.5]);747 figure.mock.timeStep(0.4, frameStep);748 figure.mock.timeStep(0.1, frameStep);749 expect(transforms()).toEqual(['playing', 1, [1], [], [1], 2]);750 });751 test('Dissolve', () => {752 recorder.settings.play = 'dissolve';753 recorder.startPlayback();754 dissolveTester(755 [3, [], [], [1]],756 [1, [], [], [1]],757 [1, [1], [], [1]],758 2,759 );760 expect(transforms()).toEqual(['playing', 1, [1], [], [1], 2]);761 });762 });763 describe('Pulse Change', () => {764 beforeEach(() => {765 figure.unpause();766 a.pulse({ duration: 2, scale: 2, when: 'syncNow' });767 figure.mock.timeStep(0.5, frameStep);768 figure.mock.timeStep(0.5, frameStep);769 expect(transforms()).toEqual(['idle', 1, [2], [], [2], 1]);770 });771 test('Instant', () => {772 recorder.settings.play = 'instant';773 recorder.startPlayback();774 expect(transforms()).toEqual(['playing', 1, [], [], [2], 2]);775 figure.mock.timeStep(0);776 expect(transforms()).toEqual(['playing', 1, [1], [], [1], 2]);777 });778 test('Animate', () => {779 recorder.settings.play = {780 how: 'animate',781 velocity: {},782 };783 recorder.startPlayback();784 expect(transforms()).toEqual(['preparingToPlay', 1, [], [2], [2], 1]);785 figure.mock.timeStep(0.5, frameStep);786 expect(transforms()).toEqual(['preparingToPlay', 1, [], [1.5], [1.5], 0.5]);787 figure.mock.timeStep(0.5, frameStep);788 expect(transforms()).toEqual(['playing', 1, [1], [], [1], 2]);789 });790 test('Dissolve', () => {791 recorder.settings.play = 'dissolve';792 recorder.startPlayback();793 dissolveTester(794 [1, [], [2], [2]],795 [1, [], [], [1]],796 [1, [1], [], [1]],797 2,798 );799 expect(transforms()).toEqual(['playing', 1, [1], [], [1], 2]);800 });801 });802 describe('Position and Pulse Change', () => {803 beforeEach(() => {804 figure.unpause();805 // a.pulseNow(2, 2);806 a.pulse({ duration: 2, scale: 2, when: 'syncNow' });807 a.setPosition(3, 3);808 figure.mock.timeStep(0);809 figure.mock.timeStep(0.5, frameStep);810 figure.mock.timeStep(0.5, frameStep);811 expect(transforms()).toEqual(['idle', 3, [2], [], [2], 1]);812 });813 test('Instant', () => {814 recorder.settings.play = 'instant';815 recorder.startPlayback();816 expect(transforms()).toEqual(['playing', 1, [], [], [2], 2]);817 figure.mock.timeStep(0);818 expect(transforms()).toEqual(['playing', 1, [1], [], [1], 2]);819 });820 test('Animate', () => {821 recorder.settings.play = {822 how: 'animate',823 velocity: {},824 };825 recorder.startPlayback();826 expect(transforms()).toEqual(['preparingToPlay', 3, [], [2], [2], 1]);827 figure.mock.timeStep(0.5, frameStep);828 expect(transforms()).toEqual(['preparingToPlay', 2, [], [1.5], [1.5], 0.5]);829 figure.mock.timeStep(0.5, frameStep);830 expect(transforms()).toEqual(['playing', 1, [1], [], [1], 2]);831 });832 test('Dissolve', () => {833 recorder.settings.play = 'dissolve';834 recorder.startPlayback();835 dissolveTester(836 [3, [], [2], [2]],837 [1, [], [], [1]],838 [1, [1], [], [1]],839 2,840 );841 expect(transforms()).toEqual(['playing', 1, [1], [], [1], 2]);842 });843 });844 });845 describe('Seek to middle of pulse', () => {846 beforeEach(() => {847 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);848 recorder.seek(3.5);849 expect(transforms()).toEqual(['idle', 2, [], [1.5], [1], 0]);850 figure.mock.timeStep(0, frameStep);851 expect(transforms()).toEqual(['idle', 2, [], [1.5], [1.5], 0]);852 });853 afterEach(() => {854 expect(transforms()).toEqual(['playing', 2, [1.5], [], [1.5], 0.5]);855 figure.mock.timeStep(0.5, frameStep);856 expect(transforms()).toEqual(['playing', 2, [1], [], [1], 0]);857 figure.mock.timeStep(0.5, frameStep);858 expect(transforms()).toEqual(['playing', 2, [], [], [1], 0]);859 figure.mock.timeStep(0.5, frameStep);860 expect(transforms()).toEqual(['idle', 2, [], [], [1], 0]);861 });862 test('No state change', () => {863 recorder.startPlayback();864 expect(transforms()).toEqual(['playing', 2, [1.5], [], [1.5], 0.5]);865 figure.mock.timeStep(0);866 expect(transforms()).toEqual(['playing', 2, [1.5], [], [1.5], 0.5]);867 });868 describe('Position Change', () => {869 beforeEach(() => {870 // expect(transforms()).toEqual(['idle', 2, [], [1.5], [1], 0]);871 // figure.mock.timeStep(0, frameStep);872 // expect(transforms()).toEqual(['idle', 2, [], [1.5], [1.5], 0]);873 a.setPosition(4, 4);874 expect(transforms()).toEqual(['idle', 4, [], [1.5], [1.5], 0]);875 figure.mock.timeStep(1, frameStep);876 expect(transforms()).toEqual(['idle', 4, [], [1.5], [1.5], 0]);877 });878 test('Instant', () => {879 recorder.settings.play = 'instant';880 recorder.startPlayback();881 });882 // only next883 test('Animate', () => {884 recorder.settings.play = {885 how: 'animate',886 velocity: {},887 };888 // debugger;889 recorder.startPlayback();890 expect(transforms()).toEqual(['preparingToPlay', 4, [], [1.5], [1.5], 1]);891 figure.mock.timeStep(0.5, frameStep);892 expect(transforms()).toEqual(['preparingToPlay', 3, [], [1.5], [1.5], 0.5]);893 figure.mock.timeStep(0.4, frameStep);894 figure.mock.timeStep(0.1, frameStep);895 });896 test('Dissolve', () => {897 recorder.settings.play = 'dissolve';898 recorder.startPlayback();899 dissolveTester(900 [4, [], [1.5], [1.5]],901 [2, [], [1.5], [1.5]],902 [2, [1.5], [], [1.5]],903 0.5,904 );905 });906 });907 describe('Pulse Change', () => {908 beforeEach(() => {909 figure.unpause();910 a.pulse({ duration: 2, scale: 2.5, when: 'syncNow' });911 figure.mock.timeStep(0.5, frameStep);912 figure.mock.timeStep(0.5, frameStep);913 expect(transforms()).toEqual(['idle', 2, [2.5], [], [2.5], 1]);914 });915 test('Instant', () => {916 recorder.settings.play = 'instant';917 recorder.startPlayback();918 expect(transforms()).toEqual(['playing', 2, [1.5], [], [2.5], 0.5]);919 figure.mock.timeStep(0);920 });921 test('Animate', () => {922 recorder.settings.play = {923 how: 'animate',924 velocity: {},925 };926 recorder.startPlayback();927 expect(transforms()).toEqual(['preparingToPlay', 2, [], [2.5], [2.5], 1]);928 figure.mock.timeStep(0.5, frameStep);929 expect(transforms()).toEqual(['preparingToPlay', 2, [], [2], [2], 0.5]);930 figure.mock.timeStep(0.5, frameStep);931 });932 test('Dissolve', () => {933 recorder.settings.play = 'dissolve';934 recorder.startPlayback();935 dissolveTester(936 [2, [], [2.5], [2.5]],937 [2, [], [1.5], [1.5]],938 [2, [1.5], [], [1.5]],939 0.5,940 );941 });942 });943 describe('Position and Pulse Change', () => {944 beforeEach(() => {945 figure.unpause();946 // a.pulseNow(2, 2);947 a.pulse({ duration: 2, scale: 2.5, when: 'syncNow' });948 a.setPosition(4, 4);949 figure.mock.timeStep(0);950 figure.mock.timeStep(0.5, frameStep);951 figure.mock.timeStep(0.5, frameStep);952 expect(transforms()).toEqual(['idle', 4, [2.5], [], [2.5], 1]);953 });954 test('Instant', () => {955 recorder.settings.play = 'instant';956 recorder.startPlayback();957 expect(transforms()).toEqual(['playing', 2, [1.5], [], [2.5], 0.5]);958 figure.mock.timeStep(0);959 });960 test('Animate', () => {961 recorder.settings.play = {962 how: 'animate',963 velocity: {},964 };965 recorder.startPlayback();966 expect(transforms()).toEqual(['preparingToPlay', 4, [], [2.5], [2.5], 1]);967 figure.mock.timeStep(0.5, frameStep);968 expect(transforms()).toEqual(['preparingToPlay', 3, [], [2], [2], 0.5]);969 figure.mock.timeStep(0.5, frameStep);970 });971 test('Dissolve', () => {972 recorder.settings.play = 'dissolve';973 recorder.startPlayback();974 dissolveTester(975 [4, [], [2.5], [2.5]],976 [2, [], [1.5], [1.5]],977 [2, [1.5], [], [1.5]],978 0.5,979 );980 });981 });982 });983 describe('Seek to end of pulse', () => {984 beforeEach(() => {985 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);986 recorder.seek(4);987 expect(transforms()).toEqual(['idle', 2, [1], [], [1], 0]);988 });989 afterEach(() => {990 expect(transforms()).toEqual(['playing', 2, [], [], [1], 0]);991 figure.mock.timeStep(0.5, frameStep);992 expect(transforms()).toEqual(['playing', 2, [], [], [1], 0]);993 figure.mock.timeStep(0.5, frameStep);994 expect(transforms()).toEqual(['idle', 2, [], [], [1], 0]);995 });996 describe('No state change', () => {997 afterEach(() => {998 // recorder.startPlayback();999 expect(transforms()).toEqual(['playing', 2, [1], [], [1], 0]);1000 figure.mock.timeStep(0);1001 expect(transforms()).toEqual(['playing', 2, [], [], [1], 0]);1002 });1003 test('Instant', () => {1004 recorder.settings.play = 'instant';1005 recorder.startPlayback();1006 });1007 test('Animate', () => {1008 recorder.settings.play = {1009 how: 'animate',1010 velocity: {},1011 };1012 recorder.startPlayback();1013 });1014 test('Dissolve', () => {1015 recorder.settings.play = 'dissolve';1016 recorder.startPlayback();1017 // dissolveTester(1018 // [2, [], [], [1]],1019 // [2, [], [1], [1]],1020 // [2, [], [], [1]],1021 // 0,1022 // );1023 });1024 });1025 describe('Position Change', () => {1026 beforeEach(() => {1027 a.setPosition(4, 4);1028 figure.mock.timeStep(1, frameStep);1029 expect(transforms()).toEqual(['idle', 4, [], [], [1], 0]);1030 });1031 test('Instant', () => {1032 recorder.settings.play = 'instant';1033 recorder.startPlayback();1034 expect(transforms()).toEqual(['playing', 2, [1], [], [1], 0]);1035 figure.mock.timeStep(0);1036 expect(transforms()).toEqual(['playing', 2, [], [], [1], 0]);1037 });1038 // only next1039 test('Animate', () => {1040 recorder.settings.play = {1041 how: 'animate',1042 velocity: {},1043 };1044 // debugger;1045 recorder.startPlayback();1046 expect(transforms()).toEqual(['preparingToPlay', 4, [], [1], [1], 1]);1047 figure.mock.timeStep(0.5, frameStep);1048 expect(transforms()).toEqual(['preparingToPlay', 3, [], [1], [1], 0.5]);1049 figure.mock.timeStep(0.5, frameStep);1050 });1051 test('Dissolve', () => {1052 recorder.settings.play = 'dissolve';1053 recorder.startPlayback();1054 dissolveTester(1055 [4, [], [], [1]],1056 [2, [], [1], [1]],1057 [2, [], [], [1]],1058 0,1059 );1060 });1061 });1062 describe('Pulse Change', () => {1063 beforeEach(() => {1064 figure.unpause();1065 a.pulse({ duration: 2, scale: 2, when: 'syncNow' });1066 figure.mock.timeStep(0.5, frameStep);1067 figure.mock.timeStep(0.5, frameStep);1068 expect(transforms()).toEqual(['idle', 2, [2], [], [2], 1]);1069 });1070 test('Instant', () => {1071 recorder.settings.play = 'instant';1072 recorder.startPlayback();1073 expect(transforms()).toEqual(['playing', 2, [1], [], [2], 0]);1074 figure.mock.timeStep(0);1075 });1076 test('Animate', () => {1077 recorder.settings.play = {1078 how: 'animate',1079 velocity: {},1080 };1081 recorder.startPlayback();1082 expect(transforms()).toEqual(['preparingToPlay', 2, [], [2], [2], 1]);1083 figure.mock.timeStep(0.5, frameStep);1084 expect(transforms()).toEqual(['preparingToPlay', 2, [], [1.5], [1.5], 0.5]);1085 figure.mock.timeStep(0.5, frameStep);1086 });1087 test('Dissolve', () => {1088 recorder.settings.play = 'dissolve';1089 recorder.startPlayback();1090 dissolveTester(1091 [2, [], [2], [2]],1092 [2, [], [1], [1]],1093 [2, [], [], [1]],1094 0,1095 );1096 });1097 });1098 describe('Position and Pulse Change', () => {1099 beforeEach(() => {1100 figure.unpause();1101 a.pulse({ duration: 2, scale: 2, when: 'syncNow' });1102 a.setPosition(4, 4);1103 figure.mock.timeStep(0);1104 figure.mock.timeStep(0.5, frameStep);1105 figure.mock.timeStep(0.5, frameStep);1106 expect(transforms()).toEqual(['idle', 4, [2], [], [2], 1]);1107 });1108 test('Instant', () => {1109 recorder.settings.play = 'instant';1110 recorder.startPlayback();1111 expect(transforms()).toEqual(['playing', 2, [1], [], [2], 0]);1112 figure.mock.timeStep(0);1113 });1114 test('Animate', () => {1115 recorder.settings.play = {1116 how: 'animate',1117 velocity: {},1118 };1119 recorder.startPlayback();1120 expect(transforms()).toEqual(['preparingToPlay', 4, [], [2], [2], 1]);1121 figure.mock.timeStep(0.5, frameStep);1122 expect(transforms()).toEqual(['preparingToPlay', 3, [], [1.5], [1.5], 0.5]);1123 figure.mock.timeStep(0.5, frameStep);1124 });1125 test('Dissolve', () => {1126 recorder.settings.play = 'dissolve';1127 recorder.startPlayback();1128 dissolveTester(1129 [4, [], [2], [2]],1130 [2, [], [1], [1]],1131 [2, [], [], [1]],1132 0,1133 );1134 });1135 });1136 });1137 test('Seek to middle of animation, touch and move figure element', () => {1138 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);1139 recorder.seek(1.5);1140 figure.mock.timeStep(0);1141 // figure.unpause();1142 a.setMovable(true);1143 // figure.mock.touchDown([0.5, 0.5]);1144 figure.mock.touchDown([0.5, 0.5]);1145 figure.mock.touchMove([4, 4]);1146 expect(a.getPosition().round().x).toBe(4);1147 });1148 test('Seek to middle of animation, start another animation', () => {1149 expect(transforms()).toEqual(['idle', 0, [], [], [1], 0]);1150 recorder.seek(1.5);1151 figure.mock.timeStep(0);1152 // figure.unpause();1153 a.animations.new()1154 .position({ target: [1.5, 1.5], duration: 1 })1155 .start();1156 figure.mock.timeStep(0);1157 expect(a.getPosition().round().x).toBe(0.5);1158 figure.mock.timeStep(0.5);1159 expect(a.getPosition().round().x).toBe(1);1160 figure.mock.timeStep(1);1161 expect(a.getPosition().round().x).toBe(1.5);1162 });...
video_decode_stats_recorder.mojom.js
Source:video_decode_stats_recorder.mojom.js
1// media/mojo/mojom/video_decode_stats_recorder.mojom.js is auto generated by mojom_bindings_generator.py, do not edit2// Copyright 2014 The Chromium Authors. All rights reserved.3// Use of this source code is governed by a BSD-style license that can be4// found in the LICENSE file.5'use strict';6(function() {7 var mojomId = 'media/mojo/mojom/video_decode_stats_recorder.mojom';8 if (mojo.internal.isMojomLoaded(mojomId)) {9 console.warn('The following mojom is loaded multiple times: ' + mojomId);10 return;11 }12 mojo.internal.markMojomLoaded(mojomId);13 var bindings = mojo;14 var associatedBindings = mojo;15 var codec = mojo.internal;16 var validator = mojo.internal;17 var exports = mojo.internal.exposeNamespace('media.mojom');18 var media_types$ =19 mojo.internal.exposeNamespace('media.mojom');20 if (mojo.config.autoLoadMojomDeps) {21 mojo.internal.loadMojomIfNecessary(22 'media/mojo/mojom/media_types.mojom', 'media_types.mojom.js');23 }24 var geometry$ =25 mojo.internal.exposeNamespace('gfx.mojom');26 if (mojo.config.autoLoadMojomDeps) {27 mojo.internal.loadMojomIfNecessary(28 'ui/gfx/geometry/mojom/geometry.mojom', '../../../ui/gfx/geometry/mojom/geometry.mojom.js');29 }30 function VideoDecodeStatsRecorder_StartNewRecord_Params(values) {31 this.initDefaults_();32 this.initFields_(values);33 }34 VideoDecodeStatsRecorder_StartNewRecord_Params.prototype.initDefaults_ = function() {35 this.features = null;36 };37 VideoDecodeStatsRecorder_StartNewRecord_Params.prototype.initFields_ = function(fields) {38 for(var field in fields) {39 if (this.hasOwnProperty(field))40 this[field] = fields[field];41 }42 };43 VideoDecodeStatsRecorder_StartNewRecord_Params.validate = function(messageValidator, offset) {44 var err;45 err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);46 if (err !== validator.validationError.NONE)47 return err;48 var kVersionSizes = [49 {version: 0, numBytes: 16}50 ];51 err = messageValidator.validateStructVersion(offset, kVersionSizes);52 if (err !== validator.validationError.NONE)53 return err;54 // validate VideoDecodeStatsRecorder_StartNewRecord_Params.features55 err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 0, media_types$.PredictionFeatures, false);56 if (err !== validator.validationError.NONE)57 return err;58 return validator.validationError.NONE;59 };60 VideoDecodeStatsRecorder_StartNewRecord_Params.encodedSize = codec.kStructHeaderSize + 8;61 VideoDecodeStatsRecorder_StartNewRecord_Params.decode = function(decoder) {62 var packed;63 var val = new VideoDecodeStatsRecorder_StartNewRecord_Params();64 var numberOfBytes = decoder.readUint32();65 var version = decoder.readUint32();66 val.features =67 decoder.decodeStructPointer(media_types$.PredictionFeatures);68 return val;69 };70 VideoDecodeStatsRecorder_StartNewRecord_Params.encode = function(encoder, val) {71 var packed;72 encoder.writeUint32(VideoDecodeStatsRecorder_StartNewRecord_Params.encodedSize);73 encoder.writeUint32(0);74 encoder.encodeStructPointer(media_types$.PredictionFeatures, val.features);75 };76 function VideoDecodeStatsRecorder_UpdateRecord_Params(values) {77 this.initDefaults_();78 this.initFields_(values);79 }80 VideoDecodeStatsRecorder_UpdateRecord_Params.prototype.initDefaults_ = function() {81 this.targets = null;82 };83 VideoDecodeStatsRecorder_UpdateRecord_Params.prototype.initFields_ = function(fields) {84 for(var field in fields) {85 if (this.hasOwnProperty(field))86 this[field] = fields[field];87 }88 };89 VideoDecodeStatsRecorder_UpdateRecord_Params.validate = function(messageValidator, offset) {90 var err;91 err = messageValidator.validateStructHeader(offset, codec.kStructHeaderSize);92 if (err !== validator.validationError.NONE)93 return err;94 var kVersionSizes = [95 {version: 0, numBytes: 16}96 ];97 err = messageValidator.validateStructVersion(offset, kVersionSizes);98 if (err !== validator.validationError.NONE)99 return err;100 // validate VideoDecodeStatsRecorder_UpdateRecord_Params.targets101 err = messageValidator.validateStructPointer(offset + codec.kStructHeaderSize + 0, media_types$.PredictionTargets, false);102 if (err !== validator.validationError.NONE)103 return err;104 return validator.validationError.NONE;105 };106 VideoDecodeStatsRecorder_UpdateRecord_Params.encodedSize = codec.kStructHeaderSize + 8;107 VideoDecodeStatsRecorder_UpdateRecord_Params.decode = function(decoder) {108 var packed;109 var val = new VideoDecodeStatsRecorder_UpdateRecord_Params();110 var numberOfBytes = decoder.readUint32();111 var version = decoder.readUint32();112 val.targets =113 decoder.decodeStructPointer(media_types$.PredictionTargets);114 return val;115 };116 VideoDecodeStatsRecorder_UpdateRecord_Params.encode = function(encoder, val) {117 var packed;118 encoder.writeUint32(VideoDecodeStatsRecorder_UpdateRecord_Params.encodedSize);119 encoder.writeUint32(0);120 encoder.encodeStructPointer(media_types$.PredictionTargets, val.targets);121 };122 var kVideoDecodeStatsRecorder_StartNewRecord_Name = 414570215;123 var kVideoDecodeStatsRecorder_UpdateRecord_Name = 103403230;124 function VideoDecodeStatsRecorderPtr(handleOrPtrInfo) {125 this.ptr = new bindings.InterfacePtrController(VideoDecodeStatsRecorder,126 handleOrPtrInfo);127 }128 function VideoDecodeStatsRecorderAssociatedPtr(associatedInterfacePtrInfo) {129 this.ptr = new associatedBindings.AssociatedInterfacePtrController(130 VideoDecodeStatsRecorder, associatedInterfacePtrInfo);131 }132 VideoDecodeStatsRecorderAssociatedPtr.prototype =133 Object.create(VideoDecodeStatsRecorderPtr.prototype);134 VideoDecodeStatsRecorderAssociatedPtr.prototype.constructor =135 VideoDecodeStatsRecorderAssociatedPtr;136 function VideoDecodeStatsRecorderProxy(receiver) {137 this.receiver_ = receiver;138 }139 VideoDecodeStatsRecorderPtr.prototype.startNewRecord = function() {140 return VideoDecodeStatsRecorderProxy.prototype.startNewRecord141 .apply(this.ptr.getProxy(), arguments);142 };143 VideoDecodeStatsRecorderProxy.prototype.startNewRecord = function(features) {144 var params_ = new VideoDecodeStatsRecorder_StartNewRecord_Params();145 params_.features = features;146 var builder = new codec.MessageV0Builder(147 kVideoDecodeStatsRecorder_StartNewRecord_Name,148 codec.align(VideoDecodeStatsRecorder_StartNewRecord_Params.encodedSize));149 builder.encodeStruct(VideoDecodeStatsRecorder_StartNewRecord_Params, params_);150 var message = builder.finish();151 this.receiver_.accept(message);152 };153 VideoDecodeStatsRecorderPtr.prototype.updateRecord = function() {154 return VideoDecodeStatsRecorderProxy.prototype.updateRecord155 .apply(this.ptr.getProxy(), arguments);156 };157 VideoDecodeStatsRecorderProxy.prototype.updateRecord = function(targets) {158 var params_ = new VideoDecodeStatsRecorder_UpdateRecord_Params();159 params_.targets = targets;160 var builder = new codec.MessageV0Builder(161 kVideoDecodeStatsRecorder_UpdateRecord_Name,162 codec.align(VideoDecodeStatsRecorder_UpdateRecord_Params.encodedSize));163 builder.encodeStruct(VideoDecodeStatsRecorder_UpdateRecord_Params, params_);164 var message = builder.finish();165 this.receiver_.accept(message);166 };167 function VideoDecodeStatsRecorderStub(delegate) {168 this.delegate_ = delegate;169 }170 VideoDecodeStatsRecorderStub.prototype.startNewRecord = function(features) {171 return this.delegate_ && this.delegate_.startNewRecord && this.delegate_.startNewRecord(features);172 }173 VideoDecodeStatsRecorderStub.prototype.updateRecord = function(targets) {174 return this.delegate_ && this.delegate_.updateRecord && this.delegate_.updateRecord(targets);175 }176 VideoDecodeStatsRecorderStub.prototype.accept = function(message) {177 var reader = new codec.MessageReader(message);178 switch (reader.messageName) {179 case kVideoDecodeStatsRecorder_StartNewRecord_Name:180 var params = reader.decodeStruct(VideoDecodeStatsRecorder_StartNewRecord_Params);181 this.startNewRecord(params.features);182 return true;183 case kVideoDecodeStatsRecorder_UpdateRecord_Name:184 var params = reader.decodeStruct(VideoDecodeStatsRecorder_UpdateRecord_Params);185 this.updateRecord(params.targets);186 return true;187 default:188 return false;189 }190 };191 VideoDecodeStatsRecorderStub.prototype.acceptWithResponder =192 function(message, responder) {193 var reader = new codec.MessageReader(message);194 switch (reader.messageName) {195 default:196 return false;197 }198 };199 function validateVideoDecodeStatsRecorderRequest(messageValidator) {200 var message = messageValidator.message;201 var paramsClass = null;202 switch (message.getName()) {203 case kVideoDecodeStatsRecorder_StartNewRecord_Name:204 if (!message.expectsResponse() && !message.isResponse())205 paramsClass = VideoDecodeStatsRecorder_StartNewRecord_Params;206 break;207 case kVideoDecodeStatsRecorder_UpdateRecord_Name:208 if (!message.expectsResponse() && !message.isResponse())209 paramsClass = VideoDecodeStatsRecorder_UpdateRecord_Params;210 break;211 }212 if (paramsClass === null)213 return validator.validationError.NONE;214 return paramsClass.validate(messageValidator, messageValidator.message.getHeaderNumBytes());215 }216 function validateVideoDecodeStatsRecorderResponse(messageValidator) {217 return validator.validationError.NONE;218 }219 var VideoDecodeStatsRecorder = {220 name: 'media.mojom.VideoDecodeStatsRecorder',221 kVersion: 0,222 ptrClass: VideoDecodeStatsRecorderPtr,223 proxyClass: VideoDecodeStatsRecorderProxy,224 stubClass: VideoDecodeStatsRecorderStub,225 validateRequest: validateVideoDecodeStatsRecorderRequest,226 validateResponse: null,227 };228 VideoDecodeStatsRecorderStub.prototype.validator = validateVideoDecodeStatsRecorderRequest;229 VideoDecodeStatsRecorderProxy.prototype.validator = null;230 exports.VideoDecodeStatsRecorder = VideoDecodeStatsRecorder;231 exports.VideoDecodeStatsRecorderPtr = VideoDecodeStatsRecorderPtr;232 exports.VideoDecodeStatsRecorderAssociatedPtr = VideoDecodeStatsRecorderAssociatedPtr;...
index.spec.js
Source:index.spec.js
...83 recorder.reset();84 });85 describe("replay mode @unit", () => {86 const simpleTestReplay = () => {87 recorder.start(dir, "replay-tests", { mode: "replay" });88 // Replay requests should match what is in the static file89 const replayRequests = buildRequestsList("http://127.0.0.1:50000");90 return Promise.all(replayRequests.map(rpIgnoreRateLimit))91 .then(responses => {92 responses.forEach((response, id) => {93 expect(response.body).to.eql({94 // Contents in our static file95 id,96 replay: true97 });98 });99 })100 .then(recorder.stop);101 };102 it("should play back our recorded data", () => {103 return simpleTestReplay();104 });105 it("should work across consecutive replays", () => {106 return simpleTestReplay()107 .catch(throwNth(1))108 .then(() => simpleTestReplay())109 .catch(throwNth(2))110 .then(() => simpleTestReplay())111 .catch(throwNth(3));112 });113 });114 describe("record mode @live", function () {115 // eslint-disable-next-line no-invalid-this116 this.timeout(LIVE_TIMEOUT);117 const tempDir = path.join(dir, "temp");118 const RECORDED_FILE = path.join(tempDir, "record-tests-records.json");119 beforeEach(() => fs.writeFileSync(RECORDED_FILE, ""));120 const assertRecordsReturnedAndRecorded = records => {121 expect(records, "Correct number of records").to.have.lengthOf(2);122 records.forEach((record, i) => {123 const uri = `${record.scope}${record.path}`;124 expect(125 requests.findIndex(req => req.uri === uri),126 `Record ${i} URL mismatch`127 ).to.be.greaterThan(-1);128 expect(requests.find(req => req.uri === uri).method).to.eql(record.method);129 });130 // If throws, invalid JSON131 const recordedRecords = JSON.parse(fs.readFileSync(RECORDED_FILE));132 expect(recordedRecords).to.eql(records);133 };134 const simpleTestRecord = () => {135 recorder.start(tempDir, "record-tests", { mode: "record" });136 return Promise.all(requests.map(rpIgnoreRateLimit))137 .then(recorder.stop)138 .then(assertRecordsReturnedAndRecorded);139 };140 it("should record our request", () => {141 expect(fs.readFileSync(RECORDED_FILE).toString()).to.equal("");142 return simpleTestRecord();143 });144 it("should work across consecutive recordings", () => {145 return simpleTestRecord()146 .catch(throwNth(1))147 .then(() => simpleTestRecord())148 .catch(throwNth(2))149 .then(() => simpleTestRecord())150 .catch(throwNth(3));151 });152 });153 describe("live mode @live", function () {154 // eslint-disable-next-line no-invalid-this155 this.timeout(LIVE_TIMEOUT);156 it("should make a live request", () => {157 recorder.start(dir, "live-tests", { mode: "live" });158 return Promise.all(requests.map(rpIgnoreRateLimit))159 .then(responses => {160 responses.forEach(response => {161 expect(162 response.headers,163 "Missing 'date' header. GH api may have changed"164 ).to.have.property("date");165 const time = new Date(response.headers.date).getTime();166 expect(isNaN(time)).to.equal(false);167 expect(time, "Response is contemporary").to.be.closeTo(Date.now(), LIVE_TIMEOUT);168 });169 })170 .then(recorder.stop);171 });172 });173 describe("recorder#start() @unit", () => {174 it("will throw an error if the recorder has already been started", () => {175 recorder.start(dir, "foo");176 expect(() => recorder.start(dir, "foo")).to.throw(/Nocktor already running/);177 });178 it("will throw an error if started with invalid mode", () => {179 expect(() => recorder.start(dir, "foo", { mode: "foo" }))180 .to181 .throw(/Nocktor failure - unexpected mode 'foo'/);182 });183 });184 describe("recorder#stop() @unit", () => {185 it("will throw an error if the recorder has not been started", () => {186 expect(() => recorder.stop()).to.throw(/can\'t stop, Nocktor is not running/);187 });188 });189 describe("recorder#reset()", () => {190 it("is cancels ongoing recordings @live", () => {191 recorder.start(dir, "reset-cancels-record", { mode: "record" });192 recorder.reset();193 return Promise.all(requests.map(rpIgnoreRateLimit))194 .then(() => {195 expect(nock.recorder.play()).to.have.lengthOf(0);196 });197 });198 it("sets `recorder#stop` back to the default @unit", () => {199 recorder.start(dir, "foo");200 recorder.reset();201 expect(() => recorder.stop()).to.throw(/can\'t stop, Nocktor is not running/);202 });203 it("enables one to call `recorder.start()` again @unit", () => {204 recorder.start(dir, "foo");205 recorder.reset();206 recorder.start(dir, "foo");207 });208 });209 describe("recorder#getgetMode() @unit", () => {210 it("should return the active mode if running", () => {211 ["live", "replay", "record"].forEach(mode => {212 recorder.start(dir, "foo", { mode });213 expect(recorder.getMode()).to.equal(mode);214 recorder.stop();215 recorder.start(dir, "foo");216 expect(recorder.getMode(), "Mode returns to default").to.equal("replay");217 recorder.stop();218 });219 });220 it("should return the value of $NOCKTOR_MODE if set", () => {221 ["live", "replay", "record"].forEach(mode => {222 process.env.NOCKTOR_MODE = mode;223 recorder.start(dir, "foo");224 expect(recorder.getMode()).to.equal(mode);225 recorder.stop();226 recorder.start(dir, "foo", { mode: "live" });227 expect(recorder.getMode(), "Active mode overrides defaults").to.equal("live");228 recorder.stop();229 delete process.env.NOCKTOR_MODE;230 recorder.start(dir, "foo");231 expect(recorder.getMode(), "Mode returns to default").to.equal("replay");232 recorder.stop();233 });234 });235 it("should default to 'replay'", () => {236 delete process.env.NOCKTOR_MODE;237 recorder.start(dir, "foo");238 expect(recorder.getMode()).to.equal("replay");239 recorder.stop();240 });241 it("should throw if not running", () => {242 delete process.env.NOCKTOR_MODE;243 expect(recorder.getMode).to.throw(/Nocktor failure - attempt to access mode/);244 });245 });246 describe("recorder#getModesEnum() @unit", () => {247 it("returns object of available modes", () => {248 expect(recorder.getModesEnum()).to.eql({249 REPLAY: "replay",250 LIVE: "live",251 RECORD: "record",...
dc-electronic-load.js
Source:dc-electronic-load.js
1'use strict';2$(function() {3 var setAmperageForm = $('#set-amperage-form');4 var connectButton = $('.btn-connect');5 var recorderStartStopButton = $('.btn-recorder-start-stop');6 var connectMessage = $('.connect-message');7 var data = {8 voltage: [],9 amperage: [],10 power: []11 };12 function round(v, places) {13 return parseFloat(v).toFixed(places);14 }15 function updateGraph() {16 $.plot("#graph", [17 {label: 'Voltage (V)', data: data.voltage, yaxis: 1},18 {label: 'Amperage (mA)', data: data.amperage, yaxis: 2},19 {label: 'Power (W)', data: data.power, yaxis: 3}20 ], {21 xaxis: {22 mode: "time"23 },24 yaxes: [25 {min: 0, axisLabel: 'Voltage (V)'},26 {min: 0, axisLabel: 'Amperage (mA)', tickFormatter: function(val, axis) { return parseInt(val); }},27 {min: 0, axisLabel: 'Power (W)', position: 'right'}28 ]29 });30 }31 function clearGraph() {32 data.voltage = [];33 data.amperage = [];34 data.power = [];35 updateGraph();36 }37 function toggleConnect() {38 if (document.wsConnection) {39 closeWebSocket();40 } else {41 openWebSocket();42 }43 }44 function closeWebSocket() {45 console.log('Closing ws');46 if (document.wsConnection) {47 document.wsConnection.send("CLOSE");48 document.wsConnection.close();49 }50 connectButton.html('Connect');51 connectButton.removeClass('disabled');52 document.wsConnection = null;53 }54 function openWebSocket() {55 connectMessage.html('');56 connectButton.html('Connecting...');57 connectButton.addClass('disabled');58 var wsAddr = 'ws://' + location.hostname + (location.port ? ':' + location.port : '') + '/ws';59 console.log('connecting ws: ' + wsAddr);60 document.wsConnection = new WebSocket(wsAddr);61 document.wsConnection.onopen = function() {62 console.log('connected ws: ' + wsAddr);63 connectButton.html('Disconnect');64 connectButton.removeClass('disabled');65 };66 document.wsConnection.onerror = function(error) {67 console.log('WebSocket Error ', error, document.wsConnection);68 connectMessage.html('Error connecting');69 closeWebSocket();70 };71 document.wsConnection.onmessage = function(e) {72 var json = JSON.parse(e.data);73 console.log('Server:', json);74 var power = (json.voltage / 1000.0) * (json.amperage / 1000.0);75 $('#current-set-amperage').html(round(json.targetAmps, 0) + "mA");76 $('#current-amperage').html(round(json.amperage, 0) + "mA");77 $('#current-voltage').html(round(json.voltage / 1000.0, 2) + "V");78 $('#current-power').html(round(power, 2) + "W");79 var recordingState = json.recording ? 'Recording' : 'Stopped';80 recordingState += ' (samples: ' + json.recordingSamples + ')';81 $('#current-recording-state').html(recordingState);82 if (json.recording) {83 recorderStartStopButton.html('Stop');84 } else {85 recorderStartStopButton.html('Start');86 }87 data.voltage.push([json.time, json.voltage / 1000.0]);88 data.amperage.push([json.time, json.amperage]);89 data.power.push([json.time, power]);90 updateGraph();91 };92 }93 function ajaxForms() {94 ajaxSetAmperageForm();95 }96 function setAmps(value) {97 $.ajax({98 type: "POST",99 url: setAmperageForm.attr('action'),100 data: {101 value: value102 },103 success: function() {104 console.log(arguments);105 }106 });107 }108 function ajaxSetAmperageForm() {109 $(".btn-zero-amps", setAmperageForm).click(function(event) {110 setAmps(0);111 });112 $(".btn-set-amps", setAmperageForm).click(function(event) {113 event.preventDefault();114 var valueField = $("[name='value']", setAmperageForm);115 var value = $.trim(valueField.val());116 if (value == '' || parseInt(value) < 0 || parseInt(value) > 5000) {117 valueField.closest('div.form-group').addClass('has-error');118 return;119 }120 valueField.closest('div.form-group').removeClass('has-error');121 setAmps(value);122 });123 }124 function startStopRecording() {125 if (recorderStartStopButton.text() == 'Start') {126 var rate = $("#recorder-form [name='rate'] option:selected").val();127 $.ajax({128 type: "POST",129 url: '/recorder/start',130 data: {131 rate: rate132 },133 success: function() {134 console.log(arguments);135 recorderStartStopButton.html('Stop');136 }137 });138 } else {139 $.ajax({140 type: "POST",141 url: '/recorder/stop',142 success: function() {143 console.log(arguments);144 recorderStartStopButton.html('Start');145 }146 });147 }148 }149 updateGraph();150 openWebSocket();151 ajaxForms();152 connectButton.click(toggleConnect);153 recorderStartStopButton.click(startStopRecording);154 $('.btn-clear').click(clearGraph);...
actor_test.js
Source:actor_test.js
...46 customStep() {47 return this.hello();48 },49 });50 recorder.start();51 const promise = I.customStep();52 return promise.then(val => expect(val).toEqual('hello world'));53 });54 it('should init pageobject methods as metastep', () => {55 actor({56 customStep: () => 3,57 });58 expect(I.customStep()).toEqual(3);59 });60 it('should correct add translation for step from Helper', () => {61 expect(I).toHaveProperty('пÑивеÑ');62 });63 it('should correct add translation for step from PageObject', () => {64 container.translation().vocabulary.actions.customStep = 'каÑÑомнÑй_Ñаг';65 actor({66 customStep: () => 3,67 });68 expect(I).toHaveProperty('каÑÑомнÑй_Ñаг');69 });70 it('should take all methods from helpers and built in', () => {71 ['hello', 'bye', 'die', 'failAfter', 'say', 'retry', 'greeting'].forEach(key => {72 expect(I).toHaveProperty(key);73 });74 });75 it('should return promise', () => {76 recorder.start();77 const promise = I.hello();78 expect(promise).toBeInstanceOf(Promise);79 return promise.then(val => expect(val).toEqual('hello world'));80 });81 it('should produce step events', () => {82 recorder.start();83 let listeners = 0;84 event.dispatcher.addListener(event.step.before, () => listeners++);85 event.dispatcher.addListener(event.step.after, () => listeners++);86 event.dispatcher.addListener(event.step.passed, (step) => {87 listeners++;88 expect(step.endTime).toBeTruthy();89 expect(step.startTime).toBeTruthy();90 });91 return I.hello().then(() => {92 expect(listeners).toEqual(3);93 });94 });95 it('should retry failed step with #retry', () => {96 recorder.start();97 return I.retry({ retries: 2, minTimeout: 0 }).failAfter(1);98 });99 it('should retry once step with #retry', () => {100 recorder.start();101 return I.retry().failAfter(1);102 });103 it('should alway use the latest global retry options', () => {104 recorder.start();105 recorder.retry({106 retries: 0,107 minTimeout: 0,108 when: () => true,109 });110 recorder.retry({111 retries: 1,112 minTimeout: 0,113 when: () => true,114 });115 I.hello(); // before fix: this changed the order of retries116 return I.failAfter(1);117 });118 it('should not delete a global retry option', () => {119 recorder.start();120 recorder.retry({121 retries: 2,122 minTimeout: 0,123 when: () => true,124 });125 I.retry(1).failAfter(1); // before fix: this changed the order of retries126 return I.failAfter(2);127 });128 it('should print handle failed steps', () => {129 recorder.start();130 let listeners = 0;131 event.dispatcher.addListener(event.step.before, () => listeners++);132 event.dispatcher.addListener(event.step.after, () => listeners++);133 event.dispatcher.addListener(event.step.failed, (step) => {134 listeners++;135 expect(step.endTime).toBeTruthy();136 expect(step.startTime).toBeTruthy();137 });138 return I.die()139 .then(() => listeners = 0)140 .catch(() => null)141 .then(() => {142 expect(listeners).toEqual(3);143 });...
006_plain_html.t.js
Source:006_plain_html.t.js
...4 var recorder = new Siesta.Recorder.Recorder({ ignoreSynthetic : false });5 recorder.attach(window);6 t.it('click', function (t) {7 recorder.clear();8 recorder.start();9 t.click('#lab');10 var actions = recorder.getRecordedActions();11 t.is(actions.length, 1);12 t.is(actions[0].action, 'click');13 t.isDeeply(actions[0].getTarget(), { type : 'css', target : '#lab', offset : t.any() });14 recorder.stop();15 })16 t.it('right click', function (t) {17 recorder.clear();18 recorder.start();19 t.rightClick('#lab');20 var actions = recorder.getRecordedActions();21 t.is(actions.length, 1);22 t.is(actions[0].action, 'contextmenu');23 t.isDeeply(actions[0].getTarget(), { type : 'css', target : '#lab', offset : t.any() });24 recorder.stop();25 });26 t.it('double click', function (t) {27 recorder.clear();28 recorder.start();29 t.doubleClick('#lab');30 var actions = recorder.getRecordedActions();31 t.is(actions.length, 1);32 t.is(actions[0].action, 'dblclick');33 t.isDeeply(actions[0].getTarget(), { type : 'css', target : '#lab', offset : t.any() });34 recorder.stop();35 recorder.clear();36 })37 })38 t.describe('Should record text content of A tag', function (t) {39 var recorder = new Siesta.Recorder.Recorder({ ignoreSynthetic : false });40 recorder.attach(window);41 t.it('simple click', function (t) {42 document.body.innerHTML = '<a>BAR</a>'43 recorder.clear();44 recorder.start();45 t.click('a:contains(BAR)');46 var actions = recorder.getRecordedActions();47 t.is(actions.length, 1);48 t.is(actions[0].action, 'click');49 t.isDeeply(actions[0].getTarget(), { type : 'css', target : 'a:contains(BAR)', offset : t.any() });50 recorder.stop();51 })52 t.it('ignore if A tag contains markup', function (t) {53 document.body.innerHTML = '<a><span>BAR</span></a>'54 recorder.clear();55 recorder.start();56 t.click('a:contains(BAR)');57 var actions = recorder.getRecordedActions();58 t.is(actions.length, 1);59 t.is(actions[0].action, 'click');60 t.is(actions[0].getTarget().type, 'xy');61 recorder.stop();62 })63 })64 t.describe('Should support configuring which unique attribute to prioritize', function (t) {65 document.body.innerHTML = '<div id="foo"><span id="DONT_USE" other_id="USE_ME">Hello</span></div>'66 document.body.innerHTML += '<div other_id="someId"><span class="cls">Hello</span></div>'67 var recorder = new Siesta.Recorder.Recorder({68 extractorConfig : {69 uniqueDomNodeProperty : 'other_id'70 },71 ignoreSynthetic : false72 });73 recorder.attach(window);74 recorder.start();75 t.click('#DONT_USE');76 var actions = recorder.getRecordedActions();77 t.is(actions.length, 1);78 t.is(actions[0].action, 'click');79 t.isDeeply(actions[0].getTarget(), {80 type : 'css',81 target : '[other_id=\'USE_ME\']',82 offset : t.any()83 });84 recorder.stop();85 recorder.clear();86 recorder.start();87 t.click('.cls');88 var actions = recorder.getRecordedActions();89 t.is(actions.length, 1);90 t.is(actions[0].action, 'click');91 t.isDeeply(actions[0].getTarget(), {92 type : 'css',93 target : '[other_id=\'someId\'] .cls',94 offset : t.any()95 });96 recorder.stop();97 })...
p5.recorder.test.js
Source:p5.recorder.test.js
1import Recorder from "../src/p5.recorder";2describe("smoke tests", () => {3 var mainRecorder = new Recorder("aaa", false);4 test("can create an instance", () => {5 expect(mainRecorder).toBeTruthy();6 });7});8describe("env tests", () => {9 test("should p5 appear on global scope", () => {10 expect(global.p5).toBeTruthy();11 });12 test("should p5 appear on window scope", () => {13 expect(window.p5).toBeTruthy();14 });15 test("should created canvas", () => {16 expect(document.getElementById("defaultCanvas0")).toBeTruthy();17 });18 test("p5 instance should exist", () => {19 expect(myp5).toBeTruthy();20 });21 test("should setup be true", () => {22 expect(myp5._setupDone).toBeTruthy();23 });24});25describe("Recorder", () => {26 var mainRecorder = new Recorder();27 beforeEach(() => {28 //stop navigation error of on download module29 // window.history.pushState({}, "Test Title", "/test.html?query=true");30 mainRecorder = new Recorder();31 });32 test("should override the output name", () => {33 mainRecorder._outputName = "aloha.webm";34 expect(mainRecorder._outputName).toEqual("aloha.webm");35 });36 test("should override the saveAfterStop option", () => {37 expect(mainRecorder._saveAfterStop).toBeTruthy();38 mainRecorder._saveAfterStop = false;39 expect(mainRecorder._saveAfterStop).toBeFalsy();40 });41 test("should start and stop stream", () => {42 const somethingSpy = jest.spyOn(myp5.canvas, "captureStream");43 mainRecorder.start(myp5.canvas);44 expect(somethingSpy).toBeCalled();45 expect(mainRecorder._isRecording).toBeTruthy();46 mainRecorder.stop();47 expect(mainRecorder._isRecording).toBeFalsy();48 });49 test("should throw error on start twice", () => {50 mainRecorder.start(myp5.canvas);51 expect(() => mainRecorder.start(myp5.canvas)).toThrow("Stop first before start again");52 });53 test("should download file after stop", () => {54 const somethingSpy = jest.spyOn(mainRecorder, "download");55 mainRecorder.start(myp5.canvas);56 mainRecorder.stop();57 expect(somethingSpy).toBeCalled();58 });59 test("chunks available after stop", () => {60 // const somethingSpy = jest.spyOn(mainRecorder, "download");61 mainRecorder.start(myp5.canvas);62 const somethingSpy = jest.spyOn(mainRecorder._recorder, "ondataavailable");63 mainRecorder.stop();64 expect(somethingSpy).toBeCalled();65 expect(mainRecorder._chunks).toHaveLength(1);66 });67 test("should record timers", () => {68 mainRecorder.start(myp5.canvas);69 //make duration as 5s70 //should check faketimers71 mainRecorder._initialRecordingTime = new Date(72 mainRecorder._initialRecordingTime.getTime() - 500073 );74 expect(mainRecorder.currentRecordingTime).toEqual(5000);75 expect(mainRecorder.totalRecordedTime).toBeUndefined();76 mainRecorder.stop();77 expect(mainRecorder.totalRecordedTime).toBeTruthy();78 //make duration as 10s79 mainRecorder._endRecordingTime = new Date(mainRecorder._initialRecordingTime.getTime() + 10000);80 expect(mainRecorder.totalRecordedTime).toEqual(10000);81 });82 test("recorded frames should be bigger than zero", function(done) {83 /**84 * console.error85 Error: Not implemented: navigation (except hash changes)86 */87 jest.spyOn(console, "error").mockImplementation();88 mainRecorder.start(myp5.canvas);89 myp5.draw();90 jest.useRealTimers();91 setTimeout(function() {92 mainRecorder.stop();93 expect(mainRecorder.totalRecordedTime).toBeGreaterThan(500);94 expect(mainRecorder.totalRecordedFrames).toBeGreaterThan(95 (500 * mainRecorder._targetFps) / 100096 );97 done();98 }, 500);99 expect(mainRecorder.currentRecordingFrames).toBeGreaterThan(1);100 expect(mainRecorder.totalRecordedTime).toBeUndefined();101 });...
2321be041edb15e776a5f9a37c6580b95e7d38a8test.js
Source:2321be041edb15e776a5f9a37c6580b95e7d38a8test.js
...3var events = require('events');4describe('recorder', function () {5 it('should capture a valid shortcut', function (done) {6 i = 0;7 recorder.start()8 .on('end', function (res) {9 res.should.eql(['ctrl', 'x']);10 i++;11 });12 dispatch('keydown', 'ctrl');13 dispatch('keydown', 'x');14 dispatch('keydown', 'y');15 recorder.start()16 .on('end', function (res) {17 res.should.eql(['ctrl', 'alt', 'y']);18 i++;19 });20 dispatch('keydown', 'alt');21 dispatch('keydown', 'ctrl');22 dispatch('keydown', 'y');23 dispatch('keydown', 'x');24 recorder.start()25 .on('end', function (res) {26 res.should.eql(['ctrl', 'command', 'x']);27 if(i == 2) done();28 });29 dispatch('keydown', 'command');30 dispatch('keydown', 'ctrl');31 dispatch('keydown', 'x');32 });33 it('should update unpressed pfx keys', function (done) {34 recorder.start()35 .on('end', function (res) {36 res.should.eql(['ctrl', 'x']);37 done();38 });39 dispatch('keydown', 'alt');40 dispatch('keydown', 'shift');41 dispatch('keyup', 'shift');42 dispatch('keyup', 'alt');43 dispatch('keydown', 'ctrl');44 dispatch('keydown', 'x');45 });46 it('should not end when only shift is pressed', function (done) {47 recorder.start()48 .on('end', function (res) {49 res.should.eql(['shift', 'command', 'y']);50 done();51 });52 dispatch('keydown', 'shift');53 dispatch('keydown', 'x');54 dispatch('keyup', 'x');55 dispatch('keydown', 'command');56 dispatch('keydown', 'y');57 });58 it('should cancel explicitly', function (done) {59 recorder.start()60 .on('cancel', function () {61 done();62 });63 dispatch('keydown', 'ctrl');64 recorder.cancel();65 });66 it('should cancel implicitly', function (done) {67 recorder.start()68 .on('cancel', function () {69 done();70 });71 recorder.start();72 });73 it('should cancel upon a single esc', function (done) {74 recorder.start()75 .on('end', function (res) {76 res.should.eql(['ctrl', 'esc']);77 recorder.start()78 .on('cancel', function ()Â {79 done();80 });81 dispatch('keydown', 'ctrl');82 dispatch('keyup', 'ctrl');83 dispatch('keydown', 'esc');84 });85 dispatch('keydown', 'ctrl');86 dispatch('keydown', 'esc');87 });88});89function dispatch (type, key) {90 var code = keycode(key),91 e = document.createEvent('Event');...
Using AI Code Generation
1const { remote } = require('webdriverio');2const opts = {3 capabilities: {4 }5};6(async () => {7 const client = await remote(opts);8 await client.pause(5000);9 await client.startRecordingScreen({10 });11 await client.pause(30000);12 const base64Data = await client.stopRecordingScreen();13 console.log(base64Data);14})();
Using AI Code Generation
1const wd = require('wd');2const assert = require('assert');3const opts = {4 capabilities: {5 },6};7async function main() {8 let driver = wd.promiseChainRemote(opts);9 await driver.init(opts.capabilities);10 await driver.setImplicitWaitTimeout(5000);11 await driver.setAsyncScriptTimeout(30000);12 await driver.setPageLoadTimeout(30000);13 await driver.startRecordingScreen();14 await driver.sleep(5000);15 await driver.stopRecordingScreen();16}17main();18const wd = require('wd');19const assert = require('assert');20const opts = {21 capabilities: {22 },23};24async function main() {25 let driver = wd.promiseChainRemote(opts);26 await driver.init(opts.capabilities);27 await driver.setImplicitWaitTimeout(5000);28 await driver.setAsyncScriptTimeout(30000);29 await driver.setPageLoadTimeout(30000);30 await driver.startRecordingScreen();31 await driver.sleep(5000);32 await driver.stopRecordingScreen();33}34main();35const wd = require('wd');36const assert = require('assert');37const opts = {
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!