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

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

Issue 232683003: Fix for often broken fling scrolls on Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added test Created 6 years, 8 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
« no previous file with comments | « content/renderer/input/input_handler_proxy.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/renderer/input/input_handler_proxy.h" 5 #include "content/renderer/input/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 "cc/base/swap_promise_monitor.h" 9 #include "cc/base/swap_promise_monitor.h"
10 #include "content/common/input/did_overscroll_params.h" 10 #include "content/common/input/did_overscroll_params.h"
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 WebTouchEvent touch; 1250 WebTouchEvent touch;
1251 touch.type = WebInputEvent::TouchStart; 1251 touch.type = WebInputEvent::TouchStart;
1252 1252
1253 touch.touchesLength = 3; 1253 touch.touchesLength = 3;
1254 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0); 1254 touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 0, 0);
1255 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10); 1255 touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10);
1256 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10); 1256 touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::StatePressed, -10, 10);
1257 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch)); 1257 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(touch));
1258 } 1258 }
1259 1259
1260 TEST_F(InputHandlerProxyTest, GestureFlingWithNegativeTimeDelta) {
1261 // We shouldn't send any events to the widget for this gesture.
1262 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1263 VERIFY_AND_RESET_MOCKS();
1264
1265 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1266 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1267
1268 gesture_.type = WebInputEvent::GestureScrollBegin;
1269 gesture_.sourceDevice = WebGestureEvent::Touchscreen;
1270 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1271
1272 VERIFY_AND_RESET_MOCKS();
1273
1274 // On the fling start, we should schedule an animation but not actually start
1275 // scrolling.
1276 base::TimeDelta startTimeOffset = base::TimeDelta::FromMilliseconds(10);
1277 gesture_.type = WebInputEvent::GestureFlingStart;
1278 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
1279 WebPoint fling_point = WebPoint(7, 13);
1280 WebPoint fling_global_point = WebPoint(17, 23);
1281 int modifiers = WebInputEvent::ControlKey;
1282 gesture_.timeStampSeconds = startTimeOffset.InSecondsF();
1283 gesture_.data.flingStart.velocityX = fling_delta.x;
1284 gesture_.data.flingStart.velocityY = fling_delta.y;
1285 gesture_.sourceDevice = WebGestureEvent::Touchscreen;
1286 gesture_.x = fling_point.x;
1287 gesture_.y = fling_point.y;
1288 gesture_.globalX = fling_global_point.x;
1289 gesture_.globalY = fling_global_point.y;
1290 gesture_.modifiers = modifiers;
1291 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1292 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1293 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1294 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1295
1296 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1297
1298 // If we get a negative time delta, that is, the Animation tick time happens
1299 // before the fling's start time then we should *not* try scrolling and
1300 // instead reset the fling start time.
1301 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1302 EXPECT_CALL(mock_input_handler_,
1303 ScrollBy(testing::_,
1304 testing::_)).Times(0);
1305 base::TimeTicks time =
1306 base::TimeTicks() + base::TimeDelta::FromMilliseconds(8);
1307 input_handler_->Animate(time);
1308
1309 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1310
1311 // The first call should have reset the start time so subsequent calls should
1312 // generate scroll events.
1313 EXPECT_CALL(mock_input_handler_, ScheduleAnimation());
1314 EXPECT_CALL(mock_input_handler_,
1315 ScrollBy(testing::_,
1316 testing::Property(&gfx::Vector2dF::x, testing::Lt(0))))
1317 .WillOnce(testing::Return(true));
1318
1319 input_handler_->Animate(time + base::TimeDelta::FromMilliseconds(1));
1320
1321 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1322
1323 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1324 gesture_.type = WebInputEvent::GestureFlingCancel;
1325 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1326 }
1327
1260 } // namespace 1328 } // namespace
1261 } // namespace content 1329 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/input_handler_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698