| 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/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| (...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 result += " "; | 1104 result += " "; |
| 1105 result += WebInputEventTraits::GetName(event->type); | 1105 result += WebInputEventTraits::GetName(event->type); |
| 1106 } | 1106 } |
| 1107 process->sink().ClearMessages(); | 1107 process->sink().ClearMessages(); |
| 1108 return result; | 1108 return result; |
| 1109 } | 1109 } |
| 1110 | 1110 |
| 1111 TEST_F(RenderWidgetHostTest, TouchEmulator) { | 1111 TEST_F(RenderWidgetHostTest, TouchEmulator) { |
| 1112 simulated_event_time_delta_seconds_ = 0.1; | 1112 simulated_event_time_delta_seconds_ = 0.1; |
| 1113 // Immediately ack all touches instead of sending them to the renderer. | 1113 // Immediately ack all touches instead of sending them to the renderer. |
| 1114 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); | 1114 host_->OnMessageReceived(InputHostMsg_HasTouchEventHandlers(0, false)); |
| 1115 host_->SetTouchEventEmulationEnabled( | 1115 host_->SetTouchEventEmulationEnabled( |
| 1116 true, ui::GestureProviderConfigType::GENERIC_MOBILE); | 1116 true, ui::GestureProviderConfigType::GENERIC_MOBILE); |
| 1117 process_->sink().ClearMessages(); | 1117 process_->sink().ClearMessages(); |
| 1118 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); | 1118 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); |
| 1119 view_->Show(); | 1119 view_->Show(); |
| 1120 | 1120 |
| 1121 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 10, 0, false); | 1121 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 10, 0, false); |
| 1122 EXPECT_EQ(0U, process_->sink().message_count()); | 1122 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1123 | 1123 |
| 1124 // Mouse press becomes touch start which in turn becomes tap. | 1124 // Mouse press becomes touch start which in turn becomes tap. |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 host_->SetupForInputRouterTest(); | 1406 host_->SetupForInputRouterTest(); |
| 1407 | 1407 |
| 1408 host_->OnMessageReceived(InputHostMsg_SelectRange_ACK(0)); | 1408 host_->OnMessageReceived(InputHostMsg_SelectRange_ACK(0)); |
| 1409 | 1409 |
| 1410 EXPECT_TRUE(host_->mock_input_router()->message_received_); | 1410 EXPECT_TRUE(host_->mock_input_router()->message_received_); |
| 1411 } | 1411 } |
| 1412 | 1412 |
| 1413 TEST_F(RenderWidgetHostTest, InputRouterReceivesHasTouchEventHandlers) { | 1413 TEST_F(RenderWidgetHostTest, InputRouterReceivesHasTouchEventHandlers) { |
| 1414 host_->SetupForInputRouterTest(); | 1414 host_->SetupForInputRouterTest(); |
| 1415 | 1415 |
| 1416 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 1416 host_->OnMessageReceived(InputHostMsg_HasTouchEventHandlers(0, true)); |
| 1417 | 1417 |
| 1418 EXPECT_TRUE(host_->mock_input_router()->message_received_); | 1418 EXPECT_TRUE(host_->mock_input_router()->message_received_); |
| 1419 } | 1419 } |
| 1420 | 1420 |
| 1421 ui::LatencyInfo GetLatencyInfoFromInputEvent(RenderWidgetHostProcess* process) { | 1421 ui::LatencyInfo GetLatencyInfoFromInputEvent(RenderWidgetHostProcess* process) { |
| 1422 const IPC::Message* message = process->sink().GetUniqueMessageMatching( | 1422 const IPC::Message* message = process->sink().GetUniqueMessageMatching( |
| 1423 InputMsg_HandleInputEvent::ID); | 1423 InputMsg_HandleInputEvent::ID); |
| 1424 EXPECT_TRUE(message); | 1424 EXPECT_TRUE(message); |
| 1425 InputMsg_HandleInputEvent::Param params; | 1425 InputMsg_HandleInputEvent::Param params; |
| 1426 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, ¶ms)); | 1426 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, ¶ms)); |
| 1427 process->sink().ClearMessages(); | 1427 process->sink().ClearMessages(); |
| 1428 return base::get<1>(params); | 1428 return base::get<1>(params); |
| 1429 } | 1429 } |
| 1430 | 1430 |
| 1431 void CheckLatencyInfoComponentInMessage(RenderWidgetHostProcess* process, | 1431 void CheckLatencyInfoComponentInMessage(RenderWidgetHostProcess* process, |
| 1432 int64 component_id, | 1432 int64 component_id, |
| 1433 WebInputEvent::Type input_type) { | 1433 WebInputEvent::Type input_type) { |
| 1434 ui::LatencyInfo latency_info = GetLatencyInfoFromInputEvent(process); | 1434 ui::LatencyInfo latency_info = GetLatencyInfoFromInputEvent(process); |
| 1435 EXPECT_TRUE(latency_info.FindLatency( | 1435 EXPECT_TRUE(latency_info.FindLatency( |
| 1436 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 1436 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| 1437 component_id, | 1437 component_id, |
| 1438 NULL)); | 1438 NULL)); |
| 1439 } | 1439 } |
| 1440 | 1440 |
| 1441 // Tests that after input event passes through RWHI through ForwardXXXEvent() | 1441 // Tests that after input event passes through RWHI through ForwardXXXEvent() |
| 1442 // or ForwardXXXEventWithLatencyInfo(), LatencyInfo component | 1442 // or ForwardXXXEventWithLatencyInfo(), LatencyInfo component |
| 1443 // ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT will always present in the | 1443 // ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT will always present in the |
| 1444 // event's LatencyInfo. | 1444 // event's LatencyInfo. |
| 1445 TEST_F(RenderWidgetHostTest, InputEventRWHLatencyComponent) { | 1445 TEST_F(RenderWidgetHostTest, InputEventRWHLatencyComponent) { |
| 1446 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 1446 host_->OnMessageReceived(InputHostMsg_HasTouchEventHandlers(0, true)); |
| 1447 process_->sink().ClearMessages(); | 1447 process_->sink().ClearMessages(); |
| 1448 | 1448 |
| 1449 // Tests RWHI::ForwardWheelEvent(). | 1449 // Tests RWHI::ForwardWheelEvent(). |
| 1450 SimulateWheelEvent(-5, 0, 0, true); | 1450 SimulateWheelEvent(-5, 0, 0, true); |
| 1451 CheckLatencyInfoComponentInMessage( | 1451 CheckLatencyInfoComponentInMessage( |
| 1452 process_, GetLatencyComponentId(), WebInputEvent::MouseWheel); | 1452 process_, GetLatencyComponentId(), WebInputEvent::MouseWheel); |
| 1453 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); | 1453 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1454 | 1454 |
| 1455 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). | 1455 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). |
| 1456 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); | 1456 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1548 // Having an initial size set means that the size information had been sent | 1548 // Having an initial size set means that the size information had been sent |
| 1549 // with the reqiest to new up the RenderView and so subsequent WasResized | 1549 // with the reqiest to new up the RenderView and so subsequent WasResized |
| 1550 // calls should not result in new IPC (unless the size has actually changed). | 1550 // calls should not result in new IPC (unless the size has actually changed). |
| 1551 host_->WasResized(); | 1551 host_->WasResized(); |
| 1552 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); | 1552 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); |
| 1553 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size); | 1553 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size); |
| 1554 EXPECT_TRUE(host_->resize_ack_pending_); | 1554 EXPECT_TRUE(host_->resize_ack_pending_); |
| 1555 } | 1555 } |
| 1556 | 1556 |
| 1557 } // namespace content | 1557 } // namespace content |
| OLD | NEW |