Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: content/renderer/gpu/input_handler_proxy_unittest.cc

Issue 16156002: gpu: Avoid flinging beyond content edge (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 gesture_.type = WebInputEvent::GestureFlingCancel; 989 gesture_.type = WebInputEvent::GestureFlingCancel;
990 gesture_.timeStampSeconds = 1234; 990 gesture_.timeStampSeconds = 1234;
991 base::TimeTicks time = 991 base::TimeTicks time =
992 base::TimeTicks() + 992 base::TimeTicks() +
993 base::TimeDelta::FromSeconds(gesture_.timeStampSeconds); 993 base::TimeDelta::FromSeconds(gesture_.timeStampSeconds);
994 gesture_.modifiers |= WebInputEvent::IsLastInputEventForCurrentVSync; 994 gesture_.modifiers |= WebInputEvent::IsLastInputEventForCurrentVSync;
995 EXPECT_CALL(mock_input_handler_, DidReceiveLastInputEventForBeginFrame(time)); 995 EXPECT_CALL(mock_input_handler_, DidReceiveLastInputEventForBeginFrame(time));
996 input_handler_->HandleInputEvent(gesture_); 996 input_handler_->HandleInputEvent(gesture_);
997 } 997 }
998 998
999 TEST_F(InputHandlerProxyTest, GestureFlingStopsAtContentEdge) {
1000 // We shouldn't send any events to the widget for this gesture.
1001 expected_disposition_ = DidHandle;
1002 VERIFY_AND_RESET_MOCKS();
1003
1004 // On the fling start, we should schedule an animation but not actually start
1005 // scrolling.
1006 gesture_.type = WebInputEvent::GestureFlingStart;
1007 WebFloatPoint fling_delta = WebFloatPoint(1000, 1000);
1008 gesture_.data.flingStart.velocityX = fling_delta.x;
1009 gesture_.data.flingStart.velocityY = fling_delta.y;
1010 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1011 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1012 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1013 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1014 input_handler_->HandleInputEvent(gesture_);
1015 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1016
1017 // The first animate doesn't cause any scrolling.
1018 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1019 base::TimeTicks time = base::TimeTicks() + base::TimeDelta::FromSeconds(10);
1020 input_handler_->Animate(time);
1021 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1022
1023 // The second animate starts scrolling in the positive X and Y directions.
1024 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1025 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1026 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1027 EXPECT_CALL(mock_input_handler_,
1028 ScrollBy(testing::_,
1029 testing::Property(&gfx::Vector2dF::y, testing::Lt(0))))
1030 .WillOnce(testing::Return(true));
1031 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1032 time += base::TimeDelta::FromMilliseconds(100);
1033 input_handler_->Animate(time);
1034 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1035
1036 // Simulate hitting the bottom content edge.
1037 gfx::Vector2dF overscroll_amount(0, 100);
1038 gfx::Vector2dF overscroll_velocity(0, 10);
1039 input_handler_->DidOverscroll(overscroll_amount, overscroll_velocity);
1040
1041 // The next call to animate will no longer scroll vertically.
1042 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1043 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1044 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1045 EXPECT_CALL(mock_input_handler_,
1046 ScrollBy(testing::_,
1047 testing::Property(&gfx::Vector2dF::y, testing::Eq(0))))
1048 .WillOnce(testing::Return(true));
1049 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1050 time += base::TimeDelta::FromMilliseconds(100);
1051 input_handler_->Animate(time);
1052 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1053 }
1054
999 } // namespace 1055 } // namespace
OLDNEW
« content/renderer/gpu/input_handler_proxy.cc ('K') | « content/renderer/gpu/input_handler_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698