OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_iterator.h" | 5 #include "cc/layers/layer_iterator.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
| 9 #include "base/memory/ptr_util.h" |
9 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
10 #include "cc/test/fake_layer_tree_host.h" | 11 #include "cc/test/fake_layer_tree_host.h" |
11 #include "cc/test/test_task_graph_runner.h" | 12 #include "cc/test/test_task_graph_runner.h" |
12 #include "cc/trees/layer_tree_host_common.h" | 13 #include "cc/trees/layer_tree_host_common.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "ui/gfx/transform.h" | 16 #include "ui/gfx/transform.h" |
16 | 17 |
17 using ::testing::Mock; | 18 using ::testing::Mock; |
18 using ::testing::_; | 19 using ::testing::_; |
19 using ::testing::AtLeast; | 20 using ::testing::AtLeast; |
20 using ::testing::AnyNumber; | 21 using ::testing::AnyNumber; |
21 | 22 |
22 namespace cc { | 23 namespace cc { |
23 namespace { | 24 namespace { |
24 | 25 |
25 class TestLayerImpl : public LayerImpl { | 26 class TestLayerImpl : public LayerImpl { |
26 public: | 27 public: |
27 static scoped_ptr<TestLayerImpl> Create(LayerTreeImpl* tree, int id) { | 28 static std::unique_ptr<TestLayerImpl> Create(LayerTreeImpl* tree, int id) { |
28 return make_scoped_ptr(new TestLayerImpl(tree, id)); | 29 return base::WrapUnique(new TestLayerImpl(tree, id)); |
29 } | 30 } |
30 ~TestLayerImpl() override {} | 31 ~TestLayerImpl() override {} |
31 | 32 |
32 int count_representing_target_surface_; | 33 int count_representing_target_surface_; |
33 int count_representing_contributing_surface_; | 34 int count_representing_contributing_surface_; |
34 int count_representing_itself_; | 35 int count_representing_itself_; |
35 | 36 |
36 private: | 37 private: |
37 explicit TestLayerImpl(LayerTreeImpl* tree, int id) | 38 explicit TestLayerImpl(LayerTreeImpl* tree, int id) |
38 : LayerImpl(tree, id), | 39 : LayerImpl(tree, id), |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 92 } |
92 | 93 |
93 class LayerIteratorTest : public testing::Test { | 94 class LayerIteratorTest : public testing::Test { |
94 public: | 95 public: |
95 LayerIteratorTest() | 96 LayerIteratorTest() |
96 : host_impl_(&task_runner_provider_, | 97 : host_impl_(&task_runner_provider_, |
97 &shared_bitmap_manager_, | 98 &shared_bitmap_manager_, |
98 &task_graph_runner_), | 99 &task_graph_runner_), |
99 id_(1) {} | 100 id_(1) {} |
100 | 101 |
101 scoped_ptr<TestLayerImpl> CreateLayer() { | 102 std::unique_ptr<TestLayerImpl> CreateLayer() { |
102 return TestLayerImpl::Create(host_impl_.active_tree(), id_++); | 103 return TestLayerImpl::Create(host_impl_.active_tree(), id_++); |
103 } | 104 } |
104 | 105 |
105 protected: | 106 protected: |
106 FakeImplTaskRunnerProvider task_runner_provider_; | 107 FakeImplTaskRunnerProvider task_runner_provider_; |
107 TestSharedBitmapManager shared_bitmap_manager_; | 108 TestSharedBitmapManager shared_bitmap_manager_; |
108 TestTaskGraphRunner task_graph_runner_; | 109 TestTaskGraphRunner task_graph_runner_; |
109 FakeLayerTreeHostImpl host_impl_; | 110 FakeLayerTreeHostImpl host_impl_; |
110 | 111 |
111 int id_; | 112 int id_; |
112 }; | 113 }; |
113 | 114 |
114 TEST_F(LayerIteratorTest, EmptyTree) { | 115 TEST_F(LayerIteratorTest, EmptyTree) { |
115 LayerImplList render_surface_layer_list; | 116 LayerImplList render_surface_layer_list; |
116 | 117 |
117 IterateFrontToBack(&render_surface_layer_list); | 118 IterateFrontToBack(&render_surface_layer_list); |
118 } | 119 } |
119 | 120 |
120 TEST_F(LayerIteratorTest, SimpleTree) { | 121 TEST_F(LayerIteratorTest, SimpleTree) { |
121 scoped_ptr<TestLayerImpl> root_layer = CreateLayer(); | 122 std::unique_ptr<TestLayerImpl> root_layer = CreateLayer(); |
122 scoped_ptr<TestLayerImpl> first = CreateLayer(); | 123 std::unique_ptr<TestLayerImpl> first = CreateLayer(); |
123 scoped_ptr<TestLayerImpl> second = CreateLayer(); | 124 std::unique_ptr<TestLayerImpl> second = CreateLayer(); |
124 scoped_ptr<TestLayerImpl> third = CreateLayer(); | 125 std::unique_ptr<TestLayerImpl> third = CreateLayer(); |
125 scoped_ptr<TestLayerImpl> fourth = CreateLayer(); | 126 std::unique_ptr<TestLayerImpl> fourth = CreateLayer(); |
126 | 127 |
127 TestLayerImpl* root_ptr = root_layer.get(); | 128 TestLayerImpl* root_ptr = root_layer.get(); |
128 TestLayerImpl* first_ptr = first.get(); | 129 TestLayerImpl* first_ptr = first.get(); |
129 TestLayerImpl* second_ptr = second.get(); | 130 TestLayerImpl* second_ptr = second.get(); |
130 TestLayerImpl* third_ptr = third.get(); | 131 TestLayerImpl* third_ptr = third.get(); |
131 TestLayerImpl* fourth_ptr = fourth.get(); | 132 TestLayerImpl* fourth_ptr = fourth.get(); |
132 | 133 |
133 root_layer->AddChild(std::move(first)); | 134 root_layer->AddChild(std::move(first)); |
134 root_layer->AddChild(std::move(second)); | 135 root_layer->AddChild(std::move(second)); |
135 root_layer->AddChild(std::move(third)); | 136 root_layer->AddChild(std::move(third)); |
(...skipping 10 matching lines...) Expand all Loading... |
146 | 147 |
147 IterateFrontToBack(&render_surface_layer_list); | 148 IterateFrontToBack(&render_surface_layer_list); |
148 EXPECT_COUNT(root_ptr, 5, -1, 4); | 149 EXPECT_COUNT(root_ptr, 5, -1, 4); |
149 EXPECT_COUNT(first_ptr, -1, -1, 3); | 150 EXPECT_COUNT(first_ptr, -1, -1, 3); |
150 EXPECT_COUNT(second_ptr, -1, -1, 2); | 151 EXPECT_COUNT(second_ptr, -1, -1, 2); |
151 EXPECT_COUNT(third_ptr, -1, -1, 1); | 152 EXPECT_COUNT(third_ptr, -1, -1, 1); |
152 EXPECT_COUNT(fourth_ptr, -1, -1, 0); | 153 EXPECT_COUNT(fourth_ptr, -1, -1, 0); |
153 } | 154 } |
154 | 155 |
155 TEST_F(LayerIteratorTest, ComplexTree) { | 156 TEST_F(LayerIteratorTest, ComplexTree) { |
156 scoped_ptr<TestLayerImpl> root_layer = CreateLayer(); | 157 std::unique_ptr<TestLayerImpl> root_layer = CreateLayer(); |
157 scoped_ptr<TestLayerImpl> root1 = CreateLayer(); | 158 std::unique_ptr<TestLayerImpl> root1 = CreateLayer(); |
158 scoped_ptr<TestLayerImpl> root2 = CreateLayer(); | 159 std::unique_ptr<TestLayerImpl> root2 = CreateLayer(); |
159 scoped_ptr<TestLayerImpl> root3 = CreateLayer(); | 160 std::unique_ptr<TestLayerImpl> root3 = CreateLayer(); |
160 scoped_ptr<TestLayerImpl> root21 = CreateLayer(); | 161 std::unique_ptr<TestLayerImpl> root21 = CreateLayer(); |
161 scoped_ptr<TestLayerImpl> root22 = CreateLayer(); | 162 std::unique_ptr<TestLayerImpl> root22 = CreateLayer(); |
162 scoped_ptr<TestLayerImpl> root23 = CreateLayer(); | 163 std::unique_ptr<TestLayerImpl> root23 = CreateLayer(); |
163 scoped_ptr<TestLayerImpl> root221 = CreateLayer(); | 164 std::unique_ptr<TestLayerImpl> root221 = CreateLayer(); |
164 scoped_ptr<TestLayerImpl> root231 = CreateLayer(); | 165 std::unique_ptr<TestLayerImpl> root231 = CreateLayer(); |
165 | 166 |
166 TestLayerImpl* root_ptr = root_layer.get(); | 167 TestLayerImpl* root_ptr = root_layer.get(); |
167 TestLayerImpl* root1_ptr = root1.get(); | 168 TestLayerImpl* root1_ptr = root1.get(); |
168 TestLayerImpl* root2_ptr = root2.get(); | 169 TestLayerImpl* root2_ptr = root2.get(); |
169 TestLayerImpl* root3_ptr = root3.get(); | 170 TestLayerImpl* root3_ptr = root3.get(); |
170 TestLayerImpl* root21_ptr = root21.get(); | 171 TestLayerImpl* root21_ptr = root21.get(); |
171 TestLayerImpl* root22_ptr = root22.get(); | 172 TestLayerImpl* root22_ptr = root22.get(); |
172 TestLayerImpl* root23_ptr = root23.get(); | 173 TestLayerImpl* root23_ptr = root23.get(); |
173 TestLayerImpl* root221_ptr = root221.get(); | 174 TestLayerImpl* root221_ptr = root221.get(); |
174 TestLayerImpl* root231_ptr = root231.get(); | 175 TestLayerImpl* root231_ptr = root231.get(); |
(...skipping 22 matching lines...) Expand all Loading... |
197 EXPECT_COUNT(root2_ptr, -1, -1, 6); | 198 EXPECT_COUNT(root2_ptr, -1, -1, 6); |
198 EXPECT_COUNT(root21_ptr, -1, -1, 5); | 199 EXPECT_COUNT(root21_ptr, -1, -1, 5); |
199 EXPECT_COUNT(root22_ptr, -1, -1, 4); | 200 EXPECT_COUNT(root22_ptr, -1, -1, 4); |
200 EXPECT_COUNT(root221_ptr, -1, -1, 3); | 201 EXPECT_COUNT(root221_ptr, -1, -1, 3); |
201 EXPECT_COUNT(root23_ptr, -1, -1, 2); | 202 EXPECT_COUNT(root23_ptr, -1, -1, 2); |
202 EXPECT_COUNT(root231_ptr, -1, -1, 1); | 203 EXPECT_COUNT(root231_ptr, -1, -1, 1); |
203 EXPECT_COUNT(root3_ptr, -1, -1, 0); | 204 EXPECT_COUNT(root3_ptr, -1, -1, 0); |
204 } | 205 } |
205 | 206 |
206 TEST_F(LayerIteratorTest, ComplexTreeMultiSurface) { | 207 TEST_F(LayerIteratorTest, ComplexTreeMultiSurface) { |
207 scoped_ptr<TestLayerImpl> root_layer = CreateLayer(); | 208 std::unique_ptr<TestLayerImpl> root_layer = CreateLayer(); |
208 scoped_ptr<TestLayerImpl> root1 = CreateLayer(); | 209 std::unique_ptr<TestLayerImpl> root1 = CreateLayer(); |
209 scoped_ptr<TestLayerImpl> root2 = CreateLayer(); | 210 std::unique_ptr<TestLayerImpl> root2 = CreateLayer(); |
210 scoped_ptr<TestLayerImpl> root3 = CreateLayer(); | 211 std::unique_ptr<TestLayerImpl> root3 = CreateLayer(); |
211 scoped_ptr<TestLayerImpl> root21 = CreateLayer(); | 212 std::unique_ptr<TestLayerImpl> root21 = CreateLayer(); |
212 scoped_ptr<TestLayerImpl> root22 = CreateLayer(); | 213 std::unique_ptr<TestLayerImpl> root22 = CreateLayer(); |
213 scoped_ptr<TestLayerImpl> root23 = CreateLayer(); | 214 std::unique_ptr<TestLayerImpl> root23 = CreateLayer(); |
214 scoped_ptr<TestLayerImpl> root221 = CreateLayer(); | 215 std::unique_ptr<TestLayerImpl> root221 = CreateLayer(); |
215 scoped_ptr<TestLayerImpl> root231 = CreateLayer(); | 216 std::unique_ptr<TestLayerImpl> root231 = CreateLayer(); |
216 | 217 |
217 TestLayerImpl* root_ptr = root_layer.get(); | 218 TestLayerImpl* root_ptr = root_layer.get(); |
218 TestLayerImpl* root1_ptr = root1.get(); | 219 TestLayerImpl* root1_ptr = root1.get(); |
219 TestLayerImpl* root2_ptr = root2.get(); | 220 TestLayerImpl* root2_ptr = root2.get(); |
220 TestLayerImpl* root3_ptr = root3.get(); | 221 TestLayerImpl* root3_ptr = root3.get(); |
221 TestLayerImpl* root21_ptr = root21.get(); | 222 TestLayerImpl* root21_ptr = root21.get(); |
222 TestLayerImpl* root22_ptr = root22.get(); | 223 TestLayerImpl* root22_ptr = root22.get(); |
223 TestLayerImpl* root23_ptr = root23.get(); | 224 TestLayerImpl* root23_ptr = root23.get(); |
224 TestLayerImpl* root221_ptr = root221.get(); | 225 TestLayerImpl* root221_ptr = root221.get(); |
225 TestLayerImpl* root231_ptr = root231.get(); | 226 TestLayerImpl* root231_ptr = root231.get(); |
(...skipping 27 matching lines...) Expand all Loading... |
253 EXPECT_COUNT(root21_ptr, -1, -1, 9); | 254 EXPECT_COUNT(root21_ptr, -1, -1, 9); |
254 EXPECT_COUNT(root22_ptr, 7, 8, 6); | 255 EXPECT_COUNT(root22_ptr, 7, 8, 6); |
255 EXPECT_COUNT(root221_ptr, -1, -1, 5); | 256 EXPECT_COUNT(root221_ptr, -1, -1, 5); |
256 EXPECT_COUNT(root23_ptr, 3, 4, 2); | 257 EXPECT_COUNT(root23_ptr, 3, 4, 2); |
257 EXPECT_COUNT(root231_ptr, -1, -1, 1); | 258 EXPECT_COUNT(root231_ptr, -1, -1, 1); |
258 EXPECT_COUNT(root3_ptr, -1, -1, 0); | 259 EXPECT_COUNT(root3_ptr, -1, -1, 0); |
259 } | 260 } |
260 | 261 |
261 } // namespace | 262 } // namespace |
262 } // namespace cc | 263 } // namespace cc |
OLD | NEW |