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

Side by Side Diff: polymer_0.5.4/bower_components/web-animations-js/test/js/effect.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 1
2 function leftAsNumber(target) { 2 function leftAsNumber(target) {
3 var left = getComputedStyle(target).left; 3 var left = getComputedStyle(target).left;
4 return Number(left.substring(0, left.length - 2)); 4 return Number(left.substring(0, left.length - 2));
5 } 5 }
6 6
7 suite('effect', function() { 7 suite('effect', function() {
8 // Test normalize. 8 // Test normalize.
9 test('Normalize keyframes with all offsets specified but not sorted by offset. Some offsets are out of [0, 1] range.', function() { 9 test('Normalize keyframes with all offsets specified but not sorted by offset. Some offsets are out of [0, 1] range.', function() {
10 var normalizedKeyframes; 10 var normalizedKeyframes;
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 document.documentElement.appendChild(this.target); 437 document.documentElement.appendChild(this.target);
438 }); 438 });
439 teardown(function() { 439 teardown(function() {
440 if (this.target.parent) 440 if (this.target.parent)
441 this.target.removeChild(this.target); 441 this.target.removeChild(this.target);
442 }); 442 });
443 443
444 test('Convert effect input for a simple effect with one property.', function() { 444 test('Convert effect input for a simple effect with one property.', function() {
445 var effectFunction; 445 var effectFunction;
446 assert.doesNotThrow(function() { 446 assert.doesNotThrow(function() {
447 effectFunction = webAnimationsMinifill.convertEffectInput([ 447 effectFunction = webAnimations1.convertEffectInput([
448 {left: '0px'}, 448 {left: '0px'},
449 {left: '200px', offset: 0.3}, 449 {left: '200px', offset: 0.3},
450 {left: '100px'} 450 {left: '100px'}
451 ]); 451 ]);
452 }); 452 });
453 453
454 effectFunction(this.target, 0); 454 effectFunction(this.target, 0);
455 assert.closeTo(leftAsNumber(this.target), 0, 0.001); 455 assert.closeTo(leftAsNumber(this.target), 0, 0.001);
456 effectFunction(this.target, 0.075); 456 effectFunction(this.target, 0.075);
457 assert.closeTo(leftAsNumber(this.target), 50, 0.001); 457 assert.closeTo(leftAsNumber(this.target), 50, 0.001);
458 effectFunction(this.target, 0.15); 458 effectFunction(this.target, 0.15);
459 assert.closeTo(leftAsNumber(this.target), 100, 0.001); 459 assert.closeTo(leftAsNumber(this.target), 100, 0.001);
460 effectFunction(this.target, 0.65); 460 effectFunction(this.target, 0.65);
461 assert.closeTo(leftAsNumber(this.target), 150, 0.001); 461 assert.closeTo(leftAsNumber(this.target), 150, 0.001);
462 effectFunction(this.target, 1); 462 effectFunction(this.target, 1);
463 assert.closeTo(leftAsNumber(this.target), 100, 0.001); 463 assert.closeTo(leftAsNumber(this.target), 100, 0.001);
464 effectFunction(this.target, 2); 464 effectFunction(this.target, 2);
465 assert.closeTo(leftAsNumber(this.target), -42.856, 0.01); 465 assert.closeTo(leftAsNumber(this.target), -42.856, 0.01);
466 }); 466 });
467 467
468 test('Convert effect input where one property is animated and the property has two keyframes at offset 1.', function() { 468 test('Convert effect input where one property is animated and the property has two keyframes at offset 1.', function() {
469 var effectFunction; 469 var effectFunction;
470 assert.doesNotThrow(function() { 470 assert.doesNotThrow(function() {
471 effectFunction = webAnimationsMinifill.convertEffectInput([ 471 effectFunction = webAnimations1.convertEffectInput([
472 {left: '0px', offset: 0}, 472 {left: '0px', offset: 0},
473 {left: '20px', offset: 1}, 473 {left: '20px', offset: 1},
474 {left: '30px'} 474 {left: '30px'}
475 ]); 475 ]);
476 }); 476 });
477 effectFunction(this.target, 1); 477 effectFunction(this.target, 1);
478 assert.equal(getComputedStyle(this.target).left, '30px'); 478 assert.equal(getComputedStyle(this.target).left, '30px');
479 effectFunction(this.target, 2); 479 effectFunction(this.target, 2);
480 assert.equal(getComputedStyle(this.target).left, '30px'); 480 assert.equal(getComputedStyle(this.target).left, '30px');
481 }); 481 });
482 482
483 test('Convert effect input and apply effect at fraction null.', function() { 483 test('Convert effect input and apply effect at fraction null.', function() {
484 var effectFunction; 484 var effectFunction;
485 var underlying = getComputedStyle(this.target).left; 485 var underlying = getComputedStyle(this.target).left;
486 assert.doesNotThrow(function() { 486 assert.doesNotThrow(function() {
487 effectFunction = webAnimationsMinifill.convertEffectInput([ 487 effectFunction = webAnimations1.convertEffectInput([
488 {left: '0px'}, 488 {left: '0px'},
489 {left: '100px'} 489 {left: '100px'}
490 ]); 490 ]);
491 }); 491 });
492 492
493 effectFunction(this.target, 1); 493 effectFunction(this.target, 1);
494 assert.equal(getComputedStyle(this.target).left, '100px'); 494 assert.equal(getComputedStyle(this.target).left, '100px');
495 effectFunction(this.target, null); 495 effectFunction(this.target, null);
496 assert.equal(getComputedStyle(this.target).left, underlying); 496 assert.equal(getComputedStyle(this.target).left, underlying);
497 }); 497 });
498 }); 498 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698