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 // Tests for the TouchFlingGestureCurve. | 5 // Tests for the TouchFlingGestureCurve. |
6 | 6 |
7 #include "content/child/touch_fling_gesture_curve.h" | 7 #include "content/child/touch_fling_gesture_curve.h" |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 }; | 43 }; |
44 | 44 |
45 } // namespace anonymous | 45 } // namespace anonymous |
46 | 46 |
47 TEST(TouchFlingGestureCurve, flingCurveTouch) | 47 TEST(TouchFlingGestureCurve, flingCurveTouch) |
48 { | 48 { |
49 double initialVelocity = 5000; | 49 double initialVelocity = 5000; |
50 MockGestureCurveTarget target; | 50 MockGestureCurveTarget target; |
51 | 51 |
52 scoped_ptr<WebGestureCurve> curve(content::TouchFlingGestureCurve::Create( | 52 scoped_ptr<WebGestureCurve> curve(content::TouchFlingGestureCurve::Create( |
53 WebFloatPoint(initialVelocity, 0), | 53 WebFloatPoint(initialVelocity, 0), WebSize())); |
54 -5.70762e+03f, 1.72e+02f, 3.7e+00f, WebSize())); | |
55 | 54 |
56 // Note: the expectations below are dependent on the curve parameters hard | 55 // Note: the expectations below are dependent on the curve parameters hard |
57 // coded into the create call above. | 56 // coded into the create call above. |
58 EXPECT_TRUE(curve->apply(0, &target)); | 57 EXPECT_TRUE(curve->apply(0, &target)); |
59 EXPECT_TRUE(curve->apply(0.25, &target)); | 58 EXPECT_TRUE(curve->apply(0.25, &target)); |
60 EXPECT_NEAR(target.current_velocity().width, 1878, 1); | 59 EXPECT_NEAR(target.current_velocity().width, 1878, 1); |
61 EXPECT_EQ(target.current_velocity().height, 0); | 60 EXPECT_EQ(target.current_velocity().height, 0); |
62 EXPECT_TRUE(curve->apply(0.45f, &target)); // Use non-uniform tick spacing. | 61 EXPECT_TRUE(curve->apply(0.45f, &target)); // Use non-uniform tick spacing. |
63 EXPECT_TRUE(curve->apply(1, &target)); | 62 EXPECT_TRUE(curve->apply(1, &target)); |
64 EXPECT_FALSE(curve->apply(1.5, &target)); | 63 EXPECT_FALSE(curve->apply(1.5, &target)); |
65 EXPECT_NEAR(target.cumulative_delta().width, 1193, 1); | 64 EXPECT_NEAR(target.cumulative_delta().width, 1193, 1); |
66 EXPECT_EQ(target.cumulative_delta().height, 0); | 65 EXPECT_EQ(target.cumulative_delta().height, 0); |
67 EXPECT_EQ(target.current_velocity().width, 0); | 66 EXPECT_EQ(target.current_velocity().width, 0); |
68 EXPECT_EQ(target.current_velocity().height, 0); | 67 EXPECT_EQ(target.current_velocity().height, 0); |
69 } | 68 } |
70 | 69 |
OLD | NEW |