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

Side by Side Diff: ui/events/gestures/fling_curve_unittest.cc

Issue 634373003: Consolidate content fling implementations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win build Created 6 years, 2 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
« no previous file with comments | « ui/events/gestures/fling_curve.cc ('k') | ui/gfx/BUILD.gn » ('j') | 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 "ui/events/gestures/fling_curve.h" 5 #include "ui/events/gestures/fling_curve.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/gfx/frame_time.h" 8 #include "ui/gfx/frame_time.h"
9 9
10 namespace ui { 10 namespace ui {
11 11
12 TEST(FlingCurveTest, Basic) { 12 TEST(FlingCurveTest, Basic) {
13 const gfx::Vector2dF velocity(0, 5000); 13 const gfx::Vector2dF velocity(0, 5000);
14 base::TimeTicks now = gfx::FrameTime::Now(); 14 base::TimeTicks now = gfx::FrameTime::Now();
15 FlingCurve curve(velocity, now); 15 FlingCurve curve(velocity, now);
16 16
17 gfx::Vector2dF scroll = 17 gfx::Vector2dF delta;
18 curve.GetScrollAmountAtTime(now + base::TimeDelta::FromMilliseconds(20)); 18 EXPECT_TRUE(curve.ComputeScrollDeltaAtTime(
19 EXPECT_EQ(0, scroll.x()); 19 now + base::TimeDelta::FromMilliseconds(20), &delta));
20 EXPECT_NEAR(scroll.y(), 96, 1); 20 EXPECT_EQ(0, delta.x());
21 EXPECT_NEAR(delta.y(), 96, 1);
21 22
22 scroll = 23 EXPECT_TRUE(curve.ComputeScrollDeltaAtTime(
23 curve.GetScrollAmountAtTime(now + base::TimeDelta::FromMilliseconds(250)); 24 now + base::TimeDelta::FromMilliseconds(250), &delta));
24 EXPECT_EQ(0, scroll.x()); 25 EXPECT_EQ(0, delta.x());
25 EXPECT_NEAR(scroll.y(), 705, 1); 26 EXPECT_NEAR(delta.y(), 705, 1);
26 27
27 scroll = 28 EXPECT_FALSE(curve.ComputeScrollDeltaAtTime(
28 curve.GetScrollAmountAtTime(now + base::TimeDelta::FromSeconds(10)); 29 now + base::TimeDelta::FromSeconds(10), &delta));
29 EXPECT_EQ(0, scroll.x()); 30 EXPECT_EQ(0, delta.x());
30 EXPECT_NEAR(scroll.y(), 392, 1); 31 EXPECT_NEAR(delta.y(), 392, 1);
31 32
32 EXPECT_TRUE(curve.GetScrollAmountAtTime( 33 EXPECT_FALSE(curve.ComputeScrollDeltaAtTime(
33 now + base::TimeDelta::FromSeconds(20)).IsZero()); 34 now + base::TimeDelta::FromSeconds(20), &delta));
35 EXPECT_TRUE(delta.IsZero());
34 } 36 }
35 37
36 } // namespace ui 38 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gestures/fling_curve.cc ('k') | ui/gfx/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698