| Index: third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-model/animation-types/discrete-animation.html
|
| diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-model/animation-types/discrete-animation.html b/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-model/animation-types/discrete-animation.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..31b78028c3a17010342334194dae381af297a255
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/imported/web-platform-tests/web-animations/animation-model/animation-types/discrete-animation.html
|
| @@ -0,0 +1,136 @@
|
| +<!DOCTYPE html>
|
| +<meta charset=utf-8>
|
| +<title>Tests for discrete animation</title>
|
| +<link rel="help" href="http://w3c.github.io/web-animations/#animatable-as-string-section">
|
| +<script src="../../../../../resources/testharness.js"></script>
|
| +<script src="../../../../../resources/testharnessreport.js"></script>
|
| +<script src="../../testcommon.js"></script>
|
| +<link rel="stylesheet" href="../../../../../resources/testharness.css">
|
| +<body>
|
| +<div id="log"></div>
|
| +<script>
|
| +'use strict';
|
| +
|
| +test(function(t) {
|
| + var div = createDiv(t);
|
| +
|
| + var anim = div.animate({ fontStyle: [ 'normal', 'italic' ] },
|
| + { duration: 1000, fill: 'forwards' });
|
| +
|
| + assert_equals(getComputedStyle(div).fontStyle, 'normal',
|
| + 'Animation produces \'from\' value at start of interval');
|
| + anim.currentTime = anim.effect.getComputedTiming().duration / 2 - 1;
|
| + assert_equals(getComputedStyle(div).fontStyle, 'normal',
|
| + 'Animation produces \'from\' value just before the middle of'
|
| + + ' the interval');
|
| + anim.currentTime++;
|
| + assert_equals(getComputedStyle(div).fontStyle, 'italic',
|
| + 'Animation produces \'to\' value at exact middle of'
|
| + + ' the interval');
|
| + anim.finish();
|
| + assert_equals(getComputedStyle(div).fontStyle, 'italic',
|
| + 'Animation produces \'to\' value during forwards fill');
|
| +}, 'Test animating discrete values');
|
| +
|
| +test(function(t) {
|
| + var div = createDiv(t);
|
| + var originalHeight = getComputedStyle(div).height;
|
| +
|
| + var anim = div.animate({ height: [ 'auto', '200px' ] },
|
| + { duration: 1000, fill: 'forwards' });
|
| +
|
| + assert_equals(getComputedStyle(div).height, originalHeight,
|
| + 'Animation produces \'from\' value at start of interval');
|
| + anim.currentTime = anim.effect.getComputedTiming().duration / 2 - 1;
|
| + assert_equals(getComputedStyle(div).height, originalHeight,
|
| + 'Animation produces \'from\' value just before the middle of'
|
| + + ' the interval');
|
| + anim.currentTime++;
|
| + assert_equals(getComputedStyle(div).height, '200px',
|
| + 'Animation produces \'to\' value at exact middle of'
|
| + + ' the interval');
|
| + anim.finish();
|
| + assert_equals(getComputedStyle(div).height, '200px',
|
| + 'Animation produces \'to\' value during forwards fill');
|
| +}, 'Test discrete animation is used when interpolation fails');
|
| +
|
| +test(function(t) {
|
| + var div = createDiv(t);
|
| + var originalHeight = getComputedStyle(div).height;
|
| +
|
| + var anim = div.animate({ height: [ 'auto',
|
| + '200px',
|
| + '300px',
|
| + 'auto',
|
| + '400px' ] },
|
| + { duration: 1000, fill: 'forwards' });
|
| +
|
| + // There are five values, so there are four pairs to try to interpolate.
|
| + // We test at the middle of each pair.
|
| + assert_equals(getComputedStyle(div).height, originalHeight,
|
| + 'Animation produces \'from\' value at start of interval');
|
| + anim.currentTime = 125;
|
| + assert_equals(getComputedStyle(div).height, '200px',
|
| + 'First non-interpolable pair uses discrete interpolation');
|
| + anim.currentTime += 250;
|
| + assert_equals(getComputedStyle(div).height, '250px',
|
| + 'Second interpolable pair uses linear interpolation');
|
| + anim.currentTime += 250;
|
| + assert_equals(getComputedStyle(div).height, originalHeight,
|
| + 'Third non-interpolable pair uses discrete interpolation');
|
| + anim.currentTime += 250;
|
| + assert_equals(getComputedStyle(div).height, '400px',
|
| + 'Fourth non-interpolable pair uses discrete interpolation');
|
| +}, 'Test discrete animation is used only for pairs of values that cannot'
|
| + + ' be interpolated');
|
| +
|
| +test(function(t) {
|
| + var div = createDiv(t);
|
| + var originalHeight = getComputedStyle(div).height;
|
| +
|
| + // Easing: http://cubic-bezier.com/#.68,0,1,.01
|
| + // With this curve, we don't reach the 50% point until about 95% of
|
| + // the time has expired.
|
| + var anim = div.animate({ fontStyle: [ 'italic', 'oblique' ] },
|
| + { duration: 1000, fill: 'forwards',
|
| + easing: 'cubic-bezier(0.68,0,1,0.01)' });
|
| +
|
| + assert_equals(getComputedStyle(div).fontStyle, 'italic',
|
| + 'Animation produces \'from\' value at start of interval');
|
| + anim.currentTime = 940;
|
| + assert_equals(getComputedStyle(div).fontStyle, 'italic',
|
| + 'Animation produces \'from\' value at 94% of the iteration'
|
| + + ' time');
|
| + anim.currentTime = 960;
|
| + assert_equals(getComputedStyle(div).fontStyle, 'oblique',
|
| + 'Animation produces \'to\' value at 96% of the iteration'
|
| + + ' time');
|
| +}, 'Test the 50% switch point for discrete animation is based on the'
|
| + + ' effect easing');
|
| +
|
| +test(function(t) {
|
| + var div = createDiv(t);
|
| + var originalHeight = getComputedStyle(div).height;
|
| +
|
| + // Easing: http://cubic-bezier.com/#.68,0,1,.01
|
| + // With this curve, we don't reach the 50% point until about 95% of
|
| + // the time has expired.
|
| + var anim = div.animate([ { fontStyle: 'italic',
|
| + easing: 'cubic-bezier(0.68,0,1,0.01)' },
|
| + { fontStyle: 'oblique' } ],
|
| + { duration: 1000, fill: 'forwards' });
|
| +
|
| + assert_equals(getComputedStyle(div).fontStyle, 'italic',
|
| + 'Animation produces \'from\' value at start of interval');
|
| + anim.currentTime = 940;
|
| + assert_equals(getComputedStyle(div).fontStyle, 'italic',
|
| + 'Animation produces \'from\' value at 94% of the iteration'
|
| + + ' time');
|
| + anim.currentTime = 960;
|
| + assert_equals(getComputedStyle(div).fontStyle, 'oblique',
|
| + 'Animation produces \'to\' value at 96% of the iteration'
|
| + + ' time');
|
| +}, 'Test the 50% switch point for discrete animation is based on the'
|
| + + ' keyframe easing');
|
| +
|
| +</script>
|
|
|