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

Side by Side Diff: ui/events/gesture_detection/gesture_provider_unittest.cc

Issue 1049383003: Postpone rail application for touch scrolling - chrome side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 ASSERT_LT(0U, GetReceivedGestureCount()); 832 ASSERT_LT(0U, GetReceivedGestureCount());
833 GestureEventData gesture = GetMostRecentGestureEvent(); 833 GestureEventData gesture = GetMostRecentGestureEvent();
834 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, gesture.type()); 834 EXPECT_EQ(ET_GESTURE_SCROLL_UPDATE, gesture.type());
835 EXPECT_EQ(event_time + kOneMicrosecond * 2, gesture.time); 835 EXPECT_EQ(event_time + kOneMicrosecond * 2, gesture.time);
836 EXPECT_EQ(kFakeCoordX - delta_x, gesture.x); 836 EXPECT_EQ(kFakeCoordX - delta_x, gesture.x);
837 EXPECT_EQ(kFakeCoordY - delta_y, gesture.y); 837 EXPECT_EQ(kFakeCoordY - delta_y, gesture.y);
838 EXPECT_EQ(kFakeCoordX - delta_x + raw_offset_x, gesture.raw_x); 838 EXPECT_EQ(kFakeCoordX - delta_x + raw_offset_x, gesture.raw_x);
839 EXPECT_EQ(kFakeCoordY - delta_y + raw_offset_y, gesture.raw_y); 839 EXPECT_EQ(kFakeCoordY - delta_y + raw_offset_y, gesture.raw_y);
840 EXPECT_EQ(1, gesture.details.touch_points()); 840 EXPECT_EQ(1, gesture.details.touch_points());
841 841
842 // No horizontal delta because of snapping. 842 EXPECT_EQ(-delta_x / 2, gesture.details.scroll_x());
843 EXPECT_EQ(0, gesture.details.scroll_x());
844 EXPECT_EQ(-delta_y / 2, gesture.details.scroll_y()); 843 EXPECT_EQ(-delta_y / 2, gesture.details.scroll_y());
844 EXPECT_EQ(GestureEventDetails::ScrollRailState::Vertical,
845 gesture.details.scroll_rail_state());
845 } 846 }
846 847
847 // Verify that fractional scroll deltas are rounded as expected and that 848 // Verify that fractional scroll deltas are rounded as expected and that
848 // fractional scrolling doesn't break scroll snapping. 849 // fractional scrolling doesn't break scroll snapping.
849 TEST_F(GestureProviderTest, FractionalScroll) { 850 TEST_F(GestureProviderTest, FractionalScroll) {
850 const float delta_x = 0.4f; 851 const float delta_x = 0.4f;
851 const float delta_y = 5.2f; 852 const float delta_y = 5.2f;
852 853
853 const base::TimeTicks event_time = TimeTicks::Now(); 854 const base::TimeTicks event_time = TimeTicks::Now();
854 855
(...skipping 29 matching lines...) Expand all
884 // Verify that the event co-ordinates are still the precise values we 885 // Verify that the event co-ordinates are still the precise values we
885 // supplied. 886 // supplied.
886 EXPECT_EQ(kFakeCoordX + delta_x * i, gesture.x); 887 EXPECT_EQ(kFakeCoordX + delta_x * i, gesture.x);
887 EXPECT_FLOAT_EQ(kFakeCoordY + delta_y * i, gesture.y); 888 EXPECT_FLOAT_EQ(kFakeCoordY + delta_y * i, gesture.y);
888 889
889 // Verify that we're scrolling vertically by the expected amount 890 // Verify that we're scrolling vertically by the expected amount
890 // (modulo rounding). 891 // (modulo rounding).
891 EXPECT_GE(gesture.details.scroll_y(), (int)delta_y); 892 EXPECT_GE(gesture.details.scroll_y(), (int)delta_y);
892 EXPECT_LE(gesture.details.scroll_y(), ((int)delta_y) + 1); 893 EXPECT_LE(gesture.details.scroll_y(), ((int)delta_y) + 1);
893 894
894 // And that there has been no horizontal motion at all. 895 // And that there has been very little horizontal motion.
895 EXPECT_EQ(0, gesture.details.scroll_x()); 896 EXPECT_GT(gesture.details.scroll_x(), 0);
897 EXPECT_LT(gesture.details.scroll_x(), 0.5);
898 EXPECT_EQ(GestureEventDetails::ScrollRailState::Vertical,
899 gesture.details.scroll_rail_state());
896 } 900 }
897 } 901 }
898 902
899 // Generate a scroll gesture and verify that the resulting scroll begin event 903 // Generate a scroll gesture and verify that the resulting scroll begin event
900 // has the expected hint values. 904 // has the expected hint values.
901 TEST_F(GestureProviderTest, ScrollBeginValues) { 905 TEST_F(GestureProviderTest, ScrollBeginValues) {
902 const float delta_x = 13; 906 const float delta_x = 13;
903 const float delta_y = 89; 907 const float delta_y = 89;
904 908
905 const base::TimeTicks event_time = TimeTicks::Now(); 909 const base::TimeTicks event_time = TimeTicks::Now();
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after
2520 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); 2524 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event));
2521 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); 2525 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType());
2522 2526
2523 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); 2527 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count());
2524 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); 2528 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points());
2525 EXPECT_EQ(gfx::RectF(0, 0, 20, 20), 2529 EXPECT_EQ(gfx::RectF(0, 0, 20, 20),
2526 GetMostRecentGestureEvent().details.bounding_box()); 2530 GetMostRecentGestureEvent().details.bounding_box());
2527 } 2531 }
2528 2532
2529 } // namespace ui 2533 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698