| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/effect_tree_layer_list_iterator.h" | 5 #include "cc/layers/effect_tree_layer_list_iterator.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| 11 #include "cc/test/fake_layer_tree_host.h" | 11 #include "cc/test/fake_layer_tree_host.h" |
| 12 #include "cc/test/layer_test_common.h" |
| 12 #include "cc/test/test_task_graph_runner.h" | 13 #include "cc/test/test_task_graph_runner.h" |
| 13 #include "cc/trees/layer_tree_host_common.h" | 14 #include "cc/trees/layer_tree_host_common.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "ui/gfx/transform.h" | 17 #include "ui/gfx/transform.h" |
| 17 | 18 |
| 18 namespace cc { | 19 namespace cc { |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 class TestLayerImpl : public LayerImpl { | 22 class TestLayerImpl : public LayerImpl { |
| 22 public: | 23 public: |
| 23 static std::unique_ptr<TestLayerImpl> Create(LayerTreeImpl* tree, int id) { | 24 static std::unique_ptr<TestLayerImpl> Create(LayerTreeImpl* tree, int id) { |
| 24 return base::WrapUnique(new TestLayerImpl(tree, id)); | 25 return base::WrapUnique(new TestLayerImpl(tree, id)); |
| 25 } | 26 } |
| 26 ~TestLayerImpl() override {} | 27 ~TestLayerImpl() override {} |
| 27 | 28 |
| 28 int count_; | 29 int count_; |
| 29 | 30 |
| 30 private: | 31 private: |
| 31 explicit TestLayerImpl(LayerTreeImpl* tree, int id) | 32 explicit TestLayerImpl(LayerTreeImpl* tree, int id) |
| 32 : LayerImpl(tree, id), count_(-1) { | 33 : LayerImpl(tree, id), count_(-1) { |
| 33 SetBounds(gfx::Size(100, 100)); | 34 SetBounds(gfx::Size(100, 100)); |
| 34 SetPosition(gfx::PointF()); | 35 SetPosition(gfx::PointF()); |
| 35 SetDrawsContent(true); | 36 SetDrawsContent(true); |
| 36 } | 37 } |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 #define EXPECT_COUNT(layer, target, contrib, itself) \ | 40 #define EXPECT_COUNT(layer, target, contrib, itself) \ |
| 40 if (layer->GetRenderSurface()) { \ | 41 if (GetRenderSurface(layer)) { \ |
| 41 EXPECT_EQ(target, target_surface_count_[layer->effect_tree_index()]); \ | 42 EXPECT_EQ(target, target_surface_count_[layer->effect_tree_index()]); \ |
| 42 EXPECT_EQ(contrib, \ | 43 EXPECT_EQ(contrib, \ |
| 43 contributing_surface_count_[layer->effect_tree_index()]); \ | 44 contributing_surface_count_[layer->effect_tree_index()]); \ |
| 44 } \ | 45 } \ |
| 45 EXPECT_EQ(itself, layer->count_); | 46 EXPECT_EQ(itself, layer->count_); |
| 46 | 47 |
| 47 class EffectTreeLayerListIteratorTest : public testing::Test { | 48 class EffectTreeLayerListIteratorTest : public testing::Test { |
| 48 public: | 49 public: |
| 49 EffectTreeLayerListIteratorTest() | 50 EffectTreeLayerListIteratorTest() |
| 50 : host_impl_(&task_runner_provider_, &task_graph_runner_), id_(1) {} | 51 : host_impl_(&task_runner_provider_, &task_graph_runner_), id_(1) {} |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 EXPECT_COUNT(root21_ptr, -1, -1, 9); | 248 EXPECT_COUNT(root21_ptr, -1, -1, 9); |
| 248 EXPECT_COUNT(root22_ptr, 7, 8, 6); | 249 EXPECT_COUNT(root22_ptr, 7, 8, 6); |
| 249 EXPECT_COUNT(root221_ptr, -1, -1, 5); | 250 EXPECT_COUNT(root221_ptr, -1, -1, 5); |
| 250 EXPECT_COUNT(root23_ptr, 3, 4, 2); | 251 EXPECT_COUNT(root23_ptr, 3, 4, 2); |
| 251 EXPECT_COUNT(root231_ptr, -1, -1, 1); | 252 EXPECT_COUNT(root231_ptr, -1, -1, 1); |
| 252 EXPECT_COUNT(root3_ptr, -1, -1, 0); | 253 EXPECT_COUNT(root3_ptr, -1, -1, 0); |
| 253 } | 254 } |
| 254 | 255 |
| 255 } // namespace | 256 } // namespace |
| 256 } // namespace cc | 257 } // namespace cc |
| OLD | NEW |