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
3 // found in the LICENSE file.
5 #include "ui/events/gestures/fling_curve.h"
7 #include "testing/gtest/include/gtest/gtest.h"
11 TEST(FlingCurveTest
, Basic
) {
12 const gfx::Vector2dF
velocity(0, 5000);
13 base::TimeTicks now
= base::TimeTicks::Now();
14 FlingCurve
curve(velocity
, now
);
17 EXPECT_TRUE(curve
.ComputeScrollDeltaAtTime(
18 now
+ base::TimeDelta::FromMilliseconds(20), &delta
));
19 EXPECT_EQ(0, delta
.x());
20 EXPECT_NEAR(delta
.y(), 96, 1);
22 EXPECT_TRUE(curve
.ComputeScrollDeltaAtTime(
23 now
+ base::TimeDelta::FromMilliseconds(250), &delta
));
24 EXPECT_EQ(0, delta
.x());
25 EXPECT_NEAR(delta
.y(), 705, 1);
27 EXPECT_FALSE(curve
.ComputeScrollDeltaAtTime(
28 now
+ base::TimeDelta::FromSeconds(10), &delta
));
29 EXPECT_EQ(0, delta
.x());
30 EXPECT_NEAR(delta
.y(), 392, 1);
32 EXPECT_FALSE(curve
.ComputeScrollDeltaAtTime(
33 now
+ base::TimeDelta::FromSeconds(20), &delta
));
34 EXPECT_TRUE(delta
.IsZero());