From 5cc523e77d837268099303703417a34ffda5ccc3 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Fri, 29 May 2015 11:04:22 -0400 Subject: [PATCH] Bug 1166871 - Add a test. r=botond --- gfx/layers/apz/src/AsyncPanZoomController.cpp | 1 + .../gtest/TestAsyncPanZoomController.cpp | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 13fc4c94c2d..df9ffbf0d86 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -1505,6 +1505,7 @@ AsyncPanZoomController::AllowScrollHandoffInWheelTransaction() const nsEventStatus AsyncPanZoomController::OnScrollWheel(const ScrollWheelInput& aEvent) { LayoutDevicePoint delta = GetScrollWheelDelta(aEvent); + APZC_LOG("%p got a scroll-wheel with delta %s\n", this, Stringify(delta).c_str()); if ((delta.x || delta.y) && !CanScrollWithWheel(delta) && diff --git a/gfx/tests/gtest/TestAsyncPanZoomController.cpp b/gfx/tests/gtest/TestAsyncPanZoomController.cpp index 61005661135..7746fb22abf 100644 --- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp +++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp @@ -1899,6 +1899,8 @@ protected: layerBound.width, layerBound.height)); metrics.SetScrollableRect(aScrollableRect); metrics.SetScrollOffset(CSSPoint(0, 0)); + metrics.SetPageScrollAmount(LayoutDeviceIntSize(50, 100)); + metrics.SetAllowVerticalScrollWithWheel(); aLayer->SetFrameMetrics(metrics); aLayer->SetClipRect(Some(ViewAs(layerBound))); if (!aScrollableRect.IsEqualEdges(CSSRect(-1, -1, -1, -1))) { @@ -2424,6 +2426,37 @@ TEST_F(APZHitTestingTester, TestRepaintFlushOnNewInputBlock) { mcc->RunThroughDelayedTasks(); } +TEST_F(APZHitTestingTester, TestRepaintFlushOnWheelEvents) { + // The purpose of this test is to ensure that wheel events trigger a repaint + // flush as per bug 1166871, and that the wheel event untransform is a no-op. + + CreateSimpleScrollingLayer(); + ScopedLayerTreeRegistration registration(0, root, mcc); + manager->UpdateHitTestingTree(nullptr, root, false, 0, 0); + TestAsyncPanZoomController* apzcroot = ApzcOf(root); + + EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(AtLeast(3)); + ScreenPoint origin(100, 50); + for (int i = 0; i < 3; i++) { + ScrollWheelInput swi(MillisecondsSinceStartup(mTime), mTime, 0, + ScrollWheelInput::SCROLLMODE_INSTANT, ScrollWheelInput::SCROLLDELTA_PIXEL, + origin, 0, 10); + EXPECT_EQ(nsEventStatus_eConsumeDoDefault, manager->ReceiveInputEvent(swi, nullptr, nullptr)); + EXPECT_EQ(origin, swi.mOrigin); + + ViewTransform viewTransform; + ParentLayerPoint point; + apzcroot->SampleContentTransformForFrame(mTime, &viewTransform, point); + EXPECT_EQ(0, point.x); + EXPECT_EQ((i + 1) * 10, point.y); + EXPECT_EQ(0, viewTransform.mTranslation.x); + EXPECT_EQ((i + 1) * -10, viewTransform.mTranslation.y); + + mTime += TimeDuration::FromMilliseconds(5); + } + mcc->RunThroughDelayedTasks(); +} + TEST_F(APZHitTestingTester, Bug1148350) { CreateBug1148350LayerTree(); ScopedLayerTreeRegistration registration(0, root, mcc);