[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / content / browser / renderer_host / input / mock_input_ack_handler.cc
blob309280988555c29c7b20ce6de9a8caea65826e2a
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.
5 #include "content/browser/renderer_host/input/mock_input_ack_handler.h"
7 #include "content/browser/renderer_host/input/input_router.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 using base::TimeDelta;
11 using blink::WebGestureEvent;
12 using blink::WebInputEvent;
13 using blink::WebMouseEvent;
14 using blink::WebMouseWheelEvent;
15 using blink::WebTouchEvent;
16 using blink::WebTouchPoint;
18 namespace content {
20 MockInputAckHandler::MockInputAckHandler()
21 : input_router_(NULL),
22 ack_count_(0),
23 unexpected_event_ack_called_(false),
24 ack_event_type_(WebInputEvent::Undefined),
25 ack_state_(INPUT_EVENT_ACK_STATE_UNKNOWN) {
28 MockInputAckHandler::~MockInputAckHandler() {}
30 void MockInputAckHandler::OnKeyboardEventAck(
31 const NativeWebKeyboardEvent& event,
32 InputEventAckState ack_result) {
33 VLOG(1) << __FUNCTION__ << " called!";
34 acked_key_event_ = event;
35 RecordAckCalled(event.type, ack_result);
38 void MockInputAckHandler::OnWheelEventAck(
39 const MouseWheelEventWithLatencyInfo& event,
40 InputEventAckState ack_result) {
41 VLOG(1) << __FUNCTION__ << " called!";
42 acked_wheel_event_ = event.event;
43 RecordAckCalled(event.event.type, ack_result);
46 void MockInputAckHandler::OnTouchEventAck(
47 const TouchEventWithLatencyInfo& event,
48 InputEventAckState ack_result) {
49 VLOG(1) << __FUNCTION__ << " called!";
50 acked_touch_event_ = event;
51 RecordAckCalled(event.event.type, ack_result);
52 if (touch_followup_event_)
53 input_router_->SendTouchEvent(*touch_followup_event_);
54 if (gesture_followup_event_)
55 input_router_->SendGestureEvent(*gesture_followup_event_);
58 void MockInputAckHandler::OnGestureEventAck(
59 const GestureEventWithLatencyInfo& event,
60 InputEventAckState ack_result) {
61 VLOG(1) << __FUNCTION__ << " called!";
62 acked_gesture_event_ = event.event;
63 RecordAckCalled(event.event.type, ack_result);
66 void MockInputAckHandler::OnUnexpectedEventAck(UnexpectedEventAckType type) {
67 VLOG(1) << __FUNCTION__ << " called!";
68 unexpected_event_ack_called_ = true;
71 size_t MockInputAckHandler::GetAndResetAckCount() {
72 size_t ack_count = ack_count_;
73 ack_count_ = 0;
74 return ack_count;
77 void MockInputAckHandler::RecordAckCalled(blink::WebInputEvent::Type type,
78 InputEventAckState ack_result) {
79 ack_event_type_ = type;
80 ++ack_count_;
81 ack_state_ = ack_result;
84 } // namespace content