| Index: content/browser/renderer_host/input/mock_input_router_client.cc
|
| diff --git a/content/browser/renderer_host/input/mock_input_router_client.cc b/content/browser/renderer_host/input/mock_input_router_client.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..89c4996a603508c6d1feff2c9b3f844a24428ae2
|
| --- /dev/null
|
| +++ b/content/browser/renderer_host/input/mock_input_router_client.cc
|
| @@ -0,0 +1,203 @@
|
| +// 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.
|
| +
|
| +#include "content/browser/renderer_host/input/mock_input_router_client.h"
|
| +
|
| +#include "content/browser/renderer_host/input/input_router.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +using base::TimeDelta;
|
| +using WebKit::WebGestureEvent;
|
| +using WebKit::WebInputEvent;
|
| +using WebKit::WebMouseEvent;
|
| +using WebKit::WebMouseWheelEvent;
|
| +using WebKit::WebTouchEvent;
|
| +using WebKit::WebTouchPoint;
|
| +
|
| +namespace content {
|
| +
|
| +MockInputRouterClient::MockInputRouterClient()
|
| + : input_router_(NULL),
|
| + in_flight_event_count_(0),
|
| + has_touch_handler_(false),
|
| + ack_count_(0),
|
| + unexpected_event_ack_called_(false),
|
| + ack_state_(INPUT_EVENT_ACK_STATE_UNKNOWN),
|
| + filter_state_(INPUT_EVENT_ACK_STATE_NOT_CONSUMED),
|
| + is_shortcut_(false),
|
| + allow_send_event_(true),
|
| + send_called_(false),
|
| + send_immediately_called_(false),
|
| + sync_flush_(false),
|
| + did_flush_called_(false),
|
| + set_needs_flush_called_(false) {}
|
| +
|
| +MockInputRouterClient::~MockInputRouterClient() {}
|
| +
|
| +InputEventAckState MockInputRouterClient::FilterInputEvent(
|
| + const WebInputEvent& input_event,
|
| + const ui::LatencyInfo& latency_info) {
|
| + return filter_state_;
|
| +}
|
| +
|
| +void MockInputRouterClient::IncrementInFlightEventCount() {
|
| + ++in_flight_event_count_;
|
| +}
|
| +
|
| +void MockInputRouterClient::DecrementInFlightEventCount() {
|
| + --in_flight_event_count_;
|
| +}
|
| +
|
| +void MockInputRouterClient::OnHasTouchEventHandlers(
|
| + bool has_handlers) {
|
| + has_touch_handler_ = has_handlers;
|
| +}
|
| +
|
| +bool MockInputRouterClient::OnSendKeyboardEvent(
|
| + const NativeWebKeyboardEvent& key_event,
|
| + const ui::LatencyInfo& latency_info,
|
| + bool* is_shortcut) {
|
| + send_called_ = true;
|
| + sent_key_event_ = key_event;
|
| + *is_shortcut = is_shortcut_;
|
| +
|
| + return allow_send_event_;
|
| +}
|
| +
|
| +bool MockInputRouterClient::OnSendWheelEvent(
|
| + const MouseWheelEventWithLatencyInfo& wheel_event) {
|
| + send_called_ = true;
|
| + sent_wheel_event_ = wheel_event;
|
| +
|
| + return allow_send_event_;
|
| +}
|
| +
|
| +bool MockInputRouterClient::OnSendMouseEvent(
|
| + const MouseEventWithLatencyInfo& mouse_event) {
|
| + send_called_ = true;
|
| + sent_mouse_event_ = mouse_event;
|
| +
|
| + return allow_send_event_;
|
| +}
|
| +
|
| +bool MockInputRouterClient::OnSendTouchEvent(
|
| + const TouchEventWithLatencyInfo& touch_event) {
|
| + send_called_ = true;
|
| + sent_touch_event_ = touch_event;
|
| +
|
| + return allow_send_event_;
|
| +}
|
| +
|
| +bool MockInputRouterClient::OnSendGestureEvent(
|
| + const GestureEventWithLatencyInfo& gesture_event) {
|
| + send_called_ = true;
|
| + sent_gesture_event_ = gesture_event;
|
| +
|
| + return allow_send_event_ &&
|
| + input_router_->ShouldForwardGestureEvent(gesture_event);
|
| +}
|
| +
|
| +bool MockInputRouterClient::OnSendMouseEventImmediately(
|
| + const MouseEventWithLatencyInfo& mouse_event) {
|
| + send_immediately_called_ = true;
|
| + immediately_sent_mouse_event_ = mouse_event;
|
| +
|
| + return allow_send_event_;
|
| +}
|
| +
|
| +bool MockInputRouterClient::OnSendTouchEventImmediately(
|
| + const TouchEventWithLatencyInfo& touch_event) {
|
| + send_immediately_called_ = true;
|
| + immediately_sent_touch_event_ = touch_event;
|
| +
|
| + return allow_send_event_;
|
| +}
|
| +
|
| +bool MockInputRouterClient::OnSendGestureEventImmediately(
|
| + const GestureEventWithLatencyInfo& gesture_event) {
|
| + send_immediately_called_ = true;
|
| + immediately_sent_gesture_event_ = gesture_event;
|
| + return allow_send_event_;
|
| +}
|
| +
|
| +void MockInputRouterClient::OnKeyboardEventAck(
|
| + const NativeWebKeyboardEvent& event,
|
| + InputEventAckState ack_result) {
|
| + VLOG(1) << __FUNCTION__ << " called!";
|
| + acked_key_event_ = event;
|
| + RecordAckCalled(ack_result);
|
| +}
|
| +
|
| +void MockInputRouterClient::OnWheelEventAck(
|
| + const WebMouseWheelEvent& event,
|
| + InputEventAckState ack_result) {
|
| + VLOG(1) << __FUNCTION__ << " called!";
|
| + acked_wheel_event_ = event;
|
| + RecordAckCalled(ack_result);
|
| +}
|
| +
|
| +void MockInputRouterClient::OnTouchEventAck(
|
| + const TouchEventWithLatencyInfo& event,
|
| + InputEventAckState ack_result) {
|
| + VLOG(1) << __FUNCTION__ << " called!";
|
| + acked_touch_event_ = event;
|
| + RecordAckCalled(ack_result);
|
| + if (touch_followup_event_)
|
| + input_router_->SendGestureEvent(*touch_followup_event_);
|
| +}
|
| +
|
| +void MockInputRouterClient::OnGestureEventAck(
|
| + const WebGestureEvent& event,
|
| + InputEventAckState ack_result) {
|
| + VLOG(1) << __FUNCTION__ << " called!";
|
| + acked_gesture_event_ = event;
|
| + RecordAckCalled(ack_result);
|
| +}
|
| +
|
| +void MockInputRouterClient::OnUnexpectedEventAck(bool bad_message) {
|
| + VLOG(1) << __FUNCTION__ << " called!";
|
| + unexpected_event_ack_called_ = true;
|
| +}
|
| +
|
| +void MockInputRouterClient::ExpectSendCalled(bool called) {
|
| + EXPECT_EQ(called, send_called_);
|
| + send_called_ = false;
|
| +}
|
| +
|
| +void MockInputRouterClient::ExpectSendImmediatelyCalled(bool called) {
|
| + EXPECT_EQ(called, send_immediately_called_);
|
| + send_immediately_called_ = false;
|
| +}
|
| +
|
| +void MockInputRouterClient::ExpectAckCalled(int times) {
|
| + EXPECT_EQ(times, ack_count_);
|
| + ack_count_ = 0;
|
| +}
|
| +
|
| +void MockInputRouterClient::ExpectNeedsFlushCalled(bool called) {
|
| + EXPECT_EQ(called, set_needs_flush_called_);
|
| + set_needs_flush_called_ = false;
|
| +}
|
| +
|
| +void MockInputRouterClient::ExpectDidFlushCalled(bool called) {
|
| + EXPECT_EQ(called, did_flush_called_);
|
| + did_flush_called_ = false;
|
| +}
|
| +
|
| +void MockInputRouterClient::RecordAckCalled(InputEventAckState ack_result) {
|
| + ++ack_count_;
|
| + ack_state_ = ack_result;
|
| +}
|
| +
|
| +void MockInputRouterClient::DidFlush() {
|
| + did_flush_called_ = true;
|
| +}
|
| +
|
| +void MockInputRouterClient::SetNeedsFlush() {
|
| + set_needs_flush_called_ = true;
|
| + if (sync_flush_)
|
| + input_router_->Flush();
|
| +}
|
| +
|
| +} // namespace content
|
|
|