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

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

Issue 19220002: [WIP] BufferedInputRouter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix client assignment Created 7 years, 3 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 did_flush_called_(false),
30 set_needs_flush_called_(false) {}
31
32 MockInputRouterClient::~MockInputRouterClient() {}
33
34 InputEventAckState MockInputRouterClient::FilterInputEvent(
35 const WebInputEvent& input_event,
36 const ui::LatencyInfo& latency_info) {
37 return filter_state_;
38 }
39
40 void MockInputRouterClient::IncrementInFlightEventCount() {
41 ++in_flight_event_count_;
42 }
43
44 void MockInputRouterClient::DecrementInFlightEventCount() {
45 --in_flight_event_count_;
46 }
47
48 void MockInputRouterClient::OnHasTouchEventHandlers(
49 bool has_handlers) {
50 has_touch_handler_ = has_handlers;
51 }
52
53 bool MockInputRouterClient::OnSendKeyboardEvent(
54 const NativeWebKeyboardEvent& key_event,
55 const ui::LatencyInfo& latency_info,
56 bool* is_shortcut) {
57 send_called_ = true;
58 sent_key_event_ = key_event;
59 *is_shortcut = is_shortcut_;
60
61 return allow_send_event_;
62 }
63
64 bool MockInputRouterClient::OnSendWheelEvent(
65 const MouseWheelEventWithLatencyInfo& wheel_event) {
66 send_called_ = true;
67 sent_wheel_event_ = wheel_event;
68
69 return allow_send_event_;
70 }
71
72 bool MockInputRouterClient::OnSendMouseEvent(
73 const MouseEventWithLatencyInfo& mouse_event) {
74 send_called_ = true;
75 sent_mouse_event_ = mouse_event;
76
77 return allow_send_event_;
78 }
79
80 bool MockInputRouterClient::OnSendTouchEvent(
81 const TouchEventWithLatencyInfo& touch_event) {
82 send_called_ = true;
83 sent_touch_event_ = touch_event;
84
85 return allow_send_event_;
86 }
87
88 bool MockInputRouterClient::OnSendGestureEvent(
89 const GestureEventWithLatencyInfo& gesture_event) {
90 send_called_ = true;
91 sent_gesture_event_ = gesture_event;
92
93 return allow_send_event_ &&
94 input_router_->ShouldForwardGestureEvent(gesture_event);
95 }
96
97 bool MockInputRouterClient::OnSendMouseEventImmediately(
98 const MouseEventWithLatencyInfo& mouse_event) {
99 send_immediately_called_ = true;
100 immediately_sent_mouse_event_ = mouse_event;
101
102 return allow_send_event_;
103 }
104
105 bool MockInputRouterClient::OnSendTouchEventImmediately(
106 const TouchEventWithLatencyInfo& touch_event) {
107 send_immediately_called_ = true;
108 immediately_sent_touch_event_ = touch_event;
109
110 return allow_send_event_;
111 }
112
113 bool MockInputRouterClient::OnSendGestureEventImmediately(
114 const GestureEventWithLatencyInfo& gesture_event) {
115 send_immediately_called_ = true;
116 immediately_sent_gesture_event_ = gesture_event;
117 return allow_send_event_;
118 }
119
120 void MockInputRouterClient::ExpectSendCalled(bool called) {
121 EXPECT_EQ(called, send_called_);
122 send_called_ = false;
123 }
124
125 void MockInputRouterClient::ExpectSendImmediatelyCalled(bool called) {
126 EXPECT_EQ(called, send_immediately_called_);
127 send_immediately_called_ = false;
128 }
129
130 void MockInputRouterClient::ExpectNeedsFlushCalled(bool called) {
131 EXPECT_EQ(called, set_needs_flush_called_);
132 set_needs_flush_called_ = false;
133 }
134
135 void MockInputRouterClient::ExpectDidFlushCalled(bool called) {
136 EXPECT_EQ(called, did_flush_called_);
137 did_flush_called_ = false;
138 }
139
140 void MockInputRouterClient::DidFlush() {
141 did_flush_called_ = true;
142 }
143
144 void MockInputRouterClient::SetNeedsFlush() {
145 set_needs_flush_called_ = true;
146 }
147
148 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698