From 289c907525e4f7845af05fcf86fab56fdffdc691 Mon Sep 17 00:00:00 2001 From: "bokan@chromium.org" Date: Wed, 30 Apr 2014 14:37:07 +0000 Subject: Added compositor test for viewport container bounds clobbering behavior. Added a new test to make sure that if the inner viewport container layer has 'masks_to_bounds' set, as it does on non-Android platforms, the inner viewport container layer's size isn't clobbered by the viewport size. BUG= Review URL: https://codereview.chromium.org/254133005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267202 0039d316-1c4b-4281-b951-d872f2087c98 --- cc/trees/layer_tree_host_impl_unittest.cc | 55 +++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'cc') diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index fc7645d..b9c35f6 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -946,6 +946,61 @@ TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { } } +TEST_F(LayerTreeHostImplTest, MasksToBoundsDoesntClobberInnerContainerSize) { + SetupScrollAndContentsLayers(gfx::Size(100, 100)); + host_impl_->SetViewportSize(gfx::Size(50, 50)); + DrawFrame(); + + LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); + LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); + DCHECK(scroll_layer); + + float min_page_scale = 1.f; + float max_page_scale = 4.f; + host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, + min_page_scale, + max_page_scale); + + // If the container's masks_to_bounds is false, the viewport size should + // overwrite the inner viewport container layer's size. + { + EXPECT_EQ(gfx::Size(50, 50), + container_layer->bounds()); + container_layer->SetMasksToBounds(false); + + container_layer->SetBounds(gfx::Size(30, 25)); + EXPECT_EQ(gfx::Size(30, 25), + container_layer->bounds()); + + // This should cause a reset of the inner viewport container layer's bounds. + host_impl_->DidChangeTopControlsPosition(); + + EXPECT_EQ(gfx::Size(50, 50), + container_layer->bounds()); + } + + host_impl_->SetViewportSize(gfx::Size(50, 50)); + container_layer->SetBounds(gfx::Size(50, 50)); + + // If the container's masks_to_bounds is true, the viewport size should + // *NOT* overwrite the inner viewport container layer's size. + { + EXPECT_EQ(gfx::Size(50, 50), + container_layer->bounds()); + container_layer->SetMasksToBounds(true); + + container_layer->SetBounds(gfx::Size(30, 25)); + EXPECT_EQ(gfx::Size(30, 25), + container_layer->bounds()); + + // This should cause a reset of the inner viewport container layer's bounds. + host_impl_->DidChangeTopControlsPosition(); + + EXPECT_EQ(gfx::Size(30, 25), + container_layer->bounds()); + } +} + TEST_F(LayerTreeHostImplTest, PinchGesture) { SetupScrollAndContentsLayers(gfx::Size(100, 100)); host_impl_->SetViewportSize(gfx::Size(50, 50)); -- cgit v1.1