Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Unified Diff: cc/layer_tree_host_impl_unittest.cc

Issue 12045002: Delete zoomed_viewport_offset_ and its users. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add imports for DisabledTest and rebase to 179449 Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layer_tree_host_impl.cc ('k') | cc/layer_tree_host_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layer_tree_host_impl_unittest.cc
diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc
index d707b46f90622c4c4f88256542e232c218e1e386..7eb981385a278f1561938345f4810cc9affb9c42 100644
--- a/cc/layer_tree_host_impl_unittest.cc
+++ b/cc/layer_tree_host_impl_unittest.cc
@@ -572,25 +572,6 @@ TEST_P(LayerTreeHostImplTest, implPinchZoom)
const float minPageScale = 1, maxPageScale = 4;
const gfx::Transform identityScaleTransform;
- // The impl-based pinch zoom should not adjust the max scroll position.
- {
- m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- scrollLayer->setImplTransform(identityScaleTransform);
- scrollLayer->setScrollDelta(gfx::Vector2d());
-
- float pageScaleDelta = 2;
- m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
- m_hostImpl->pinchGestureEnd();
- EXPECT_TRUE(m_didRequestRedraw);
- EXPECT_TRUE(m_didRequestCommit);
-
- scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
- EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
-
- EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(50, 50));
- }
-
// Scrolling after a pinch gesture should always be in local space. The scroll deltas do not
// have the page scale factor applied.
{
@@ -773,121 +754,6 @@ TEST_P(LayerTreeHostImplTest, pageScaleAnimation)
}
}
-TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
-{
- setupScrollAndContentsLayers(gfx::Size(100, 100));
- m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
- initializeRendererAndDrawFrame();
-
- LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
- DCHECK(scrollLayer);
-
- const float minPageScale = m_hostImpl->settings().pageScalePinchZoomEnabled ? 1 : 0.5;
- const float maxPageScale = 4;
-
- // Pinch zoom in.
- {
- // Start a pinch in gesture at the bottom right corner of the viewport.
- const float zoomInDelta = 2;
- m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(zoomInDelta, gfx::Point(50, 50));
-
- // Because we are pinch zooming in, we shouldn't get any scroll or page
- // scale deltas.
- scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
- EXPECT_EQ(scrollInfo->pageScaleDelta, 1);
- EXPECT_EQ(scrollInfo->scrolls.size(), 0u);
-
- // Once the gesture ends, we get the final scroll and page scale values.
- m_hostImpl->pinchGestureEnd();
- scrollInfo = m_hostImpl->processScrollDeltas();
- EXPECT_EQ(scrollInfo->pageScaleDelta, zoomInDelta);
- if (!m_hostImpl->settings().pageScalePinchZoomEnabled) {
- expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25));
- } else {
- EXPECT_TRUE(scrollInfo->scrolls.empty());
- }
- }
-
- // Pinch zoom out.
- {
- // Start a pinch out gesture at the bottom right corner of the viewport.
- const float zoomOutDelta = 0.75;
- m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(zoomOutDelta, gfx::Point(50, 50));
-
- // Since we are pinch zooming out, we should get an update to zoom all
- // the way out to the minimum page scale.
- scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
- if (!m_hostImpl->settings().pageScalePinchZoomEnabled) {
- EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
- expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(0, 0));
- } else {
- EXPECT_EQ(scrollInfo->pageScaleDelta, 1);
- EXPECT_TRUE(scrollInfo->scrolls.empty());
- }
-
- // Once the gesture ends, we get the final scroll and page scale values.
- m_hostImpl->pinchGestureEnd();
- scrollInfo = m_hostImpl->processScrollDeltas();
- if (m_hostImpl->settings().pageScalePinchZoomEnabled) {
- EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
- expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25));
- } else {
- EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta);
- expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(8, 8));
- }
- }
-}
-
-TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPageScale)
-{
- setupScrollAndContentsLayers(gfx::Size(100, 100));
- m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
- initializeRendererAndDrawFrame();
-
- LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
- DCHECK(scrollLayer);
-
- const float minPageScale = 0.5;
- const float maxPageScale = 4;
- const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromSeconds(1);
- const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
- const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2;
- const base::TimeTicks endTime = startTime + duration;
-
- const float pageScaleDelta = 2;
- gfx::Vector2d target(25, 25);
- gfx::Vector2d scaledTarget = target;
- if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
- scaledTarget = gfx::Vector2d(12, 12);
-
- m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- m_hostImpl->startPageScaleAnimation(target, false, pageScaleDelta, startTime, duration);
-
- // We should immediately get the final zoom and scroll values for the
- // animation.
- m_hostImpl->animate(halfwayThroughAnimation, base::Time());
- scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
- EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
- expectContains(*scrollInfo, scrollLayer->id(), scaledTarget);
-
- // Scrolling during the animation is ignored.
- const gfx::Vector2d scrollDelta(0, 10);
- EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(target.x(), target.y()), InputHandlerClient::Wheel), InputHandlerClient::ScrollStarted);
- m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
- m_hostImpl->scrollEnd();
-
- // The final page scale and scroll deltas should match what we got
- // earlier.
- m_hostImpl->animate(endTime, base::Time());
- scrollInfo = m_hostImpl->processScrollDeltas();
- EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
- expectContains(*scrollInfo, scrollLayer->id(), scaledTarget);
-}
-
TEST_P(LayerTreeHostImplTest, compositorFrameMetadata)
{
setupScrollAndContentsLayers(gfx::Size(100, 100));
@@ -4009,377 +3875,6 @@ TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses)
}
}
-// Make sure that scrolls that only pan the pinch viewport, and not the document,
-// still force redraw/commit.
-void LayerTreeHostImplTest::pinchZoomPanViewportForcesCommitRedraw(const float deviceScaleFactor)
-{
- m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
-
- gfx::Size layoutSurfaceSize(10, 20);
- gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(deviceScaleFactor),
- layoutSurfaceSize.height() * static_cast<int>(deviceScaleFactor));
- float pageScale = 2;
- scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize);
- // For this test we want to force scrolls to only pan the pinchZoomViewport
- // and not the document, we can verify commit/redraw are requested.
- root->setMaxScrollOffset(gfx::Vector2d());
- m_hostImpl->activeTree()->SetRootLayer(root.Pass());
- m_hostImpl->activeTree()->DidBecomeActive();
- m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
- m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
- initializeRendererAndDrawFrame();
-
- // Set new page scale on impl thread by pinching.
- m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
- m_hostImpl->pinchGestureEnd();
- drawOneFrame();
-
- gfx::Transform expectedImplTransform;
- expectedImplTransform.Scale(pageScale, pageScale);
-
- // Verify the pinch zoom took place.
- EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
-
- // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
- // so no point in continuing without it.
- if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
- return;
-
- m_didRequestCommit = false;
- m_didRequestRedraw = false;
-
- // This scroll will force the viewport to pan horizontally.
- gfx::Vector2d scrollDelta(5, 0);
- EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
- m_hostImpl->scrollEnd();
-
- EXPECT_EQ(true, m_didRequestCommit);
- EXPECT_EQ(true, m_didRequestRedraw);
-
- m_didRequestCommit = false;
- m_didRequestRedraw = false;
-
- // This scroll will force the viewport to pan vertically.
- scrollDelta = gfx::Vector2d(0, 5);
- EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
- m_hostImpl->scrollEnd();
-
- EXPECT_EQ(true, m_didRequestCommit);
- EXPECT_EQ(true, m_didRequestRedraw);
-}
-
-TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportForcesCommitDeviceScaleFactor1)
-{
- pinchZoomPanViewportForcesCommitRedraw(1);
-}
-
-TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportForcesCommitDeviceScaleFactor2)
-{
- pinchZoomPanViewportForcesCommitRedraw(2);
-}
-
-// The following test confirms correct operation of scroll of the pinchZoomViewport.
-// The device scale factor directly affects computation of the implTransform, so
-// we test the two most common use cases.
-void LayerTreeHostImplTest::pinchZoomPanViewportTest(const float deviceScaleFactor)
-{
- m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
-
- gfx::Size layoutSurfaceSize(10, 20);
- gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(deviceScaleFactor),
- layoutSurfaceSize.height() * static_cast<int>(deviceScaleFactor));
- float pageScale = 2;
- scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize);
- // For this test we want to force scrolls to move the pinchZoomViewport so
- // we can see the scroll component on the implTransform.
- root->setMaxScrollOffset(gfx::Vector2d());
- m_hostImpl->activeTree()->SetRootLayer(root.Pass());
- m_hostImpl->activeTree()->DidBecomeActive();
- m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
- m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
- initializeRendererAndDrawFrame();
-
- // Set new page scale on impl thread by pinching.
- m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
- m_hostImpl->pinchGestureEnd();
- drawOneFrame();
-
- gfx::Transform expectedImplTransform;
- expectedImplTransform.Scale(pageScale, pageScale);
-
- EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
-
- // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
- // so no point in continuing without it.
- if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
- return;
-
- gfx::Vector2d scrollDelta(5, 0);
- // TODO(wjmaclean): Fix the math here so that the expectedTranslation is
- // scaled instead of the scroll input.
- gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
- gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
- EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
- m_hostImpl->scrollEnd();
- drawOneFrame();
-
- gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScaleFactor());
- expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y());
-
- EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
- // No change expected.
- EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
- // None of the scroll delta should have been used for document scroll.
- scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
- expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id());
-
- // Test scroll in y-direction also.
- scrollDelta = gfx::Vector2d(0, 5);
- scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
- EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
- m_hostImpl->scrollEnd();
- drawOneFrame();
-
- expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScaleFactor());
- expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y());
-
- EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
- // No change expected.
- EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
- // None of the scroll delta should have been used for document scroll.
- scrollInfo = m_hostImpl->processScrollDeltas();
- expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id());
-}
-
-TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportWithDeviceScaleFactor1)
-{
- pinchZoomPanViewportTest(1);
-}
-
-TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportWithDeviceScaleFactor2)
-{
- pinchZoomPanViewportTest(2);
-}
-
-// This test verifies the correct behaviour of the document-then-pinchZoomViewport
-// scrolling model, in both x- and y-directions.
-void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float deviceScaleFactor)
-{
- m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
-
- gfx::Size layoutSurfaceSize(10, 20);
- gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(deviceScaleFactor),
- layoutSurfaceSize.height() * static_cast<int>(deviceScaleFactor));
- float pageScale = 2;
- scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize);
- // For this test we want to scrolls to move both the document and the
- // pinchZoomViewport so we can see some scroll component on the implTransform.
- root->setMaxScrollOffset(gfx::Vector2d(3, 4));
- m_hostImpl->activeTree()->SetRootLayer(root.Pass());
- m_hostImpl->activeTree()->DidBecomeActive();
- m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
- m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
- initializeRendererAndDrawFrame();
-
- // Set new page scale on impl thread by pinching.
- m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
- m_hostImpl->pinchGestureEnd();
- drawOneFrame();
-
- gfx::Transform expectedImplTransform;
- expectedImplTransform.Scale(pageScale, pageScale);
-
- EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
-
- // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
- // so no point in continuing without it.
- if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
- return;
-
- // Scroll document only: scrollDelta chosen to move document horizontally
- // to its max scroll offset.
- gfx::Vector2d scrollDelta(3, 0);
- gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
- gfx::Vector2d expectedScrollDelta(scrollDelta);
- gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
- EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
- m_hostImpl->scrollEnd();
- drawOneFrame();
-
- // The scroll delta is not scaled because the main thread did not scale.
- scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
- expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta);
- EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
-
- // Verify we did not change the implTransform this time.
- EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
-
- // Further scrolling should move the pinchZoomViewport only.
- scrollDelta = gfx::Vector2d(2, 0);
- scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
- EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
- m_hostImpl->scrollEnd();
- drawOneFrame();
-
- gfx::Vector2d expectedPanDelta(scrollDelta);
- gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor());
- expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y());
-
- EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
-
- // The scroll delta on the main thread should not have been affected by this.
- scrollInfo = m_hostImpl->processScrollDeltas();
- expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta);
- EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
-
- // Perform same test sequence in y-direction also.
- // Document only scroll.
- scrollDelta = gfx::Vector2d(0, 4);
- scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
- expectedScrollDelta += scrollDelta;
- EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
- m_hostImpl->scrollEnd();
- drawOneFrame();
-
- // The scroll delta is not scaled because the main thread did not scale.
- scrollInfo = m_hostImpl->processScrollDeltas();
- expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta);
- EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
-
- // Verify we did not change the implTransform this time.
- EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
-
- // pinchZoomViewport scroll only.
- scrollDelta = gfx::Vector2d(0, 1);
- scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
- EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
- m_hostImpl->scrollEnd();
- drawOneFrame();
-
- expectedPanDelta = scrollDelta;
- expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor());
- expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y());
-
- EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
-
- // The scroll delta on the main thread should not have been affected by this.
- scrollInfo = m_hostImpl->processScrollDeltas();
- expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta);
- EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
-}
-
-TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollWithDeviceScaleFactor)
-{
- pinchZoomPanViewportAndScrollTest(1);
-}
-
-TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollWithDeviceScaleFactor2)
-{
- pinchZoomPanViewportAndScrollTest(2);
-}
-
-// This test verifies the correct behaviour of the document-then-pinchZoomViewport
-// scrolling model, in both x- and y-directions, but this time using a single scroll
-// that crosses the 'boundary' of what will cause document-only scroll and what will
-// cause both document-scroll and zoomViewport panning.
-void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor)
-{
- m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
-
- gfx::Size layoutSurfaceSize(10, 20);
- gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(deviceScaleFactor),
- layoutSurfaceSize.height() * static_cast<int>(deviceScaleFactor));
- float pageScale = 2;
- scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize);
- // For this test we want to scrolls to move both the document and the
- // pinchZoomViewport so we can see some scroll component on the implTransform.
- root->setMaxScrollOffset(gfx::Vector2d(3, 4));
- m_hostImpl->activeTree()->SetRootLayer(root.Pass());
- m_hostImpl->activeTree()->DidBecomeActive();
- m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
- m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
- initializeRendererAndDrawFrame();
-
- // Set new page scale on impl thread by pinching.
- m_hostImpl->pinchGestureBegin();
- m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
- m_hostImpl->pinchGestureEnd();
- drawOneFrame();
-
- gfx::Transform expectedImplTransform;
- expectedImplTransform.Scale(pageScale, pageScale);
-
- EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
-
- // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
- // so no point in continuing without it.
- if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
- return;
-
- // Scroll document and pann zoomViewport in one scroll-delta.
- gfx::Vector2d scrollDelta(5, 0);
- gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
- gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component gets handled by document scroll.
- gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
-
- EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
- m_hostImpl->scrollEnd();
- drawOneFrame();
-
- // The scroll delta is not scaled because the main thread did not scale.
- scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
- expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta);
- EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
-
- gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoomViewport pan.
- gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor());
- expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y());
-
- EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
-
- // Perform same test sequence in y-direction also.
- scrollDelta = gfx::Vector2d(0, 5);
- scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
- expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled by document scroll.
- EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
- m_hostImpl->scrollEnd();
- drawOneFrame();
-
- // The scroll delta is not scaled because the main thread did not scale.
- scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handled by zoomViewport pan.
- expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta);
- EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
-
- expectedPanDelta = gfx::Vector2d(0, 1);
- expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor());
- expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y());
-
- EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
-}
-
-TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceScaleFactor)
-{
- pinchZoomPanViewportAndScrollBoundaryTest(1);
-}
-
-TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceScaleFactor2)
-{
- pinchZoomPanViewportAndScrollBoundaryTest(2);
-}
-
class LayerTreeHostImplTestWithDelegatingRenderer : public LayerTreeHostImplTest {
protected:
virtual scoped_ptr<OutputSurface> createOutputSurface()
« no previous file with comments | « cc/layer_tree_host_impl.cc ('k') | cc/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698