OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/events/gestures/fling_curve.h" | 5 #include "ui/events/gestures/fling_curve.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/gfx/frame_time.h" | |
9 | 8 |
10 namespace ui { | 9 namespace ui { |
11 | 10 |
12 TEST(FlingCurveTest, Basic) { | 11 TEST(FlingCurveTest, Basic) { |
13 const gfx::Vector2dF velocity(0, 5000); | 12 const gfx::Vector2dF velocity(0, 5000); |
14 base::TimeTicks now = gfx::FrameTime::Now(); | 13 base::TimeTicks now = base::TimeTicks::Now(); |
15 FlingCurve curve(velocity, now); | 14 FlingCurve curve(velocity, now); |
16 | 15 |
17 gfx::Vector2dF delta; | 16 gfx::Vector2dF delta; |
18 EXPECT_TRUE(curve.ComputeScrollDeltaAtTime( | 17 EXPECT_TRUE(curve.ComputeScrollDeltaAtTime( |
19 now + base::TimeDelta::FromMilliseconds(20), &delta)); | 18 now + base::TimeDelta::FromMilliseconds(20), &delta)); |
20 EXPECT_EQ(0, delta.x()); | 19 EXPECT_EQ(0, delta.x()); |
21 EXPECT_NEAR(delta.y(), 96, 1); | 20 EXPECT_NEAR(delta.y(), 96, 1); |
22 | 21 |
23 EXPECT_TRUE(curve.ComputeScrollDeltaAtTime( | 22 EXPECT_TRUE(curve.ComputeScrollDeltaAtTime( |
24 now + base::TimeDelta::FromMilliseconds(250), &delta)); | 23 now + base::TimeDelta::FromMilliseconds(250), &delta)); |
25 EXPECT_EQ(0, delta.x()); | 24 EXPECT_EQ(0, delta.x()); |
26 EXPECT_NEAR(delta.y(), 705, 1); | 25 EXPECT_NEAR(delta.y(), 705, 1); |
27 | 26 |
28 EXPECT_FALSE(curve.ComputeScrollDeltaAtTime( | 27 EXPECT_FALSE(curve.ComputeScrollDeltaAtTime( |
29 now + base::TimeDelta::FromSeconds(10), &delta)); | 28 now + base::TimeDelta::FromSeconds(10), &delta)); |
30 EXPECT_EQ(0, delta.x()); | 29 EXPECT_EQ(0, delta.x()); |
31 EXPECT_NEAR(delta.y(), 392, 1); | 30 EXPECT_NEAR(delta.y(), 392, 1); |
32 | 31 |
33 EXPECT_FALSE(curve.ComputeScrollDeltaAtTime( | 32 EXPECT_FALSE(curve.ComputeScrollDeltaAtTime( |
34 now + base::TimeDelta::FromSeconds(20), &delta)); | 33 now + base::TimeDelta::FromSeconds(20), &delta)); |
35 EXPECT_TRUE(delta.IsZero()); | 34 EXPECT_TRUE(delta.IsZero()); |
36 } | 35 } |
37 | 36 |
38 } // namespace ui | 37 } // namespace ui |
OLD | NEW |