OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <math.h> | 5 #include <math.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 void ReleaseTouchPoint(int index) { | 286 void ReleaseTouchPoint(int index) { |
287 touch_event_.ReleasePoint(index); | 287 touch_event_.ReleasePoint(index); |
288 } | 288 } |
289 | 289 |
290 void CancelTouchPoint(int index) { | 290 void CancelTouchPoint(int index) { |
291 touch_event_.CancelPoint(index); | 291 touch_event_.CancelPoint(index); |
292 } | 292 } |
293 | 293 |
294 void SendInputEventACK(blink::WebInputEvent::Type type, | 294 void SendInputEventACK(blink::WebInputEvent::Type type, |
295 InputEventAckState ack_result) { | 295 InputEventAckState ack_result) { |
296 scoped_ptr<IPC::Message> response( | 296 InputHostMsg_HandleInputEvent_ACK_Params ack; |
297 new InputHostMsg_HandleInputEvent_ACK(0, type, ack_result, | 297 ack.type = type; |
298 ui::LatencyInfo())); | 298 ack.state = ack_result; |
299 input_router_->OnMessageReceived(*response); | 299 input_router_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); |
300 } | 300 } |
301 | 301 |
302 InputRouterImpl* input_router() const { | 302 InputRouterImpl* input_router() const { |
303 return input_router_.get(); | 303 return input_router_.get(); |
304 } | 304 } |
305 | 305 |
306 bool TouchEventQueueEmpty() const { | 306 bool TouchEventQueueEmpty() const { |
307 return input_router()->touch_event_queue_.empty(); | 307 return input_router()->touch_event_queue_.empty(); |
308 } | 308 } |
309 | 309 |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1646 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 1646 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
1647 EXPECT_EQ(1, client_->in_flight_event_count()); | 1647 EXPECT_EQ(1, client_->in_flight_event_count()); |
1648 | 1648 |
1649 // Ack the wheel event. | 1649 // Ack the wheel event. |
1650 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); | 1650 SendInputEventACK(WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); |
1651 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1651 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
1652 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); | 1652 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
1653 EXPECT_EQ(0, client_->in_flight_event_count()); | 1653 EXPECT_EQ(0, client_->in_flight_event_count()); |
1654 } | 1654 } |
1655 | 1655 |
| 1656 // Test proper routing of overscroll notifications received either from |
| 1657 // event acks or from |DidOverscroll| IPC messages. |
| 1658 TEST_F(InputRouterImplTest, OverscrollDispatch) { |
| 1659 DidOverscrollParams overscroll; |
| 1660 overscroll.accumulated_overscroll = gfx::Vector2dF(-14, 14); |
| 1661 overscroll.latest_overscroll_delta = gfx::Vector2dF(-7, 0); |
| 1662 overscroll.current_fling_velocity = gfx::Vector2dF(-1, 0); |
| 1663 |
| 1664 input_router_->OnMessageReceived(InputHostMsg_DidOverscroll(0, overscroll)); |
| 1665 DidOverscrollParams client_overscroll = client_->GetAndResetOverscroll(); |
| 1666 EXPECT_EQ(overscroll.accumulated_overscroll, |
| 1667 client_overscroll.accumulated_overscroll); |
| 1668 EXPECT_EQ(overscroll.latest_overscroll_delta, |
| 1669 client_overscroll.latest_overscroll_delta); |
| 1670 EXPECT_EQ(overscroll.current_fling_velocity, |
| 1671 client_overscroll.current_fling_velocity); |
| 1672 |
| 1673 DidOverscrollParams wheel_overscroll; |
| 1674 wheel_overscroll.accumulated_overscroll = gfx::Vector2dF(7, -7); |
| 1675 wheel_overscroll.latest_overscroll_delta = gfx::Vector2dF(3, 0); |
| 1676 wheel_overscroll.current_fling_velocity = gfx::Vector2dF(1, 0); |
| 1677 |
| 1678 SimulateWheelEvent(3, 0, 0, false); |
| 1679 InputHostMsg_HandleInputEvent_ACK_Params ack; |
| 1680 ack.type = WebInputEvent::MouseWheel; |
| 1681 ack.state = INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 1682 ack.overscroll.reset(new DidOverscrollParams(wheel_overscroll)); |
| 1683 input_router_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); |
| 1684 |
| 1685 client_overscroll = client_->GetAndResetOverscroll(); |
| 1686 EXPECT_EQ(wheel_overscroll.accumulated_overscroll, |
| 1687 client_overscroll.accumulated_overscroll); |
| 1688 EXPECT_EQ(wheel_overscroll.latest_overscroll_delta, |
| 1689 client_overscroll.latest_overscroll_delta); |
| 1690 EXPECT_EQ(wheel_overscroll.current_fling_velocity, |
| 1691 client_overscroll.current_fling_velocity); |
| 1692 } |
| 1693 |
1656 } // namespace content | 1694 } // namespace content |
OLD | NEW |