Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Side by Side Diff: content/browser/renderer_host/input/mock_input_router_client.cc

Issue 20356003: Provided batched input delivery with a BufferedInputRouter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/renderer_host/input/mock_input_router_client.h"
6
7 #include "content/browser/renderer_host/input/input_router.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 using base::TimeDelta;
11 using WebKit::WebGestureEvent;
12 using WebKit::WebInputEvent;
13 using WebKit::WebMouseEvent;
14 using WebKit::WebMouseWheelEvent;
15 using WebKit::WebTouchEvent;
16 using WebKit::WebTouchPoint;
17
18 namespace content {
19
20 MockInputRouterClient::MockInputRouterClient()
21 : input_router_(NULL),
22 in_flight_event_count_(0),
23 has_touch_handler_(false),
24 filter_state_(INPUT_EVENT_ACK_STATE_NOT_CONSUMED),
25 is_shortcut_(false),
26 allow_send_event_(true),
27 send_called_(false),
28 send_immediately_called_(false),
29 sync_flush_(false),
30 did_flush_called_(false),
31 set_needs_flush_called_(false) {}
32
33 MockInputRouterClient::~MockInputRouterClient() {}
34
35 InputEventAckState MockInputRouterClient::FilterInputEvent(
36 const WebInputEvent& input_event,
37 const ui::LatencyInfo& latency_info) {
38 return filter_state_;
39 }
40
41 void MockInputRouterClient::IncrementInFlightEventCount() {
42 ++in_flight_event_count_;
43 }
44
45 void MockInputRouterClient::DecrementInFlightEventCount() {
46 --in_flight_event_count_;
47 }
48
49 void MockInputRouterClient::OnHasTouchEventHandlers(
50 bool has_handlers) {
51 has_touch_handler_ = has_handlers;
52 }
53
54 bool MockInputRouterClient::OnSendKeyboardEvent(
55 const NativeWebKeyboardEvent& key_event,
56 const ui::LatencyInfo& latency_info,
57 bool* is_shortcut) {
58 send_called_ = true;
59 sent_key_event_ = key_event;
60 *is_shortcut = is_shortcut_;
61
62 return allow_send_event_;
63 }
64
65 bool MockInputRouterClient::OnSendWheelEvent(
66 const MouseWheelEventWithLatencyInfo& wheel_event) {
67 send_called_ = true;
68 sent_wheel_event_ = wheel_event;
69
70 return allow_send_event_;
71 }
72
73 bool MockInputRouterClient::OnSendMouseEvent(
74 const MouseEventWithLatencyInfo& mouse_event) {
75 send_called_ = true;
76 sent_mouse_event_ = mouse_event;
77
78 return allow_send_event_;
79 }
80
81 bool MockInputRouterClient::OnSendTouchEvent(
82 const TouchEventWithLatencyInfo& touch_event) {
83 send_called_ = true;
84 sent_touch_event_ = touch_event;
85
86 return allow_send_event_;
87 }
88
89 bool MockInputRouterClient::OnSendGestureEvent(
90 const GestureEventWithLatencyInfo& gesture_event) {
91 send_called_ = true;
92 sent_gesture_event_ = gesture_event;
93
94 return allow_send_event_ &&
95 input_router_->ShouldForwardGestureEvent(gesture_event);
96 }
97
98 bool MockInputRouterClient::OnSendMouseEventImmediately(
99 const MouseEventWithLatencyInfo& mouse_event) {
100 send_immediately_called_ = true;
101 immediately_sent_mouse_event_ = mouse_event;
102
103 return allow_send_event_;
104 }
105
106 bool MockInputRouterClient::OnSendTouchEventImmediately(
107 const TouchEventWithLatencyInfo& touch_event) {
108 send_immediately_called_ = true;
109 immediately_sent_touch_event_ = touch_event;
110
111 return allow_send_event_;
112 }
113
114 bool MockInputRouterClient::OnSendGestureEventImmediately(
115 const GestureEventWithLatencyInfo& gesture_event) {
116 send_immediately_called_ = true;
117 immediately_sent_gesture_event_ = gesture_event;
118 return allow_send_event_;
119 }
120
121 void MockInputRouterClient::ExpectSendCalled(bool called) {
122 EXPECT_EQ(called, send_called_);
123 send_called_ = false;
124 }
125
126 void MockInputRouterClient::ExpectSendImmediatelyCalled(bool called) {
127 EXPECT_EQ(called, send_immediately_called_);
128 send_immediately_called_ = false;
129 }
130
131 void MockInputRouterClient::ExpectNeedsFlushCalled(bool called) {
132 EXPECT_EQ(called, set_needs_flush_called_);
133 set_needs_flush_called_ = false;
134 }
135
136 void MockInputRouterClient::ExpectDidFlushCalled(bool called) {
137 EXPECT_EQ(called, did_flush_called_);
138 did_flush_called_ = false;
139 }
140
141 void MockInputRouterClient::DidFlush() {
142 did_flush_called_ = true;
143 }
144
145 void MockInputRouterClient::SetNeedsFlush() {
146 set_needs_flush_called_ = true;
147 }
148
149 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698