OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_list_iterator.h" | 5 #include "cc/layers/layer_list_iterator.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/containers/adapters.h" | 9 #include "base/containers/adapters.h" |
10 #include "cc/test/fake_impl_task_runner_provider.h" | 10 #include "cc/test/fake_impl_task_runner_provider.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 232 |
233 layer2->test_properties()->AddChild(std::move(layer3)); | 233 layer2->test_properties()->AddChild(std::move(layer3)); |
234 layer2->test_properties()->AddChild(std::move(layer4)); | 234 layer2->test_properties()->AddChild(std::move(layer4)); |
235 | 235 |
236 layer5->test_properties()->AddChild(std::move(layer6)); | 236 layer5->test_properties()->AddChild(std::move(layer6)); |
237 layer5->test_properties()->AddChild(std::move(layer7)); | 237 layer5->test_properties()->AddChild(std::move(layer7)); |
238 | 238 |
239 layer1->test_properties()->AddChild(std::move(layer2)); | 239 layer1->test_properties()->AddChild(std::move(layer2)); |
240 layer1->test_properties()->AddChild(std::move(layer5)); | 240 layer1->test_properties()->AddChild(std::move(layer5)); |
241 | 241 |
242 host_impl.active_tree()->SetRootLayer(std::move(layer1)); | 242 host_impl.active_tree()->SetRootLayerForTesting(std::move(layer1)); |
243 host_impl.active_tree()->BuildLayerListForTesting(); | 243 host_impl.active_tree()->BuildLayerListForTesting(); |
244 | 244 |
245 int i = 1; | 245 int i = 1; |
246 for (auto* layer : *host_impl.active_tree()) { | 246 for (auto* layer : *host_impl.active_tree()) { |
247 EXPECT_EQ(i++, layer->id()); | 247 EXPECT_EQ(i++, layer->id()); |
248 } | 248 } |
249 EXPECT_EQ(8, i); | 249 EXPECT_EQ(8, i); |
250 } | 250 } |
251 | 251 |
252 TEST(LayerListIteratorTest, VerifySingleLayerImpl) { | 252 TEST(LayerListIteratorTest, VerifySingleLayerImpl) { |
253 // Unfortunate preamble. | 253 // Unfortunate preamble. |
254 FakeImplTaskRunnerProvider task_runner_provider; | 254 FakeImplTaskRunnerProvider task_runner_provider; |
255 TestSharedBitmapManager shared_bitmap_manager; | 255 TestSharedBitmapManager shared_bitmap_manager; |
256 TestTaskGraphRunner task_graph_runner; | 256 TestTaskGraphRunner task_graph_runner; |
257 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 257 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
258 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 258 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
259 &task_graph_runner); | 259 &task_graph_runner); |
260 host_impl.SetVisible(true); | 260 host_impl.SetVisible(true); |
261 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); | 261 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); |
262 | 262 |
263 // This test constructs a tree consisting of a single layer. | 263 // This test constructs a tree consisting of a single layer. |
264 std::unique_ptr<LayerImpl> layer1 = | 264 std::unique_ptr<LayerImpl> layer1 = |
265 LayerImpl::Create(host_impl.active_tree(), 1); | 265 LayerImpl::Create(host_impl.active_tree(), 1); |
266 host_impl.active_tree()->SetRootLayer(std::move(layer1)); | 266 host_impl.active_tree()->SetRootLayerForTesting(std::move(layer1)); |
267 host_impl.active_tree()->BuildLayerListForTesting(); | 267 host_impl.active_tree()->BuildLayerListForTesting(); |
268 | 268 |
269 int i = 1; | 269 int i = 1; |
270 for (auto* layer : *host_impl.active_tree()) { | 270 for (auto* layer : *host_impl.active_tree()) { |
271 EXPECT_EQ(i++, layer->id()); | 271 EXPECT_EQ(i++, layer->id()); |
272 } | 272 } |
273 EXPECT_EQ(2, i); | 273 EXPECT_EQ(2, i); |
274 } | 274 } |
275 | 275 |
276 TEST(LayerListIteratorTest, VerifyNullFirstLayerImpl) { | 276 TEST(LayerListIteratorTest, VerifyNullFirstLayerImpl) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 322 |
323 layer2->test_properties()->AddChild(std::move(layer3)); | 323 layer2->test_properties()->AddChild(std::move(layer3)); |
324 layer2->test_properties()->AddChild(std::move(layer4)); | 324 layer2->test_properties()->AddChild(std::move(layer4)); |
325 | 325 |
326 layer5->test_properties()->AddChild(std::move(layer6)); | 326 layer5->test_properties()->AddChild(std::move(layer6)); |
327 layer5->test_properties()->AddChild(std::move(layer7)); | 327 layer5->test_properties()->AddChild(std::move(layer7)); |
328 | 328 |
329 layer1->test_properties()->AddChild(std::move(layer2)); | 329 layer1->test_properties()->AddChild(std::move(layer2)); |
330 layer1->test_properties()->AddChild(std::move(layer5)); | 330 layer1->test_properties()->AddChild(std::move(layer5)); |
331 | 331 |
332 host_impl.active_tree()->SetRootLayer(std::move(layer1)); | 332 host_impl.active_tree()->SetRootLayerForTesting(std::move(layer1)); |
333 host_impl.active_tree()->BuildLayerListForTesting(); | 333 host_impl.active_tree()->BuildLayerListForTesting(); |
334 | 334 |
335 int i = 7; | 335 int i = 7; |
336 | 336 |
337 for (auto* layer : base::Reversed(*host_impl.active_tree())) { | 337 for (auto* layer : base::Reversed(*host_impl.active_tree())) { |
338 EXPECT_EQ(i--, layer->id()); | 338 EXPECT_EQ(i--, layer->id()); |
339 } | 339 } |
340 | 340 |
341 EXPECT_EQ(0, i); | 341 EXPECT_EQ(0, i); |
342 } | 342 } |
343 | 343 |
344 TEST(LayerListReverseIteratorTest, VerifySingleLayerImpl) { | 344 TEST(LayerListReverseIteratorTest, VerifySingleLayerImpl) { |
345 // Unfortunate preamble. | 345 // Unfortunate preamble. |
346 FakeImplTaskRunnerProvider task_runner_provider; | 346 FakeImplTaskRunnerProvider task_runner_provider; |
347 TestSharedBitmapManager shared_bitmap_manager; | 347 TestSharedBitmapManager shared_bitmap_manager; |
348 TestTaskGraphRunner task_graph_runner; | 348 TestTaskGraphRunner task_graph_runner; |
349 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 349 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
350 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 350 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
351 &task_graph_runner); | 351 &task_graph_runner); |
352 host_impl.SetVisible(true); | 352 host_impl.SetVisible(true); |
353 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); | 353 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); |
354 | 354 |
355 // This test constructs a tree consisting of a single layer. | 355 // This test constructs a tree consisting of a single layer. |
356 std::unique_ptr<LayerImpl> layer1 = | 356 std::unique_ptr<LayerImpl> layer1 = |
357 LayerImpl::Create(host_impl.active_tree(), 1); | 357 LayerImpl::Create(host_impl.active_tree(), 1); |
358 host_impl.active_tree()->SetRootLayer(std::move(layer1)); | 358 host_impl.active_tree()->SetRootLayerForTesting(std::move(layer1)); |
359 host_impl.active_tree()->BuildLayerListForTesting(); | 359 host_impl.active_tree()->BuildLayerListForTesting(); |
360 | 360 |
361 int i = 1; | 361 int i = 1; |
362 for (auto* layer : base::Reversed(*host_impl.active_tree())) { | 362 for (auto* layer : base::Reversed(*host_impl.active_tree())) { |
363 EXPECT_EQ(i--, layer->id()); | 363 EXPECT_EQ(i--, layer->id()); |
364 } | 364 } |
365 EXPECT_EQ(0, i); | 365 EXPECT_EQ(0, i); |
366 } | 366 } |
367 | 367 |
368 TEST(LayerListReverseIteratorTest, VerifyNullFirstLayerImpl) { | 368 TEST(LayerListReverseIteratorTest, VerifyNullFirstLayerImpl) { |
369 // Ensures that if an iterator is constructed with a nullptr, that it can be | 369 // Ensures that if an iterator is constructed with a nullptr, that it can be |
370 // iterated without issue and that it remains equal to any other | 370 // iterated without issue and that it remains equal to any other |
371 // null-initialized iterator. | 371 // null-initialized iterator. |
372 LayerListReverseIterator<LayerImpl> it(nullptr); | 372 LayerListReverseIterator<LayerImpl> it(nullptr); |
373 LayerListReverseIterator<LayerImpl> end(nullptr); | 373 LayerListReverseIterator<LayerImpl> end(nullptr); |
374 | 374 |
375 EXPECT_EQ(it, end); | 375 EXPECT_EQ(it, end); |
376 ++it; | 376 ++it; |
377 EXPECT_EQ(it, end); | 377 EXPECT_EQ(it, end); |
378 } | 378 } |
379 | 379 |
380 } // namespace | 380 } // namespace |
381 } // namespace cc | 381 } // namespace cc |
OLD | NEW |