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

Unified Diff: ui/events/gesture_detection/gesture_provider_unittest.cc

Issue 183013010: Don't send touchcancel on touch scroll start (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a couple tests Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/gesture_detection/gesture_provider_unittest.cc
diff --git a/ui/events/gesture_detection/gesture_provider_unittest.cc b/ui/events/gesture_detection/gesture_provider_unittest.cc
index ddeb191ed250e3c932cd873d3e0d879e9fd593ed..de4562ee8ed3504505a5f6373c2f154542d295e9 100644
--- a/ui/events/gesture_detection/gesture_provider_unittest.cc
+++ b/ui/events/gesture_detection/gesture_provider_unittest.cc
@@ -516,6 +516,57 @@ TEST_F(GestureProviderTest, ScrollUpdateValues) {
EXPECT_EQ(-delta_y / 2, gesture.details.scroll_update.delta_y);
}
+// Verify that fractional scroll deltas are rounded as expected and that
+// fractional scrolling doesn't break scroll snapping.
+TEST_F(GestureProviderTest, FractionalScroll) {
Rick Byers 2014/03/07 20:58:53 This was a case I initially thought was broken but
jdduke (slow) 2014/03/07 21:07:32 Yeah this is great. I can hold off with the timin
+ const float delta_x = 0.4;
+ const float delta_y = 5.2;
+
+ const base::TimeTicks event_time = TimeTicks::Now();
+
+ MockMotionEvent event =
+ ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+
+ // Skip past the touch slop and move back.
+ event = ObtainMotionEvent(event_time,
+ MotionEvent::ACTION_MOVE,
+ kFakeCoordX,
+ kFakeCoordY + 100);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+ event = ObtainMotionEvent(event_time,
+ MotionEvent::ACTION_MOVE);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+
+ // Now move up slowly, mostly vertically but with a (fractional) bit of
+ // horizontal motion.
+ for(int i = 1; i <= 10; i++) {
+ event = ObtainMotionEvent(event_time + kFiveMilliseconds * i,
+ MotionEvent::ACTION_MOVE,
+ kFakeCoordX + delta_x * i,
+ kFakeCoordY + delta_y * i);
+ EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
+
+ ASSERT_LT(0U, GetReceivedGestureCount());
+ GestureEventData gesture = GetMostRecentGestureEvent();
+ EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, gesture.type);
+ EXPECT_EQ(event_time + kFiveMilliseconds * i, gesture.time);
+
+ // Verify that the event co-ordinates are still the precise values we
+ // supplied.
+ EXPECT_EQ(kFakeCoordX + delta_x * i, gesture.x);
+ EXPECT_EQ(kFakeCoordY + delta_y * i, gesture.y);
+
+ // Verify that we're scrolling vertically by the expected amount
+ // (modulo rounding).
+ EXPECT_GE(gesture.details.scroll_update.delta_y, (int)delta_y);
+ EXPECT_LE(gesture.details.scroll_update.delta_y, ((int)delta_y) + 1);
+
+ // And that there has been no horizontal motion at all.
+ EXPECT_EQ(0, gesture.details.scroll_update.delta_x);
+ }
+}
+
// Generate a scroll gesture and verify that the resulting scroll begin event
// has the expected hint values.
TEST_F(GestureProviderTest, ScrollBeginValues) {

Powered by Google App Engine
This is Rietveld 408576698