Chromium Code Reviews| 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 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #include "content/common/content_constants_internal.h" | 26 #include "content/common/content_constants_internal.h" |
| 27 #include "content/common/edit_command.h" | 27 #include "content/common/edit_command.h" |
| 28 #include "content/common/input/synthetic_web_input_event_builders.h" | 28 #include "content/common/input/synthetic_web_input_event_builders.h" |
| 29 #include "content/common/input/touch_action.h" | 29 #include "content/common/input/touch_action.h" |
| 30 #include "content/common/input_messages.h" | 30 #include "content/common/input_messages.h" |
| 31 #include "content/common/view_messages.h" | 31 #include "content/common/view_messages.h" |
| 32 #include "content/public/common/content_switches.h" | 32 #include "content/public/common/content_switches.h" |
| 33 #include "content/public/test/mock_render_process_host.h" | 33 #include "content/public/test/mock_render_process_host.h" |
| 34 #include "content/public/test/test_browser_context.h" | 34 #include "content/public/test/test_browser_context.h" |
| 35 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
| 36 #include "ui/events/base_event_utils.h" | |
| 36 #include "ui/events/blink/web_input_event_traits.h" | 37 #include "ui/events/blink/web_input_event_traits.h" |
| 37 #include "ui/events/keycodes/keyboard_codes.h" | 38 #include "ui/events/keycodes/keyboard_codes.h" |
| 38 | 39 |
| 39 #if defined(USE_AURA) | 40 #if defined(USE_AURA) |
| 40 #include "content/browser/renderer_host/ui_events_helper.h" | 41 #include "content/browser/renderer_host/ui_events_helper.h" |
| 41 #include "ui/events/event.h" | 42 #include "ui/events/event.h" |
| 42 #endif | 43 #endif |
| 43 | 44 |
| 44 using blink::WebGestureDevice; | 45 using blink::WebGestureDevice; |
| 45 using blink::WebGestureEvent; | 46 using blink::WebGestureEvent; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 static WebKeyboardEvent key; | 78 static WebKeyboardEvent key; |
| 78 event = &key; | 79 event = &key; |
| 79 } else if (WebInputEvent::isGestureEventType(type)) { | 80 } else if (WebInputEvent::isGestureEventType(type)) { |
| 80 static WebGestureEvent gesture; | 81 static WebGestureEvent gesture; |
| 81 event = &gesture; | 82 event = &gesture; |
| 82 } else if (type == WebInputEvent::MouseWheel) { | 83 } else if (type == WebInputEvent::MouseWheel) { |
| 83 static WebMouseWheelEvent wheel; | 84 static WebMouseWheelEvent wheel; |
| 84 event = &wheel; | 85 event = &wheel; |
| 85 } | 86 } |
| 86 CHECK(event); | 87 CHECK(event); |
| 87 event->type = type; | 88 event->setType(type); |
| 88 return *event; | 89 return *event; |
| 89 } | 90 } |
| 90 | 91 |
| 91 template<typename MSG_T, typename ARG_T1> | 92 template<typename MSG_T, typename ARG_T1> |
| 92 void ExpectIPCMessageWithArg1(const IPC::Message* msg, const ARG_T1& arg1) { | 93 void ExpectIPCMessageWithArg1(const IPC::Message* msg, const ARG_T1& arg1) { |
| 93 ASSERT_EQ(MSG_T::ID, msg->type()); | 94 ASSERT_EQ(MSG_T::ID, msg->type()); |
| 94 typename MSG_T::Schema::Param param; | 95 typename MSG_T::Schema::Param param; |
| 95 ASSERT_TRUE(MSG_T::Read(msg, ¶m)); | 96 ASSERT_TRUE(MSG_T::Read(msg, ¶m)); |
| 96 EXPECT_EQ(arg1, std::get<0>(param)); | 97 EXPECT_EQ(arg1, std::get<0>(param)); |
| 97 } | 98 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 base::TimeDelta::FromMilliseconds(desktop_timeout_ms); | 179 base::TimeDelta::FromMilliseconds(desktop_timeout_ms); |
| 179 config_.touch_config.mobile_touch_ack_timeout_delay = | 180 config_.touch_config.mobile_touch_ack_timeout_delay = |
| 180 base::TimeDelta::FromMilliseconds(mobile_timeout_ms); | 181 base::TimeDelta::FromMilliseconds(mobile_timeout_ms); |
| 181 config_.touch_config.touch_ack_timeout_supported = true; | 182 config_.touch_config.touch_ack_timeout_supported = true; |
| 182 TearDown(); | 183 TearDown(); |
| 183 SetUp(); | 184 SetUp(); |
| 184 input_router()->NotifySiteIsMobileOptimized(false); | 185 input_router()->NotifySiteIsMobileOptimized(false); |
| 185 } | 186 } |
| 186 | 187 |
| 187 void SimulateKeyboardEvent(WebInputEvent::Type type) { | 188 void SimulateKeyboardEvent(WebInputEvent::Type type) { |
| 188 WebKeyboardEvent event = SyntheticWebKeyboardEventBuilder::Build(type); | 189 NativeWebKeyboardEventWithLatencyInfo key_event( |
| 189 NativeWebKeyboardEvent native_event; | 190 type, WebInputEvent::NoModifiers, |
| 190 memcpy(&native_event, &event, sizeof(event)); | 191 ui::EventTimeStampToSeconds(ui::EventTimeForNow()), ui::LatencyInfo()); |
|
majidvp
2016/12/19 20:09:52
Any idea why the original logic was doing rather c
dtapuska
2016/12/20 19:49:21
Because there wasn't a constructor on the NativeWe
| |
| 191 NativeWebKeyboardEventWithLatencyInfo key_event(native_event); | |
| 192 input_router_->SendKeyboardEvent(key_event); | 192 input_router_->SendKeyboardEvent(key_event); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void SimulateWheelEvent(float x, | 195 void SimulateWheelEvent(float x, |
| 196 float y, | 196 float y, |
| 197 float dX, | 197 float dX, |
| 198 float dY, | 198 float dY, |
| 199 int modifiers, | 199 int modifiers, |
| 200 bool precise) { | 200 bool precise) { |
| 201 input_router_->SendWheelEvent(MouseWheelEventWithLatencyInfo( | 201 input_router_->SendWheelEvent(MouseWheelEventWithLatencyInfo( |
| (...skipping 2079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2281 EXPECT_EQ(80, sent_event->data.flingStart.velocityY); | 2281 EXPECT_EQ(80, sent_event->data.flingStart.velocityY); |
| 2282 | 2282 |
| 2283 const WebGestureEvent* filter_event = | 2283 const WebGestureEvent* filter_event = |
| 2284 GetFilterWebInputEvent<WebGestureEvent>(); | 2284 GetFilterWebInputEvent<WebGestureEvent>(); |
| 2285 TestLocationInFilterEvent(filter_event, orig); | 2285 TestLocationInFilterEvent(filter_event, orig); |
| 2286 EXPECT_EQ(30, filter_event->data.flingStart.velocityX); | 2286 EXPECT_EQ(30, filter_event->data.flingStart.velocityX); |
| 2287 EXPECT_EQ(40, filter_event->data.flingStart.velocityY); | 2287 EXPECT_EQ(40, filter_event->data.flingStart.velocityY); |
| 2288 } | 2288 } |
| 2289 | 2289 |
| 2290 } // namespace content | 2290 } // namespace content |
| OLD | NEW |