OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/layer_tree_json_parser.h" | 5 #include "cc/test/layer_tree_json_parser.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
10 #include "cc/test/fake_impl_task_runner_provider.h" | 10 #include "cc/test/fake_impl_task_runner_provider.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 gfx::Transform translate; | 78 gfx::Transform translate; |
79 translate.Translate(10, 15); | 79 translate.Translate(10, 15); |
80 child->test_properties()->transform = translate; | 80 child->test_properties()->transform = translate; |
81 | 81 |
82 parent->SetPosition(gfx::PointF(25.f, 25.f)); | 82 parent->SetPosition(gfx::PointF(25.f, 25.f)); |
83 | 83 |
84 parent->test_properties()->AddChild(std::move(child)); | 84 parent->test_properties()->AddChild(std::move(child)); |
85 root_impl->test_properties()->AddChild(std::move(parent)); | 85 root_impl->test_properties()->AddChild(std::move(parent)); |
86 tree->SetRootLayerForTesting(std::move(root_impl)); | 86 tree->SetRootLayerForTesting(std::move(root_impl)); |
| 87 tree->BuildPropertyTreesForTesting(); |
87 | 88 |
88 std::string json = host_impl.LayerTreeAsJson(); | 89 std::string json = host_impl.LayerTreeAsJson(); |
89 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); | 90 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); |
90 ASSERT_TRUE(root.get()); | 91 ASSERT_TRUE(root.get()); |
91 EXPECT_TRUE(LayerTreesMatch(host_impl.active_tree()->root_layer_for_testing(), | 92 EXPECT_TRUE(LayerTreesMatch(host_impl.active_tree()->root_layer_for_testing(), |
92 root.get())); | 93 root.get())); |
93 } | 94 } |
94 | 95 |
95 TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) { | 96 TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) { |
96 FakeImplTaskRunnerProvider task_runner_provider; | 97 FakeImplTaskRunnerProvider task_runner_provider; |
97 TestTaskGraphRunner task_graph_runner; | 98 TestTaskGraphRunner task_graph_runner; |
98 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); | 99 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
99 LayerTreeImpl* tree = host_impl.active_tree(); | 100 LayerTreeImpl* tree = host_impl.active_tree(); |
100 | 101 |
101 std::unique_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); | 102 std::unique_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); |
102 std::unique_ptr<LayerImpl> touch_layer(LayerImpl::Create(tree, 2)); | 103 std::unique_ptr<LayerImpl> touch_layer(LayerImpl::Create(tree, 2)); |
103 | 104 |
104 root_impl->SetBounds(gfx::Size(100, 100)); | 105 root_impl->SetBounds(gfx::Size(100, 100)); |
105 touch_layer->SetBounds(gfx::Size(50, 50)); | 106 touch_layer->SetBounds(gfx::Size(50, 50)); |
106 | 107 |
107 Region touch_region; | 108 Region touch_region; |
108 touch_region.Union(gfx::Rect(10, 10, 20, 30)); | 109 touch_region.Union(gfx::Rect(10, 10, 20, 30)); |
109 touch_region.Union(gfx::Rect(40, 10, 20, 20)); | 110 touch_region.Union(gfx::Rect(40, 10, 20, 20)); |
110 touch_layer->SetTouchEventHandlerRegion(touch_region); | 111 touch_layer->SetTouchEventHandlerRegion(touch_region); |
111 | 112 |
112 root_impl->test_properties()->AddChild(std::move(touch_layer)); | 113 root_impl->test_properties()->AddChild(std::move(touch_layer)); |
113 tree->SetRootLayerForTesting(std::move(root_impl)); | 114 tree->SetRootLayerForTesting(std::move(root_impl)); |
| 115 tree->BuildPropertyTreesForTesting(); |
114 | 116 |
115 std::string json = host_impl.LayerTreeAsJson(); | 117 std::string json = host_impl.LayerTreeAsJson(); |
116 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); | 118 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); |
117 ASSERT_TRUE(root.get()); | 119 ASSERT_TRUE(root.get()); |
118 EXPECT_TRUE(LayerTreesMatch(host_impl.active_tree()->root_layer_for_testing(), | 120 EXPECT_TRUE(LayerTreesMatch(host_impl.active_tree()->root_layer_for_testing(), |
119 root.get())); | 121 root.get())); |
120 } | 122 } |
121 | 123 |
122 } // namespace cc | 124 } // namespace cc |
OLD | NEW |