From 6d818f7c22263ac5818cfcf965297262176aaa6e Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Fri, 27 Jun 2014 16:39:27 -0400 Subject: [PATCH] Bug 1031024 - Add a test for canceling fling animations to ensure overscroll is cleared. r=drs --- .../gtest/TestAsyncPanZoomController.cpp | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/gfx/tests/gtest/TestAsyncPanZoomController.cpp b/gfx/tests/gtest/TestAsyncPanZoomController.cpp index ce85b87d7be1..0387161a127e 100644 --- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp +++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp @@ -953,6 +953,44 @@ TEST_F(AsyncPanZoomControllerTester, OverScrollPanning) { apzc->Destroy(); } +TEST_F(AsyncPanZoomControllerTester, OverScrollAbort) { + TestScopedBoolPref overscrollEnabledPref("apz.overscroll.enabled", true); + + TimeStamp testStartTime = TimeStamp::Now(); + AsyncPanZoomController::SetFrameTime(testStartTime); + + nsRefPtr mcc = new NiceMock(); + nsRefPtr tm = new TestAPZCTreeManager(); + nsRefPtr apzc = new TestAsyncPanZoomController(0, mcc, tm); + + apzc->SetFrameMetrics(TestFrameMetrics()); + apzc->NotifyLayersUpdated(TestFrameMetrics(), true); + + // Pan sufficiently to hit overscroll behavior + int time = 0; + int touchStart = 500; + int touchEnd = 10; + ApzcPan(apzc, tm, time, touchStart, touchEnd); + EXPECT_TRUE(apzc->IsOverscrolled()); + + ScreenPoint pointOut; + ViewTransform viewTransformOut; + + // This sample call will run to the end of the non-overscrolling fling animation + // and will schedule the overscrolling fling animation (see comment in OverScrollPanning + // above for more explanation). + apzc->SampleContentTransformForFrame(testStartTime + TimeDuration::FromMilliseconds(10000), &viewTransformOut, pointOut); + EXPECT_TRUE(apzc->IsOverscrolled()); + + // At this point, we have an active overscrolling fling animation. + // Check that cancelling the animation clears the overscroll. + apzc->CancelAnimation(); + EXPECT_FALSE(apzc->IsOverscrolled()); + apzc->AssertStateIsReset(); + + apzc->Destroy(); +} + TEST_F(AsyncPanZoomControllerTester, ShortPress) { nsRefPtr mcc = new NiceMock(); nsRefPtr tm = new TestAPZCTreeManager();