| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1516 } | 1516 } |
| 1517 | 1517 |
| 1518 TEST_F(RenderWidgetHostTest, InputRouterReceivesHasTouchEventHandlers) { | 1518 TEST_F(RenderWidgetHostTest, InputRouterReceivesHasTouchEventHandlers) { |
| 1519 host_->SetupForInputRouterTest(); | 1519 host_->SetupForInputRouterTest(); |
| 1520 | 1520 |
| 1521 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 1521 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
| 1522 | 1522 |
| 1523 EXPECT_TRUE(host_->mock_input_router()->message_received_); | 1523 EXPECT_TRUE(host_->mock_input_router()->message_received_); |
| 1524 } | 1524 } |
| 1525 | 1525 |
| 1526 ui::LatencyInfo GetLatencyInfoFromInputEvent(RenderWidgetHostProcess* process) { | |
| 1527 const IPC::Message* message = process->sink().GetUniqueMessageMatching( | |
| 1528 InputMsg_HandleInputEvent::ID); | |
| 1529 EXPECT_TRUE(message); | |
| 1530 InputMsg_HandleInputEvent::Param params; | |
| 1531 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, ¶ms)); | |
| 1532 process->sink().ClearMessages(); | |
| 1533 return base::get<1>(params); | |
| 1534 } | |
| 1535 | |
| 1536 void CheckLatencyInfoComponentInMessage(RenderWidgetHostProcess* process, | 1526 void CheckLatencyInfoComponentInMessage(RenderWidgetHostProcess* process, |
| 1537 int64_t component_id, | 1527 int64_t component_id, |
| 1538 WebInputEvent::Type input_type) { | 1528 WebInputEvent::Type expected_type) { |
| 1539 ui::LatencyInfo latency_info = GetLatencyInfoFromInputEvent(process); | 1529 EXPECT_EQ(process->sink().message_count(), 1U); |
| 1530 |
| 1531 const IPC::Message* message = process->sink().GetMessageAt(0); |
| 1532 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); |
| 1533 InputMsg_HandleInputEvent::Param params; |
| 1534 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, ¶ms)); |
| 1535 |
| 1536 const WebInputEvent* event = base::get<0>(params); |
| 1537 ui::LatencyInfo latency_info = base::get<1>(params); |
| 1538 |
| 1539 EXPECT_TRUE(event->type == expected_type); |
| 1540 EXPECT_TRUE(latency_info.FindLatency( | 1540 EXPECT_TRUE(latency_info.FindLatency( |
| 1541 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 1541 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, component_id, NULL)); |
| 1542 component_id, | 1542 |
| 1543 NULL)); | 1543 process->sink().ClearMessages(); |
| 1544 } | 1544 } |
| 1545 | 1545 |
| 1546 // Tests that after input event passes through RWHI through ForwardXXXEvent() | 1546 // Tests that after input event passes through RWHI through ForwardXXXEvent() |
| 1547 // or ForwardXXXEventWithLatencyInfo(), LatencyInfo component | 1547 // or ForwardXXXEventWithLatencyInfo(), LatencyInfo component |
| 1548 // ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT will always present in the | 1548 // ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT will always present in the |
| 1549 // event's LatencyInfo. | 1549 // event's LatencyInfo. |
| 1550 TEST_F(RenderWidgetHostTest, InputEventRWHLatencyComponent) { | 1550 TEST_F(RenderWidgetHostTest, InputEventRWHLatencyComponent) { |
| 1551 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 1551 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
| 1552 process_->sink().ClearMessages(); | 1552 process_->sink().ClearMessages(); |
| 1553 | 1553 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1673 ui::LatencyInfo()); | 1673 ui::LatencyInfo()); |
| 1674 | 1674 |
| 1675 | 1675 |
| 1676 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). | 1676 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). |
| 1677 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); | 1677 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); |
| 1678 | 1678 |
| 1679 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); | 1679 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); |
| 1680 } | 1680 } |
| 1681 | 1681 |
| 1682 } // namespace content | 1682 } // namespace content |
| OLD | NEW |