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

Unified Diff: Source/core/animation/AnimationPlayerTest.cpp

Issue 534193002: Web-Animations: Implement idle state for AnimationPlayers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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 | « Source/core/animation/AnimationPlayer.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/AnimationPlayerTest.cpp
diff --git a/Source/core/animation/AnimationPlayerTest.cpp b/Source/core/animation/AnimationPlayerTest.cpp
index 28cd31ae4422de98d2cb849f5ae1879d9c31d5bd..301a8fac4f727d46e0af081f5d82b6e75977bf13 100644
--- a/Source/core/animation/AnimationPlayerTest.cpp
+++ b/Source/core/animation/AnimationPlayerTest.cpp
@@ -754,10 +754,14 @@ TEST_F(AnimationAnimationPlayerTest, TimeToNextEffectWhenCancelledBeforeStart)
EXPECT_EQ(0, player->timeToEffectChange());
player->setCurrentTimeInternal(-8);
player->setPlaybackRate(2);
+ EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
player->cancel();
+ EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
player->update(TimingUpdateOnDemand);
+ // This frame will fire the finish event event though no start time has been
+ // received from the compositor yet, as cancel() nukes start times.
simulateFrame(0);
- EXPECT_EQ(4, player->timeToEffectChange());
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChange());
}
TEST_F(AnimationAnimationPlayerTest, TimeToNextEffectWhenCancelledBeforeStartReverse)
@@ -765,10 +769,26 @@ TEST_F(AnimationAnimationPlayerTest, TimeToNextEffectWhenCancelledBeforeStartRev
EXPECT_EQ(0, player->timeToEffectChange());
player->setCurrentTimeInternal(9);
player->setPlaybackRate(-3);
+ EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
player->cancel();
+ EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
player->update(TimingUpdateOnDemand);
+ // This frame will fire the finish event event though no start time has been
+ // received from the compositor yet, as cancel() nukes start times.
simulateFrame(0);
- EXPECT_EQ(3, player->timeToEffectChange());
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChange());
+}
+
+TEST_F(AnimationAnimationPlayerTest, TimeToNextEffectSimpleCancelledBeforeStart)
+{
+ EXPECT_EQ(0, player->timeToEffectChange());
+ EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
+ player->cancel();
+ player->update(TimingUpdateOnDemand);
+ // This frame will fire the finish event event though no start time has been
+ // received from the compositor yet, as cancel() nukes start times.
+ simulateFrame(0);
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChange());
}
TEST_F(AnimationAnimationPlayerTest, AttachedAnimationPlayers)
@@ -794,4 +814,81 @@ TEST_F(AnimationAnimationPlayerTest, HasLowerPriority)
EXPECT_TRUE(AnimationPlayer::hasLowerPriority(player1.get(), player2.get()));
}
+TEST_F(AnimationAnimationPlayerTest, PlayAfterCancel)
+{
+ player->cancel();
+ EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
+ EXPECT_TRUE(std::isnan(player->currentTime()));
+ EXPECT_TRUE(std::isnan(player->startTime()));
+ player->play();
+ EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
+ EXPECT_EQ(0, player->currentTime());
+ EXPECT_TRUE(std::isnan(player->startTime()));
+ simulateFrame(10);
+ EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
+ EXPECT_EQ(0, player->currentTime());
+ EXPECT_EQ(10 * 1000, player->startTime());
+}
+
+TEST_F(AnimationAnimationPlayerTest, PlayBackwardsAfterCancel)
+{
+ player->setPlaybackRate(-1);
+ player->setCurrentTime(15 * 1000);
+ simulateFrame(0);
+ player->cancel();
+ EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
+ EXPECT_TRUE(std::isnan(player->currentTime()));
+ EXPECT_TRUE(std::isnan(player->startTime()));
+ player->play();
+ EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
+ EXPECT_EQ(30 * 1000, player->currentTime());
+ EXPECT_TRUE(std::isnan(player->startTime()));
+ simulateFrame(10);
+ EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
+ EXPECT_EQ(30 * 1000, player->currentTime());
+ EXPECT_EQ(40 * 1000, player->startTime());
+}
+
+// FIXME: crbug.com/410229, when fixed, will reuqire the expected results of
+// this test to change (currentTime -> 30 * 1000).
+TEST_F(AnimationAnimationPlayerTest, ReverseAfterCancel)
+{
+ player->cancel();
+ EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
+ EXPECT_TRUE(std::isnan(player->currentTime()));
+ EXPECT_TRUE(std::isnan(player->startTime()));
+ player->reverse();
+ EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
+ EXPECT_TRUE(std::isnan(player->currentTime()));
+ EXPECT_TRUE(std::isnan(player->startTime()));
+ simulateFrame(10);
+ EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal());
+ EXPECT_EQ(0 * 1000, player->currentTime());
+ EXPECT_EQ(10 * 1000, player->startTime());
+}
+
+TEST_F(AnimationAnimationPlayerTest, FinishAfterCancel)
+{
+ player->cancel();
+ EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
+ EXPECT_TRUE(std::isnan(player->currentTime()));
+ EXPECT_TRUE(std::isnan(player->startTime()));
+ player->finish(exceptionState);
+ EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal());
+ EXPECT_EQ(30 * 1000, player->currentTime());
+ EXPECT_EQ(0, player->startTime());
+}
+
+TEST_F(AnimationAnimationPlayerTest, PauseAfterCancel)
+{
+ player->cancel();
+ EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
+ EXPECT_TRUE(std::isnan(player->currentTime()));
+ EXPECT_TRUE(std::isnan(player->startTime()));
+ player->pause();
+ EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
+ EXPECT_TRUE(std::isnan(player->currentTime()));
+ EXPECT_TRUE(std::isnan(player->startTime()));
+}
+
}
« no previous file with comments | « Source/core/animation/AnimationPlayer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698