Chromium Code Reviews| Index: cc/layers/layer_position_constraint_unittest.cc |
| diff --git a/cc/layers/layer_position_constraint_unittest.cc b/cc/layers/layer_position_constraint_unittest.cc |
| index 8f6dcb11798a5ba1153db4155931a7e8667f7df4..c278cdc3e85753b8735459c816039d17c6db6a1d 100644 |
| --- a/cc/layers/layer_position_constraint_unittest.cc |
| +++ b/cc/layers/layer_position_constraint_unittest.cc |
| @@ -39,13 +39,14 @@ void ExecuteCalculateDrawProperties(LayerImpl* root_layer, |
| bool can_use_lcd_text) { |
| gfx::Transform identity_matrix; |
| std::vector<LayerImpl*> dummy_render_surface_layer_list; |
| + LayerImpl* scroll_layer = root_layer->children()[0]; |
| gfx::Size device_viewport_size = |
| gfx::Size(root_layer->bounds().width() * device_scale_factor, |
| root_layer->bounds().height() * device_scale_factor); |
| - // We are probably not testing what is intended if the root_layer bounds are |
| + // We are probably not testing what is intended if the scroll_layer bounds are |
| // empty. |
| - DCHECK(!root_layer->bounds().IsEmpty()); |
| + DCHECK(!scroll_layer->bounds().IsEmpty()); |
| LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| root_layer, device_viewport_size, &dummy_render_surface_layer_list); |
| inputs.device_scale_factor = device_scale_factor; |
| @@ -66,6 +67,7 @@ class LayerPositionConstraintTest : public testing::Test { |
| LayerPositionConstraintTest() |
| : host_impl_(&proxy_) { |
| root_ = CreateTreeForTest(); |
| + scroll_ = root_->children()[0]; |
| fixed_to_top_left_.set_is_fixed_position(true); |
| fixed_to_bottom_right_.set_is_fixed_position(true); |
| fixed_to_bottom_right_.set_is_fixed_to_right_edge(true); |
| @@ -74,6 +76,8 @@ class LayerPositionConstraintTest : public testing::Test { |
| scoped_ptr<LayerImpl> CreateTreeForTest() { |
| scoped_ptr<LayerImpl> root = |
| + LayerImpl::Create(host_impl_.active_tree(), 42); |
| + scoped_ptr<LayerImpl> scroll_layer = |
| LayerImpl::Create(host_impl_.active_tree(), 1); |
| scoped_ptr<LayerImpl> child = |
| LayerImpl::Create(host_impl_.active_tree(), 2); |
| @@ -85,8 +89,9 @@ class LayerPositionConstraintTest : public testing::Test { |
| gfx::Transform IdentityMatrix; |
| gfx::PointF anchor; |
| gfx::PointF position; |
| - gfx::Size bounds(100, 100); |
| - SetLayerPropertiesForTesting(root.get(), |
| + gfx::Size bounds(200, 200); |
| + gfx::Size clip_bounds(100, 100); |
| + SetLayerPropertiesForTesting(scroll_layer.get(), |
| IdentityMatrix, |
| IdentityMatrix, |
| anchor, |
| @@ -115,16 +120,15 @@ class LayerPositionConstraintTest : public testing::Test { |
| bounds, |
| false); |
| - root->SetMaxScrollOffset(gfx::Vector2d(100, 100)); |
| - root->SetScrollable(true); |
| - child->SetMaxScrollOffset(gfx::Vector2d(100, 100)); |
| - child->SetScrollable(true); |
| - grand_child->SetMaxScrollOffset(gfx::Vector2d(100, 100)); |
| - grand_child->SetScrollable(true); |
| + root->SetBounds(clip_bounds); |
| + scroll_layer->SetScrollable(root->id()); |
| + child->SetScrollable(root->id()); |
| + grand_child->SetScrollable(root->id()); |
| grand_child->AddChild(great_grand_child.Pass()); |
| child->AddChild(grand_child.Pass()); |
| - root->AddChild(child.Pass()); |
| + scroll_layer->AddChild(child.Pass()); |
| + root->AddChild(scroll_layer.Pass()); |
| return root.Pass(); |
| } |
| @@ -133,6 +137,7 @@ class LayerPositionConstraintTest : public testing::Test { |
| FakeImplProxy proxy_; |
| FakeLayerTreeHostImpl host_impl_; |
| scoped_ptr<LayerImpl> root_; |
| + LayerImpl* scroll_; |
| LayerPositionConstraint fixed_to_top_left_; |
| LayerPositionConstraint fixed_to_bottom_right_; |
| @@ -142,7 +147,7 @@ TEST_F(LayerPositionConstraintTest, |
| ScrollCompensationForFixedPositionLayerWithDirectContainer) { |
| // This test checks for correct scroll compensation when the fixed-position |
| // container is the direct parent of the fixed-position layer. |
| - LayerImpl* child = root_->children()[0]; |
| + LayerImpl* child = scroll_->children()[0]; |
| LayerImpl* grand_child = child->children()[0]; |
| child->SetIsContainerForFixedPositionLayers(true); |
| @@ -210,7 +215,7 @@ TEST_F(LayerPositionConstraintTest, |
| // Transforms are in general non-commutative; using something like a |
| // non-uniform scale helps to verify that translations and non-uniform scales |
| // are applied in the correct order. |
| - LayerImpl* child = root_->children()[0]; |
| + LayerImpl* child = scroll_->children()[0]; |
| LayerImpl* grand_child = child->children()[0]; |
| // This scale will cause child and grand_child to be effectively 200 x 800 |
| @@ -282,7 +287,7 @@ TEST_F(LayerPositionConstraintTest, |
| ScrollCompensationForFixedPositionLayerWithDistantContainer) { |
| // This test checks for correct scroll compensation when the fixed-position |
| // container is NOT the direct parent of the fixed-position layer. |
| - LayerImpl* child = root_->children()[0]; |
| + LayerImpl* child = scroll_->children()[0]; |
| LayerImpl* grand_child = child->children()[0]; |
| LayerImpl* great_grand_child = grand_child->children()[0]; |
| @@ -362,7 +367,7 @@ TEST_F(LayerPositionConstraintTest, |
| // container is NOT the direct parent of the fixed-position layer, and the |
| // hierarchy has various transforms that have to be processed in the correct |
| // order. |
| - LayerImpl* child = root_->children()[0]; |
| + LayerImpl* child = scroll_->children()[0]; |
| LayerImpl* grand_child = child->children()[0]; |
| LayerImpl* great_grand_child = grand_child->children()[0]; |
| @@ -474,7 +479,7 @@ TEST_F(LayerPositionConstraintTest, |
| // container is NOT the direct parent of the fixed-position layer, and the |
| // hierarchy has various transforms that have to be processed in the correct |
| // order. |
| - LayerImpl* child = root_->children()[0]; |
| + LayerImpl* child = scroll_->children()[0]; |
| LayerImpl* grand_child = child->children()[0]; |
| LayerImpl* great_grand_child = grand_child->children()[0]; |
| @@ -585,7 +590,7 @@ TEST_F(LayerPositionConstraintTest, |
| // container contributes to a different render surface than the fixed-position |
| // layer. In this case, the surface draw transforms also have to be accounted |
| // for when checking the scroll delta. |
| - LayerImpl* child = root_->children()[0]; |
| + LayerImpl* child = scroll_->children()[0]; |
| LayerImpl* grand_child = child->children()[0]; |
| LayerImpl* great_grand_child = grand_child->children()[0]; |
| @@ -709,7 +714,7 @@ TEST_F(LayerPositionConstraintTest, |
| // layer, with additional render surfaces in-between. This checks that the |
| // conversion to ancestor surfaces is accumulated properly in the final matrix |
| // transform. |
| - LayerImpl* child = root_->children()[0]; |
| + LayerImpl* child = scroll_->children()[0]; |
| LayerImpl* grand_child = child->children()[0]; |
| LayerImpl* great_grand_child = grand_child->children()[0]; |
| @@ -896,7 +901,7 @@ TEST_F(LayerPositionConstraintTest, |
| // should be treated like a layer that contributes to a render target, and |
| // that render target is completely irrelevant; it should not affect the |
| // scroll compensation. |
| - LayerImpl* child = root_->children()[0]; |
| + LayerImpl* child = scroll_->children()[0]; |
| LayerImpl* grand_child = child->children()[0]; |
| child->SetIsContainerForFixedPositionLayers(true); |
| @@ -974,7 +979,7 @@ TEST_F(LayerPositionConstraintTest, |
| // This test checks the scenario where a fixed-position layer also happens to |
| // be a container itself for a descendant fixed position layer. In particular, |
| // the layer should not accidentally be fixed to itself. |
| - LayerImpl* child = root_->children()[0]; |
| + LayerImpl* child = scroll_->children()[0]; |
| LayerImpl* grand_child = child->children()[0]; |
| child->SetIsContainerForFixedPositionLayers(true); |
| @@ -1038,17 +1043,17 @@ TEST_F(LayerPositionConstraintTest, |
| // This test checks scroll compensation when a fixed-position layer does not |
| // find any ancestor that is a "containerForFixedPositionLayers". In this |
| // situation, the layer should be fixed to the root layer. |
| - LayerImpl* child = root_->children()[0]; |
| + LayerImpl* child = scroll_->children()[0]; |
| LayerImpl* grand_child = child->children()[0]; |
| gfx::Transform rotation_by_z; |
| rotation_by_z.RotateAboutZAxis(90.0); |
| - root_->SetTransform(rotation_by_z); |
| + scroll_->SetTransform(rotation_by_z); |
| grand_child->SetPositionConstraint(fixed_to_top_left_); |
| // Case 1: root scroll delta of 0, 0 |
| - root_->SetScrollDelta(gfx::Vector2d(0, 0)); |
| + scroll_->SetScrollDelta(gfx::Vector2d(0, 0)); |
| ExecuteCalculateDrawProperties(root_.get()); |
| gfx::Transform identity_matrix; |
| @@ -1058,7 +1063,7 @@ TEST_F(LayerPositionConstraintTest, |
| grand_child->draw_transform()); |
| // Case 2: root scroll delta of 10, 10 |
| - root_->SetScrollDelta(gfx::Vector2d(10, 20)); |
| + scroll_->SetScrollDelta(gfx::Vector2d(10, 20)); |
| ExecuteCalculateDrawProperties(root_.get()); |
| gfx::Transform expected_child_transform; |
| @@ -1085,7 +1090,8 @@ TEST_F(LayerPositionConstraintTest, |
| ExecuteCalculateDrawProperties(root_.get()); |
| gfx::Transform expected_grand_child_transform; |
| - expected_grand_child_transform.Translate(-20.0, 20.0); |
| + // TODO(wjmaclean) Not sure why this used to be (-20, 20), is this right? |
|
enne (OOO)
2013/11/19 19:30:22
I would talk to shawnsingh about this, but I think
wjmaclean
2013/12/24 21:03:49
I have contacted Shawn about this, and will resolv
|
| + expected_grand_child_transform.Translate(20.0, 20.0); |
| expected_grand_child_transform.PreconcatTransform(rotation_by_z); |
| EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| @@ -1102,7 +1108,7 @@ TEST_F(LayerPositionConstraintTest, |
| // the scroll compensation, and the child fixed-position layer does not |
| // need to compensate further. |
| - LayerImpl* child = root_->children()[0]; |
| + LayerImpl* child = scroll_->children()[0]; |
| LayerImpl* grand_child = child->children()[0]; |
| LayerImpl* great_grand_child = grand_child->children()[0]; |
| @@ -1161,7 +1167,7 @@ TEST_F(LayerPositionConstraintTest, |
| // position containers. In this situation, the child fixed-position element |
| // would still have to compensate with respect to its container. |
| - LayerImpl* container1 = root_->children()[0]; |
| + LayerImpl* container1 = scroll_->children()[0]; |
| LayerImpl* fixed_to_container1 = container1->children()[0]; |
| LayerImpl* container2 = fixed_to_container1->children()[0]; |