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

Side by Side 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: Fix win compile warning 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/input/touch_event_queue_unittest.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, gesture.type); 509 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, gesture.type);
510 EXPECT_EQ(event_time + kFiveMilliseconds * 2, gesture.time); 510 EXPECT_EQ(event_time + kFiveMilliseconds * 2, gesture.time);
511 EXPECT_EQ(kFakeCoordX - delta_x, gesture.x); 511 EXPECT_EQ(kFakeCoordX - delta_x, gesture.x);
512 EXPECT_EQ(kFakeCoordY - delta_y, gesture.y); 512 EXPECT_EQ(kFakeCoordY - delta_y, gesture.y);
513 513
514 // No horizontal delta because of snapping. 514 // No horizontal delta because of snapping.
515 EXPECT_EQ(0, gesture.details.scroll_update.delta_x); 515 EXPECT_EQ(0, gesture.details.scroll_update.delta_x);
516 EXPECT_EQ(-delta_y / 2, gesture.details.scroll_update.delta_y); 516 EXPECT_EQ(-delta_y / 2, gesture.details.scroll_update.delta_y);
517 } 517 }
518 518
519 // Verify that fractional scroll deltas are rounded as expected and that
520 // fractional scrolling doesn't break scroll snapping.
521 TEST_F(GestureProviderTest, FractionalScroll) {
522 const float delta_x = 0.4f;
523 const float delta_y = 5.2f;
524
525 const base::TimeTicks event_time = TimeTicks::Now();
526
527 MockMotionEvent event =
528 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
529 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
530
531 // Skip past the touch slop and move back.
532 event = ObtainMotionEvent(event_time,
533 MotionEvent::ACTION_MOVE,
534 kFakeCoordX,
535 kFakeCoordY + 100);
536 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
537 event = ObtainMotionEvent(event_time,
538 MotionEvent::ACTION_MOVE);
539 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
540
541 // Now move up slowly, mostly vertically but with a (fractional) bit of
542 // horizontal motion.
543 for(int i = 1; i <= 10; i++) {
544 event = ObtainMotionEvent(event_time + kFiveMilliseconds * i,
545 MotionEvent::ACTION_MOVE,
546 kFakeCoordX + delta_x * i,
547 kFakeCoordY + delta_y * i);
548 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
549
550 ASSERT_LT(0U, GetReceivedGestureCount());
551 GestureEventData gesture = GetMostRecentGestureEvent();
552 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, gesture.type);
553 EXPECT_EQ(event_time + kFiveMilliseconds * i, gesture.time);
554
555 // Verify that the event co-ordinates are still the precise values we
556 // supplied.
557 EXPECT_EQ(kFakeCoordX + delta_x * i, gesture.x);
558 EXPECT_EQ(kFakeCoordY + delta_y * i, gesture.y);
559
560 // Verify that we're scrolling vertically by the expected amount
561 // (modulo rounding).
562 EXPECT_GE(gesture.details.scroll_update.delta_y, (int)delta_y);
563 EXPECT_LE(gesture.details.scroll_update.delta_y, ((int)delta_y) + 1);
564
565 // And that there has been no horizontal motion at all.
566 EXPECT_EQ(0, gesture.details.scroll_update.delta_x);
567 }
568 }
569
519 // Generate a scroll gesture and verify that the resulting scroll begin event 570 // Generate a scroll gesture and verify that the resulting scroll begin event
520 // has the expected hint values. 571 // has the expected hint values.
521 TEST_F(GestureProviderTest, ScrollBeginValues) { 572 TEST_F(GestureProviderTest, ScrollBeginValues) {
522 const int delta_x = 13; 573 const int delta_x = 13;
523 const int delta_y = 89; 574 const int delta_y = 89;
524 575
525 const base::TimeTicks event_time = TimeTicks::Now(); 576 const base::TimeTicks event_time = TimeTicks::Now();
526 577
527 MockMotionEvent event = 578 MockMotionEvent event =
528 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN); 579 ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN);
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 MotionEvent::ACTION_UP); 1063 MotionEvent::ACTION_UP);
1013 EXPECT_FALSE(gesture_provider_->OnTouchEvent(event)); 1064 EXPECT_FALSE(gesture_provider_->OnTouchEvent(event));
1014 1065
1015 event = ObtainMotionEvent(event_time + kFiveMilliseconds * 3, 1066 event = ObtainMotionEvent(event_time + kFiveMilliseconds * 3,
1016 MotionEvent::ACTION_DOWN); 1067 MotionEvent::ACTION_DOWN);
1017 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 1068 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
1018 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType()); 1069 EXPECT_EQ(ET_GESTURE_TAP_DOWN, GetMostRecentGestureEventType());
1019 } 1070 }
1020 1071
1021 } // namespace ui 1072 } // namespace ui
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/touch_event_queue_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698