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

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: test update 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
« no previous file with comments | « cc/layers/layer_proto_converter.cc ('k') | cc/layers/layer_unittest.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 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 layer_src_root->SetLayerTreeHost(nullptr); 309 layer_src_root->SetLayerTreeHost(nullptr);
310 } 310 }
311 311
312 TEST_F(LayerProtoConverterTest, PictureLayerTypeSerialization) { 312 TEST_F(LayerProtoConverterTest, PictureLayerTypeSerialization) {
313 // Make sure that PictureLayers serialize to the 313 // Make sure that PictureLayers serialize to the
314 // proto::LayerType::PICTURE_LAYER type. 314 // proto::LayerType::PICTURE_LAYER type.
315 scoped_refptr<PictureLayer> layer = 315 scoped_refptr<PictureLayer> layer =
316 PictureLayer::Create(EmptyContentLayerClient::GetInstance()); 316 PictureLayer::Create(EmptyContentLayerClient::GetInstance());
317 317
318 proto::LayerNode layer_hierarchy; 318 proto::LayerNode layer_hierarchy;
319 LayerProtoConverter::SerializeLayerHierarchy(layer.get(), &layer_hierarchy); 319 layer->ToLayerNodeProto(&layer_hierarchy);
320 EXPECT_EQ(proto::LayerNode::PICTURE_LAYER, layer_hierarchy.type()); 320 EXPECT_EQ(proto::LayerNode::PICTURE_LAYER, layer_hierarchy.type());
321 } 321 }
322 322
323 TEST_F(LayerProtoConverterTest, PictureLayerTypeDeserialization) { 323 TEST_F(LayerProtoConverterTest, PictureLayerTypeDeserialization) {
324 // Make sure that proto::LayerType::PICTURE_LAYER ends up building a 324 // Make sure that proto::LayerType::PICTURE_LAYER ends up building a
325 // PictureLayer. 325 // PictureLayer.
326 scoped_refptr<Layer> old_root = 326 scoped_refptr<Layer> old_root =
327 PictureLayer::Create(EmptyContentLayerClient::GetInstance()); 327 PictureLayer::Create(EmptyContentLayerClient::GetInstance());
328 proto::LayerNode root_node; 328 proto::LayerNode root_node;
329 root_node.set_id(old_root->id()); 329 root_node.set_id(old_root->id());
(...skipping 14 matching lines...) Expand all
344 344
345 new_root->SetLayerTreeHost(nullptr); 345 new_root->SetLayerTreeHost(nullptr);
346 } 346 }
347 347
348 TEST_F(LayerProtoConverterTest, HudLayerTypeSerialization) { 348 TEST_F(LayerProtoConverterTest, HudLayerTypeSerialization) {
349 // Make sure that PictureLayers serialize to the 349 // Make sure that PictureLayers serialize to the
350 // proto::LayerType::HEADS_UP_DISPLAY_LAYER type. 350 // proto::LayerType::HEADS_UP_DISPLAY_LAYER type.
351 scoped_refptr<HeadsUpDisplayLayer> layer = HeadsUpDisplayLayer::Create(); 351 scoped_refptr<HeadsUpDisplayLayer> layer = HeadsUpDisplayLayer::Create();
352 352
353 proto::LayerNode layer_hierarchy; 353 proto::LayerNode layer_hierarchy;
354 LayerProtoConverter::SerializeLayerHierarchy(layer.get(), &layer_hierarchy); 354 layer->ToLayerNodeProto(&layer_hierarchy);
355 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, layer_hierarchy.type()); 355 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, layer_hierarchy.type());
356 } 356 }
357 357
358 TEST_F(LayerProtoConverterTest, HudLayerTypeDeserialization) { 358 TEST_F(LayerProtoConverterTest, HudLayerTypeDeserialization) {
359 // Make sure that proto::LayerType::HEADS_UP_DISPLAY_LAYER ends up building a 359 // Make sure that proto::LayerType::HEADS_UP_DISPLAY_LAYER ends up building a
360 // HeadsUpDisplayLayer. 360 // HeadsUpDisplayLayer.
361 scoped_refptr<Layer> old_root = HeadsUpDisplayLayer::Create(); 361 scoped_refptr<Layer> old_root = HeadsUpDisplayLayer::Create();
362 proto::LayerNode root_node; 362 proto::LayerNode root_node;
363 root_node.set_id(old_root->id()); 363 root_node.set_id(old_root->id());
364 root_node.set_type(proto::LayerNode::HEADS_UP_DISPLAY_LAYER); 364 root_node.set_type(proto::LayerNode::HEADS_UP_DISPLAY_LAYER);
365 365
366 scoped_refptr<Layer> new_root = 366 scoped_refptr<Layer> new_root =
367 LayerProtoConverter::DeserializeLayerHierarchy(old_root, root_node, 367 LayerProtoConverter::DeserializeLayerHierarchy(old_root, root_node,
368 layer_tree_host_.get()); 368 layer_tree_host_.get());
369 369
370 // Validate that the ids are equal. 370 // Validate that the ids are equal.
371 EXPECT_EQ(old_root->id(), new_root->id()); 371 EXPECT_EQ(old_root->id(), new_root->id());
372 372
373 // Check that the layer type is equal by using the type this layer would 373 // Check that the layer type is equal by using the type this layer would
374 // serialize to. 374 // serialize to.
375 proto::LayerNode layer_node; 375 proto::LayerNode layer_node;
376 new_root->SetTypeForProtoSerialization(&layer_node); 376 new_root->SetTypeForProtoSerialization(&layer_node);
377 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, layer_node.type()); 377 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, layer_node.type());
378 378
379 new_root->SetLayerTreeHost(nullptr); 379 new_root->SetLayerTreeHost(nullptr);
380 } 380 }
381 381
382 } // namespace 382 } // namespace
383 } // namespace cc 383 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_proto_converter.cc ('k') | cc/layers/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698