Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: polymer_0.5.4/bower_components/web-animations-js/test/js/player.js

Issue 895523005: Added Polymer 0.5.4 (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 suite('player', function() { 1 suite('player', function() {
2 setup(function() { 2 setup(function() {
3 webAnimationsMinifill.timeline._players = []; 3 webAnimations1.timeline._players = [];
4 }); 4 });
5 test('zero duration animation works', function() { 5 test('zero duration animation works', function() {
6 tick(90); 6 tick(90);
7 var p = document.body.animate([], 0); 7 var p = document.body.animate([], 0);
8 tick(100); 8 tick(100);
9 assert.equal(p.startTime, 100); 9 assert.equal(p.startTime, 100);
10 assert.equal(p.currentTime, 0); 10 assert.equal(p.currentTime, 0);
11 }); 11 });
12 test('playing works as expected', function() { 12 test('playing works as expected', function() {
13 tick(90); 13 tick(90);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 tick(0); 255 tick(0);
256 var target = document.createElement('div'); 256 var target = document.createElement('div');
257 document.documentElement.appendChild(target); 257 document.documentElement.appendChild(target);
258 var player = target.animate([{marginLeft: '50px'}, {marginLeft: '50px'}], 10 00); 258 var player = target.animate([{marginLeft: '50px'}, {marginLeft: '50px'}], 10 00);
259 tick(10); 259 tick(10);
260 tick(110); 260 tick(110);
261 assert.equal(getComputedStyle(target).marginLeft, '50px'); 261 assert.equal(getComputedStyle(target).marginLeft, '50px');
262 player.cancel(); 262 player.cancel();
263 // getComputedStyle forces a tick. 263 // getComputedStyle forces a tick.
264 assert.equal(getComputedStyle(target).marginLeft, '0px'); 264 assert.equal(getComputedStyle(target).marginLeft, '0px');
265 assert.deepEqual(webAnimationsMinifill.timeline._players, []); 265 assert.deepEqual(webAnimations1.timeline._players, []);
266 tick(120); 266 tick(120);
267 assert.equal(getComputedStyle(target).marginLeft, '0px'); 267 assert.equal(getComputedStyle(target).marginLeft, '0px');
268 assert.deepEqual(webAnimationsMinifill.timeline._players, []); 268 assert.deepEqual(webAnimations1.timeline._players, []);
269 document.documentElement.removeChild(target); 269 document.documentElement.removeChild(target);
270 }); 270 });
271 test('startTime is set on first tick if timeline hasn\'t started', function() { 271 test('startTime is set on first tick if timeline hasn\'t started', function() {
272 webAnimationsMinifill.timeline.currentTime = undefined; 272 webAnimations1.timeline.currentTime = undefined;
273 var p = document.body.animate([], 1000); 273 var p = document.body.animate([], 1000);
274 tick(0); 274 tick(0);
275 tick(100); 275 tick(100);
276 assert.equal(p.startTime, 0); 276 assert.equal(p.startTime, 0);
277 }); 277 });
278 test('players which are finished and not filling get discarded', function() { 278 test('players which are finished and not filling get discarded', function() {
279 tick(90); 279 tick(90);
280 var nofill = document.body.animate([], 100); 280 var nofill = document.body.animate([], 100);
281 var fill = document.body.animate([], {duration: 100, fill: 'forwards'}); 281 var fill = document.body.animate([], {duration: 100, fill: 'forwards'});
282 assert.deepEqual(webAnimationsMinifill.timeline._players, [nofill._player || nofill, fill._player || fill]); 282 assert.deepEqual(webAnimations1.timeline._players, [nofill._player || nofill , fill._player || fill]);
283 tick(100); 283 tick(100);
284 assert.deepEqual(webAnimationsMinifill.timeline._players, [nofill._player || nofill, fill._player || fill]); 284 assert.deepEqual(webAnimations1.timeline._players, [nofill._player || nofill , fill._player || fill]);
285 tick(400); 285 tick(400);
286 assert.deepEqual(webAnimationsMinifill.timeline._players, [fill._player || f ill]); 286 assert.deepEqual(webAnimations1.timeline._players, [fill._player || fill]);
287 }); 287 });
288 test('discarded players get re-added on modification', function() { 288 test('discarded players get re-added on modification', function() {
289 tick(90); 289 tick(90);
290 var player = document.body.animate([], 100); 290 var player = document.body.animate([], 100);
291 tick(100); 291 tick(100);
292 tick(400); 292 tick(400);
293 assert.deepEqual(webAnimationsMinifill.timeline._players, []); 293 assert.deepEqual(webAnimations1.timeline._players, []);
294 player.currentTime = 0; 294 player.currentTime = 0;
295 assert.deepEqual(webAnimationsMinifill.timeline._players, [player._player || player]); 295 assert.deepEqual(webAnimations1.timeline._players, [player._player || player ]);
296 }); 296 });
297 test('players in the before phase are not discarded', function() { 297 test('players in the before phase are not discarded', function() {
298 tick(100); 298 tick(100);
299 var player = document.body.animate([], 100); 299 var player = document.body.animate([], 100);
300 player.currentTime = -50; 300 player.currentTime = -50;
301 tick(110); 301 tick(110);
302 assert.deepEqual(webAnimationsMinifill.timeline._players, [player._player || player]); 302 assert.deepEqual(webAnimations1.timeline._players, [player._player || player ]);
303 }); 303 });
304 test('players that go out of effect should not clear the effect of players tha t are in effect', function() { 304 test('players that go out of effect should not clear the effect of players tha t are in effect', function() {
305 var target = document.createElement('div'); 305 var target = document.createElement('div');
306 document.body.appendChild(target); 306 document.body.appendChild(target);
307 tick(0); 307 tick(0);
308 var playerBehind = target.animate([{marginLeft: '200px'}, {marginLeft: '200p x'}], 200); 308 var playerBehind = target.animate([{marginLeft: '200px'}, {marginLeft: '200p x'}], 200);
309 var playerInfront = target.animate([{marginLeft: '100px'}, {marginLeft: '100 px'}], 100); 309 var playerInfront = target.animate([{marginLeft: '100px'}, {marginLeft: '100 px'}], 100);
310 tick(50); 310 tick(50);
311 assert.equal(getComputedStyle(target).marginLeft, '100px', 't = 50'); 311 assert.equal(getComputedStyle(target).marginLeft, '100px', 't = 50');
312 tick(150); 312 tick(150);
(...skipping 13 matching lines...) Expand all
326 assert.equal(getComputedStyle(target).width, '50px'); 326 assert.equal(getComputedStyle(target).width, '50px');
327 playerInfront.currentTime = 100; 327 playerInfront.currentTime = 100;
328 assert.equal(getComputedStyle(target).width, '1234px'); 328 assert.equal(getComputedStyle(target).width, '1234px');
329 playerInfront.play(); 329 playerInfront.play();
330 assert.equal(getComputedStyle(target).width, '0px'); 330 assert.equal(getComputedStyle(target).width, '0px');
331 playerInfront.startTime = -50; 331 playerInfront.startTime = -50;
332 assert.equal(getComputedStyle(target).width, '50px'); 332 assert.equal(getComputedStyle(target).width, '50px');
333 document.body.removeChild(target); 333 document.body.removeChild(target);
334 }); 334 });
335 test('Player that hasn\'t been played has playState \'idle\'', function() { 335 test('Player that hasn\'t been played has playState \'idle\'', function() {
336 var source = new minifillAnimation(document.body, [], 1000); 336 var source = new webAnimations1Animation(document.body, [], 1000);
337 var p = new Player(source); 337 var p = new Player(source);
338 assert.equal(p.playState, 'idle'); 338 assert.equal(p.playState, 'idle');
339 }); 339 });
340 test('playState works for a simple animation', function() { 340 test('playState works for a simple animation', function() {
341 var p = document.body.animate([], 1000); 341 var p = document.body.animate([], 1000);
342 tick(0); 342 tick(0);
343 assert.equal(p.playState, 'running'); 343 assert.equal(p.playState, 'running');
344 tick(100); 344 tick(100);
345 assert.equal(p.playState, 'running'); 345 assert.equal(p.playState, 'running');
346 p.pause(); 346 p.pause();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 test('reverse() should not set a start time', function() { 452 test('reverse() should not set a start time', function() {
453 var p = document.body.animate([], 1000); 453 var p = document.body.animate([], 1000);
454 p.cancel(); 454 p.cancel();
455 assert.equal(p.startTime, null); 455 assert.equal(p.startTime, null);
456 assert.equal(p.playState, 'idle'); 456 assert.equal(p.playState, 'idle');
457 p.reverse(); 457 p.reverse();
458 assert.equal(p.startTime, null); 458 assert.equal(p.startTime, null);
459 assert.equal(p.playState, 'pending'); 459 assert.equal(p.playState, 'pending');
460 }); 460 });
461 }); 461 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698