OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 sent_wheel_event_(false), | 63 sent_wheel_event_(false), |
64 sent_keyboard_event_(false), | 64 sent_keyboard_event_(false), |
65 sent_gesture_event_(false), | 65 sent_gesture_event_(false), |
66 send_touch_event_not_cancelled_(false), | 66 send_touch_event_not_cancelled_(false), |
67 message_received_(false), | 67 message_received_(false), |
68 client_(client) { | 68 client_(client) { |
69 } | 69 } |
70 virtual ~MockInputRouter() {} | 70 virtual ~MockInputRouter() {} |
71 | 71 |
72 // InputRouter | 72 // InputRouter |
73 virtual void Flush() OVERRIDE { | 73 virtual void Flush() override { |
74 flush_called_ = true; | 74 flush_called_ = true; |
75 } | 75 } |
76 virtual bool SendInput(scoped_ptr<IPC::Message> message) OVERRIDE { | 76 virtual bool SendInput(scoped_ptr<IPC::Message> message) override { |
77 send_event_called_ = true; | 77 send_event_called_ = true; |
78 return true; | 78 return true; |
79 } | 79 } |
80 virtual void SendMouseEvent( | 80 virtual void SendMouseEvent( |
81 const MouseEventWithLatencyInfo& mouse_event) OVERRIDE { | 81 const MouseEventWithLatencyInfo& mouse_event) override { |
82 sent_mouse_event_ = true; | 82 sent_mouse_event_ = true; |
83 } | 83 } |
84 virtual void SendWheelEvent( | 84 virtual void SendWheelEvent( |
85 const MouseWheelEventWithLatencyInfo& wheel_event) OVERRIDE { | 85 const MouseWheelEventWithLatencyInfo& wheel_event) override { |
86 sent_wheel_event_ = true; | 86 sent_wheel_event_ = true; |
87 } | 87 } |
88 virtual void SendKeyboardEvent( | 88 virtual void SendKeyboardEvent( |
89 const NativeWebKeyboardEvent& key_event, | 89 const NativeWebKeyboardEvent& key_event, |
90 const ui::LatencyInfo& latency_info, | 90 const ui::LatencyInfo& latency_info, |
91 bool is_shortcut) OVERRIDE { | 91 bool is_shortcut) override { |
92 sent_keyboard_event_ = true; | 92 sent_keyboard_event_ = true; |
93 } | 93 } |
94 virtual void SendGestureEvent( | 94 virtual void SendGestureEvent( |
95 const GestureEventWithLatencyInfo& gesture_event) OVERRIDE { | 95 const GestureEventWithLatencyInfo& gesture_event) override { |
96 sent_gesture_event_ = true; | 96 sent_gesture_event_ = true; |
97 } | 97 } |
98 virtual void SendTouchEvent( | 98 virtual void SendTouchEvent( |
99 const TouchEventWithLatencyInfo& touch_event) OVERRIDE { | 99 const TouchEventWithLatencyInfo& touch_event) override { |
100 send_touch_event_not_cancelled_ = | 100 send_touch_event_not_cancelled_ = |
101 client_->FilterInputEvent(touch_event.event, touch_event.latency) == | 101 client_->FilterInputEvent(touch_event.event, touch_event.latency) == |
102 INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 102 INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
103 } | 103 } |
104 virtual const NativeWebKeyboardEvent* GetLastKeyboardEvent() const OVERRIDE { | 104 virtual const NativeWebKeyboardEvent* GetLastKeyboardEvent() const override { |
105 NOTREACHED(); | 105 NOTREACHED(); |
106 return NULL; | 106 return NULL; |
107 } | 107 } |
108 virtual bool ShouldForwardTouchEvent() const OVERRIDE { return true; } | 108 virtual bool ShouldForwardTouchEvent() const override { return true; } |
109 virtual void OnViewUpdated(int view_flags) OVERRIDE {} | 109 virtual void OnViewUpdated(int view_flags) override {} |
110 virtual bool HasPendingEvents() const OVERRIDE { return false; } | 110 virtual bool HasPendingEvents() const override { return false; } |
111 | 111 |
112 // IPC::Listener | 112 // IPC::Listener |
113 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { | 113 virtual bool OnMessageReceived(const IPC::Message& message) override { |
114 message_received_ = true; | 114 message_received_ = true; |
115 return false; | 115 return false; |
116 } | 116 } |
117 | 117 |
118 bool flush_called_; | 118 bool flush_called_; |
119 bool send_event_called_; | 119 bool send_event_called_; |
120 bool sent_mouse_event_; | 120 bool sent_mouse_event_; |
121 bool sent_wheel_event_; | 121 bool sent_wheel_event_; |
122 bool sent_keyboard_event_; | 122 bool sent_keyboard_event_; |
123 bool sent_gesture_event_; | 123 bool sent_gesture_event_; |
(...skipping 22 matching lines...) Expand all Loading... |
146 // Allow poking at a few private members. | 146 // Allow poking at a few private members. |
147 using RenderWidgetHostImpl::OnUpdateRect; | 147 using RenderWidgetHostImpl::OnUpdateRect; |
148 using RenderWidgetHostImpl::RendererExited; | 148 using RenderWidgetHostImpl::RendererExited; |
149 using RenderWidgetHostImpl::last_requested_size_; | 149 using RenderWidgetHostImpl::last_requested_size_; |
150 using RenderWidgetHostImpl::is_hidden_; | 150 using RenderWidgetHostImpl::is_hidden_; |
151 using RenderWidgetHostImpl::resize_ack_pending_; | 151 using RenderWidgetHostImpl::resize_ack_pending_; |
152 using RenderWidgetHostImpl::input_router_; | 152 using RenderWidgetHostImpl::input_router_; |
153 | 153 |
154 virtual void OnTouchEventAck( | 154 virtual void OnTouchEventAck( |
155 const TouchEventWithLatencyInfo& event, | 155 const TouchEventWithLatencyInfo& event, |
156 InputEventAckState ack_result) OVERRIDE { | 156 InputEventAckState ack_result) override { |
157 // Sniff touch acks. | 157 // Sniff touch acks. |
158 acked_touch_event_type_ = event.event.type; | 158 acked_touch_event_type_ = event.event.type; |
159 RenderWidgetHostImpl::OnTouchEventAck(event, ack_result); | 159 RenderWidgetHostImpl::OnTouchEventAck(event, ack_result); |
160 } | 160 } |
161 | 161 |
162 bool unresponsive_timer_fired() const { | 162 bool unresponsive_timer_fired() const { |
163 return unresponsive_timer_fired_; | 163 return unresponsive_timer_fired_; |
164 } | 164 } |
165 | 165 |
166 void set_hung_renderer_delay_ms(int delay_ms) { | 166 void set_hung_renderer_delay_ms(int delay_ms) { |
(...skipping 11 matching lines...) Expand all Loading... |
178 | 178 |
179 void SetupForInputRouterTest() { | 179 void SetupForInputRouterTest() { |
180 input_router_.reset(new MockInputRouter(this)); | 180 input_router_.reset(new MockInputRouter(this)); |
181 } | 181 } |
182 | 182 |
183 MockInputRouter* mock_input_router() { | 183 MockInputRouter* mock_input_router() { |
184 return static_cast<MockInputRouter*>(input_router_.get()); | 184 return static_cast<MockInputRouter*>(input_router_.get()); |
185 } | 185 } |
186 | 186 |
187 protected: | 187 protected: |
188 virtual void NotifyRendererUnresponsive() OVERRIDE { | 188 virtual void NotifyRendererUnresponsive() override { |
189 unresponsive_timer_fired_ = true; | 189 unresponsive_timer_fired_ = true; |
190 } | 190 } |
191 | 191 |
192 bool unresponsive_timer_fired_; | 192 bool unresponsive_timer_fired_; |
193 WebInputEvent::Type acked_touch_event_type_; | 193 WebInputEvent::Type acked_touch_event_type_; |
194 | 194 |
195 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHost); | 195 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHost); |
196 }; | 196 }; |
197 | 197 |
198 namespace { | 198 namespace { |
199 | 199 |
200 // RenderWidgetHostProcess ----------------------------------------------------- | 200 // RenderWidgetHostProcess ----------------------------------------------------- |
201 | 201 |
202 class RenderWidgetHostProcess : public MockRenderProcessHost { | 202 class RenderWidgetHostProcess : public MockRenderProcessHost { |
203 public: | 203 public: |
204 explicit RenderWidgetHostProcess(BrowserContext* browser_context) | 204 explicit RenderWidgetHostProcess(BrowserContext* browser_context) |
205 : MockRenderProcessHost(browser_context), | 205 : MockRenderProcessHost(browser_context), |
206 update_msg_reply_flags_(0) { | 206 update_msg_reply_flags_(0) { |
207 } | 207 } |
208 virtual ~RenderWidgetHostProcess() { | 208 virtual ~RenderWidgetHostProcess() { |
209 } | 209 } |
210 | 210 |
211 void set_update_msg_reply_flags(int flags) { | 211 void set_update_msg_reply_flags(int flags) { |
212 update_msg_reply_flags_ = flags; | 212 update_msg_reply_flags_ = flags; |
213 } | 213 } |
214 | 214 |
215 // Fills the given update parameters with resonable default values. | 215 // Fills the given update parameters with resonable default values. |
216 void InitUpdateRectParams(ViewHostMsg_UpdateRect_Params* params); | 216 void InitUpdateRectParams(ViewHostMsg_UpdateRect_Params* params); |
217 | 217 |
218 virtual bool HasConnection() const OVERRIDE { return true; } | 218 virtual bool HasConnection() const override { return true; } |
219 | 219 |
220 protected: | 220 protected: |
221 // Indicates the flags that should be sent with a repaint request. This | 221 // Indicates the flags that should be sent with a repaint request. This |
222 // only has an effect when update_msg_should_reply_ is true. | 222 // only has an effect when update_msg_should_reply_ is true. |
223 int update_msg_reply_flags_; | 223 int update_msg_reply_flags_; |
224 | 224 |
225 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostProcess); | 225 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostProcess); |
226 }; | 226 }; |
227 | 227 |
228 void RenderWidgetHostProcess::InitUpdateRectParams( | 228 void RenderWidgetHostProcess::InitUpdateRectParams( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 271 |
272 void SetMockPhysicalBackingSize(const gfx::Size& mock_physical_backing_size) { | 272 void SetMockPhysicalBackingSize(const gfx::Size& mock_physical_backing_size) { |
273 use_fake_physical_backing_size_ = true; | 273 use_fake_physical_backing_size_ = true; |
274 mock_physical_backing_size_ = mock_physical_backing_size; | 274 mock_physical_backing_size_ = mock_physical_backing_size; |
275 } | 275 } |
276 void ClearMockPhysicalBackingSize() { | 276 void ClearMockPhysicalBackingSize() { |
277 use_fake_physical_backing_size_ = false; | 277 use_fake_physical_backing_size_ = false; |
278 } | 278 } |
279 | 279 |
280 // RenderWidgetHostView override. | 280 // RenderWidgetHostView override. |
281 virtual gfx::Rect GetViewBounds() const OVERRIDE { | 281 virtual gfx::Rect GetViewBounds() const override { |
282 return bounds_; | 282 return bounds_; |
283 } | 283 } |
284 virtual void ProcessAckedTouchEvent(const TouchEventWithLatencyInfo& touch, | 284 virtual void ProcessAckedTouchEvent(const TouchEventWithLatencyInfo& touch, |
285 InputEventAckState ack_result) OVERRIDE { | 285 InputEventAckState ack_result) override { |
286 acked_event_ = touch.event; | 286 acked_event_ = touch.event; |
287 ++acked_event_count_; | 287 ++acked_event_count_; |
288 } | 288 } |
289 virtual void WheelEventAck(const WebMouseWheelEvent& event, | 289 virtual void WheelEventAck(const WebMouseWheelEvent& event, |
290 InputEventAckState ack_result) OVERRIDE { | 290 InputEventAckState ack_result) override { |
291 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) | 291 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) |
292 return; | 292 return; |
293 unhandled_wheel_event_count_++; | 293 unhandled_wheel_event_count_++; |
294 unhandled_wheel_event_ = event; | 294 unhandled_wheel_event_ = event; |
295 } | 295 } |
296 virtual void GestureEventAck(const WebGestureEvent& event, | 296 virtual void GestureEventAck(const WebGestureEvent& event, |
297 InputEventAckState ack_result) OVERRIDE { | 297 InputEventAckState ack_result) override { |
298 gesture_event_type_ = event.type; | 298 gesture_event_type_ = event.type; |
299 ack_result_ = ack_result; | 299 ack_result_ = ack_result; |
300 } | 300 } |
301 virtual gfx::Size GetPhysicalBackingSize() const OVERRIDE { | 301 virtual gfx::Size GetPhysicalBackingSize() const override { |
302 if (use_fake_physical_backing_size_) | 302 if (use_fake_physical_backing_size_) |
303 return mock_physical_backing_size_; | 303 return mock_physical_backing_size_; |
304 return TestRenderWidgetHostView::GetPhysicalBackingSize(); | 304 return TestRenderWidgetHostView::GetPhysicalBackingSize(); |
305 } | 305 } |
306 #if defined(USE_AURA) | 306 #if defined(USE_AURA) |
307 virtual ~TestView() { | 307 virtual ~TestView() { |
308 // Simulate the mouse exit event dispatched when an aura window is | 308 // Simulate the mouse exit event dispatched when an aura window is |
309 // destroyed. (MakeWebMouseEventFromAuraEvent translates ET_MOUSE_EXITED | 309 // destroyed. (MakeWebMouseEventFromAuraEvent translates ET_MOUSE_EXITED |
310 // into WebInputEvent::MouseMove.) | 310 // into WebInputEvent::MouseMove.) |
311 rwh_->input_router()->SendMouseEvent( | 311 rwh_->input_router()->SendMouseEvent( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 void set_handle_wheel_event(bool handle) { | 369 void set_handle_wheel_event(bool handle) { |
370 handle_wheel_event_ = handle; | 370 handle_wheel_event_ = handle; |
371 } | 371 } |
372 | 372 |
373 bool handle_wheel_event_called() { | 373 bool handle_wheel_event_called() { |
374 return handle_wheel_event_called_; | 374 return handle_wheel_event_called_; |
375 } | 375 } |
376 | 376 |
377 protected: | 377 protected: |
378 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 378 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
379 bool* is_keyboard_shortcut) OVERRIDE { | 379 bool* is_keyboard_shortcut) override { |
380 prehandle_keyboard_event_type_ = event.type; | 380 prehandle_keyboard_event_type_ = event.type; |
381 prehandle_keyboard_event_called_ = true; | 381 prehandle_keyboard_event_called_ = true; |
382 return prehandle_keyboard_event_; | 382 return prehandle_keyboard_event_; |
383 } | 383 } |
384 | 384 |
385 virtual void HandleKeyboardEvent( | 385 virtual void HandleKeyboardEvent( |
386 const NativeWebKeyboardEvent& event) OVERRIDE { | 386 const NativeWebKeyboardEvent& event) override { |
387 unhandled_keyboard_event_type_ = event.type; | 387 unhandled_keyboard_event_type_ = event.type; |
388 unhandled_keyboard_event_called_ = true; | 388 unhandled_keyboard_event_called_ = true; |
389 } | 389 } |
390 | 390 |
391 virtual bool HandleWheelEvent( | 391 virtual bool HandleWheelEvent( |
392 const blink::WebMouseWheelEvent& event) OVERRIDE { | 392 const blink::WebMouseWheelEvent& event) override { |
393 handle_wheel_event_called_ = true; | 393 handle_wheel_event_called_ = true; |
394 return handle_wheel_event_; | 394 return handle_wheel_event_; |
395 } | 395 } |
396 | 396 |
397 private: | 397 private: |
398 bool prehandle_keyboard_event_; | 398 bool prehandle_keyboard_event_; |
399 bool prehandle_keyboard_event_called_; | 399 bool prehandle_keyboard_event_called_; |
400 WebInputEvent::Type prehandle_keyboard_event_type_; | 400 WebInputEvent::Type prehandle_keyboard_event_type_; |
401 | 401 |
402 bool unhandled_keyboard_event_called_; | 402 bool unhandled_keyboard_event_called_; |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 | 1500 |
1501 ASSERT_TRUE(host_->is_hidden()); | 1501 ASSERT_TRUE(host_->is_hidden()); |
1502 host_->RendererExited(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); | 1502 host_->RendererExited(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
1503 ASSERT_FALSE(host_->is_hidden()); | 1503 ASSERT_FALSE(host_->is_hidden()); |
1504 | 1504 |
1505 // Make sure the input router is in a fresh state. | 1505 // Make sure the input router is in a fresh state. |
1506 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); | 1506 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); |
1507 } | 1507 } |
1508 | 1508 |
1509 } // namespace content | 1509 } // namespace content |
OLD | NEW |