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

Unified Diff: cc/layers/layer_position_constraint_unittest.cc

Issue 23983047: Pinch/Zoom Infrastructure & Plumbing CL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to r248052. Created 6 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/layers/layer_perftest.cc ('k') | cc/layers/layer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 efa81e2e3695b19ae587c5707f1865b63917ac3c..88db6a8f030f70b0eb48d84f0cbd9d7f2f4d6f02 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->SetScrollClipLayer(root->id());
+ child->SetScrollClipLayer(root->id());
+ grand_child->SetScrollClipLayer(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);
@@ -1034,67 +1039,6 @@ TEST_F(LayerPositionConstraintTest,
}
TEST_F(LayerPositionConstraintTest,
- ScrollCompensationForFixedPositionLayerThatHasNoContainer) {
- // 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* grand_child = child->children()[0];
-
- gfx::Transform rotation_by_z;
- rotation_by_z.RotateAboutZAxis(90.0);
-
- root_->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));
- ExecuteCalculateDrawProperties(root_.get());
-
- gfx::Transform identity_matrix;
-
- EXPECT_TRANSFORMATION_MATRIX_EQ(rotation_by_z, child->draw_transform());
- EXPECT_TRANSFORMATION_MATRIX_EQ(rotation_by_z,
- grand_child->draw_transform());
-
- // Case 2: root scroll delta of 10, 10
- root_->SetScrollDelta(gfx::Vector2d(10, 20));
- ExecuteCalculateDrawProperties(root_.get());
-
- gfx::Transform expected_child_transform;
- expected_child_transform.Translate(-10.0, -20.0);
- expected_child_transform.PreconcatTransform(rotation_by_z);
-
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform,
- child->draw_transform());
- EXPECT_TRANSFORMATION_MATRIX_EQ(rotation_by_z,
- grand_child->draw_transform());
-
- // Case 3: fixed-container size delta of 20, 20
- root_->SetFixedContainerSizeDelta(gfx::Vector2d(20, 20));
- ExecuteCalculateDrawProperties(root_.get());
-
- // Top-left fixed-position layer should not be affected by container size.
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform,
- child->draw_transform());
- EXPECT_TRANSFORMATION_MATRIX_EQ(rotation_by_z,
- grand_child->draw_transform());
-
- // Case 4: Bottom-right fixed-position layer.
- grand_child->SetPositionConstraint(fixed_to_bottom_right_);
- ExecuteCalculateDrawProperties(root_.get());
-
- gfx::Transform expected_grand_child_transform;
- expected_grand_child_transform.Translate(-20.0, 20.0);
- expected_grand_child_transform.PreconcatTransform(rotation_by_z);
-
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform,
- child->draw_transform());
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform,
- grand_child->draw_transform());
-}
-
-TEST_F(LayerPositionConstraintTest,
ScrollCompensationForFixedWithinFixedWithSameContainer) {
// This test checks scroll compensation for a fixed-position layer that is
// inside of another fixed-position layer and both share the same container.
@@ -1102,7 +1046,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 +1105,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];
« no previous file with comments | « cc/layers/layer_perftest.cc ('k') | cc/layers/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698