OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/multi_animation.h" | 5 #include "app/multi_animation.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 typedef testing::Test MultiAnimationTest; | 8 typedef testing::Test MultiAnimationTest; |
9 | 9 |
10 TEST_F(MultiAnimationTest, Basic) { | 10 TEST_F(MultiAnimationTest, Basic) { |
(...skipping 16 matching lines...) Expand all Loading... |
27 base::TimeDelta::FromMilliseconds(120)); | 27 base::TimeDelta::FromMilliseconds(120)); |
28 EXPECT_EQ(Tween::CalculateValue(Tween::EASE_OUT, .2), | 28 EXPECT_EQ(Tween::CalculateValue(Tween::EASE_OUT, .2), |
29 animation.GetCurrentValue()); | 29 animation.GetCurrentValue()); |
30 | 30 |
31 // Step to 320, which is 20% through the second part. | 31 // Step to 320, which is 20% through the second part. |
32 as_element->Step(base::TimeTicks() + | 32 as_element->Step(base::TimeTicks() + |
33 base::TimeDelta::FromMilliseconds(320)); | 33 base::TimeDelta::FromMilliseconds(320)); |
34 EXPECT_EQ(Tween::CalculateValue(Tween::EASE_OUT, .2), | 34 EXPECT_EQ(Tween::CalculateValue(Tween::EASE_OUT, .2), |
35 animation.GetCurrentValue()); | 35 animation.GetCurrentValue()); |
36 } | 36 } |
| 37 |
| 38 TEST_F(MultiAnimationTest, DifferingStartAndEnd) { |
| 39 // Create a MultiAnimation with two parts. |
| 40 MultiAnimation::Parts parts; |
| 41 parts.push_back(MultiAnimation::Part(200, Tween::LINEAR)); |
| 42 parts[0].start_time_ms = 100; |
| 43 parts[0].end_time_ms = 400; |
| 44 |
| 45 MultiAnimation animation(parts); |
| 46 AnimationContainer::Element* as_element = |
| 47 static_cast<AnimationContainer::Element*>(&animation); |
| 48 as_element->SetStartTime(base::TimeTicks()); |
| 49 |
| 50 // Step to 0. Because the start_time is 100, this should be 100ms into the |
| 51 // animation |
| 52 as_element->Step(base::TimeTicks()); |
| 53 EXPECT_EQ(.25, animation.GetCurrentValue()); |
| 54 |
| 55 // Step to 100, which is effectively 200ms into the animation. |
| 56 as_element->Step(base::TimeTicks() + base::TimeDelta::FromMilliseconds(100)); |
| 57 EXPECT_EQ(.5, animation.GetCurrentValue()); |
| 58 } |
OLD | NEW |