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

Unified Diff: cc/animation/animation_unittest.cc

Issue 23926003: Take time_offset into account when ticking animations that are Starting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | « cc/animation/animation.cc ('k') | cc/animation/layer_animation_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/animation_unittest.cc
diff --git a/cc/animation/animation_unittest.cc b/cc/animation/animation_unittest.cc
index 337d3eedb359ac3362d3a85be454791a58fd5aa8..23d416976792b6e88e8aa8781c5fa12f7b5092b0 100644
--- a/cc/animation/animation_unittest.cc
+++ b/cc/animation/animation_unittest.cc
@@ -110,6 +110,41 @@ TEST(AnimationTest, TrimTimeZeroDuration) {
EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(1.0));
}
+TEST(AnimationTest, TrimTimeStarting) {
+ scoped_ptr<Animation> anim(CreateAnimation(1, 5.0));
+ anim->SetRunState(Animation::Starting, 0.0);
+ EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(-1.0));
+ EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(0.0));
+ EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(1.0));
+ anim->set_time_offset(2.0);
+ EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(-1.0));
+ EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(0.0));
+ EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(1.0));
+ anim->set_start_time(1.0);
+ EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(-1.0));
+ EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(0.0));
+ EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(1.0));
+ EXPECT_EQ(3.0, anim->TrimTimeToCurrentIteration(2.0));
+}
+
+TEST(AnimationTest, TrimTimeNeedsSynchronizedStartTime) {
+ scoped_ptr<Animation> anim(CreateAnimation(1, 5.0));
+ anim->SetRunState(Animation::Running, 0.0);
+ anim->set_needs_synchronized_start_time(true);
+ EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(-1.0));
+ EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(0.0));
+ EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(1.0));
+ anim->set_time_offset(2.0);
+ EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(-1.0));
+ EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(0.0));
+ EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(1.0));
+ anim->set_start_time(1.0);
+ anim->set_needs_synchronized_start_time(false);
+ EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(0.0));
+ EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(1.0));
+ EXPECT_EQ(3.0, anim->TrimTimeToCurrentIteration(2.0));
+}
+
TEST(AnimationTest, IsFinishedAtZeroIterations) {
scoped_ptr<Animation> anim(CreateAnimation(0));
anim->SetRunState(Animation::Running, 0.0);
« no previous file with comments | « cc/animation/animation.cc ('k') | cc/animation/layer_animation_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698