зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1706865. Add test. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D113501
This commit is contained in:
Родитель
591164dc82
Коммит
38c8c055c5
|
@ -358,3 +358,76 @@ TEST_F(APZCBasicTester, MultipleSmoothScrollsSmooth) {
|
|||
lastOffset = offset;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(APZCBasicTester, ZoomAndScrollableRectChangeAfterZoomChange) {
|
||||
// We want to check that a small scrollable rect change (which causes us to
|
||||
// reclamp our scroll position, including in the sampled state) does not move
|
||||
// the scroll offset in the sample state based the zoom in the apzc, only
|
||||
// based on the zoom in the sampled state.
|
||||
|
||||
// First we zoom in to the right hand side. Then start zooming out, then send
|
||||
// a scrollable rect change and check that it doesn't change the sampled state
|
||||
// scroll offset.
|
||||
|
||||
ScrollMetadata metadata;
|
||||
FrameMetrics& metrics = metadata.GetMetrics();
|
||||
metrics.SetCompositionBounds(ParentLayerRect(0, 0, 100, 100));
|
||||
metrics.SetScrollableRect(CSSRect(0, 0, 100, 1000));
|
||||
metrics.SetLayoutViewport(CSSRect(0, 0, 100, 100));
|
||||
metrics.SetVisualScrollOffset(CSSPoint(0, 0));
|
||||
metrics.SetZoom(CSSToParentLayerScale2D(1.0, 1.0));
|
||||
metrics.SetIsRootContent(true);
|
||||
apzc->SetFrameMetrics(metrics);
|
||||
|
||||
MakeApzcZoomable();
|
||||
|
||||
// Zoom to right side.
|
||||
ZoomTarget zoomTarget{CSSRect(75, 25, 25, 25), Nothing()};
|
||||
apzc->ZoomToRect(zoomTarget, 0);
|
||||
|
||||
// Run the animation to completion, should take 250ms/16.67ms = 15 frames, but
|
||||
// do extra to make sure.
|
||||
for (uint32_t i = 0; i < 30; i++) {
|
||||
SampleAnimationOneFrame();
|
||||
}
|
||||
|
||||
EXPECT_FALSE(apzc->IsAsyncZooming());
|
||||
|
||||
// Zoom out.
|
||||
ZoomTarget zoomTarget2{CSSRect(0, 0, 100, 100), Nothing()};
|
||||
apzc->ZoomToRect(zoomTarget2, 0);
|
||||
|
||||
// Run the animation a few times to get it going.
|
||||
for (uint32_t i = 0; i < 2; i++) {
|
||||
SampleAnimationOneFrame();
|
||||
}
|
||||
|
||||
// Check that it is decreasing in scale.
|
||||
float prevScale =
|
||||
apzc->GetCurrentPinchZoomScale(AsyncPanZoomController::eForCompositing)
|
||||
.scale;
|
||||
for (uint32_t i = 0; i < 2; i++) {
|
||||
SampleAnimationOneFrame();
|
||||
float scale =
|
||||
apzc->GetCurrentPinchZoomScale(AsyncPanZoomController::eForCompositing)
|
||||
.scale;
|
||||
ASSERT_GT(prevScale, scale);
|
||||
prevScale = scale;
|
||||
}
|
||||
|
||||
float offset =
|
||||
apzc->GetCurrentAsyncScrollOffset(AsyncPanZoomController::eForCompositing)
|
||||
.x;
|
||||
|
||||
// Change the scrollable rect slightly to trigger a reclamp.
|
||||
ScrollMetadata metadata2 = metadata;
|
||||
metadata2.GetMetrics().SetScrollableRect(CSSRect(0, 0, 100, 1000.2));
|
||||
apzc->NotifyLayersUpdated(metadata2, /*isFirstPaint=*/false,
|
||||
/*thisLayerTreeUpdated=*/true);
|
||||
|
||||
float newOffset =
|
||||
apzc->GetCurrentAsyncScrollOffset(AsyncPanZoomController::eForCompositing)
|
||||
.x;
|
||||
|
||||
ASSERT_EQ(newOffset, offset);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче