OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/animation/animation.h" | 5 #include "cc/animation/animation.h" |
6 | 6 |
7 #include "cc/test/animation_test_common.h" | 7 #include "cc/test/animation_test_common.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 } | 103 } |
104 | 104 |
105 TEST(AnimationTest, TrimTimeZeroDuration) { | 105 TEST(AnimationTest, TrimTimeZeroDuration) { |
106 scoped_ptr<Animation> anim(CreateAnimation(0, 0)); | 106 scoped_ptr<Animation> anim(CreateAnimation(0, 0)); |
107 anim->SetRunState(Animation::Running, 0.0); | 107 anim->SetRunState(Animation::Running, 0.0); |
108 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(-1.0)); | 108 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(-1.0)); |
109 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(0.0)); | 109 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(0.0)); |
110 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(1.0)); | 110 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(1.0)); |
111 } | 111 } |
112 | 112 |
| 113 TEST(AnimationTest, TrimTimeStarting) { |
| 114 scoped_ptr<Animation> anim(CreateAnimation(1, 5.0)); |
| 115 anim->SetRunState(Animation::Starting, 0.0); |
| 116 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(-1.0)); |
| 117 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(0.0)); |
| 118 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(1.0)); |
| 119 anim->set_time_offset(2.0); |
| 120 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(-1.0)); |
| 121 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(0.0)); |
| 122 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(1.0)); |
| 123 anim->set_start_time(1.0); |
| 124 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(-1.0)); |
| 125 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(0.0)); |
| 126 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(1.0)); |
| 127 EXPECT_EQ(3.0, anim->TrimTimeToCurrentIteration(2.0)); |
| 128 } |
| 129 |
| 130 TEST(AnimationTest, TrimTimeNeedsSynchronizedStartTime) { |
| 131 scoped_ptr<Animation> anim(CreateAnimation(1, 5.0)); |
| 132 anim->SetRunState(Animation::Running, 0.0); |
| 133 anim->set_needs_synchronized_start_time(true); |
| 134 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(-1.0)); |
| 135 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(0.0)); |
| 136 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(1.0)); |
| 137 anim->set_time_offset(2.0); |
| 138 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(-1.0)); |
| 139 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(0.0)); |
| 140 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(1.0)); |
| 141 anim->set_start_time(1.0); |
| 142 anim->set_needs_synchronized_start_time(false); |
| 143 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(0.0)); |
| 144 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(1.0)); |
| 145 EXPECT_EQ(3.0, anim->TrimTimeToCurrentIteration(2.0)); |
| 146 } |
| 147 |
113 TEST(AnimationTest, IsFinishedAtZeroIterations) { | 148 TEST(AnimationTest, IsFinishedAtZeroIterations) { |
114 scoped_ptr<Animation> anim(CreateAnimation(0)); | 149 scoped_ptr<Animation> anim(CreateAnimation(0)); |
115 anim->SetRunState(Animation::Running, 0.0); | 150 anim->SetRunState(Animation::Running, 0.0); |
116 EXPECT_FALSE(anim->IsFinishedAt(-1.0)); | 151 EXPECT_FALSE(anim->IsFinishedAt(-1.0)); |
117 EXPECT_TRUE(anim->IsFinishedAt(0.0)); | 152 EXPECT_TRUE(anim->IsFinishedAt(0.0)); |
118 EXPECT_TRUE(anim->IsFinishedAt(1.0)); | 153 EXPECT_TRUE(anim->IsFinishedAt(1.0)); |
119 } | 154 } |
120 | 155 |
121 TEST(AnimationTest, IsFinishedAtOneIteration) { | 156 TEST(AnimationTest, IsFinishedAtOneIteration) { |
122 scoped_ptr<Animation> anim(CreateAnimation(1)); | 157 scoped_ptr<Animation> anim(CreateAnimation(1)); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 EXPECT_EQ(Animation::Paused, anim->run_state()); | 231 EXPECT_EQ(Animation::Paused, anim->run_state()); |
197 anim->SetRunState(Animation::Running, 0.0); | 232 anim->SetRunState(Animation::Running, 0.0); |
198 EXPECT_EQ(Animation::Paused, anim->run_state()); | 233 EXPECT_EQ(Animation::Paused, anim->run_state()); |
199 anim->Resume(0); | 234 anim->Resume(0); |
200 anim->SetRunState(Animation::Running, 0.0); | 235 anim->SetRunState(Animation::Running, 0.0); |
201 EXPECT_EQ(Animation::Running, anim->run_state()); | 236 EXPECT_EQ(Animation::Running, anim->run_state()); |
202 } | 237 } |
203 | 238 |
204 } // namespace | 239 } // namespace |
205 } // namespace cc | 240 } // namespace cc |
OLD | NEW |