OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/input_router_impl.h" | 5 #include "content/browser/renderer_host/input/input_router_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <tuple> | 12 #include <tuple> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
19 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
20 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
22 #include "base/test/scoped_feature_list.h" | 22 #include "base/test/scoped_feature_list.h" |
| 23 #include "base/test/scoped_task_environment.h" |
23 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
24 #include "build/build_config.h" | 25 #include "build/build_config.h" |
25 #include "content/browser/renderer_host/input/gesture_event_queue.h" | 26 #include "content/browser/renderer_host/input/gesture_event_queue.h" |
26 #include "content/browser/renderer_host/input/input_router_client.h" | 27 #include "content/browser/renderer_host/input/input_router_client.h" |
27 #include "content/browser/renderer_host/input/mock_input_ack_handler.h" | 28 #include "content/browser/renderer_host/input/mock_input_ack_handler.h" |
28 #include "content/browser/renderer_host/input/mock_input_router_client.h" | 29 #include "content/browser/renderer_host/input/mock_input_router_client.h" |
29 #include "content/common/content_constants_internal.h" | 30 #include "content/common/content_constants_internal.h" |
30 #include "content/common/edit_command.h" | 31 #include "content/common/edit_command.h" |
31 #include "content/common/input/synthetic_web_input_event_builders.h" | 32 #include "content/common/input/synthetic_web_input_event_builders.h" |
32 #include "content/common/input/touch_action.h" | 33 #include "content/common/input/touch_action.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 146 |
146 return true; | 147 return true; |
147 } | 148 } |
148 #endif // defined(USE_AURA) | 149 #endif // defined(USE_AURA) |
149 | 150 |
150 } // namespace | 151 } // namespace |
151 | 152 |
152 class InputRouterImplTest : public testing::Test { | 153 class InputRouterImplTest : public testing::Test { |
153 public: | 154 public: |
154 InputRouterImplTest(bool raf_aligned_touch = true, | 155 InputRouterImplTest(bool raf_aligned_touch = true, |
155 bool wheel_scroll_latching = true) { | 156 bool wheel_scroll_latching = true) |
| 157 : scoped_task_environment_( |
| 158 base::test::ScopedTaskEnvironment::MainThreadType::UI) { |
156 if (raf_aligned_touch && wheel_scroll_latching) { | 159 if (raf_aligned_touch && wheel_scroll_latching) { |
157 feature_list_.InitWithFeatures( | 160 feature_list_.InitWithFeatures( |
158 {features::kRafAlignedTouchInputEvents, | 161 {features::kRafAlignedTouchInputEvents, |
159 features::kTouchpadAndWheelScrollLatching}, | 162 features::kTouchpadAndWheelScrollLatching}, |
160 {}); | 163 {}); |
161 } else if (raf_aligned_touch && !wheel_scroll_latching) { | 164 } else if (raf_aligned_touch && !wheel_scroll_latching) { |
162 feature_list_.InitWithFeatures( | 165 feature_list_.InitWithFeatures( |
163 {features::kRafAlignedTouchInputEvents}, | 166 {features::kRafAlignedTouchInputEvents}, |
164 {features::kTouchpadAndWheelScrollLatching}); | 167 {features::kTouchpadAndWheelScrollLatching}); |
165 } else if (!raf_aligned_touch && wheel_scroll_latching) { | 168 } else if (!raf_aligned_touch && wheel_scroll_latching) { |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 } | 456 } |
454 } | 457 } |
455 | 458 |
456 InputRouterImpl::Config config_; | 459 InputRouterImpl::Config config_; |
457 std::unique_ptr<MockRenderProcessHost> process_; | 460 std::unique_ptr<MockRenderProcessHost> process_; |
458 std::unique_ptr<MockInputRouterClient> client_; | 461 std::unique_ptr<MockInputRouterClient> client_; |
459 std::unique_ptr<MockInputAckHandler> ack_handler_; | 462 std::unique_ptr<MockInputAckHandler> ack_handler_; |
460 std::unique_ptr<InputRouterImpl> input_router_; | 463 std::unique_ptr<InputRouterImpl> input_router_; |
461 | 464 |
462 private: | 465 private: |
463 base::MessageLoopForUI message_loop_; | 466 base::test::ScopedTaskEnvironment scoped_task_environment_; |
464 SyntheticWebTouchEvent touch_event_; | 467 SyntheticWebTouchEvent touch_event_; |
465 | 468 |
466 base::test::ScopedFeatureList feature_list_; | 469 base::test::ScopedFeatureList feature_list_; |
467 std::unique_ptr<TestBrowserContext> browser_context_; | 470 std::unique_ptr<TestBrowserContext> browser_context_; |
468 }; | 471 }; |
469 | 472 |
470 class InputRouterImplRafAlignedTouchDisabledTest : public InputRouterImplTest { | 473 class InputRouterImplRafAlignedTouchDisabledTest : public InputRouterImplTest { |
471 public: | 474 public: |
472 InputRouterImplRafAlignedTouchDisabledTest() | 475 InputRouterImplRafAlignedTouchDisabledTest() |
473 : InputRouterImplTest(false, false) {} | 476 : InputRouterImplTest(false, false) {} |
(...skipping 2023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2497 EXPECT_EQ(80, sent_event->data.fling_start.velocity_y); | 2500 EXPECT_EQ(80, sent_event->data.fling_start.velocity_y); |
2498 | 2501 |
2499 const WebGestureEvent* filter_event = | 2502 const WebGestureEvent* filter_event = |
2500 GetFilterWebInputEvent<WebGestureEvent>(); | 2503 GetFilterWebInputEvent<WebGestureEvent>(); |
2501 TestLocationInFilterEvent(filter_event, orig); | 2504 TestLocationInFilterEvent(filter_event, orig); |
2502 EXPECT_EQ(30, filter_event->data.fling_start.velocity_x); | 2505 EXPECT_EQ(30, filter_event->data.fling_start.velocity_x); |
2503 EXPECT_EQ(40, filter_event->data.fling_start.velocity_y); | 2506 EXPECT_EQ(40, filter_event->data.fling_start.velocity_y); |
2504 } | 2507 } |
2505 | 2508 |
2506 } // namespace content | 2509 } // namespace content |
OLD | NEW |