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

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

Issue 1581693010: Add support for (de)serializing HeadsUpDisplayLayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/proto/layer.proto » ('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/layer.h" 9 #include "cc/layers/layer.h"
9 #include "cc/layers/layer_settings.h" 10 #include "cc/layers/layer_settings.h"
10 #include "cc/layers/picture_layer.h" 11 #include "cc/layers/picture_layer.h"
11 #include "cc/proto/layer.pb.h" 12 #include "cc/proto/layer.pb.h"
12 #include "cc/test/fake_layer_tree_host.h" 13 #include "cc/test/fake_layer_tree_host.h"
13 #include "cc/test/fake_layer_tree_host_client.h" 14 #include "cc/test/fake_layer_tree_host_client.h"
14 #include "cc/test/test_task_graph_runner.h" 15 #include "cc/test/test_task_graph_runner.h"
15 #include "cc/trees/layer_tree_settings.h" 16 #include "cc/trees/layer_tree_settings.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 // Validate that the ids are equal. 397 // Validate that the ids are equal.
397 EXPECT_EQ(old_root->id(), new_root->id()); 398 EXPECT_EQ(old_root->id(), new_root->id());
398 399
399 // Check that the layer type is equal by using the type this layer would 400 // Check that the layer type is equal by using the type this layer would
400 // serialize to. 401 // serialize to.
401 proto::LayerNode layer_node; 402 proto::LayerNode layer_node;
402 new_root->SetTypeForProtoSerialization(&layer_node); 403 new_root->SetTypeForProtoSerialization(&layer_node);
403 EXPECT_EQ(proto::LayerType::PICTURE_LAYER, layer_node.type()); 404 EXPECT_EQ(proto::LayerType::PICTURE_LAYER, layer_node.type());
404 } 405 }
405 406
407 TEST_F(LayerProtoConverterTest, HUDLayerTypeSerialization) {
vmpstr 2016/01/15 23:01:39 nit: I prefer lowercase ud (Hud vs HUD)
nyquist 2016/01/15 23:09:54 Done.
408 // Make sure that PictureLayers serialize to the
409 // proto::LayerType::HEADS_UP_DISPLAY_LAYER type.
410 scoped_refptr<HeadsUpDisplayLayer> layer =
411 HeadsUpDisplayLayer::Create(LayerSettings());
412
413 proto::LayerNode layer_hierarchy;
414 LayerProtoConverter::SerializeLayerHierarchy(layer.get(), &layer_hierarchy);
415 EXPECT_EQ(proto::LayerType::HEADS_UP_DISPLAY_LAYER, layer_hierarchy.type());
416 }
417
418 TEST_F(LayerProtoConverterTest, HUDLayerTypeDeserialization) {
419 // Make sure that proto::LayerType::HEADS_UP_DISPLAY_LAYER ends up building a
420 // HeadsUpDisplayLayer.
421 scoped_refptr<Layer> old_root = HeadsUpDisplayLayer::Create(LayerSettings());
422 proto::LayerNode root_node;
423 root_node.set_id(old_root->id());
424 root_node.set_type(proto::LayerType::HEADS_UP_DISPLAY_LAYER);
425
426 scoped_refptr<Layer> new_root =
427 LayerProtoConverter::DeserializeLayerHierarchy(old_root, root_node);
428
429 // Validate that the ids are equal.
430 EXPECT_EQ(old_root->id(), new_root->id());
431
432 // Check that the layer type is equal by using the type this layer would
433 // serialize to.
434 proto::LayerNode layer_node;
435 new_root->SetTypeForProtoSerialization(&layer_node);
436 EXPECT_EQ(proto::LayerType::HEADS_UP_DISPLAY_LAYER, layer_node.type());
437 }
438
406 } // namespace 439 } // namespace
407 } // namespace cc 440 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_proto_converter.cc ('k') | cc/proto/layer.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698