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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 TEST(AnimationTest, TrimTimeInfiniteIterations) { | 44 TEST(AnimationTest, TrimTimeInfiniteIterations) { |
45 scoped_ptr<Animation> anim(CreateAnimation(-1)); | 45 scoped_ptr<Animation> anim(CreateAnimation(-1)); |
46 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(0.0)); | 46 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(0.0)); |
47 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(0.5)); | 47 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(0.5)); |
48 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(1.0)); | 48 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(1.0)); |
49 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(1.5)); | 49 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(1.5)); |
50 } | 50 } |
51 | 51 |
52 TEST(AnimationTest, TrimTimeAlternating) { | 52 TEST(AnimationTest, TrimTimeReverse) { |
53 scoped_ptr<Animation> anim(CreateAnimation(-1)); | 53 scoped_ptr<Animation> anim(CreateAnimation(-1)); |
54 anim->set_alternates_direction(true); | 54 anim->set_direction(Animation::Reverse); |
| 55 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(0)); |
| 56 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(0.25)); |
| 57 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(0.5)); |
| 58 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(0.75)); |
| 59 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(1.0)); |
| 60 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(1.25)); |
| 61 } |
| 62 |
| 63 TEST(AnimationTest, TrimTimeAlternate) { |
| 64 scoped_ptr<Animation> anim(CreateAnimation(-1)); |
| 65 anim->set_direction(Animation::Alternate); |
55 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(0.0)); | 66 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(0.0)); |
| 67 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(0.25)); |
56 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(0.5)); | 68 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(0.5)); |
| 69 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(0.75)); |
57 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(1.0)); | 70 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(1.0)); |
58 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(1.25)); | 71 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(1.25)); |
59 } | 72 } |
60 | 73 |
| 74 TEST(AnimationTest, TrimTimeAlternateReverse) { |
| 75 scoped_ptr<Animation> anim(CreateAnimation(-1)); |
| 76 anim->set_direction(Animation::AlternateReverse); |
| 77 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(0.0)); |
| 78 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(0.25)); |
| 79 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(0.5)); |
| 80 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(0.75)); |
| 81 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(1.0)); |
| 82 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(1.25)); |
| 83 } |
| 84 |
61 TEST(AnimationTest, TrimTimeStartTime) { | 85 TEST(AnimationTest, TrimTimeStartTime) { |
62 scoped_ptr<Animation> anim(CreateAnimation(1)); | 86 scoped_ptr<Animation> anim(CreateAnimation(1)); |
63 anim->set_start_time(4); | 87 anim->set_start_time(4); |
64 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(0.0)); | 88 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(0.0)); |
65 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(4.0)); | 89 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(4.0)); |
66 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(4.5)); | 90 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(4.5)); |
67 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(5.0)); | 91 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(5.0)); |
68 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(6.0)); | 92 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(6.0)); |
69 } | 93 } |
70 | 94 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 EXPECT_EQ(Animation::Paused, anim->run_state()); | 278 EXPECT_EQ(Animation::Paused, anim->run_state()); |
255 anim->SetRunState(Animation::Running, 0.0); | 279 anim->SetRunState(Animation::Running, 0.0); |
256 EXPECT_EQ(Animation::Paused, anim->run_state()); | 280 EXPECT_EQ(Animation::Paused, anim->run_state()); |
257 anim->Resume(0); | 281 anim->Resume(0); |
258 anim->SetRunState(Animation::Running, 0.0); | 282 anim->SetRunState(Animation::Running, 0.0); |
259 EXPECT_EQ(Animation::Running, anim->run_state()); | 283 EXPECT_EQ(Animation::Running, anim->run_state()); |
260 } | 284 } |
261 | 285 |
262 } // namespace | 286 } // namespace |
263 } // namespace cc | 287 } // namespace cc |
OLD | NEW |