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
;
20 MockInputAckHandler::MockInputAckHandler()
21 : input_router_(NULL
),
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 NativeWebKeyboardEventWithLatencyInfo
& event
,
32 InputEventAckState ack_result
) {
33 VLOG(1) << __FUNCTION__
<< " called!";
34 acked_key_event_
= event
.event
;
35 RecordAckCalled(event
.event
.type
, ack_result
);
38 void MockInputAckHandler::OnMouseEventAck(
39 const MouseEventWithLatencyInfo
& event
,
40 InputEventAckState ack_result
) {
41 VLOG(1) << __FUNCTION__
<< " called!";
42 acked_mouse_event_
= event
.event
;
43 RecordAckCalled(event
.event
.type
, ack_result
);
46 void MockInputAckHandler::OnWheelEventAck(
47 const MouseWheelEventWithLatencyInfo
& event
,
48 InputEventAckState ack_result
) {
49 VLOG(1) << __FUNCTION__
<< " called!";
50 acked_wheel_event_
= event
.event
;
51 RecordAckCalled(event
.event
.type
, ack_result
);
54 void MockInputAckHandler::OnTouchEventAck(
55 const TouchEventWithLatencyInfo
& event
,
56 InputEventAckState ack_result
) {
57 VLOG(1) << __FUNCTION__
<< " called!";
58 acked_touch_event_
= event
;
59 RecordAckCalled(event
.event
.type
, ack_result
);
60 if (touch_followup_event_
)
61 input_router_
->SendTouchEvent(*touch_followup_event_
);
62 if (gesture_followup_event_
)
63 input_router_
->SendGestureEvent(*gesture_followup_event_
);
66 void MockInputAckHandler::OnGestureEventAck(
67 const GestureEventWithLatencyInfo
& event
,
68 InputEventAckState ack_result
) {
69 VLOG(1) << __FUNCTION__
<< " called!";
70 acked_gesture_event_
= event
.event
;
71 RecordAckCalled(event
.event
.type
, ack_result
);
74 void MockInputAckHandler::OnUnexpectedEventAck(UnexpectedEventAckType type
) {
75 VLOG(1) << __FUNCTION__
<< " called!";
76 unexpected_event_ack_called_
= true;
79 size_t MockInputAckHandler::GetAndResetAckCount() {
80 size_t ack_count
= ack_count_
;
85 void MockInputAckHandler::RecordAckCalled(blink::WebInputEvent::Type type
,
86 InputEventAckState ack_result
) {
87 ack_event_type_
= type
;
89 ack_state_
= ack_result
;
92 } // namespace content