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

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

Issue 2375363002: cc/blimp: Set up the framework for state serialization. (Closed)
Patch Set: Created 4 years, 2 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 layer_src_root->SetLayerTreeHost(nullptr); 317 layer_src_root->SetLayerTreeHost(nullptr);
318 } 318 }
319 319
320 TEST_F(LayerProtoConverterTest, PictureLayerTypeSerialization) { 320 TEST_F(LayerProtoConverterTest, PictureLayerTypeSerialization) {
321 // Make sure that PictureLayers serialize to the 321 // Make sure that PictureLayers serialize to the
322 // proto::LayerType::PICTURE_LAYER type. 322 // proto::LayerType::PICTURE_LAYER type.
323 scoped_refptr<PictureLayer> layer = 323 scoped_refptr<PictureLayer> layer =
324 PictureLayer::Create(EmptyContentLayerClient::GetInstance()); 324 PictureLayer::Create(EmptyContentLayerClient::GetInstance());
325 325
326 proto::LayerNode layer_hierarchy; 326 proto::LayerNode layer_hierarchy;
327 LayerProtoConverter::SerializeLayerHierarchy(layer.get(), &layer_hierarchy); 327 layer->ToLayerNodeProto(&layer_hierarchy);
328 EXPECT_EQ(proto::LayerNode::PICTURE_LAYER, layer_hierarchy.type()); 328 EXPECT_EQ(proto::LayerNode::PICTURE_LAYER, layer_hierarchy.type());
329 } 329 }
330 330
331 TEST_F(LayerProtoConverterTest, PictureLayerTypeDeserialization) { 331 TEST_F(LayerProtoConverterTest, PictureLayerTypeDeserialization) {
332 // Make sure that proto::LayerType::PICTURE_LAYER ends up building a 332 // Make sure that proto::LayerType::PICTURE_LAYER ends up building a
333 // PictureLayer. 333 // PictureLayer.
334 scoped_refptr<Layer> old_root = 334 scoped_refptr<Layer> old_root =
335 PictureLayer::Create(EmptyContentLayerClient::GetInstance()); 335 PictureLayer::Create(EmptyContentLayerClient::GetInstance());
336 proto::LayerNode root_node; 336 proto::LayerNode root_node;
337 root_node.set_id(old_root->id()); 337 root_node.set_id(old_root->id());
(...skipping 14 matching lines...) Expand all
352 352
353 new_root->SetLayerTreeHost(nullptr); 353 new_root->SetLayerTreeHost(nullptr);
354 } 354 }
355 355
356 TEST_F(LayerProtoConverterTest, HudLayerTypeSerialization) { 356 TEST_F(LayerProtoConverterTest, HudLayerTypeSerialization) {
357 // Make sure that PictureLayers serialize to the 357 // Make sure that PictureLayers serialize to the
358 // proto::LayerType::HEADS_UP_DISPLAY_LAYER type. 358 // proto::LayerType::HEADS_UP_DISPLAY_LAYER type.
359 scoped_refptr<HeadsUpDisplayLayer> layer = HeadsUpDisplayLayer::Create(); 359 scoped_refptr<HeadsUpDisplayLayer> layer = HeadsUpDisplayLayer::Create();
360 360
361 proto::LayerNode layer_hierarchy; 361 proto::LayerNode layer_hierarchy;
362 LayerProtoConverter::SerializeLayerHierarchy(layer.get(), &layer_hierarchy); 362 layer->ToLayerNodeProto(&layer_hierarchy);
363 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, layer_hierarchy.type()); 363 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, layer_hierarchy.type());
364 } 364 }
365 365
366 TEST_F(LayerProtoConverterTest, HudLayerTypeDeserialization) { 366 TEST_F(LayerProtoConverterTest, HudLayerTypeDeserialization) {
367 // Make sure that proto::LayerType::HEADS_UP_DISPLAY_LAYER ends up building a 367 // Make sure that proto::LayerType::HEADS_UP_DISPLAY_LAYER ends up building a
368 // HeadsUpDisplayLayer. 368 // HeadsUpDisplayLayer.
369 scoped_refptr<Layer> old_root = HeadsUpDisplayLayer::Create(); 369 scoped_refptr<Layer> old_root = HeadsUpDisplayLayer::Create();
370 proto::LayerNode root_node; 370 proto::LayerNode root_node;
371 root_node.set_id(old_root->id()); 371 root_node.set_id(old_root->id());
372 root_node.set_type(proto::LayerNode::HEADS_UP_DISPLAY_LAYER); 372 root_node.set_type(proto::LayerNode::HEADS_UP_DISPLAY_LAYER);
373 373
374 scoped_refptr<Layer> new_root = 374 scoped_refptr<Layer> new_root =
375 LayerProtoConverter::DeserializeLayerHierarchy(old_root, root_node, 375 LayerProtoConverter::DeserializeLayerHierarchy(old_root, root_node,
376 layer_tree_host_.get()); 376 layer_tree_host_.get());
377 377
378 // Validate that the ids are equal. 378 // Validate that the ids are equal.
379 EXPECT_EQ(old_root->id(), new_root->id()); 379 EXPECT_EQ(old_root->id(), new_root->id());
380 380
381 // Check that the layer type is equal by using the type this layer would 381 // Check that the layer type is equal by using the type this layer would
382 // serialize to. 382 // serialize to.
383 proto::LayerNode layer_node; 383 proto::LayerNode layer_node;
384 new_root->SetTypeForProtoSerialization(&layer_node); 384 new_root->SetTypeForProtoSerialization(&layer_node);
385 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, layer_node.type()); 385 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, layer_node.type());
386 386
387 new_root->SetLayerTreeHost(nullptr); 387 new_root->SetLayerTreeHost(nullptr);
388 } 388 }
389 389
390 } // namespace 390 } // namespace
391 } // namespace cc 391 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698