| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 : main_task_runner_(new base::TestSimpleTaskRunner()), | 43 : main_task_runner_(new base::TestSimpleTaskRunner()), |
| 44 queue_( | 44 queue_( |
| 45 new MainThreadEventQueue(kTestRoutingID, this, main_task_runner_)) { | 45 new MainThreadEventQueue(kTestRoutingID, this, main_task_runner_)) { |
| 46 } | 46 } |
| 47 | 47 |
| 48 void HandleEventOnMainThread(int routing_id, | 48 void HandleEventOnMainThread(int routing_id, |
| 49 const blink::WebInputEvent* event, | 49 const blink::WebInputEvent* event, |
| 50 const ui::LatencyInfo& latency, | 50 const ui::LatencyInfo& latency, |
| 51 InputEventDispatchType type) override { | 51 InputEventDispatchType type) override { |
| 52 EXPECT_EQ(kTestRoutingID, routing_id); | 52 EXPECT_EQ(kTestRoutingID, routing_id); |
| 53 handled_events_.push_back(WebInputEventTraits::Clone(*event)); | 53 handled_events_.push_back(ui::WebInputEventTraits::Clone(*event)); |
| 54 queue_->EventHandled(event->type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 54 queue_->EventHandled(event->type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void SendInputEventAck(int routing_id, | 57 void SendInputEventAck(int routing_id, |
| 58 blink::WebInputEvent::Type type, | 58 blink::WebInputEvent::Type type, |
| 59 InputEventAckState ack_result, | 59 InputEventAckState ack_result, |
| 60 uint32_t touch_event_id) override { | 60 uint32_t touch_event_id) override { |
| 61 additional_acked_events_.push_back(touch_event_id); | 61 additional_acked_events_.push_back(touch_event_id); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void HandleEvent(WebInputEvent& event, InputEventAckState ack_result) { | 64 void HandleEvent(WebInputEvent& event, InputEventAckState ack_result) { |
| 65 queue_->HandleEvent(WebInputEventTraits::Clone(event), ui::LatencyInfo(), | 65 queue_->HandleEvent(ui::WebInputEventTraits::Clone(event), |
| 66 DISPATCH_TYPE_BLOCKING, | 66 ui::LatencyInfo(), DISPATCH_TYPE_BLOCKING, ack_result); |
| 67 ack_result); | |
| 68 } | 67 } |
| 69 | 68 |
| 70 WebInputEventQueue<EventWithDispatchType>& event_queue() { | 69 WebInputEventQueue<EventWithDispatchType>& event_queue() { |
| 71 return queue_->events_; | 70 return queue_->events_; |
| 72 } | 71 } |
| 73 | 72 |
| 74 protected: | 73 protected: |
| 75 scoped_refptr<base::TestSimpleTaskRunner> main_task_runner_; | 74 scoped_refptr<base::TestSimpleTaskRunner> main_task_runner_; |
| 76 scoped_refptr<MainThreadEventQueue> queue_; | 75 scoped_refptr<MainThreadEventQueue> queue_; |
| 77 std::vector<ScopedWebInputEvent> handled_events_; | 76 std::vector<ui::ScopedWebInputEvent> handled_events_; |
| 78 std::vector<uint32_t> additional_acked_events_; | 77 std::vector<uint32_t> additional_acked_events_; |
| 79 }; | 78 }; |
| 80 | 79 |
| 81 TEST_F(MainThreadEventQueueTest, NonBlockingWheel) { | 80 TEST_F(MainThreadEventQueueTest, NonBlockingWheel) { |
| 82 WebMouseWheelEvent kEvents[4] = { | 81 WebMouseWheelEvent kEvents[4] = { |
| 83 SyntheticWebMouseWheelEventBuilder::Build(10, 10, 0, 53, 0, false), | 82 SyntheticWebMouseWheelEventBuilder::Build(10, 10, 0, 53, 0, false), |
| 84 SyntheticWebMouseWheelEventBuilder::Build(20, 20, 0, 53, 0, false), | 83 SyntheticWebMouseWheelEventBuilder::Build(20, 20, 0, 53, 0, false), |
| 85 SyntheticWebMouseWheelEventBuilder::Build(30, 30, 0, 53, 1, false), | 84 SyntheticWebMouseWheelEventBuilder::Build(30, 30, 0, 53, 1, false), |
| 86 SyntheticWebMouseWheelEventBuilder::Build(30, 30, 0, 53, 1, false), | 85 SyntheticWebMouseWheelEventBuilder::Build(30, 30, 0, 53, 1, false), |
| 87 }; | 86 }; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 static_cast<const WebTouchEvent*>(handled_events_.at(1).get()); | 240 static_cast<const WebTouchEvent*>(handled_events_.at(1).get()); |
| 242 WebTouchEvent coalesced_event = kTouchEvents[0]; | 241 WebTouchEvent coalesced_event = kTouchEvents[0]; |
| 243 internal::Coalesce(kTouchEvents[1], &coalesced_event); | 242 internal::Coalesce(kTouchEvents[1], &coalesced_event); |
| 244 coalesced_event.dispatchType = | 243 coalesced_event.dispatchType = |
| 245 WebInputEvent::DispatchType::ListenersNonBlockingPassive; | 244 WebInputEvent::DispatchType::ListenersNonBlockingPassive; |
| 246 EXPECT_EQ(coalesced_event, *last_touch_event); | 245 EXPECT_EQ(coalesced_event, *last_touch_event); |
| 247 } | 246 } |
| 248 } | 247 } |
| 249 | 248 |
| 250 } // namespace content | 249 } // namespace content |
| OLD | NEW |