Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1011)

Side by Side Diff: cc/layers/layer_list_iterator_unittest.cc

Issue 2216203002: Refactor MutatorHostClient from LayerTreeHost to LayerTree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on another LTH refactor CL. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/layers/layer_proto_converter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 layer5->AddChild(std::move(layer6)); 61 layer5->AddChild(std::move(layer6));
62 layer5->AddChild(std::move(layer7)); 62 layer5->AddChild(std::move(layer7));
63 63
64 layer1->AddChild(std::move(layer2)); 64 layer1->AddChild(std::move(layer2));
65 layer1->AddChild(std::move(layer5)); 65 layer1->AddChild(std::move(layer5));
66 66
67 host->SetRootLayer(std::move(layer1)); 67 host->SetRootLayer(std::move(layer1));
68 68
69 int i = 1; 69 int i = 1;
70 for (auto* layer : *host) { 70 for (auto* layer : *host->GetLayerTree()) {
71 EXPECT_EQ(i++, layer_id_to_order[layer->id()]); 71 EXPECT_EQ(i++, layer_id_to_order[layer->id()]);
72 } 72 }
73 EXPECT_EQ(8, i); 73 EXPECT_EQ(8, i);
74 } 74 }
75 75
76 TEST(LayerListIteratorTest, VerifySingleLayer) { 76 TEST(LayerListIteratorTest, VerifySingleLayer) {
77 // Unfortunate preamble. 77 // Unfortunate preamble.
78 FakeLayerTreeHostClient client; 78 FakeLayerTreeHostClient client;
79 TestTaskGraphRunner task_graph_runner; 79 TestTaskGraphRunner task_graph_runner;
80 std::unique_ptr<FakeLayerTreeHost> host_ptr = 80 std::unique_ptr<FakeLayerTreeHost> host_ptr =
81 FakeLayerTreeHost::Create(&client, &task_graph_runner); 81 FakeLayerTreeHost::Create(&client, &task_graph_runner);
82 FakeLayerTreeHost* host = host_ptr.get(); 82 FakeLayerTreeHost* host = host_ptr.get();
83 83
84 // This test constructs a tree consisting of a single layer. 84 // This test constructs a tree consisting of a single layer.
85 scoped_refptr<Layer> layer1 = Layer::Create(); 85 scoped_refptr<Layer> layer1 = Layer::Create();
86 std::unordered_map<int, int> layer_id_to_order; 86 std::unordered_map<int, int> layer_id_to_order;
87 layer_id_to_order[layer1->id()] = 1; 87 layer_id_to_order[layer1->id()] = 1;
88 host->SetRootLayer(std::move(layer1)); 88 host->SetRootLayer(std::move(layer1));
89 89
90 int i = 1; 90 int i = 1;
91 for (auto* layer : *host) { 91 for (auto* layer : *host->GetLayerTree()) {
92 EXPECT_EQ(i++, layer_id_to_order[layer->id()]); 92 EXPECT_EQ(i++, layer_id_to_order[layer->id()]);
93 } 93 }
94 EXPECT_EQ(2, i); 94 EXPECT_EQ(2, i);
95 } 95 }
96 96
97 TEST(LayerListIteratorTest, VerifyNullFirstLayer) { 97 TEST(LayerListIteratorTest, VerifyNullFirstLayer) {
98 // Ensures that if an iterator is constructed with a nullptr, that it can be 98 // Ensures that if an iterator is constructed with a nullptr, that it can be
99 // iterated without issue and that it remains equal to any other 99 // iterated without issue and that it remains equal to any other
100 // null-initialized iterator. 100 // null-initialized iterator.
101 LayerListIterator<Layer> it(nullptr); 101 LayerListIterator<Layer> it(nullptr);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 layer5->AddChild(std::move(layer6)); 146 layer5->AddChild(std::move(layer6));
147 layer5->AddChild(std::move(layer7)); 147 layer5->AddChild(std::move(layer7));
148 148
149 layer1->AddChild(std::move(layer2)); 149 layer1->AddChild(std::move(layer2));
150 layer1->AddChild(std::move(layer5)); 150 layer1->AddChild(std::move(layer5));
151 151
152 host->SetRootLayer(std::move(layer1)); 152 host->SetRootLayer(std::move(layer1));
153 153
154 int i = 7; 154 int i = 7;
155 155
156 for (auto* layer : base::Reversed(*host)) { 156 for (auto* layer : base::Reversed(*host->GetLayerTree())) {
157 EXPECT_EQ(i--, layer_id_to_order[layer->id()]); 157 EXPECT_EQ(i--, layer_id_to_order[layer->id()]);
158 } 158 }
159 159
160 EXPECT_EQ(0, i); 160 EXPECT_EQ(0, i);
161 } 161 }
162 162
163 TEST(LayerListReverseIteratorTest, VerifySingleLayer) { 163 TEST(LayerListReverseIteratorTest, VerifySingleLayer) {
164 // Unfortunate preamble. 164 // Unfortunate preamble.
165 FakeLayerTreeHostClient client; 165 FakeLayerTreeHostClient client;
166 TestTaskGraphRunner task_graph_runner; 166 TestTaskGraphRunner task_graph_runner;
167 std::unique_ptr<FakeLayerTreeHost> host_ptr = 167 std::unique_ptr<FakeLayerTreeHost> host_ptr =
168 FakeLayerTreeHost::Create(&client, &task_graph_runner); 168 FakeLayerTreeHost::Create(&client, &task_graph_runner);
169 FakeLayerTreeHost* host = host_ptr.get(); 169 FakeLayerTreeHost* host = host_ptr.get();
170 170
171 // This test constructs a tree consisting of a single layer. 171 // This test constructs a tree consisting of a single layer.
172 scoped_refptr<Layer> layer1 = Layer::Create(); 172 scoped_refptr<Layer> layer1 = Layer::Create();
173 std::unordered_map<int, int> layer_id_to_order; 173 std::unordered_map<int, int> layer_id_to_order;
174 layer_id_to_order[layer1->id()] = 1; 174 layer_id_to_order[layer1->id()] = 1;
175 host->SetRootLayer(std::move(layer1)); 175 host->SetRootLayer(std::move(layer1));
176 176
177 int i = 1; 177 int i = 1;
178 for (auto* layer : base::Reversed(*host)) { 178 for (auto* layer : base::Reversed(*host->GetLayerTree())) {
179 EXPECT_EQ(i--, layer_id_to_order[layer->id()]); 179 EXPECT_EQ(i--, layer_id_to_order[layer->id()]);
180 } 180 }
181 EXPECT_EQ(0, i); 181 EXPECT_EQ(0, i);
182 } 182 }
183 183
184 TEST(LayerListReverseIteratorTest, VerifyNullFirstLayer) { 184 TEST(LayerListReverseIteratorTest, VerifyNullFirstLayer) {
185 // Ensures that if an iterator is constructed with a nullptr, that it can be 185 // Ensures that if an iterator is constructed with a nullptr, that it can be
186 // iterated without issue and that it remains equal to any other 186 // iterated without issue and that it remains equal to any other
187 // null-initialized iterator. 187 // null-initialized iterator.
188 LayerListReverseIterator<Layer> it(nullptr); 188 LayerListReverseIterator<Layer> it(nullptr);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 LayerListReverseIterator<LayerImpl> it(nullptr); 376 LayerListReverseIterator<LayerImpl> it(nullptr);
377 LayerListReverseIterator<LayerImpl> end(nullptr); 377 LayerListReverseIterator<LayerImpl> end(nullptr);
378 378
379 EXPECT_EQ(it, end); 379 EXPECT_EQ(it, end);
380 ++it; 380 ++it;
381 EXPECT_EQ(it, end); 381 EXPECT_EQ(it, end);
382 } 382 }
383 383
384 } // namespace 384 } // namespace
385 } // namespace cc 385 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/layers/layer_proto_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698