OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/scroll_offset_animation_curve.h" | 5 #include "cc/animation/scroll_offset_animation_curve.h" |
6 | 6 |
7 #include "cc/animation/timing_function.h" | 7 #include "cc/animation/timing_function.h" |
8 #include "cc/test/geometry_test_utils.h" | 8 #include "cc/test/geometry_test_utils.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 target_value, | 112 target_value, |
113 clone->ToScrollOffsetAnimationCurve()->GetValue(duration + 1.0)); | 113 clone->ToScrollOffsetAnimationCurve()->GetValue(duration + 1.0)); |
114 | 114 |
115 // Verify that the timing function was cloned correctly. | 115 // Verify that the timing function was cloned correctly. |
116 gfx::Vector2dF value = | 116 gfx::Vector2dF value = |
117 clone->ToScrollOffsetAnimationCurve()->GetValue(duration / 4.0); | 117 clone->ToScrollOffsetAnimationCurve()->GetValue(duration / 4.0); |
118 EXPECT_NEAR(3.0333f, value.x(), 0.00015f); | 118 EXPECT_NEAR(3.0333f, value.x(), 0.00015f); |
119 EXPECT_NEAR(37.4168f, value.y(), 0.00015f); | 119 EXPECT_NEAR(37.4168f, value.y(), 0.00015f); |
120 } | 120 } |
121 | 121 |
122 TEST(ScrollOffsetAnimationCurveTest, UpdateTarget) { | |
123 gfx::Vector2dF initial_value(0.f, 0.f); | |
124 gfx::Vector2dF target_value(0.f, 3600.f); | |
125 scoped_ptr<ScrollOffsetAnimationCurve> curve( | |
126 ScrollOffsetAnimationCurve::Create( | |
127 target_value, EaseInOutTimingFunction::Create().Pass())); | |
128 curve->SetInitialValue(initial_value); | |
129 EXPECT_EQ(1.0, curve->Duration()); | |
130 EXPECT_EQ(1800.0, curve->GetValue(0.5).y()); | |
131 EXPECT_EQ(3600.0, curve->GetValue(1.0).y()); | |
132 | |
133 curve->UpdateTarget(0.5, gfx::Vector2dF(0.0, 9900.0)); | |
134 | |
135 EXPECT_EQ(2.0, curve->Duration()); | |
136 EXPECT_EQ(1800.0, curve->GetValue(0.5).y()); | |
137 EXPECT_NEAR(5566.49, curve->GetValue(1.0).y(), 0.01); | |
138 EXPECT_EQ(9900.0, curve->GetValue(2.0).y()); | |
ajuma
2014/07/16 20:35:23
Please add one more re-targeting here (to verify t
skobes
2014/07/16 21:10:48
Done.
| |
139 } | |
140 | |
122 } // namespace | 141 } // namespace |
123 } // namespace cc | 142 } // namespace cc |
OLD | NEW |