| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 111 |
| 111 // IPC::Listener | 112 // IPC::Listener |
| 112 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { | 113 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { |
| 113 message_received_ = true; | 114 message_received_ = true; |
| 114 return false; | 115 return false; |
| 115 } | 116 } |
| 116 | 117 |
| 117 bool flush_called_; | 118 bool flush_called_; |
| 118 bool send_event_called_; | 119 bool send_event_called_; |
| 119 bool sent_mouse_event_; | 120 bool sent_mouse_event_; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 virtual void GestureEventAck(const WebGestureEvent& event, | 296 virtual void GestureEventAck(const WebGestureEvent& event, |
| 296 InputEventAckState ack_result) OVERRIDE { | 297 InputEventAckState ack_result) OVERRIDE { |
| 297 gesture_event_type_ = event.type; | 298 gesture_event_type_ = event.type; |
| 298 ack_result_ = ack_result; | 299 ack_result_ = ack_result; |
| 299 } | 300 } |
| 300 virtual gfx::Size GetPhysicalBackingSize() const OVERRIDE { | 301 virtual gfx::Size GetPhysicalBackingSize() const OVERRIDE { |
| 301 if (use_fake_physical_backing_size_) | 302 if (use_fake_physical_backing_size_) |
| 302 return mock_physical_backing_size_; | 303 return mock_physical_backing_size_; |
| 303 return TestRenderWidgetHostView::GetPhysicalBackingSize(); | 304 return TestRenderWidgetHostView::GetPhysicalBackingSize(); |
| 304 } | 305 } |
| 306 #if defined(USE_AURA) |
| 307 virtual ~TestView() { |
| 308 // Simulate the mouse exit event dispatched when an aura window is |
| 309 // destroyed. (MakeWebMouseEventFromAuraEvent translates ET_MOUSE_EXITED |
| 310 // into WebInputEvent::MouseMove.) |
| 311 rwh_->input_router()->SendMouseEvent( |
| 312 MouseEventWithLatencyInfo( |
| 313 SyntheticWebMouseEventBuilder::Build(WebInputEvent::MouseMove), |
| 314 ui::LatencyInfo())); |
| 315 } |
| 316 #endif |
| 305 | 317 |
| 306 protected: | 318 protected: |
| 307 WebMouseWheelEvent unhandled_wheel_event_; | 319 WebMouseWheelEvent unhandled_wheel_event_; |
| 308 int unhandled_wheel_event_count_; | 320 int unhandled_wheel_event_count_; |
| 309 WebTouchEvent acked_event_; | 321 WebTouchEvent acked_event_; |
| 310 int acked_event_count_; | 322 int acked_event_count_; |
| 311 int gesture_event_type_; | 323 int gesture_event_type_; |
| 312 gfx::Rect bounds_; | 324 gfx::Rect bounds_; |
| 313 bool use_fake_physical_backing_size_; | 325 bool use_fake_physical_backing_size_; |
| 314 gfx::Size mock_physical_backing_size_; | 326 gfx::Size mock_physical_backing_size_; |
| (...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 INPUT_EVENT_ACK_STATE_CONSUMED); | 1404 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1393 | 1405 |
| 1394 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). | 1406 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). |
| 1395 PressTouchPoint(0, 1); | 1407 PressTouchPoint(0, 1); |
| 1396 SendTouchEvent(); | 1408 SendTouchEvent(); |
| 1397 CheckLatencyInfoComponentInMessage( | 1409 CheckLatencyInfoComponentInMessage( |
| 1398 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); | 1410 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); |
| 1399 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); | 1411 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1400 } | 1412 } |
| 1401 | 1413 |
| 1414 TEST_F(RenderWidgetHostTest, RendererExitedResetsInputRouter) { |
| 1415 // RendererExited will delete the view. |
| 1416 host_->SetView(new TestView(host_.get())); |
| 1417 host_->RendererExited(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
| 1418 |
| 1419 // Make sure the input router is in a fresh state. |
| 1420 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); |
| 1421 } |
| 1422 |
| 1402 } // namespace content | 1423 } // namespace content |
| OLD | NEW |