Index: ui/events/gestures/fling_curve_unittest.cc |
diff --git a/ui/events/gestures/fling_curve_unittest.cc b/ui/events/gestures/fling_curve_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..653a5effff8c9ea5cf2bf64f683183eca156cc76 |
--- /dev/null |
+++ b/ui/events/gestures/fling_curve_unittest.cc |
@@ -0,0 +1,36 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ui/events/gestures/fling_curve.h" |
+ |
+#include "testing/gtest/include/gtest/gtest.h" |
+#include "ui/gfx/frame_time.h" |
+ |
+namespace ui { |
+ |
+TEST(FlingCurveTest, Basic) { |
+ const gfx::Vector2dF velocity(0, 5000); |
+ base::TimeTicks now = gfx::FrameTime::Now(); |
+ FlingCurve curve(velocity, now); |
+ |
+ gfx::Vector2dF scroll = |
+ curve.GetScrollAmountAtTime(now + base::TimeDelta::FromMilliseconds(20)); |
+ EXPECT_EQ(0, scroll.x()); |
+ EXPECT_NEAR(scroll.y(), 96, 1); |
+ |
+ scroll = |
+ curve.GetScrollAmountAtTime(now + base::TimeDelta::FromMilliseconds(250)); |
+ EXPECT_EQ(0, scroll.x()); |
+ EXPECT_NEAR(scroll.y(), 705, 1); |
+ |
+ scroll = |
+ curve.GetScrollAmountAtTime(now + base::TimeDelta::FromSeconds(10)); |
+ EXPECT_EQ(0, scroll.x()); |
+ EXPECT_NEAR(scroll.y(), 392, 1); |
+ |
+ EXPECT_TRUE(curve.GetScrollAmountAtTime( |
+ now + base::TimeDelta::FromSeconds(20)).IsZero()); |
+} |
+ |
+} // namespace ui |