Index: cc/trees/layer_tree_host_impl_unittest.cc |
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc |
index 79abc1c02f2ef28116296a3c79f43ce0a1a998c2..a70382db095ac9668ef191713c8e7b634405c6d6 100644 |
--- a/cc/trees/layer_tree_host_impl_unittest.cc |
+++ b/cc/trees/layer_tree_host_impl_unittest.cc |
@@ -2250,8 +2250,6 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { |
} |
void SetupTopControlsAndScrollLayer() { |
- CreateHostImpl(settings_, CreateOutputSurface()); |
- |
scoped_ptr<LayerImpl> root = |
LayerImpl::Create(host_impl_->active_tree(), 1); |
scoped_ptr<LayerImpl> root_clip = |
@@ -2274,8 +2272,6 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { |
host_impl_->SetViewportSize(viewport_size_); |
host_impl_->SetTopControlsLayoutHeight( |
settings_.top_controls_height); |
- LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); |
- EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); |
host_impl_->CreatePendingTree(); |
root = |
@@ -2300,8 +2296,6 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { |
host_impl_->SetViewportSize(viewport_size_); |
host_impl_->sync_tree()->set_top_controls_layout_height( |
settings_.top_controls_height); |
- root_clip_ptr = host_impl_->sync_tree()->root_layer(); |
- EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); |
} |
protected: |
@@ -2312,7 +2306,30 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { |
LayerTreeSettings settings_; |
}; // class LayerTreeHostImplTopControlsTest |
+TEST_F(LayerTreeHostImplTopControlsTest, |
+ TopControlsDeltaOnlySentWithRootLayer) { |
+ CreateHostImpl(settings_, CreateOutputSurface()); |
+ |
+ host_impl_->active_tree()->set_top_controls_delta(-20.f); |
+ |
+ // Because LTH::ApplyScrollAndScale doesn't know what to do with a scroll |
+ // delta packet when the root layer doesn't exist yet, make sure not to set |
+ // sent_top_controls_delta either to avoid the delta getting clobbered on the |
+ // next commit. |
+ scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
+ EXPECT_EQ(scroll_info->top_controls_delta, 0.f); |
+ EXPECT_EQ(host_impl_->active_tree()->sent_top_controls_delta(), 0.f); |
+ |
+ SetupTopControlsAndScrollLayer(); |
+ |
+ // After the root layer exists, it should be set normally. |
+ scroll_info = host_impl_->ProcessScrollDeltas(); |
+ EXPECT_EQ(scroll_info->top_controls_delta, -20.f); |
+ EXPECT_EQ(host_impl_->active_tree()->sent_top_controls_delta(), -20.f); |
+} |
+ |
TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsByFractionalAmount) { |
+ CreateHostImpl(settings_, CreateOutputSurface()); |
SetupTopControlsAndScrollLayer(); |
DrawFrame(); |
@@ -2336,6 +2353,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsByFractionalAmount) { |
} |
TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsWithPageScale) { |
+ CreateHostImpl(settings_, CreateOutputSurface()); |
SetupTopControlsAndScrollLayer(); |
DrawFrame(); |
@@ -2369,6 +2387,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsWithPageScale) { |
// Ensure setting the top controls position explicitly using the setters on the |
// TreeImpl correctly affects the top controls manager and viewport bounds. |
TEST_F(LayerTreeHostImplTopControlsTest, PositionTopControlsExplicitly) { |
+ CreateHostImpl(settings_, CreateOutputSurface()); |
SetupTopControlsAndScrollLayer(); |
DrawFrame(); |
@@ -2392,6 +2411,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, PositionTopControlsExplicitly) { |
// applied on sync tree activation. The total top controls offset shouldn't |
// change after the activation. |
TEST_F(LayerTreeHostImplTopControlsTest, ApplyDeltaOnTreeActivation) { |
+ CreateHostImpl(settings_, CreateOutputSurface()); |
SetupTopControlsAndScrollLayer(); |
DrawFrame(); |
@@ -2426,6 +2446,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, ApplyDeltaOnTreeActivation) { |
// height is the amount that the inner viewport container was shrunk outside |
// the compositor to accommodate the top controls. |
TEST_F(LayerTreeHostImplTopControlsTest, TopControlsLayoutHeightChanged) { |
+ CreateHostImpl(settings_, CreateOutputSurface()); |
SetupTopControlsAndScrollLayer(); |
DrawFrame(); |
@@ -2467,6 +2488,7 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsLayoutHeightChanged) { |
TEST_F(LayerTreeHostImplTopControlsTest, |
ScrollNonScrollableRootWithTopControls) { |
+ CreateHostImpl(settings_, CreateOutputSurface()); |
SetupTopControlsAndScrollLayer(); |
DrawFrame(); |