| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 | 6 |
| 7 #include <new> | 7 #include <new> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 queue_ = new MainThreadEventQueue(kTestRoutingID, this, main_task_runner_, | 68 queue_ = new MainThreadEventQueue(kTestRoutingID, this, main_task_runner_, |
| 69 &renderer_scheduler_); | 69 &renderer_scheduler_); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void HandleEventOnMainThread(int routing_id, | 72 void HandleEventOnMainThread(int routing_id, |
| 73 const blink::WebInputEvent* event, | 73 const blink::WebInputEvent* event, |
| 74 const ui::LatencyInfo& latency, | 74 const ui::LatencyInfo& latency, |
| 75 InputEventDispatchType type) override { | 75 InputEventDispatchType type) override { |
| 76 EXPECT_EQ(kTestRoutingID, routing_id); | 76 EXPECT_EQ(kTestRoutingID, routing_id); |
| 77 handled_events_.push_back(ui::WebInputEventTraits::Clone(*event)); | 77 handled_events_.push_back(ui::WebInputEventTraits::Clone(*event)); |
| 78 queue_->EventHandled(event->type(), INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 78 queue_->EventHandled(event->type(), |
| 79 blink::WebInputEventResult::HandledApplication, |
| 80 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 79 } | 81 } |
| 80 | 82 |
| 81 void SendInputEventAck(int routing_id, | 83 void SendInputEventAck(int routing_id, |
| 82 blink::WebInputEvent::Type type, | 84 blink::WebInputEvent::Type type, |
| 83 InputEventAckState ack_result, | 85 InputEventAckState ack_result, |
| 84 uint32_t touch_event_id) override { | 86 uint32_t touch_event_id) override { |
| 85 additional_acked_events_.push_back(touch_event_id); | 87 additional_acked_events_.push_back(touch_event_id); |
| 86 } | 88 } |
| 87 | 89 |
| 88 bool HandleEvent(WebInputEvent& event, InputEventAckState ack_result) { | 90 bool HandleEvent(WebInputEvent& event, InputEventAckState ack_result) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 base::HistogramTester histogram_tester; | 239 base::HistogramTester histogram_tester; |
| 238 SyntheticWebTouchEvent kEvents[4]; | 240 SyntheticWebTouchEvent kEvents[4]; |
| 239 kEvents[0].PressPoint(10, 10); | 241 kEvents[0].PressPoint(10, 10); |
| 240 kEvents[1].PressPoint(10, 10); | 242 kEvents[1].PressPoint(10, 10); |
| 241 kEvents[1].MovePoint(0, 20, 20); | 243 kEvents[1].MovePoint(0, 20, 20); |
| 242 kEvents[2].PressPoint(10, 10); | 244 kEvents[2].PressPoint(10, 10); |
| 243 kEvents[2].MovePoint(0, 30, 30); | 245 kEvents[2].MovePoint(0, 30, 30); |
| 244 kEvents[3].PressPoint(10, 10); | 246 kEvents[3].PressPoint(10, 10); |
| 245 kEvents[3].MovePoint(0, 35, 35); | 247 kEvents[3].MovePoint(0, 35, 35); |
| 246 | 248 |
| 247 EXPECT_CALL(renderer_scheduler_, DidHandleInputEventOnMainThread(testing::_)) | 249 EXPECT_CALL(renderer_scheduler_, |
| 250 DidHandleInputEventOnMainThread(testing::_, testing::_)) |
| 248 .Times(2); | 251 .Times(2); |
| 249 // Ensure that coalescing takes place. | 252 // Ensure that coalescing takes place. |
| 250 HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); | 253 HandleEvent(kEvents[0], INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING); |
| 251 HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 254 HandleEvent(kEvents[1], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 252 HandleEvent(kEvents[2], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 255 HandleEvent(kEvents[2], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 253 HandleEvent(kEvents[3], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 256 HandleEvent(kEvents[3], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 254 | 257 |
| 255 EXPECT_EQ(2u, event_queue().size()); | 258 EXPECT_EQ(2u, event_queue().size()); |
| 256 EXPECT_TRUE(main_task_runner_->HasPendingTask()); | 259 EXPECT_TRUE(main_task_runner_->HasPendingTask()); |
| 257 RunPendingTasksWithSimulatedRaf(); | 260 RunPendingTasksWithSimulatedRaf(); |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 | 623 |
| 621 // The boolean parameterized test varies whether rAF aligned input | 624 // The boolean parameterized test varies whether rAF aligned input |
| 622 // is enabled or not. | 625 // is enabled or not. |
| 623 INSTANTIATE_TEST_CASE_P( | 626 INSTANTIATE_TEST_CASE_P( |
| 624 MainThreadEventQueueTests, | 627 MainThreadEventQueueTests, |
| 625 MainThreadEventQueueTest, | 628 MainThreadEventQueueTest, |
| 626 testing::Range(0u, | 629 testing::Range(0u, |
| 627 (kRafAlignedEnabledTouch | kRafAlignedEnabledMouse) + 1)); | 630 (kRafAlignedEnabledTouch | kRafAlignedEnabledMouse) + 1)); |
| 628 | 631 |
| 629 } // namespace content | 632 } // namespace content |
| OLD | NEW |