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

Unified Diff: content/browser/renderer_host/input/mock_input_router_client.h

Issue 20356003: Provided batched input delivery with a BufferedInputRouter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: BufferedInputRouter unit tests 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/mock_input_router_client.h
diff --git a/content/browser/renderer_host/input/mock_input_router_client.h b/content/browser/renderer_host/input/mock_input_router_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..13c5549c8ffa46c4a8450106d9ef6c06c44ac891
--- /dev/null
+++ b/content/browser/renderer_host/input/mock_input_router_client.h
@@ -0,0 +1,163 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// 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 "base/memory/scoped_ptr.h"
+#include "content/browser/renderer_host/input/input_router_client.h"
+
+namespace content {
+
+class InputRouter;
+
+class MockInputRouterClient : public InputRouterClient {
+ public:
+ MockInputRouterClient();
+ virtual ~MockInputRouterClient();
+
+ // InputRouterClient
+ virtual InputEventAckState FilterInputEvent(
+ const WebKit::WebInputEvent& input_event,
+ const ui::LatencyInfo& latency_info) OVERRIDE;
+ virtual void IncrementInFlightEventCount() OVERRIDE;
aelias_OOO_until_Jul13 2013/08/13 06:11:51 These two Increment/Decrement methods seem to only
jdduke (slow) 2013/08/13 15:29:48 ? This is how the client can determine if the rend
+ virtual void DecrementInFlightEventCount() OVERRIDE;
+ virtual void OnHasTouchEventHandlers(bool has_handlers) OVERRIDE;
+ virtual bool OnSendKeyboardEvent(
+ const NativeWebKeyboardEvent& key_event,
+ const ui::LatencyInfo& latency_info,
+ bool* is_shortcut) OVERRIDE;
+ virtual bool OnSendWheelEvent(
+ const MouseWheelEventWithLatencyInfo& wheel_event) OVERRIDE;
+ virtual bool OnSendMouseEvent(
+ const MouseEventWithLatencyInfo& mouse_event) OVERRIDE;
+ virtual bool OnSendTouchEvent(
+ const TouchEventWithLatencyInfo& touch_event) OVERRIDE;
+ virtual bool OnSendGestureEvent(
+ const GestureEventWithLatencyInfo& gesture_event) OVERRIDE;
+ virtual bool OnSendMouseEventImmediately(
+ const MouseEventWithLatencyInfo& mouse_event) OVERRIDE;
+ virtual bool OnSendTouchEventImmediately(
+ const TouchEventWithLatencyInfo& touch_event) OVERRIDE;
+ virtual bool OnSendGestureEventImmediately(
+ const GestureEventWithLatencyInfo& gesture_event) OVERRIDE;
+ virtual void OnKeyboardEventAck(const NativeWebKeyboardEvent& event,
+ InputEventAckState ack_result) OVERRIDE;
+ virtual void OnWheelEventAck(const WebKit::WebMouseWheelEvent& event,
+ InputEventAckState ack_result) OVERRIDE;
+ virtual void OnTouchEventAck(const TouchEventWithLatencyInfo& event,
+ InputEventAckState ack_result) OVERRIDE;
+ virtual void OnGestureEventAck(const WebKit::WebGestureEvent& event,
+ InputEventAckState ack_result) OVERRIDE;
+ virtual void OnUnexpectedEventAck(bool bad_message) OVERRIDE;
aelias_OOO_until_Jul13 2013/08/13 06:11:51 Looks like this is also only for testing, please d
jdduke (slow) 2013/08/13 15:29:48 I tried to restrict this patch as much as possible
+ virtual void DidFlush() OVERRIDE;
aelias_OOO_until_Jul13 2013/08/13 06:11:51 Looks like this is also only for testing, please d
jdduke (slow) 2013/08/13 15:29:48 See comment above.
+ virtual void SetNeedsFlush() OVERRIDE;
+
+ void ExpectSendCalled(bool called);
+ void ExpectSendImmediatelyCalled(bool called);
+ void ExpectAckCalled(int times);
+ void ExpectNeedsFlushCalled(bool called);
+ void ExpectDidFlushCalled(bool called);
+
+ void set_input_router(InputRouter* input_router) {
+ input_router_ = input_router;
+ }
+
+ bool has_touch_handler() const { return has_touch_handler_; }
+ InputEventAckState ack_state() const { return ack_state_; }
+ void set_filter_state(InputEventAckState filter_state) {
+ filter_state_ = filter_state;
+ }
+ int in_flight_event_count() const {
+ return in_flight_event_count_;
+ }
+ bool unexpected_event_ack_called() const {
+ return unexpected_event_ack_called_;
+ }
+ const NativeWebKeyboardEvent& acked_keyboard_event() {
+ return acked_key_event_;
+ }
+ const WebKit::WebMouseWheelEvent& acked_wheel_event() {
+ return acked_wheel_event_;
+ }
+ const TouchEventWithLatencyInfo& acked_touch_event() {
+ return acked_touch_event_;
+ }
+ const WebKit::WebGestureEvent& acked_gesture_event() {
+ return acked_gesture_event_;
+ }
+ void set_is_shortcut(bool is_shortcut) {
+ is_shortcut_ = is_shortcut;
+ }
+ void set_allow_send_event(bool allow) {
+ allow_send_event_ = allow;
+ }
+ const NativeWebKeyboardEvent& sent_key_event() {
+ return sent_key_event_;
+ }
+ const MouseWheelEventWithLatencyInfo& sent_wheel_event() {
+ return sent_wheel_event_;
+ }
+ const MouseEventWithLatencyInfo& sent_mouse_event() {
+ return sent_mouse_event_;
+ }
+ const GestureEventWithLatencyInfo& sent_gesture_event() {
+ return sent_gesture_event_;
+ }
+ const MouseEventWithLatencyInfo& immediately_sent_mouse_event() {
+ return immediately_sent_mouse_event_;
+ }
+ const TouchEventWithLatencyInfo& immediately_sent_touch_event() {
+ return immediately_sent_touch_event_;
+ }
+ const GestureEventWithLatencyInfo& immediately_sent_gesture_event() {
+ return immediately_sent_gesture_event_;
+ }
+
+ void set_sync_flush(bool sync_flush) { sync_flush_ = sync_flush; }
+ bool did_flush_called() const { return did_flush_called_; }
+ bool needs_flush_called() const { return set_needs_flush_called_; }
+ void set_followup_touch_event(scoped_ptr<GestureEventWithLatencyInfo> event) {
+ touch_followup_event_ = event.Pass();
+ }
+
+ private:
+ void RecordAckCalled(InputEventAckState ack_result);
+
+ InputRouter* input_router_;
+ int in_flight_event_count_;
+ bool has_touch_handler_;
+
+ int ack_count_;
+ bool unexpected_event_ack_called_;
+ InputEventAckState ack_state_;
+ InputEventAckState filter_state_;
+ NativeWebKeyboardEvent acked_key_event_;
+ WebKit::WebMouseWheelEvent acked_wheel_event_;
+ TouchEventWithLatencyInfo acked_touch_event_;
+ WebKit::WebGestureEvent acked_gesture_event_;
+
+ bool is_shortcut_;
+ bool allow_send_event_;
+ bool send_called_;
+ NativeWebKeyboardEvent sent_key_event_;
+ MouseWheelEventWithLatencyInfo sent_wheel_event_;
+ MouseEventWithLatencyInfo sent_mouse_event_;
+ TouchEventWithLatencyInfo sent_touch_event_;
+ GestureEventWithLatencyInfo sent_gesture_event_;
+
+ bool send_immediately_called_;
+ MouseEventWithLatencyInfo immediately_sent_mouse_event_;
+ TouchEventWithLatencyInfo immediately_sent_touch_event_;
+ GestureEventWithLatencyInfo immediately_sent_gesture_event_;
+
+ bool sync_flush_;
+ bool did_flush_called_;
+ bool set_needs_flush_called_;
+ scoped_ptr<GestureEventWithLatencyInfo> touch_followup_event_;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_MOCK_INPUT_ROUTER_CLIENT_H_

Powered by Google App Engine
This is Rietveld 408576698