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

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

Issue 2159513003: Setup LayerTree class, refactor 2 functions from LayerTreeHost to it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Layer GetLayerTree now directly uses LayerTree pointer. 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_proto_converter.h" 5 #include "cc/layers/layer_proto_converter.h"
6 6
7 #include "cc/layers/empty_content_layer_client.h" 7 #include "cc/layers/empty_content_layer_client.h"
8 #include "cc/layers/heads_up_display_layer.h" 8 #include "cc/layers/heads_up_display_layer.h"
9 #include "cc/layers/layer.h" 9 #include "cc/layers/layer.h"
10 #include "cc/layers/picture_layer.h" 10 #include "cc/layers/picture_layer.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 layer_src_b->AddChild(layer_src_d); 193 layer_src_b->AddChild(layer_src_d);
194 layer_src_b->SetMaskLayer(layer_src_b_mask.get()); 194 layer_src_b->SetMaskLayer(layer_src_b_mask.get());
195 layer_src_b->SetReplicaLayer(layer_src_b_replica.get()); 195 layer_src_b->SetReplicaLayer(layer_src_b_replica.get());
196 196
197 proto::LayerUpdate layer_update; 197 proto::LayerUpdate layer_update;
198 LayerProtoConverter::SerializeLayerProperties( 198 LayerProtoConverter::SerializeLayerProperties(
199 layer_src_root->layer_tree_host(), &layer_update); 199 layer_src_root->layer_tree_host(), &layer_update);
200 200
201 // All flags for pushing properties should have been cleared. 201 // All flags for pushing properties should have been cleared.
202 EXPECT_FALSE( 202 EXPECT_FALSE(
203 layer_src_root->layer_tree_host()->LayerNeedsPushPropertiesForTesting( 203 layer_src_root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
204 layer_src_root.get())); 204 layer_src_root.get()));
205 EXPECT_FALSE(layer_src_a->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
206 layer_src_a.get()));
207 EXPECT_FALSE(layer_src_b->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
208 layer_src_b.get()));
205 EXPECT_FALSE( 209 EXPECT_FALSE(
206 layer_src_a->layer_tree_host()->LayerNeedsPushPropertiesForTesting( 210 layer_src_b_mask->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
207 layer_src_a.get()));
208 EXPECT_FALSE(
209 layer_src_b->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
210 layer_src_b.get()));
211 EXPECT_FALSE(
212 layer_src_b_mask->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
213 layer_src_b_mask.get())); 211 layer_src_b_mask.get()));
214 EXPECT_FALSE( 212 EXPECT_FALSE(
215 layer_src_b_replica->layer_tree_host() 213 layer_src_b_replica->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
216 ->LayerNeedsPushPropertiesForTesting(layer_src_b_replica.get())); 214 layer_src_b_replica.get()));
217 EXPECT_FALSE( 215 EXPECT_FALSE(layer_src_c->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
218 layer_src_c->layer_tree_host()->LayerNeedsPushPropertiesForTesting( 216 layer_src_c.get()));
219 layer_src_c.get())); 217 EXPECT_FALSE(layer_src_d->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
220 EXPECT_FALSE( 218 layer_src_d.get()));
221 layer_src_d->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
222 layer_src_d.get()));
223 219
224 // All layers needs to push properties as their layer tree host changed. 220 // All layers needs to push properties as their layer tree host changed.
225 ASSERT_EQ(7, layer_update.layers_size()); 221 ASSERT_EQ(7, layer_update.layers_size());
226 layer_update.Clear(); 222 layer_update.Clear();
227 223
228 std::unordered_set<int> dirty_layer_ids; 224 std::unordered_set<int> dirty_layer_ids;
229 layer_src_a->SetNeedsPushProperties(); 225 layer_src_a->SetNeedsPushProperties();
230 dirty_layer_ids.insert(layer_src_a->id()); 226 dirty_layer_ids.insert(layer_src_a->id());
231 layer_src_b->SetNeedsPushProperties(); 227 layer_src_b->SetNeedsPushProperties();
232 dirty_layer_ids.insert(layer_src_b->id()); 228 dirty_layer_ids.insert(layer_src_b->id());
233 layer_src_b_mask->SetNeedsPushProperties(); 229 layer_src_b_mask->SetNeedsPushProperties();
234 dirty_layer_ids.insert(layer_src_b_mask->id()); 230 dirty_layer_ids.insert(layer_src_b_mask->id());
235 layer_src_d->SetNeedsPushProperties(); 231 layer_src_d->SetNeedsPushProperties();
236 dirty_layer_ids.insert(layer_src_d->id()); 232 dirty_layer_ids.insert(layer_src_d->id());
237 233
238 LayerProtoConverter::SerializeLayerProperties( 234 LayerProtoConverter::SerializeLayerProperties(
239 layer_src_root->layer_tree_host(), &layer_update); 235 layer_src_root->layer_tree_host(), &layer_update);
240 236
241 // All flags for pushing properties should have been cleared. 237 // All flags for pushing properties should have been cleared.
242 EXPECT_FALSE( 238 EXPECT_FALSE(
243 layer_src_root->layer_tree_host()->LayerNeedsPushPropertiesForTesting( 239 layer_src_root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
244 layer_src_root.get())); 240 layer_src_root.get()));
241 EXPECT_FALSE(layer_src_a->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
242 layer_src_a.get()));
243 EXPECT_FALSE(layer_src_b->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
244 layer_src_b.get()));
245 EXPECT_FALSE( 245 EXPECT_FALSE(
246 layer_src_a->layer_tree_host()->LayerNeedsPushPropertiesForTesting( 246 layer_src_b_mask->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
247 layer_src_a.get()));
248 EXPECT_FALSE(
249 layer_src_b->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
250 layer_src_b.get()));
251 EXPECT_FALSE(
252 layer_src_b_mask->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
253 layer_src_b_mask.get())); 247 layer_src_b_mask.get()));
254 EXPECT_FALSE( 248 EXPECT_FALSE(
255 layer_src_b_replica->layer_tree_host() 249 layer_src_b_replica->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
256 ->LayerNeedsPushPropertiesForTesting(layer_src_b_replica.get())); 250 layer_src_b_replica.get()));
257 EXPECT_FALSE( 251 EXPECT_FALSE(layer_src_c->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
258 layer_src_c->layer_tree_host()->LayerNeedsPushPropertiesForTesting( 252 layer_src_c.get()));
259 layer_src_c.get())); 253 EXPECT_FALSE(layer_src_d->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
260 EXPECT_FALSE( 254 layer_src_d.get()));
261 layer_src_d->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
262 layer_src_d.get()));
263 255
264 // Only 4 of the layers should have been serialized. 256 // Only 4 of the layers should have been serialized.
265 ASSERT_EQ(4, layer_update.layers_size()); 257 ASSERT_EQ(4, layer_update.layers_size());
266 for (int index = 0; index < layer_update.layers_size(); index++) 258 for (int index = 0; index < layer_update.layers_size(); index++)
267 EXPECT_NE(dirty_layer_ids.find(layer_update.layers(index).id()), 259 EXPECT_NE(dirty_layer_ids.find(layer_update.layers(index).id()),
268 dirty_layer_ids.end()); 260 dirty_layer_ids.end());
269 layer_src_root->SetLayerTreeHost(nullptr); 261 layer_src_root->SetLayerTreeHost(nullptr);
270 } 262 }
271 263
272 TEST_F(LayerProtoConverterTest, RecursivePropertiesSerializationSingleChild) { 264 TEST_F(LayerProtoConverterTest, RecursivePropertiesSerializationSingleChild) {
(...skipping 27 matching lines...) Expand all
300 layer_src_b->SetNeedsPushProperties(); 292 layer_src_b->SetNeedsPushProperties();
301 dirty_layer_ids.insert(layer_src_b->id()); 293 dirty_layer_ids.insert(layer_src_b->id());
302 layer_src_b_mask->SetNeedsPushProperties(); 294 layer_src_b_mask->SetNeedsPushProperties();
303 dirty_layer_ids.insert(layer_src_b_mask->id()); 295 dirty_layer_ids.insert(layer_src_b_mask->id());
304 296
305 LayerProtoConverter::SerializeLayerProperties( 297 LayerProtoConverter::SerializeLayerProperties(
306 layer_src_root->layer_tree_host(), &layer_update); 298 layer_src_root->layer_tree_host(), &layer_update);
307 299
308 // All flags for pushing properties should have been cleared. 300 // All flags for pushing properties should have been cleared.
309 EXPECT_FALSE( 301 EXPECT_FALSE(
310 layer_src_root->layer_tree_host()->LayerNeedsPushPropertiesForTesting( 302 layer_src_root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
311 layer_src_root.get())); 303 layer_src_root.get()));
304 EXPECT_FALSE(layer_src_b->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
305 layer_src_b.get()));
312 EXPECT_FALSE( 306 EXPECT_FALSE(
313 layer_src_b->layer_tree_host()->LayerNeedsPushPropertiesForTesting( 307 layer_src_b_mask->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
314 layer_src_b.get()));
315 EXPECT_FALSE(
316 layer_src_b_mask->layer_tree_host()->LayerNeedsPushPropertiesForTesting(
317 layer_src_b_mask.get())); 308 layer_src_b_mask.get()));
318 EXPECT_FALSE( 309 EXPECT_FALSE(layer_src_c->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
319 layer_src_c->layer_tree_host()->LayerNeedsPushPropertiesForTesting( 310 layer_src_c.get()));
320 layer_src_c.get()));
321 311
322 // Only 2 of the layers should have been serialized. 312 // Only 2 of the layers should have been serialized.
323 ASSERT_EQ(2, layer_update.layers_size()); 313 ASSERT_EQ(2, layer_update.layers_size());
324 for (int index = 0; index < layer_update.layers_size(); index++) 314 for (int index = 0; index < layer_update.layers_size(); index++)
325 EXPECT_NE(dirty_layer_ids.find(layer_update.layers(index).id()), 315 EXPECT_NE(dirty_layer_ids.find(layer_update.layers(index).id()),
326 dirty_layer_ids.end()); 316 dirty_layer_ids.end());
327 layer_src_root->SetLayerTreeHost(nullptr); 317 layer_src_root->SetLayerTreeHost(nullptr);
328 } 318 }
329 319
330 TEST_F(LayerProtoConverterTest, PictureLayerTypeSerialization) { 320 TEST_F(LayerProtoConverterTest, PictureLayerTypeSerialization) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 // serialize to. 382 // serialize to.
393 proto::LayerNode layer_node; 383 proto::LayerNode layer_node;
394 new_root->SetTypeForProtoSerialization(&layer_node); 384 new_root->SetTypeForProtoSerialization(&layer_node);
395 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, layer_node.type()); 385 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, layer_node.type());
396 386
397 new_root->SetLayerTreeHost(nullptr); 387 new_root->SetLayerTreeHost(nullptr);
398 } 388 }
399 389
400 } // namespace 390 } // namespace
401 } // namespace cc 391 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698