File: mock_input_router_client.h

package info (click to toggle)
chromium 143.0.7499.109-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,786,824 kB
  • sloc: cpp: 35,783,839; ansic: 7,477,365; javascript: 3,962,116; python: 1,480,521; xml: 764,832; asm: 710,816; pascal: 188,028; sh: 88,717; perl: 88,692; objc: 79,984; sql: 57,625; cs: 42,265; fortran: 24,101; makefile: 22,509; tcl: 15,277; php: 14,018; yacc: 9,043; ruby: 7,553; awk: 3,720; lisp: 3,233; lex: 1,330; ada: 727; jsp: 228; sed: 36
file content (128 lines) | stat: -rw-r--r-- 4,899 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_MOCK_INPUT_ROUTER_CLIENT_H_
#define CONTENT_BROWSER_RENDERER_HOST_INPUT_MOCK_INPUT_ROUTER_CLIENT_H_

#include <stddef.h>

#include <memory>

#include "base/memory/raw_ptr.h"
#include "components/input/fling_controller.h"
#include "components/input/input_router.h"
#include "components/input/input_router_client.h"
#include "content/browser/renderer_host/input/mock_render_widget_host_view_for_stylus_writing.h"
#include "content/browser/scheduler/browser_ui_thread_scheduler.h"
#include "content/test/mock_widget_input_handler.h"
#include "ui/events/blink/did_overscroll_params.h"

namespace content {

class MockInputRouterClient : public input::InputRouterClient,
                              public input::FlingControllerSchedulerClient {
 public:
  MockInputRouterClient();
  ~MockInputRouterClient() override;

  // InputRouterClient
  blink::mojom::InputEventResultState FilterInputEvent(
      const blink::WebInputEvent& input_event,
      const ui::LatencyInfo& latency_info) override;
  void IncrementInFlightEventCount() override;
  void DecrementInFlightEventCount(
      blink::mojom::InputEventResultSource ack_source) override;
  void DidOverscroll(blink::mojom::DidOverscrollParamsPtr params) override;
  void OnSetCompositorAllowedTouchAction(cc::TouchAction touch_action) override;
  void DidStartScrollingViewport() override;
  void ForwardWheelEventWithLatencyInfo(
      const blink::WebMouseWheelEvent& wheel_event,
      const ui::LatencyInfo& latency_info) override;
  void ForwardGestureEventWithLatencyInfo(
      const blink::WebGestureEvent& gesture_event,
      const ui::LatencyInfo& latency_info) override;
  bool IsWheelScrollInProgress() override;
  bool IsAutoscrollInProgress() override;
  void SetMouseCapture(bool capture) override {}
  void SetAutoscrollSelectionActiveInMainFrame(
      bool autoscroll_selection) override {}
  void RequestMouseLock(
      bool user_gesture,
      bool unadjusted_movement,
      blink::mojom::WidgetInputHandlerHost::RequestMouseLockCallback response)
      override {}
  gfx::Size GetRootWidgetViewportSize() override;
  void OnInvalidInputEventSource() override {}
  blink::mojom::WidgetInputHandler* GetWidgetInputHandler() override;
  void OnImeCancelComposition() override {}
  void OnImeCompositionRangeChanged(
      const gfx::Range& range,
      const std::optional<std::vector<gfx::Rect>>& character_bounds) override {}
  input::StylusInterface* GetStylusInterface() override;
  void OnStartStylusWriting() override;
  input::DispatchToRendererCallback GetDispatchToRendererCallback() override;

  bool GetAndResetFilterEventCalled();
  ui::DidOverscrollParams GetAndResetOverscroll();
  cc::TouchAction GetAndResetCompositorAllowedTouchAction();

  void set_input_router(input::InputRouter* input_router) {
    input_router_ = input_router;
  }

  void set_filter_state(blink::mojom::InputEventResultState filter_state) {
    filter_state_ = filter_state;
  }
  int in_flight_event_count() const {
    return in_flight_event_count_;
  }
  blink::WebInputEvent::Type last_in_flight_event_type() const {
    return last_filter_event()->GetType();
  }
  const blink::WebInputEvent* last_filter_event() const {
    return last_filter_event_.get();
  }
  bool on_start_stylus_writing_called() const {
    return on_start_stylus_writing_called_;
  }
  MockWidgetInputHandler::MessageVector GetAndResetDispatchedMessages() {
    return widget_input_handler_.GetAndResetDispatchedMessages();
  }
  void set_render_widget_host_view(
      MockRenderWidgetHostViewForStylusWriting* view) {
    render_widget_host_view_ = view;
  }

  // FlingControllerSchedulerClient
  void ScheduleFlingProgress(
      base::WeakPtr<input::FlingController> fling_controller) override {}
  void DidStopFlingingOnBrowser(
      base::WeakPtr<input::FlingController> fling_controller) override {}
  bool ProgressFlingOnFlingStart() override;
  bool ShouldUseMobileFlingCurve() override;
  gfx::Vector2dF GetPixelsPerInch(
      const gfx::PointF& position_in_screen) override;

 private:
  raw_ptr<input::InputRouter, DanglingUntriaged> input_router_;
  int in_flight_event_count_ = 0;

  blink::mojom::InputEventResultState filter_state_;

  bool filter_input_event_called_;
  std::unique_ptr<blink::WebInputEvent> last_filter_event_;

  ui::DidOverscrollParams overscroll_;

  cc::TouchAction compositor_allowed_touch_action_;

  bool is_wheel_scroll_in_progress_ = false;
  MockWidgetInputHandler widget_input_handler_;
  raw_ptr<MockRenderWidgetHostViewForStylusWriting> render_widget_host_view_;
  bool on_start_stylus_writing_called_ = false;
};

}  // namespace content

#endif  // CONTENT_BROWSER_RENDERER_HOST_INPUT_MOCK_INPUT_ROUTER_CLIENT_H_