| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/layers/layer_position_constraint.h" | 5 #include "cc/layers/layer_position_constraint.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "cc/layers/layer_impl.h" | 9 #include "cc/layers/layer_impl.h" |
| 10 #include "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" |
| 11 #include "cc/test/fake_layer_tree_host_impl.h" | 11 #include "cc/test/fake_layer_tree_host_impl.h" |
| 12 #include "cc/test/geometry_test_utils.h" | 12 #include "cc/test/geometry_test_utils.h" |
| 13 #include "cc/test/test_shared_bitmap_manager.h" |
| 13 #include "cc/trees/layer_tree_host_common.h" | 14 #include "cc/trees/layer_tree_host_common.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 16 |
| 16 namespace cc { | 17 namespace cc { |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 void SetLayerPropertiesForTesting(LayerImpl* layer, | 20 void SetLayerPropertiesForTesting(LayerImpl* layer, |
| 20 const gfx::Transform& transform, | 21 const gfx::Transform& transform, |
| 21 const gfx::PointF& anchor, | 22 const gfx::PointF& anchor, |
| 22 const gfx::PointF& position, | 23 const gfx::PointF& position, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 58 } |
| 58 | 59 |
| 59 void ExecuteCalculateDrawProperties(LayerImpl* root_layer) { | 60 void ExecuteCalculateDrawProperties(LayerImpl* root_layer) { |
| 60 LayerImpl* page_scale_application_layer = NULL; | 61 LayerImpl* page_scale_application_layer = NULL; |
| 61 ExecuteCalculateDrawProperties( | 62 ExecuteCalculateDrawProperties( |
| 62 root_layer, 1.f, 1.f, page_scale_application_layer, false); | 63 root_layer, 1.f, 1.f, page_scale_application_layer, false); |
| 63 } | 64 } |
| 64 | 65 |
| 65 class LayerPositionConstraintTest : public testing::Test { | 66 class LayerPositionConstraintTest : public testing::Test { |
| 66 public: | 67 public: |
| 67 LayerPositionConstraintTest() | 68 LayerPositionConstraintTest() : host_impl_(&proxy_, &shared_bitmap_manager_) { |
| 68 : host_impl_(&proxy_) { | |
| 69 root_ = CreateTreeForTest(); | 69 root_ = CreateTreeForTest(); |
| 70 scroll_ = root_->children()[0]; | 70 scroll_ = root_->children()[0]; |
| 71 fixed_to_top_left_.set_is_fixed_position(true); | 71 fixed_to_top_left_.set_is_fixed_position(true); |
| 72 fixed_to_bottom_right_.set_is_fixed_position(true); | 72 fixed_to_bottom_right_.set_is_fixed_position(true); |
| 73 fixed_to_bottom_right_.set_is_fixed_to_right_edge(true); | 73 fixed_to_bottom_right_.set_is_fixed_to_right_edge(true); |
| 74 fixed_to_bottom_right_.set_is_fixed_to_bottom_edge(true); | 74 fixed_to_bottom_right_.set_is_fixed_to_bottom_edge(true); |
| 75 } | 75 } |
| 76 | 76 |
| 77 scoped_ptr<LayerImpl> CreateTreeForTest() { | 77 scoped_ptr<LayerImpl> CreateTreeForTest() { |
| 78 scoped_ptr<LayerImpl> root = | 78 scoped_ptr<LayerImpl> root = |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 grand_child->AddChild(great_grand_child.Pass()); | 128 grand_child->AddChild(great_grand_child.Pass()); |
| 129 child->AddChild(grand_child.Pass()); | 129 child->AddChild(grand_child.Pass()); |
| 130 scroll_layer->AddChild(child.Pass()); | 130 scroll_layer->AddChild(child.Pass()); |
| 131 root->AddChild(scroll_layer.Pass()); | 131 root->AddChild(scroll_layer.Pass()); |
| 132 | 132 |
| 133 return root.Pass(); | 133 return root.Pass(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 protected: | 136 protected: |
| 137 FakeImplProxy proxy_; | 137 FakeImplProxy proxy_; |
| 138 TestSharedBitmapManager shared_bitmap_manager_; |
| 138 FakeLayerTreeHostImpl host_impl_; | 139 FakeLayerTreeHostImpl host_impl_; |
| 139 scoped_ptr<LayerImpl> root_; | 140 scoped_ptr<LayerImpl> root_; |
| 140 LayerImpl* scroll_; | 141 LayerImpl* scroll_; |
| 141 | 142 |
| 142 LayerPositionConstraint fixed_to_top_left_; | 143 LayerPositionConstraint fixed_to_top_left_; |
| 143 LayerPositionConstraint fixed_to_bottom_right_; | 144 LayerPositionConstraint fixed_to_bottom_right_; |
| 144 }; | 145 }; |
| 145 | 146 |
| 146 namespace { | 147 namespace { |
| 147 | 148 |
| (...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 fixed_to_container1->draw_transform()); | 1163 fixed_to_container1->draw_transform()); |
| 1163 | 1164 |
| 1164 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_container2_transform, | 1165 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_container2_transform, |
| 1165 container2->draw_transform()); | 1166 container2->draw_transform()); |
| 1166 | 1167 |
| 1167 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_to_container2_transform, | 1168 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_to_container2_transform, |
| 1168 fixed_to_container2->draw_transform()); | 1169 fixed_to_container2->draw_transform()); |
| 1169 } | 1170 } |
| 1170 } // namespace | 1171 } // namespace |
| 1171 } // namespace cc | 1172 } // namespace cc |
| OLD | NEW |