| 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 "content/browser/renderer_host/input/mouse_wheel_event_queue.h" | 5 #include "content/browser/renderer_host/input/mouse_wheel_event_queue.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "content/browser/renderer_host/input/timeout_monitor.h" | 17 #include "content/browser/renderer_host/input/timeout_monitor.h" |
| 18 #include "content/common/input/synthetic_web_input_event_builders.h" | 18 #include "content/common/input/synthetic_web_input_event_builders.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 20 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 21 #include "ui/events/base_event_utils.h" |
| 21 | 22 |
| 22 using blink::WebGestureEvent; | 23 using blink::WebGestureEvent; |
| 23 using blink::WebInputEvent; | 24 using blink::WebInputEvent; |
| 24 using blink::WebMouseWheelEvent; | 25 using blink::WebMouseWheelEvent; |
| 25 | 26 |
| 26 namespace content { | 27 namespace content { |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 const float kWheelScrollX = 10; | 30 const float kWheelScrollX = 10; |
| 30 const float kWheelScrollY = 12; | 31 const float kWheelScrollY = 12; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 blink::WebMouseWheelEvent::Phase phase, | 252 blink::WebMouseWheelEvent::Phase phase, |
| 252 blink::WebMouseWheelEvent::Phase momentum_phase) { | 253 blink::WebMouseWheelEvent::Phase momentum_phase) { |
| 253 WebMouseWheelEvent event = SyntheticWebMouseWheelEventBuilder::Build( | 254 WebMouseWheelEvent event = SyntheticWebMouseWheelEventBuilder::Build( |
| 254 x, y, global_x, global_y, dX, dY, modifiers, high_precision); | 255 x, y, global_x, global_y, dX, dY, modifiers, high_precision); |
| 255 event.phase = phase; | 256 event.phase = phase; |
| 256 event.momentumPhase = momentum_phase; | 257 event.momentumPhase = momentum_phase; |
| 257 queue_->QueueEvent(MouseWheelEventWithLatencyInfo(event)); | 258 queue_->QueueEvent(MouseWheelEventWithLatencyInfo(event)); |
| 258 } | 259 } |
| 259 | 260 |
| 260 void SendGestureEvent(WebInputEvent::Type type) { | 261 void SendGestureEvent(WebInputEvent::Type type) { |
| 261 WebGestureEvent event; | 262 WebGestureEvent event(type, WebInputEvent::NoModifiers, |
| 262 event.type = type; | 263 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
| 263 event.sourceDevice = blink::WebGestureDeviceTouchscreen; | 264 event.sourceDevice = blink::WebGestureDeviceTouchscreen; |
| 264 queue_->OnGestureScrollEvent( | 265 queue_->OnGestureScrollEvent( |
| 265 GestureEventWithLatencyInfo(event, ui::LatencyInfo())); | 266 GestureEventWithLatencyInfo(event, ui::LatencyInfo())); |
| 266 } | 267 } |
| 267 | 268 |
| 268 static void RunTasksAndWait(base::TimeDelta delay) { | 269 static void RunTasksAndWait(base::TimeDelta delay) { |
| 269 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 270 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 270 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), delay); | 271 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), delay); |
| 271 base::RunLoop().Run(); | 272 base::RunLoop().Run(); |
| 272 } | 273 } |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 EXPECT_EQ(1U, sent_gesture_event(updateEventIndex)->data.scrollUpdate.deltaY); | 664 EXPECT_EQ(1U, sent_gesture_event(updateEventIndex)->data.scrollUpdate.deltaY); |
| 664 EXPECT_EQ(static_cast<size_t>(updateEventIndex + 1), | 665 EXPECT_EQ(static_cast<size_t>(updateEventIndex + 1), |
| 665 GetAndResetSentEventCount()); | 666 GetAndResetSentEventCount()); |
| 666 } | 667 } |
| 667 | 668 |
| 668 INSTANTIATE_TEST_CASE_P(MouseWheelEventQueueTests, | 669 INSTANTIATE_TEST_CASE_P(MouseWheelEventQueueTests, |
| 669 MouseWheelEventQueueTest, | 670 MouseWheelEventQueueTest, |
| 670 testing::Bool()); | 671 testing::Bool()); |
| 671 | 672 |
| 672 } // namespace content | 673 } // namespace content |
| OLD | NEW |