Bug 1031024 - Add a test for canceling fling animations to ensure overscroll is cleared. r=drs

This commit is contained in:
Kartikaya Gupta 2014-06-27 16:39:27 -04:00
parent 152866bf25
commit 6d818f7c22

View File

@ -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<MockContentController> mcc = new NiceMock<MockContentController>();
nsRefPtr<TestAPZCTreeManager> tm = new TestAPZCTreeManager();
nsRefPtr<TestAsyncPanZoomController> 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<MockContentControllerDelayed> mcc = new NiceMock<MockContentControllerDelayed>();
nsRefPtr<TestAPZCTreeManager> tm = new TestAPZCTreeManager();