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

Unified Diff: ui/gfx/android/scroller_unittest.cc

Issue 136173004: Early terminate flings when scrolling impossible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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
« no previous file with comments | « ui/gfx/android/scroller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/android/scroller_unittest.cc
diff --git a/ui/gfx/android/scroller_unittest.cc b/ui/gfx/android/scroller_unittest.cc
index af3c67a1b027ab9d22e5cb179ecfdc13608a015d..9b1018d6ab9c38bd6d7d93000b464c749a7226b7 100644
--- a/ui/gfx/android/scroller_unittest.cc
+++ b/ui/gfx/android/scroller_unittest.cc
@@ -63,6 +63,18 @@ TEST_F(ScrollerTest, Scroll) {
EXPECT_GT(0.f, scroller.GetCurrVelocityY() * kDefaultDeltaY);
EXPECT_TRUE(scroller.IsScrollingInDirection(kDefaultDeltaX, kDefaultDeltaY));
+ // Repeated offset computations at the same timestamp should yield identical
+ // results.
+ float curr_x = scroller.GetCurrX();
+ float curr_y = scroller.GetCurrY();
+ float curr_velocity_x = scroller.GetCurrVelocityX();
+ float curr_velocity_y = scroller.GetCurrVelocityY();
+ scroller.ComputeScrollOffset(start_time + scroll_duration / 2);
+ EXPECT_EQ(curr_x, scroller.GetCurrX());
+ EXPECT_EQ(curr_y, scroller.GetCurrY());
+ EXPECT_EQ(curr_velocity_x, scroller.GetCurrVelocityX());
+ EXPECT_EQ(curr_velocity_y, scroller.GetCurrVelocityY());
+
// Advance to the end.
scroller.ComputeScrollOffset(start_time + scroll_duration);
EXPECT_EQ(scroller.GetFinalX(), scroller.GetCurrX());
@@ -123,6 +135,18 @@ TEST_F(ScrollerTest, Fling) {
EXPECT_TRUE(
scroller.IsScrollingInDirection(kDefaultVelocityX, kDefaultVelocityY));
+ // Repeated offset computations at the same timestamp should yield identical
+ // results.
+ float curr_x = scroller.GetCurrX();
+ float curr_y = scroller.GetCurrY();
+ float curr_velocity_x = scroller.GetCurrVelocityX();
+ float curr_velocity_y = scroller.GetCurrVelocityY();
+ scroller.ComputeScrollOffset(start_time + scroll_duration / 2);
+ EXPECT_EQ(curr_x, scroller.GetCurrX());
+ EXPECT_EQ(curr_y, scroller.GetCurrY());
+ EXPECT_EQ(curr_velocity_x, scroller.GetCurrVelocityX());
+ EXPECT_EQ(curr_velocity_y, scroller.GetCurrVelocityY());
+
// Advance to the end.
scroller.ComputeScrollOffset(start_time + scroll_duration);
EXPECT_EQ(scroller.GetFinalX(), scroller.GetCurrX());
« no previous file with comments | « ui/gfx/android/scroller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698