| 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> |
| 8 |
| 7 #include "cc/layers/layer_impl.h" | 9 #include "cc/layers/layer_impl.h" |
| 8 #include "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" |
| 9 #include "cc/test/fake_layer_tree_host_impl.h" | 11 #include "cc/test/fake_layer_tree_host_impl.h" |
| 10 #include "cc/test/geometry_test_utils.h" | 12 #include "cc/test/geometry_test_utils.h" |
| 11 #include "cc/trees/layer_tree_host_common.h" | 13 #include "cc/trees/layer_tree_host_common.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 15 |
| 14 namespace cc { | 16 namespace cc { |
| 15 namespace { | 17 namespace { |
| 16 | 18 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 37 gfx::Transform identity_matrix; | 39 gfx::Transform identity_matrix; |
| 38 std::vector<LayerImpl*> dummy_render_surface_layer_list; | 40 std::vector<LayerImpl*> dummy_render_surface_layer_list; |
| 39 int dummy_max_texture_size = 512; | 41 int dummy_max_texture_size = 512; |
| 40 gfx::Size device_viewport_size = | 42 gfx::Size device_viewport_size = |
| 41 gfx::Size(root_layer->bounds().width() * device_scale_factor, | 43 gfx::Size(root_layer->bounds().width() * device_scale_factor, |
| 42 root_layer->bounds().height() * device_scale_factor); | 44 root_layer->bounds().height() * device_scale_factor); |
| 43 | 45 |
| 44 // We are probably not testing what is intended if the root_layer bounds are | 46 // We are probably not testing what is intended if the root_layer bounds are |
| 45 // empty. | 47 // empty. |
| 46 DCHECK(!root_layer->bounds().IsEmpty()); | 48 DCHECK(!root_layer->bounds().IsEmpty()); |
| 47 LayerTreeHostCommon::CalculateDrawProperties(root_layer, | 49 LayerTreeHostCommon::CalculateDrawProperties( |
| 48 device_viewport_size, | 50 root_layer, |
| 49 device_scale_factor, | 51 device_viewport_size, |
| 50 page_scale_factor, | 52 device_scale_factor, |
| 51 dummy_max_texture_size, | 53 page_scale_factor, |
| 52 can_use_lcd_text, | 54 dummy_max_texture_size, |
| 53 &dummy_render_surface_layer_list, | 55 can_use_lcd_text, |
| 54 false); | 56 &dummy_render_surface_layer_list); |
| 55 } | 57 } |
| 56 | 58 |
| 57 void ExecuteCalculateDrawProperties(LayerImpl* root_layer) { | 59 void ExecuteCalculateDrawProperties(LayerImpl* root_layer) { |
| 58 ExecuteCalculateDrawProperties(root_layer, 1.f, 1.f, false); | 60 ExecuteCalculateDrawProperties(root_layer, 1.f, 1.f, false); |
| 59 } | 61 } |
| 60 | 62 |
| 61 class LayerPositionConstraintTest : public testing::Test { | 63 class LayerPositionConstraintTest : public testing::Test { |
| 62 public: | 64 public: |
| 63 LayerPositionConstraintTest() | 65 LayerPositionConstraintTest() |
| 64 : host_impl_(&proxy_) { | 66 : host_impl_(&proxy_) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 position, | 113 position, |
| 112 bounds, | 114 bounds, |
| 113 false); | 115 false); |
| 114 | 116 |
| 115 grand_child->AddChild(great_grand_child.Pass()); | 117 grand_child->AddChild(great_grand_child.Pass()); |
| 116 child->AddChild(grand_child.Pass()); | 118 child->AddChild(grand_child.Pass()); |
| 117 root->AddChild(child.Pass()); | 119 root->AddChild(child.Pass()); |
| 118 | 120 |
| 119 return root.Pass(); | 121 return root.Pass(); |
| 120 } | 122 } |
| 123 |
| 121 protected: | 124 protected: |
| 122 FakeImplProxy proxy_; | 125 FakeImplProxy proxy_; |
| 123 FakeLayerTreeHostImpl host_impl_; | 126 FakeLayerTreeHostImpl host_impl_; |
| 124 scoped_ptr<LayerImpl> root_; | 127 scoped_ptr<LayerImpl> root_; |
| 125 | 128 |
| 126 LayerPositionConstraint fixed_to_top_left_; | 129 LayerPositionConstraint fixed_to_top_left_; |
| 127 LayerPositionConstraint fixed_to_bottom_right_; | 130 LayerPositionConstraint fixed_to_bottom_right_; |
| 128 }; | 131 }; |
| 129 | 132 |
| 130 TEST_F(LayerPositionConstraintTest, | 133 TEST_F(LayerPositionConstraintTest, |
| (...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 ExecuteCalculateDrawProperties(root_.get()); | 1085 ExecuteCalculateDrawProperties(root_.get()); |
| 1083 | 1086 |
| 1084 // Root layer is not the fixed-container anyway. | 1087 // Root layer is not the fixed-container anyway. |
| 1085 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); | 1088 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); |
| 1086 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 1089 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 1087 grand_child->draw_transform()); | 1090 grand_child->draw_transform()); |
| 1088 } | 1091 } |
| 1089 | 1092 |
| 1090 } // namespace | 1093 } // namespace |
| 1091 } // namespace cc | 1094 } // namespace cc |
| OLD | NEW |