diff options
Diffstat (limited to 'Source/WebKit/chromium/tests/CCActiveAnimationTest.cpp')
-rw-r--r-- | Source/WebKit/chromium/tests/CCActiveAnimationTest.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Source/WebKit/chromium/tests/CCActiveAnimationTest.cpp b/Source/WebKit/chromium/tests/CCActiveAnimationTest.cpp index e14ef9bc0..a1ab770b7 100644 --- a/Source/WebKit/chromium/tests/CCActiveAnimationTest.cpp +++ b/Source/WebKit/chromium/tests/CCActiveAnimationTest.cpp @@ -80,6 +80,17 @@ TEST(CCActiveAnimationTest, TrimTimeStartTime) EXPECT_EQ(1, anim->trimTimeToCurrentIteration(6)); } +TEST(CCActiveAnimationTest, TrimTimeTimeOffset) +{ + OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); + anim->setTimeOffset(4); + anim->setStartTime(4); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); + EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); + EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1)); + EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1)); +} + TEST(CCActiveAnimationTest, TrimTimePauseResume) { OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); @@ -93,6 +104,19 @@ TEST(CCActiveAnimationTest, TrimTimePauseResume) EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1024.5)); } +TEST(CCActiveAnimationTest, TrimTimeSuspendResume) +{ + OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); + anim->setRunState(CCActiveAnimation::Running, 0); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); + EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); + anim->suspend(0.5); + EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(1024)); + anim->resume(1024); + EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(1024)); + EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1024.5)); +} + TEST(CCActiveAnimationTest, IsFinishedAtZeroIterations) { OwnPtr<CCActiveAnimation> anim(createActiveAnimation(0)); @@ -160,4 +184,35 @@ TEST(CCActiveAnimationTest, IsFinished) EXPECT_TRUE(anim->isFinished()); } +TEST(CCActiveAnimationTest, IsFinishedNeedsSynchronizedStartTime) +{ + OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); + anim->setRunState(CCActiveAnimation::Running, 2); + EXPECT_FALSE(anim->isFinished()); + anim->setRunState(CCActiveAnimation::Paused, 2); + EXPECT_FALSE(anim->isFinished()); + anim->setRunState(CCActiveAnimation::WaitingForNextTick, 2); + EXPECT_FALSE(anim->isFinished()); + anim->setRunState(CCActiveAnimation::WaitingForTargetAvailability, 2); + EXPECT_FALSE(anim->isFinished()); + anim->setRunState(CCActiveAnimation::WaitingForStartTime, 2); + EXPECT_FALSE(anim->isFinished()); + anim->setRunState(CCActiveAnimation::Finished, 0); + EXPECT_TRUE(anim->isFinished()); + anim->setRunState(CCActiveAnimation::Aborted, 0); + EXPECT_TRUE(anim->isFinished()); +} + +TEST(CCActiveAnimationTest, RunStateChangesIgnoredWhileSuspended) +{ + OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); + anim->suspend(0); + EXPECT_EQ(CCActiveAnimation::Paused, anim->runState()); + anim->setRunState(CCActiveAnimation::Running, 0); + EXPECT_EQ(CCActiveAnimation::Paused, anim->runState()); + anim->resume(0); + anim->setRunState(CCActiveAnimation::Running, 0); + EXPECT_EQ(CCActiveAnimation::Running, anim->runState()); +} + } // namespace |