| OLD | NEW | 
| (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_ack_handler.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 MockInputAckHandler::MockInputAckHandler() | 
 |  21   : input_router_(NULL), | 
 |  22     ack_count_(0), | 
 |  23     unexpected_event_ack_called_(false), | 
 |  24     ack_state_(INPUT_EVENT_ACK_STATE_UNKNOWN) {} | 
 |  25  | 
 |  26 MockInputAckHandler::~MockInputAckHandler() {} | 
 |  27  | 
 |  28 void MockInputAckHandler::OnKeyboardEventAck( | 
 |  29     const NativeWebKeyboardEvent& event, | 
 |  30     InputEventAckState ack_result)  { | 
 |  31   VLOG(1) << __FUNCTION__ << " called!"; | 
 |  32   acked_key_event_ = event; | 
 |  33   RecordAckCalled(ack_result); | 
 |  34 } | 
 |  35  | 
 |  36 void MockInputAckHandler::OnWheelEventAck( | 
 |  37     const WebMouseWheelEvent& event, | 
 |  38     InputEventAckState ack_result)  { | 
 |  39   VLOG(1) << __FUNCTION__ << " called!"; | 
 |  40   acked_wheel_event_ = event; | 
 |  41   RecordAckCalled(ack_result); | 
 |  42 } | 
 |  43  | 
 |  44 void MockInputAckHandler::OnTouchEventAck( | 
 |  45     const TouchEventWithLatencyInfo& event, | 
 |  46     InputEventAckState ack_result)  { | 
 |  47   VLOG(1) << __FUNCTION__ << " called!"; | 
 |  48   acked_touch_event_ = event; | 
 |  49   RecordAckCalled(ack_result); | 
 |  50   if (touch_followup_event_) | 
 |  51     input_router_->SendGestureEvent(*touch_followup_event_); | 
 |  52 } | 
 |  53  | 
 |  54 void MockInputAckHandler::OnGestureEventAck( | 
 |  55     const WebGestureEvent& event, | 
 |  56     InputEventAckState ack_result)  { | 
 |  57   VLOG(1) << __FUNCTION__ << " called!"; | 
 |  58   acked_gesture_event_ = event; | 
 |  59   RecordAckCalled(ack_result); | 
 |  60 } | 
 |  61  | 
 |  62 void MockInputAckHandler::OnUnexpectedEventAck(UnexpectedEventAckType type)  { | 
 |  63   VLOG(1) << __FUNCTION__ << " called!"; | 
 |  64   unexpected_event_ack_called_ = true; | 
 |  65 } | 
 |  66  | 
 |  67 void MockInputAckHandler::ExpectAckCalled(int times) { | 
 |  68   EXPECT_EQ(times, ack_count_); | 
 |  69   ack_count_ = 0; | 
 |  70 } | 
 |  71  | 
 |  72 void MockInputAckHandler::RecordAckCalled(InputEventAckState ack_result) { | 
 |  73   ++ack_count_; | 
 |  74   ack_state_ = ack_result; | 
 |  75 } | 
 |  76  | 
 |  77 }  // namespace content | 
| OLD | NEW |