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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/time/time.h" | 6 #include "base/time/time.h" |
7 #include "content/browser/renderer_host/input/synthetic_gesture_controller_new.h
" | 7 #include "content/browser/renderer_host/input/synthetic_gesture_controller_new.h
" |
8 #include "content/browser/renderer_host/input/synthetic_gesture_new.h" | 8 #include "content/browser/renderer_host/input/synthetic_gesture_new.h" |
9 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | 9 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
10 #include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture_ne
w.h" | 10 #include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture_ne
w.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 int num_success_; | 92 int num_success_; |
93 int num_failure_; | 93 int num_failure_; |
94 }; | 94 }; |
95 | 95 |
96 class MockSyntheticSmoothScrollMouseTarget : public MockSyntheticGestureTarget { | 96 class MockSyntheticSmoothScrollMouseTarget : public MockSyntheticGestureTarget { |
97 public: | 97 public: |
98 MockSyntheticSmoothScrollMouseTarget() : scroll_distance_(0) {} | 98 MockSyntheticSmoothScrollMouseTarget() : scroll_distance_(0) {} |
99 virtual ~MockSyntheticSmoothScrollMouseTarget() {} | 99 virtual ~MockSyntheticSmoothScrollMouseTarget() {} |
100 | 100 |
101 virtual void QueueInputEventToPlatform(const InputEvent& event) OVERRIDE { | 101 virtual void QueueInputEventToPlatform(const InputEvent& event) OVERRIDE { |
102 const WebKit::WebInputEvent* web_event = event.web_event.get(); | 102 const blink::WebInputEvent* web_event = event.web_event.get(); |
103 DCHECK_EQ(web_event->type, WebKit::WebInputEvent::MouseWheel); | 103 DCHECK_EQ(web_event->type, blink::WebInputEvent::MouseWheel); |
104 const WebKit::WebMouseWheelEvent* mouse_wheel_event = | 104 const blink::WebMouseWheelEvent* mouse_wheel_event = |
105 static_cast<const WebKit::WebMouseWheelEvent*>(web_event); | 105 static_cast<const blink::WebMouseWheelEvent*>(web_event); |
106 DCHECK_EQ(mouse_wheel_event->deltaX, 0); | 106 DCHECK_EQ(mouse_wheel_event->deltaX, 0); |
107 scroll_distance_ += mouse_wheel_event->deltaY; | 107 scroll_distance_ += mouse_wheel_event->deltaY; |
108 } | 108 } |
109 | 109 |
110 float scroll_distance() const { return scroll_distance_; } | 110 float scroll_distance() const { return scroll_distance_; } |
111 | 111 |
112 private: | 112 private: |
113 float scroll_distance_; | 113 float scroll_distance_; |
114 }; | 114 }; |
115 | 115 |
116 class MockSyntheticSmoothScrollTouchTarget : public MockSyntheticGestureTarget { | 116 class MockSyntheticSmoothScrollTouchTarget : public MockSyntheticGestureTarget { |
117 public: | 117 public: |
118 MockSyntheticSmoothScrollTouchTarget() | 118 MockSyntheticSmoothScrollTouchTarget() |
119 : scroll_distance_(0), anchor_y_(0), started_(false) {} | 119 : scroll_distance_(0), anchor_y_(0), started_(false) {} |
120 virtual ~MockSyntheticSmoothScrollTouchTarget() {} | 120 virtual ~MockSyntheticSmoothScrollTouchTarget() {} |
121 | 121 |
122 virtual void QueueInputEventToPlatform(const InputEvent& event) OVERRIDE { | 122 virtual void QueueInputEventToPlatform(const InputEvent& event) OVERRIDE { |
123 const WebKit::WebInputEvent* web_event = event.web_event.get(); | 123 const blink::WebInputEvent* web_event = event.web_event.get(); |
124 DCHECK(WebKit::WebInputEvent::isTouchEventType(web_event->type)); | 124 DCHECK(blink::WebInputEvent::isTouchEventType(web_event->type)); |
125 const WebKit::WebTouchEvent* touch_event = | 125 const blink::WebTouchEvent* touch_event = |
126 static_cast<const WebKit::WebTouchEvent*>(web_event); | 126 static_cast<const blink::WebTouchEvent*>(web_event); |
127 DCHECK_EQ(touch_event->touchesLength, (unsigned int)1); | 127 DCHECK_EQ(touch_event->touchesLength, (unsigned int)1); |
128 | 128 |
129 if (!started_) { | 129 if (!started_) { |
130 DCHECK_EQ(touch_event->type, WebKit::WebInputEvent::TouchStart); | 130 DCHECK_EQ(touch_event->type, blink::WebInputEvent::TouchStart); |
131 anchor_y_ = touch_event->touches[0].position.y; | 131 anchor_y_ = touch_event->touches[0].position.y; |
132 started_ = true; | 132 started_ = true; |
133 } | 133 } |
134 else { | 134 else { |
135 DCHECK_NE(touch_event->type, WebKit::WebInputEvent::TouchStart); | 135 DCHECK_NE(touch_event->type, blink::WebInputEvent::TouchStart); |
136 DCHECK_NE(touch_event->type, WebKit::WebInputEvent::TouchCancel); | 136 DCHECK_NE(touch_event->type, blink::WebInputEvent::TouchCancel); |
137 // Ignore move events. | 137 // Ignore move events. |
138 | 138 |
139 if (touch_event->type == WebKit::WebInputEvent::TouchEnd) | 139 if (touch_event->type == blink::WebInputEvent::TouchEnd) |
140 scroll_distance_ = touch_event->touches[0].position.y - anchor_y_; | 140 scroll_distance_ = touch_event->touches[0].position.y - anchor_y_; |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 float scroll_distance() const { return scroll_distance_; } | 144 float scroll_distance() const { return scroll_distance_; } |
145 | 145 |
146 private: | 146 private: |
147 float scroll_distance_; | 147 float scroll_distance_; |
148 float anchor_y_; | 148 float anchor_y_; |
149 bool started_; | 149 bool started_; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 PostQuitMessageAndRun(30); | 299 PostQuitMessageAndRun(30); |
300 | 300 |
301 EXPECT_EQ(1, smooth_scroll_mouse_target_ptr->num_success()); | 301 EXPECT_EQ(1, smooth_scroll_mouse_target_ptr->num_success()); |
302 EXPECT_EQ(0, smooth_scroll_mouse_target_ptr->num_failure()); | 302 EXPECT_EQ(0, smooth_scroll_mouse_target_ptr->num_failure()); |
303 EXPECT_GE(params.distance, smooth_scroll_mouse_target_ptr->scroll_distance()); | 303 EXPECT_GE(params.distance, smooth_scroll_mouse_target_ptr->scroll_distance()); |
304 } | 304 } |
305 | 305 |
306 } // namespace | 306 } // namespace |
307 | 307 |
308 } // namespace content | 308 } // namespace content |
OLD | NEW |