1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "content/browser/renderer_host/input/mock_input_router.h"
6 
7 #include "content/browser/renderer_host/input/input_router_client.h"
8 
9 namespace content {
10 
SendMouseEvent(const MouseEventWithLatencyInfo & mouse_event,MouseEventCallback event_result_callback)11 void MockInputRouter::SendMouseEvent(
12     const MouseEventWithLatencyInfo& mouse_event,
13     MouseEventCallback event_result_callback) {
14   sent_mouse_event_ = true;
15 }
SendWheelEvent(const MouseWheelEventWithLatencyInfo & wheel_event)16 void MockInputRouter::SendWheelEvent(
17     const MouseWheelEventWithLatencyInfo& wheel_event) {
18   sent_wheel_event_ = true;
19 }
SendKeyboardEvent(const NativeWebKeyboardEventWithLatencyInfo & key_event,KeyboardEventCallback event_result_callback)20 void MockInputRouter::SendKeyboardEvent(
21     const NativeWebKeyboardEventWithLatencyInfo& key_event,
22     KeyboardEventCallback event_result_callback) {
23   sent_keyboard_event_ = true;
24 }
SendGestureEvent(const GestureEventWithLatencyInfo & gesture_event)25 void MockInputRouter::SendGestureEvent(
26     const GestureEventWithLatencyInfo& gesture_event) {
27   sent_gesture_event_ = true;
28 }
SendTouchEvent(const TouchEventWithLatencyInfo & touch_event)29 void MockInputRouter::SendTouchEvent(
30     const TouchEventWithLatencyInfo& touch_event) {
31   send_touch_event_not_cancelled_ =
32       client_->FilterInputEvent(touch_event.event, touch_event.latency) ==
33       blink::mojom::InputEventResultState::kNotConsumed;
34 }
35 
HasPendingEvents() const36 bool MockInputRouter::HasPendingEvents() const {
37   return false;
38 }
39 
AllowedTouchAction()40 base::Optional<cc::TouchAction> MockInputRouter::AllowedTouchAction() {
41   return cc::TouchAction::kAuto;
42 }
43 
ActiveTouchAction()44 base::Optional<cc::TouchAction> MockInputRouter::ActiveTouchAction() {
45   return cc::TouchAction::kAuto;
46 }
47 
48 mojo::PendingRemote<blink::mojom::WidgetInputHandlerHost>
BindNewHost()49 MockInputRouter::BindNewHost() {
50   return mojo::NullRemote();
51 }
52 
OnHasTouchEventConsumers(blink::mojom::TouchEventConsumersPtr consumers)53 void MockInputRouter::OnHasTouchEventConsumers(
54     blink::mojom::TouchEventConsumersPtr consumers) {
55   has_handlers_ = consumers->has_touch_event_handlers;
56 }
57 
58 }  // namespace content
59