OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/renderer/gpu/input_handler_proxy.h" | 5 #include "content/renderer/gpu/input_handler_proxy.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "content/renderer/gpu/input_handler_proxy_client.h" | 9 #include "content/renderer/gpu/input_handler_proxy_client.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 gesture_.type = WebInputEvent::GestureFlingCancel; | 959 gesture_.type = WebInputEvent::GestureFlingCancel; |
960 gesture_.timeStampSeconds = 1234; | 960 gesture_.timeStampSeconds = 1234; |
961 base::TimeTicks time = | 961 base::TimeTicks time = |
962 base::TimeTicks() + | 962 base::TimeTicks() + |
963 base::TimeDelta::FromSeconds(gesture_.timeStampSeconds); | 963 base::TimeDelta::FromSeconds(gesture_.timeStampSeconds); |
964 gesture_.modifiers |= WebInputEvent::IsLastInputEventForCurrentVSync; | 964 gesture_.modifiers |= WebInputEvent::IsLastInputEventForCurrentVSync; |
965 EXPECT_CALL(mock_input_handler_, DidReceiveLastInputEventForBeginFrame(time)); | 965 EXPECT_CALL(mock_input_handler_, DidReceiveLastInputEventForBeginFrame(time)); |
966 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); | 966 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
967 } | 967 } |
968 | 968 |
| 969 TEST_F(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) { |
| 970 // We shouldn't send any events to the widget for this gesture. |
| 971 expected_disposition_ = InputHandlerProxy::DID_HANDLE; |
| 972 VERIFY_AND_RESET_MOCKS(); |
| 973 |
| 974 // On the fling start, we should schedule an animation but not actually start |
| 975 // scrolling. |
| 976 gesture_.type = WebInputEvent::GestureFlingStart; |
| 977 WebFloatPoint fling_delta = WebFloatPoint(1000, 1000); |
| 978 gesture_.data.flingStart.velocityX = fling_delta.x; |
| 979 gesture_.data.flingStart.velocityY = fling_delta.y; |
| 980 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
| 981 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 982 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 983 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 984 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); |
| 985 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 986 |
| 987 // The first animate doesn't cause any scrolling. |
| 988 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
| 989 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10); |
| 990 input_handler_->Animate(time); |
| 991 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 992 |
| 993 // The second animate starts scrolling in the positive X and Y directions. |
| 994 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
| 995 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 996 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 997 EXPECT_CALL(mock_input_handler_, |
| 998 ScrollBy(testing::_, |
| 999 testing::Property(&gfx::Vector2dF::y, testing::Lt(0)))) |
| 1000 .WillOnce(testing::Return(true)); |
| 1001 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 1002 time += base::TimeDelta::FromMilliseconds(100); |
| 1003 input_handler_->Animate(time); |
| 1004 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1005 |
| 1006 // Simulate hitting the bottom content edge. |
| 1007 gfx::Vector2dF overscroll_amount(0, 100); |
| 1008 gfx::Vector2dF overscroll_velocity(0, 10); |
| 1009 input_handler_->DidOverscroll(overscroll_amount, overscroll_velocity); |
| 1010 |
| 1011 // The next call to animate will no longer scroll vertically. |
| 1012 EXPECT_CALL(mock_input_handler_, ScheduleAnimation()); |
| 1013 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) |
| 1014 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); |
| 1015 EXPECT_CALL(mock_input_handler_, |
| 1016 ScrollBy(testing::_, |
| 1017 testing::Property(&gfx::Vector2dF::y, testing::Eq(0)))) |
| 1018 .WillOnce(testing::Return(true)); |
| 1019 EXPECT_CALL(mock_input_handler_, ScrollEnd()); |
| 1020 time += base::TimeDelta::FromMilliseconds(100); |
| 1021 input_handler_->Animate(time); |
| 1022 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); |
| 1023 } |
| 1024 |
969 } // namespace | 1025 } // namespace |
970 } // namespace content | 1026 } // namespace content |
OLD | NEW |