Chromium Code Reviews| 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 622a623f66fcab02151ead84df119d3178c5e30b..34aff06c3a89d444930a471732f017e16dfa423a 100644 |
| --- a/cc/layer_tree_host_impl_unittest.cc |
| +++ b/cc/layer_tree_host_impl_unittest.cc |
| @@ -210,6 +210,12 @@ public: |
| protected: |
| virtual scoped_ptr<OutputSurface> createOutputSurface() { return createFakeOutputSurface(); } |
| + void forcePrepareToDraw() { |
|
danakj
2012/12/13 00:03:37
why is this called force?
|
| + LayerTreeHostImpl::FrameData frameData; |
| + m_hostImpl->prepareToDraw(frameData); |
| + m_hostImpl->didDrawAllLayers(frameData); |
| + } |
| + |
| FakeProxy m_proxy; |
| DebugScopedSetImplThread m_alwaysImplThread; |
| DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; |
| @@ -1295,7 +1301,7 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) |
| m_hostImpl->pinchGestureBegin(); |
| m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
| m_hostImpl->pinchGestureEnd(); |
| - m_hostImpl->updateRootScrollLayerImplTransform(); |
| + forcePrepareToDraw(); |
| // The scroll delta is not scaled because the main thread did not scale. |
| scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
| @@ -1333,7 +1339,7 @@ TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) |
| m_hostImpl->pinchGestureBegin(); |
| m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point()); |
| m_hostImpl->pinchGestureEnd(); |
| - m_hostImpl->updateRootScrollLayerImplTransform(); |
| + forcePrepareToDraw(); |
| // The page scale delta should only be applied to the scrollable root layer. |
| EXPECT_EQ(root->implTransform(), newPageScaleMatrix); |
| @@ -1381,7 +1387,7 @@ TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) |
| float pageScale = 2; |
| m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); |
| - m_hostImpl->updateRootScrollLayerImplTransform(); |
| + forcePrepareToDraw(); |
| if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { |
| // The scale should apply to the scroll delta. |
| @@ -4557,7 +4563,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportForcesCommitRedraw(const float d |
| m_hostImpl->pinchGestureBegin(); |
| m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
| m_hostImpl->pinchGestureEnd(); |
| - m_hostImpl->updateRootScrollLayerImplTransform(); |
| + forcePrepareToDraw(); |
| gfx::Transform expectedImplTransform; |
| expectedImplTransform.Scale(pageScale, pageScale); |
| @@ -4629,7 +4635,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportTest(const float deviceScaleFact |
| m_hostImpl->pinchGestureBegin(); |
| m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
| m_hostImpl->pinchGestureEnd(); |
| - m_hostImpl->updateRootScrollLayerImplTransform(); |
| + forcePrepareToDraw(); |
| gfx::Transform expectedImplTransform; |
| expectedImplTransform.Scale(pageScale, pageScale); |
| @@ -4642,11 +4648,12 @@ void LayerTreeHostImplTest::pinchZoomPanViewportTest(const float deviceScaleFact |
| return; |
| gfx::Vector2d scrollDelta(5, 0); |
| + gfx::Vector2d scrollDeltaInViewportSpace = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactor())); |
|
danakj
2012/12/13 00:03:37
these would be the scrollDeltaInZoomedViewport
danakj
2012/12/13 00:30:47
On further thought I think this shouldn't be neede
danakj
2012/12/13 00:56:34
Ok no, this shouldn't be done. Don't scale the scr
|
| 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(), scrollDelta); |
| + m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInViewportSpace); |
| m_hostImpl->scrollEnd(); |
| - m_hostImpl->updateRootScrollLayerImplTransform(); |
| + forcePrepareToDraw(); |
| gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScaleFactor()); |
| expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y()); |
| @@ -4660,10 +4667,11 @@ void LayerTreeHostImplTest::pinchZoomPanViewportTest(const float deviceScaleFact |
| // Test scroll in y-direction also. |
| scrollDelta = gfx::Vector2d(0, 5); |
| + scrollDeltaInViewportSpace = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactor())); |
| EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture)); |
| - m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| + m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInViewportSpace); |
| m_hostImpl->scrollEnd(); |
| - m_hostImpl->updateRootScrollLayerImplTransform(); |
| + forcePrepareToDraw(); |
| expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScaleFactor()); |
| expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y()); |
| @@ -4709,7 +4717,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device |
| m_hostImpl->pinchGestureBegin(); |
| m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
| m_hostImpl->pinchGestureEnd(); |
| - m_hostImpl->updateRootScrollLayerImplTransform(); |
| + forcePrepareToDraw(); |
| gfx::Transform expectedImplTransform; |
| expectedImplTransform.Scale(pageScale, pageScale); |
| @@ -4724,12 +4732,13 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device |
| // Scroll document only: scrollDelta chosen to move document horizontally |
| // to its max scroll offset. |
| gfx::Vector2d scrollDelta(3, 0); |
| + gfx::Vector2d scrollDeltaInViewportSpace = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactor())); |
| 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(), scrollDelta); |
| + m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInViewportSpace); |
| m_hostImpl->scrollEnd(); |
| - m_hostImpl->updateRootScrollLayerImplTransform(); |
| + forcePrepareToDraw(); |
| // The scroll delta is not scaled because the main thread did not scale. |
| scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
| @@ -4741,10 +4750,11 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device |
| // Further scrolling should move the pinchZoomViewport only. |
| scrollDelta = gfx::Vector2d(2, 0); |
| + scrollDeltaInViewportSpace = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactor())); |
| EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture)); |
| - m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| + m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInViewportSpace); |
| m_hostImpl->scrollEnd(); |
| - m_hostImpl->updateRootScrollLayerImplTransform(); |
| + forcePrepareToDraw(); |
| gfx::Vector2d expectedPanDelta(scrollDelta); |
| gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor()); |
| @@ -4760,11 +4770,12 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device |
| // Perform same test sequence in y-direction also. |
| // Document only scroll. |
| scrollDelta = gfx::Vector2d(0, 4); |
| + scrollDeltaInViewportSpace = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactor())); |
| expectedScrollDelta += scrollDelta; |
| EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture)); |
| - m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| + m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInViewportSpace); |
| m_hostImpl->scrollEnd(); |
| - m_hostImpl->updateRootScrollLayerImplTransform(); |
| + forcePrepareToDraw(); |
| // The scroll delta is not scaled because the main thread did not scale. |
| scrollInfo = m_hostImpl->processScrollDeltas(); |
| @@ -4776,10 +4787,11 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device |
| // pinchZoomViewport scroll only. |
| scrollDelta = gfx::Vector2d(0, 1); |
| + scrollDeltaInViewportSpace = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactor())); |
| EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture)); |
| - m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| + m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInViewportSpace); |
| m_hostImpl->scrollEnd(); |
| - m_hostImpl->updateRootScrollLayerImplTransform(); |
| + forcePrepareToDraw(); |
| expectedPanDelta = scrollDelta; |
| expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor()); |
| @@ -4828,7 +4840,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollBoundaryTest(const floa |
| m_hostImpl->pinchGestureBegin(); |
| m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
| m_hostImpl->pinchGestureEnd(); |
| - m_hostImpl->updateRootScrollLayerImplTransform(); |
| + forcePrepareToDraw(); |
| gfx::Transform expectedImplTransform; |
| expectedImplTransform.Scale(pageScale, pageScale); |
| @@ -4842,13 +4854,14 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollBoundaryTest(const floa |
| // Scroll document and pann zoomViewport in one scroll-delta. |
| gfx::Vector2d scrollDelta(5, 0); |
| + gfx::Vector2d scrollDeltaInViewportSpace = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactor())); |
| 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(), scrollDelta); |
| + m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInViewportSpace); |
| m_hostImpl->scrollEnd(); |
| - m_hostImpl->updateRootScrollLayerImplTransform(); |
| + forcePrepareToDraw(); |
| // The scroll delta is not scaled because the main thread did not scale. |
| scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); |
| @@ -4863,11 +4876,12 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollBoundaryTest(const floa |
| // Perform same test sequence in y-direction also. |
| scrollDelta = gfx::Vector2d(0, 5); |
| + scrollDeltaInViewportSpace = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactor())); |
| 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(), scrollDelta); |
| + m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInViewportSpace); |
| m_hostImpl->scrollEnd(); |
| - m_hostImpl->updateRootScrollLayerImplTransform(); |
| + forcePrepareToDraw(); |
| // The scroll delta is not scaled because the main thread did not scale. |
| scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handled by zoomViewport pan. |