Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / events / gestures / fling_curve_unittest.cc
blob540dc633a1d4eac91199b799e84bb7063fd96fbc
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"
9 namespace ui {
11 TEST(FlingCurveTest, Basic) {
12 const gfx::Vector2dF velocity(0, 5000);
13 base::TimeTicks now = base::TimeTicks::Now();
14 FlingCurve curve(velocity, now);
16 gfx::Vector2dF delta;
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());
37 } // namespace ui