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" |
11 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 11 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
12 #include "third_party/WebKit/public/platform/WebFloatSize.h" | 12 #include "third_party/WebKit/public/platform/WebFloatSize.h" |
13 #include "third_party/WebKit/public/platform/WebGestureCurve.h" | 13 #include "third_party/WebKit/public/platform/WebGestureCurve.h" |
14 #include "third_party/WebKit/public/platform/WebGestureCurveTarget.h" | 14 #include "third_party/WebKit/public/platform/WebGestureCurveTarget.h" |
15 #include "third_party/WebKit/public/platform/WebSize.h" | 15 #include "third_party/WebKit/public/platform/WebSize.h" |
16 | 16 |
17 using blink::WebFloatPoint; | 17 using blink::WebFloatPoint; |
18 using blink::WebFloatSize; | 18 using blink::WebFloatSize; |
19 using blink::WebGestureCurve; | 19 using blink::WebGestureCurve; |
20 using blink::WebGestureCurveTarget; | 20 using blink::WebGestureCurveTarget; |
21 using blink::WebSize; | 21 using blink::WebSize; |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 class MockGestureCurveTarget : public WebGestureCurveTarget { | 25 class MockGestureCurveTarget : public WebGestureCurveTarget { |
26 public: | 26 public: |
27 virtual bool scrollBy(const WebFloatSize& delta, | 27 virtual void scrollBy(const WebFloatSize& delta) { |
28 const WebFloatSize& velocity) OVERRIDE { | |
29 cumulative_delta_.width += delta.width; | 28 cumulative_delta_.width += delta.width; |
30 cumulative_delta_.height += delta.height; | 29 cumulative_delta_.height += delta.height; |
| 30 } |
| 31 |
| 32 virtual void notifyCurrentFlingVelocity(const WebFloatSize& velocity) { |
31 current_velocity_ = velocity; | 33 current_velocity_ = velocity; |
32 return true; | |
33 } | 34 } |
34 | 35 |
35 WebFloatSize cumulative_delta() const { return cumulative_delta_; } | 36 WebFloatSize cumulative_delta() const { return cumulative_delta_; } |
36 void resetCumulativeDelta() { cumulative_delta_ = WebFloatSize(); } | 37 void resetCumulativeDelta() { cumulative_delta_ = WebFloatSize(); } |
37 | 38 |
38 WebFloatSize current_velocity() const { return current_velocity_; } | 39 WebFloatSize current_velocity() const { return current_velocity_; } |
39 | 40 |
40 private: | 41 private: |
41 WebFloatSize cumulative_delta_; | 42 WebFloatSize cumulative_delta_; |
42 WebFloatSize current_velocity_; | 43 WebFloatSize current_velocity_; |
(...skipping 18 matching lines...) Expand all Loading... |
61 EXPECT_EQ(target.current_velocity().height, 0); | 62 EXPECT_EQ(target.current_velocity().height, 0); |
62 EXPECT_TRUE(curve->apply(0.45f, &target)); // Use non-uniform tick spacing. | 63 EXPECT_TRUE(curve->apply(0.45f, &target)); // Use non-uniform tick spacing. |
63 EXPECT_TRUE(curve->apply(1, &target)); | 64 EXPECT_TRUE(curve->apply(1, &target)); |
64 EXPECT_FALSE(curve->apply(1.5, &target)); | 65 EXPECT_FALSE(curve->apply(1.5, &target)); |
65 EXPECT_NEAR(target.cumulative_delta().width, 1193, 1); | 66 EXPECT_NEAR(target.cumulative_delta().width, 1193, 1); |
66 EXPECT_EQ(target.cumulative_delta().height, 0); | 67 EXPECT_EQ(target.cumulative_delta().height, 0); |
67 EXPECT_EQ(target.current_velocity().width, 0); | 68 EXPECT_EQ(target.current_velocity().width, 0); |
68 EXPECT_EQ(target.current_velocity().height, 0); | 69 EXPECT_EQ(target.current_velocity().height, 0); |
69 } | 70 } |
70 | 71 |
OLD | NEW |