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. 4 5#include "ui/events/gestures/fling_curve.h" 6 7#include "testing/gtest/include/gtest/gtest.h" 8#include "ui/gfx/frame_time.h" 9 10namespace ui { 11 12TEST(FlingCurveTest, Basic) { 13 const gfx::Vector2dF velocity(0, 5000); 14 base::TimeTicks now = gfx::FrameTime::Now(); 15 FlingCurve curve(velocity, now); 16 17 gfx::Vector2dF scroll = 18 curve.GetScrollAmountAtTime(now + base::TimeDelta::FromMilliseconds(20)); 19 EXPECT_EQ(0, scroll.x()); 20 EXPECT_NEAR(scroll.y(), 96, 1); 21 22 scroll = 23 curve.GetScrollAmountAtTime(now + base::TimeDelta::FromMilliseconds(250)); 24 EXPECT_EQ(0, scroll.x()); 25 EXPECT_NEAR(scroll.y(), 705, 1); 26 27 scroll = 28 curve.GetScrollAmountAtTime(now + base::TimeDelta::FromSeconds(10)); 29 EXPECT_EQ(0, scroll.x()); 30 EXPECT_NEAR(scroll.y(), 392, 1); 31 32 EXPECT_TRUE(curve.GetScrollAmountAtTime( 33 now + base::TimeDelta::FromSeconds(20)).IsZero()); 34} 35 36} // namespace ui 37