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

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

Issue 1398443008: Add support for (de)serializing cc::Layer hierarchy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@review-1394353002
Patch Set: Fixed CC_EXPORT Created 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "cc/layers/layer_deserializer.h"
6
7 #include "cc/layers/layer.h"
8 #include "cc/proto/layer.pb.h"
9 #include "cc/trees/layer_tree_settings.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace cc {
13 namespace {
14
15 class LayerDeserializerTest : public testing::Test {
vmpstr 2015/10/21 22:34:14 Do you need this? Can you just do TEST(LayerDeseri
nyquist 2015/10/23 00:12:31 Done.
16 public:
17 LayerDeserializerTest() {}
18 };
19
20 } // namespace
21
22 TEST_F(LayerDeserializerTest, TestKeepingRoot) {
23 // Test deserialization of a tree that looks like:
24 // root
25 // / \
26 // a b
27 // \
28 // c
29 // The old root node will be reused during deserialization.
30 scoped_refptr<Layer> old_root = Layer::Create(LayerSettings());
31 proto::LayerNode root_node;
32 root_node.set_id(old_root->id());
33 root_node.set_type(proto::LayerType::Base);
34
35 proto::LayerNode child_a_node;
36 child_a_node.set_id(442);
vmpstr 2015/10/21 22:34:14 Same ids for a and b?
nyquist 2015/10/23 00:12:30 Doh! Fixed.
37 child_a_node.set_type(proto::LayerType::Base);
38 child_a_node.set_parent_id(old_root->id()); // root_node
39
40 proto::LayerNode child_b_node;
41 child_b_node.set_id(442);
42 child_b_node.set_type(proto::LayerType::Base);
43 child_b_node.set_parent_id(old_root->id()); // root_node
44
45 proto::LayerNode child_c_node;
46 child_c_node.set_id(443);
47 child_c_node.set_type(proto::LayerType::Base);
48 child_c_node.set_parent_id(442); // child_b_node
49
50 scoped_refptr<Layer> new_root =
51 LayerDeserializer::DeserializeLayerHierarchy(old_root, root_node);
52
53 // The new root should not be the same as the old root.
54 EXPECT_EQ(old_root->id(), new_root->id());
vmpstr 2015/10/21 22:34:14 Can you verify the full structure here?
nyquist 2015/10/23 00:12:30 Done here and below. Also updated how the structur
55 }
56
57 TEST_F(LayerDeserializerTest, TestSwappingRoot) {
58 // Test deserialization of a tree that looks like:
59 // root
60 // / \
61 // a b
62 // \
63 // c
64 // The old root node will be swapped out during deserialization.
65 proto::LayerNode root_node;
66 root_node.set_id(441);
67 root_node.set_type(proto::LayerType::Base);
68
69 proto::LayerNode child_a_node;
70 child_a_node.set_id(442);
71 child_a_node.set_type(proto::LayerType::Base);
72 child_a_node.set_parent_id(441); // root_node
73
74 proto::LayerNode child_b_node;
75 child_b_node.set_id(442);
76 child_b_node.set_type(proto::LayerType::Base);
77 child_b_node.set_parent_id(441); // root_node
78
79 proto::LayerNode child_c_node;
80 child_c_node.set_id(443);
81 child_c_node.set_type(proto::LayerType::Base);
82 child_c_node.set_parent_id(442); // child_b_node
83
84 scoped_refptr<Layer> old_root = Layer::Create(LayerSettings());
85 scoped_refptr<Layer> new_root =
86 LayerDeserializer::DeserializeLayerHierarchy(old_root, root_node);
87
88 // The new root should not be the same as the old root.
89 EXPECT_EQ(441, new_root->id());
90 }
91
92 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698