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

Unified Diff: third_party/WebKit/LayoutTests/web-animations-api/playState-changes.html

Issue 2142763002: Cleaned up animation-state-changes.html test to meet W3C standards (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed descriptions Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/web-animations-api/animation-state-changes.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/web-animations-api/playState-changes.html
diff --git a/third_party/WebKit/LayoutTests/web-animations-api/playState-changes.html b/third_party/WebKit/LayoutTests/web-animations-api/playState-changes.html
new file mode 100644
index 0000000000000000000000000000000000000000..6398c091bb95423d1bb8b8415e7e02e9056a2560
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/web-animations-api/playState-changes.html
@@ -0,0 +1,384 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Tests for discrete animation</title>
+<link rel="help" href="https://w3c.github.io/web-animations/#play-state">
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../imported/wpt/web-animations/testcommon.js"></script>
+<body>
+<script>
+'use strict';
+function createIdleAnimation(t) {
+ var animation = createDiv(t).animate([], 100000);
+ animation.cancel();
+ return animation;
+}
+
+function createRunningAnimation(t) {
+ var animation = createIdleAnimation(t);
+ animation.play();
+ animation.startTime = document.timeline.currentTime;
+ return animation;
+}
+
+function createPendingStartTimeAnimation(t) {
+ var animation = createIdleAnimation(t);
+ animation.play();
+ return animation;
+}
+
+function createPausedAnimation(t) {
+ var animation = createIdleAnimation(t);
+ animation.pause();
+ animation.currentTime = 0;
+ return animation;
+}
+
+function createFinishedAnimation(t) {
+ var animation = createIdleAnimation(t);
+ animation.play();
+ animation.finish();
+ return animation;
+}
+
+// Initial animation states
+test(function(t) {
+ var animation = createIdleAnimation(t);
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, null);
+ assert_equals(animation.playState, 'idle');
+}, "Play state is idle after cancelling an animation");
+
+test(function(t) {
+ var animation = createPendingStartTimeAnimation(t);
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 0);
+ assert_equals(animation.playState, 'pending');
+}, "Play state is pending after playing a cancelled animation");
+
+test(function(t) {
+ var animation = createRunningAnimation(t);
+ assert_equals(animation.startTime, document.timeline.currentTime - animation.currentTime);
+ assert_equals(animation.currentTime, 0);
+ assert_equals(animation.playState, 'running');
+}, "Play state is running after playing and setting start time of a cancelled animation");
+
+test(function(t) {
+ var animation = createPausedAnimation(t);
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 0);
+ assert_equals(animation.playState, 'paused');
+}, "Play state is paused after pausing and setting current time of a cancelled animation");
+
+test(function(t) {
+ var animation = createFinishedAnimation(t);
+ assert_equals(animation.startTime, document.timeline.currentTime - animation.currentTime);
+ assert_equals(animation.currentTime, 100000);
+ assert_equals(animation.playState, 'finished');
+}, "Play state is finished after playing and finishing a cancelled animation");
+
+// Changed animation states
+test(function(t) {
+ var animation = createIdleAnimation(t);
+ animation.play();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 0);
+ assert_equals(animation.playState, 'pending');
+}, "Calling play() on an idle animation");
+
+test(function(t) {
+ var animation = createIdleAnimation(t);
+ animation.pause();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 0);
+ assert_equals(animation.playState, 'pending');
+}, "Calling pause() on an idle animation");
+
+test(function(t) {
+ var animation = createIdleAnimation(t);
+ animation.cancel();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, null);
+ assert_equals(animation.playState, 'idle');
+}, "Calling cancel() on an idle animation");
+
+test(function(t) {
+ var animation = createIdleAnimation(t);
+ animation.finish();
+ assert_equals(animation.startTime, document.timeline.currentTime - animation.currentTime);
+ assert_equals(animation.currentTime, 100000);
+ assert_equals(animation.playState, 'finished');
+}, "Calling finish() on an idle animation");
+
+test(function(t) {
+ var animation = createIdleAnimation(t);
+ animation.reverse();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 100000);
+ assert_equals(animation.playState, 'pending');
+}, "Calling reverse() on an idle animation");
+
+test(function(t) {
+ var animation = createIdleAnimation(t);
+ animation.currentTime = 1000;
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 1000);
+ assert_equals(animation.playState, 'paused');
+}, "Setting currentTime on an idle animation");
+
+test(function(t) {
+ var animation = createIdleAnimation(t);
+ animation.startTime = document.timeline.currentTime - 1000;
+ assert_equals(animation.startTime, document.timeline.currentTime - 1000);
+ assert_equals(animation.currentTime, 1000);
+ assert_equals(animation.playState, 'running');
+}, "Setting startTime on an idle animation");
+
+test(function(t) {
+ var animation = createPendingStartTimeAnimation(t);
+ animation.play();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 0);
+ assert_equals(animation.playState, 'pending');
+}, "Calling play() on a pending starttime animation");
+
+test(function(t) {
+ var animation = createPendingStartTimeAnimation(t);
+ animation.pause();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 0);
+ assert_equals(animation.playState, 'pending');
+}, "Calling pause() on a pending starttime animation");
+
+test(function(t) {
+ var animation = createPendingStartTimeAnimation(t);
+ animation.cancel();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, null);
+ assert_equals(animation.playState, 'idle');
+}, "Calling cancel() on a pending starttime animation");
+
+test(function(t) {
+ var animation = createPendingStartTimeAnimation(t);
+ animation.finish();
+ assert_equals(animation.startTime, document.timeline.currentTime - animation.currentTime);
+ assert_equals(animation.currentTime, 100000);
+ assert_equals(animation.playState, 'finished');
+}, "Calling finish() on a pending starttime animation");
+
+test(function(t) {
+ var animation = createPendingStartTimeAnimation(t);
+ animation.reverse();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 100000);
+ assert_equals(animation.playState, 'pending');
+}, "Calling reverse() on a pending starttime animation");
+
+test(function(t) {
+ var animation = createPendingStartTimeAnimation(t);
+ animation.currentTime = 1000;
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 1000);
+ assert_equals(animation.playState, 'pending');
+}, "Setting currentTime on a pending starttime animation");
+
+test(function(t) {
+ var animation = createPendingStartTimeAnimation(t);
+ animation.startTime = document.timeline.currentTime - 1000;
+ assert_equals(animation.startTime, document.timeline.currentTime - 1000);
+ assert_equals(animation.currentTime, 1000);
+ assert_equals(animation.playState, 'running');
+}, "Setting startTime on a pending starttime animation");
+
+test(function(t) {
+ var animation = createRunningAnimation(t);
+ var startTime = animation.startTime;
+ var currentTime = animation.currentTime;
+ animation.play();
+ assert_equals(animation.startTime, startTime);
+ assert_equals(animation.currentTime, currentTime);
+ assert_equals(animation.playState, 'running');
+}, "Setting play() on a running animation");
+
+test(function(t) {
+ var animation = createRunningAnimation(t);
+ animation.pause();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 0);
+ assert_equals(animation.playState, 'pending');
+}, "Setting pause() on a running animation");
+
+test(function(t) {
+ var animation = createRunningAnimation(t);
+ animation.cancel();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, null);
+ assert_equals(animation.playState, 'idle');
+}, "Setting cancel() on a running animation");
+
+test(function(t) {
+ var animation = createRunningAnimation(t);
+ animation.finish();
+ assert_equals(animation.startTime, document.timeline.currentTime - animation.currentTime);
+ assert_equals(animation.currentTime, 100000);
+ assert_equals(animation.playState, 'finished');
+}, "Setting finish() on a running animation");
+
+test(function(t) {
+ var animation = createRunningAnimation(t);
+ animation.reverse();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 100000);
+ assert_equals(animation.playState, 'pending');
+}, "Setting reverse() on a running animation");
+
+
+test(function(t) {
+ var animation = createRunningAnimation(t);
+ animation.currentTime = 1000;
+ assert_equals(animation.startTime, document.timeline.currentTime - animation.currentTime);
+ assert_equals(animation.currentTime, 1000);
+ assert_equals(animation.playState, 'running');
+}, "Setting currentTime on a running animation");
+
+test(function(t) {
+ var animation = createRunningAnimation(t);
+ animation.startTime = document.timeline.currentTime - 1000;
+ assert_equals(animation.startTime, document.timeline.currentTime - 1000);
+ assert_equals(animation.currentTime, 1000);
+ assert_equals(animation.playState, 'running');
+}, "Setting startTime on a running animation");
+
+test(function(t) {
+ var animation = createPausedAnimation(t);
+ animation.play();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 0);
+ assert_equals(animation.playState, 'pending');
+}, "Calling play() on a paused animation");
+
+test(function(t) {
+ var animation = createPausedAnimation(t);
+ animation.pause();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 0);
+ assert_equals(animation.playState, 'paused');
+}, "Calling pause() on a paused animation");
+
+test(function(t) {
+ var animation = createPausedAnimation(t);
+ animation.cancel();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, null);
+ assert_equals(animation.playState, 'idle');
+}, "Calling cancel() on a paused animation");
+
+test(function(t) {
+ var animation = createPausedAnimation(t);
+ animation.finish();
+ assert_equals(animation.startTime, document.timeline.currentTime - animation.currentTime);
+ assert_equals(animation.currentTime, 100000);
+ assert_equals(animation.playState, 'finished');
+}, "Calling finish() on a paused animation");
+
+test(function(t) {
+ var animation = createPausedAnimation(t);
+ animation.reverse();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 100000);
+ assert_equals(animation.playState, 'pending');
+}, "Calling reverse() on a paused animation");
+
+test(function(t) {
+ var animation = createPausedAnimation(t);
+ animation.currentTime = 1000;
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 1000);
+ assert_equals(animation.playState, 'paused');
+}, "Setting currentTime on a paused animation");
+
+test(function(t) {
+ var animation = createPausedAnimation(t);
+ animation.startTime = document.timeline.currentTime - 1000;
+ assert_equals(animation.startTime, document.timeline.currentTime - 1000);
+ assert_equals(animation.currentTime, 1000);
+ assert_equals(animation.playState, 'running');
+}, "Setting startTime on a paused animation");
+
+test(function(t) {
+ var animation = createFinishedAnimation(t);
+ animation.play();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 0);
+ assert_equals(animation.playState, 'pending');
+}, "Calling play() on a finished animation");
+
+test(function(t) {
+ var animation = createFinishedAnimation(t);
+ animation.pause();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 100000);
+ assert_equals(animation.playState, 'pending');
+}, "Calling pause() on a finished animation");
+
+test(function(t) {
+ var animation = createFinishedAnimation(t);
+ animation.cancel();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, null);
+ assert_equals(animation.playState, 'idle');
+}, "Calling cancel() on a finished animation");
+
+test(function(t) {
+ var animation = createFinishedAnimation(t);
+ animation.finish();
+ assert_equals(animation.startTime, document.timeline.currentTime - animation.currentTime);
+ assert_equals(animation.currentTime, 100000);
+ assert_equals(animation.playState, 'finished');
+}, "Calling finish() on a finished animation");
+
+test(function(t) {
+ var animation = createFinishedAnimation(t);
+ animation.reverse();
+ assert_equals(animation.startTime, null);
+ assert_equals(animation.currentTime, 100000);
+ assert_equals(animation.playState, 'pending');
+}, "Calling reverse() on a finished animation");
+
+test(function(t) {
+ var animation = createFinishedAnimation(t);
+ animation.currentTime = 1000;
+ assert_equals(animation.startTime, document.timeline.currentTime - animation.currentTime);
+ assert_equals(animation.currentTime, 1000);
+ assert_equals(animation.playState, 'running');
+}, "Setting currentTime on a finished animation");
+
+async_test(function(t) {
+ var animation = createIdleAnimation(t);
+ animation.play();
+ var animationCurrentTime = animation.currentTime;
+ var timelineCurrentTime = document.timeline.currentTime;
+ animation.ready.then(() => {
+ t.step(() => {
+ assert_equals(animation.playState, 'running');
+ assert_greater_than_equal(animation.startTime, timelineCurrentTime);
+ assert_greater_than_equal(animation.currentTime, animationCurrentTime);
+ });
+ t.done();
+ });
+}, "PlayState is 'running' while playing a cancelled animation");
+
+async_test(function(t) {
+ let animation = createRunningAnimation(t);
+ animation.pause();
+ let animationCurrentTime = animation.currentTime;
+ animation.ready.then(() => {
+ t.step(() => {
+ assert_equals(animation.playState, 'paused');
+ assert_equals(animation.startTime, null);
+ assert_greater_than_equal(animation.currentTime, animationCurrentTime);
+ });
+ t.done();
+ });
+}, "PlayState is 'running' while pausing a running animation");
+</script>
« no previous file with comments | « third_party/WebKit/LayoutTests/web-animations-api/animation-state-changes.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698