diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
commit | 2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (patch) | |
tree | 988e8c5b116dd0466244ae2fe5af8ee9be926d76 /Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp | |
parent | dd91e772430dc294e3bf478c119ef8d43c0a3358 (diff) | |
download | qtwebkit-2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47.tar.gz |
Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286)
Diffstat (limited to 'Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp')
-rw-r--r-- | Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp b/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp index 74ca57667..362727c04 100644 --- a/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp +++ b/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp @@ -29,7 +29,7 @@ #include "ActivePlatformGestureAnimation.h" #include "PlatformGestureCurveTarget.h" -#include "TouchFlingPlatformGestureCurve.h" +#include "TouchpadFlingPlatformGestureCurve.h" #include "WheelFlingPlatformGestureCurve.h" #include "cc/CCActiveGestureAnimation.h" #include "cc/CCGestureCurve.h" @@ -42,7 +42,7 @@ using namespace WebCore; class MockPlatformGestureCurveTarget : public PlatformGestureCurveTarget { public: - virtual void setScrollIncrement(const IntPoint& delta) + virtual void scrollBy(const IntPoint& delta) { m_cumulativeDelta = m_cumulativeDelta + delta; } @@ -57,7 +57,7 @@ private: TEST(PlatformGestureCurve, flingCurve) { MockPlatformGestureCurveTarget target; - OwnPtr<ActivePlatformGestureAnimation> animation = ActivePlatformGestureAnimation::create(0, WheelFlingPlatformGestureCurve::create(FloatPoint(100, 0)), &target); + OwnPtr<ActivePlatformGestureAnimation> animation = ActivePlatformGestureAnimation::create(WheelFlingPlatformGestureCurve::create(FloatPoint(100, 0)), &target); // Note: the expectations below are dependent on the value of sigma hard-coded in the Rayleigh // curve. If sigma changes, these test expectations will also change. @@ -69,23 +69,24 @@ TEST(PlatformGestureCurve, flingCurve) EXPECT_FALSE(animation->animate(1001)); // Since the Rayleigh CDF maxes out at 1, we expect the cumulative scroll increments to // match the input velocity parameter. - // Since we can be off by +/-0.5 on each conversion to int for setScrollIncrement, - // pick the 'nearness' to be within the number of times animate returns true. EXPECT_NEAR(target.cumulativeDelta().x(), 100, 1); EXPECT_EQ(target.cumulativeDelta().y(), 0); + // Test animation when not starting at t = 0. double baseTime = 42.42; - animation = ActivePlatformGestureAnimation::create(baseTime, WheelFlingPlatformGestureCurve::create(FloatPoint(100, 0)), &target); + animation = ActivePlatformGestureAnimation::create(WheelFlingPlatformGestureCurve::create(FloatPoint(100, 0)), &target); target.resetCumulativeDelta(); EXPECT_TRUE(animation->animate(baseTime + 0.35)); EXPECT_TRUE(animation->animate(baseTime + 1.35)); - EXPECT_FALSE(animation->animate(baseTime + 1000)); + EXPECT_TRUE(animation->animate(baseTime + 1000)); + EXPECT_FALSE(animation->animate(baseTime + 1001)); EXPECT_NEAR(target.cumulativeDelta().x(), 100, 1); - animation = ActivePlatformGestureAnimation::create(0, WheelFlingPlatformGestureCurve::create(FloatPoint(50, 150)), &target); + animation = ActivePlatformGestureAnimation::create(WheelFlingPlatformGestureCurve::create(FloatPoint(50, 150)), &target); target.resetCumulativeDelta(); + // Test animation with both horizontal and vertical scroll velocities. EXPECT_TRUE(animation->animate(0)); EXPECT_TRUE(animation->animate(0.25)); EXPECT_TRUE(animation->animate(0.45)); @@ -98,21 +99,18 @@ TEST(PlatformGestureCurve, flingCurve) TEST(PlatformGestureCurve, flingCurveTouch) { + double initialVelocity = 5000; MockPlatformGestureCurveTarget target; - OwnPtr<ActivePlatformGestureAnimation> animation = ActivePlatformGestureAnimation::create(0, TouchFlingPlatformGestureCurve::create(FloatPoint(1000, 0)), &target); + OwnPtr<ActivePlatformGestureAnimation> animation = ActivePlatformGestureAnimation::create(TouchpadFlingPlatformGestureCurve::create(FloatPoint(initialVelocity, 0)), &target); - // Note: the expectations below are dependent on the value of sigma hard-coded in the Rayleigh - // curve. If sigma changes, these test expectations will also change. + // Note: the expectations below are dependent on the value of sigma hard-coded in the curve parameters. + // If the parameters change, then the tests values/expectations will need to be updated. EXPECT_TRUE(animation->animate(0)); EXPECT_TRUE(animation->animate(0.25)); EXPECT_TRUE(animation->animate(0.45)); // Use non-uniform tick spacing. - EXPECT_TRUE(animation->animate(0.75)); - EXPECT_TRUE(animation->animate(0.9)); - EXPECT_TRUE(animation->animate(1000)); - EXPECT_FALSE(animation->animate(1001)); - // Since we can be off by +/-0.5 on each conversion to int for setScrollIncrement, - // pick the 'nearness' to be within the 5 * number of times animate returns true. - EXPECT_NEAR(target.cumulativeDelta().x(), 1000, 1); + EXPECT_TRUE(animation->animate(1)); + EXPECT_FALSE(animation->animate(1.5)); + EXPECT_NEAR(target.cumulativeDelta().x(), 1193, 1); EXPECT_EQ(target.cumulativeDelta().y(), 0); } |