| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 parent->SetPosition(gfx::PointF(25.f, 25.f)); | 84 parent->SetPosition(gfx::PointF(25.f, 25.f)); |
| 85 | 85 |
| 86 parent->AddChild(std::move(child)); | 86 parent->AddChild(std::move(child)); |
| 87 root_impl->AddChild(std::move(parent)); | 87 root_impl->AddChild(std::move(parent)); |
| 88 tree->SetRootLayer(std::move(root_impl)); | 88 tree->SetRootLayer(std::move(root_impl)); |
| 89 | 89 |
| 90 std::string json = host_impl.LayerTreeAsJson(); | 90 std::string json = host_impl.LayerTreeAsJson(); |
| 91 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); | 91 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); |
| 92 ASSERT_TRUE(root.get()); | 92 ASSERT_TRUE(root.get()); |
| 93 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); | 93 EXPECT_TRUE( |
| 94 LayerTreesMatch(host_impl.active_tree()->root_layer(), root.get())); |
| 94 } | 95 } |
| 95 | 96 |
| 96 TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) { | 97 TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) { |
| 97 FakeImplTaskRunnerProvider task_runner_provider; | 98 FakeImplTaskRunnerProvider task_runner_provider; |
| 98 TestSharedBitmapManager shared_bitmap_manager; | 99 TestSharedBitmapManager shared_bitmap_manager; |
| 99 TestTaskGraphRunner task_graph_runner; | 100 TestTaskGraphRunner task_graph_runner; |
| 100 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 101 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 101 &task_graph_runner); | 102 &task_graph_runner); |
| 102 LayerTreeImpl* tree = host_impl.active_tree(); | 103 LayerTreeImpl* tree = host_impl.active_tree(); |
| 103 | 104 |
| 104 std::unique_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); | 105 std::unique_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); |
| 105 std::unique_ptr<LayerImpl> touch_layer(LayerImpl::Create(tree, 2)); | 106 std::unique_ptr<LayerImpl> touch_layer(LayerImpl::Create(tree, 2)); |
| 106 | 107 |
| 107 root_impl->SetBounds(gfx::Size(100, 100)); | 108 root_impl->SetBounds(gfx::Size(100, 100)); |
| 108 touch_layer->SetBounds(gfx::Size(50, 50)); | 109 touch_layer->SetBounds(gfx::Size(50, 50)); |
| 109 | 110 |
| 110 Region touch_region; | 111 Region touch_region; |
| 111 touch_region.Union(gfx::Rect(10, 10, 20, 30)); | 112 touch_region.Union(gfx::Rect(10, 10, 20, 30)); |
| 112 touch_region.Union(gfx::Rect(40, 10, 20, 20)); | 113 touch_region.Union(gfx::Rect(40, 10, 20, 20)); |
| 113 touch_layer->SetTouchEventHandlerRegion(touch_region); | 114 touch_layer->SetTouchEventHandlerRegion(touch_region); |
| 114 | 115 |
| 115 root_impl->AddChild(std::move(touch_layer)); | 116 root_impl->AddChild(std::move(touch_layer)); |
| 116 tree->SetRootLayer(std::move(root_impl)); | 117 tree->SetRootLayer(std::move(root_impl)); |
| 117 | 118 |
| 118 std::string json = host_impl.LayerTreeAsJson(); | 119 std::string json = host_impl.LayerTreeAsJson(); |
| 119 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); | 120 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); |
| 120 ASSERT_TRUE(root.get()); | 121 ASSERT_TRUE(root.get()); |
| 121 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); | 122 EXPECT_TRUE( |
| 123 LayerTreesMatch(host_impl.active_tree()->root_layer(), root.get())); |
| 122 } | 124 } |
| 123 | 125 |
| 124 } // namespace cc | 126 } // namespace cc |
| OLD | NEW |