| 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 "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
| 8 #include "cc/test/fake_impl_proxy.h" | 8 #include "cc/test/fake_impl_proxy.h" |
| 9 #include "cc/test/fake_layer_tree_host.h" | 9 #include "cc/test/fake_layer_tree_host.h" |
| 10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 parent->SetPosition(gfx::Point(25, 25)); | 80 parent->SetPosition(gfx::Point(25, 25)); |
| 81 | 81 |
| 82 child->SetHaveWheelEventHandlers(true); | 82 child->SetHaveWheelEventHandlers(true); |
| 83 child->SetHaveScrollEventHandlers(true); | 83 child->SetHaveScrollEventHandlers(true); |
| 84 | 84 |
| 85 parent->AddChild(child.Pass()); | 85 parent->AddChild(child.Pass()); |
| 86 root_impl->AddChild(parent.Pass()); | 86 root_impl->AddChild(parent.Pass()); |
| 87 tree->SetRootLayer(root_impl.Pass()); | 87 tree->SetRootLayer(root_impl.Pass()); |
| 88 | 88 |
| 89 std::string json = host_impl.LayerTreeAsJson(); | 89 std::string json = host_impl.LayerTreeAsJson(); |
| 90 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); | 90 scoped_refptr<Layer> root = ParseTreeFromJson(json, nullptr); |
| 91 ASSERT_TRUE(root.get()); | 91 ASSERT_TRUE(root.get()); |
| 92 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); | 92 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); |
| 93 } | 93 } |
| 94 | 94 |
| 95 TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) { | 95 TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) { |
| 96 FakeImplProxy proxy; | 96 FakeImplProxy proxy; |
| 97 TestSharedBitmapManager shared_bitmap_manager; | 97 TestSharedBitmapManager shared_bitmap_manager; |
| 98 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 98 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 99 LayerTreeImpl* tree = host_impl.active_tree(); | 99 LayerTreeImpl* tree = host_impl.active_tree(); |
| 100 | 100 |
| 101 scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); | 101 scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); |
| 102 scoped_ptr<LayerImpl> touch_layer(LayerImpl::Create(tree, 2)); | 102 scoped_ptr<LayerImpl> touch_layer(LayerImpl::Create(tree, 2)); |
| 103 | 103 |
| 104 root_impl->SetBounds(gfx::Size(100, 100)); | 104 root_impl->SetBounds(gfx::Size(100, 100)); |
| 105 touch_layer->SetBounds(gfx::Size(50, 50)); | 105 touch_layer->SetBounds(gfx::Size(50, 50)); |
| 106 | 106 |
| 107 Region touch_region; | 107 Region touch_region; |
| 108 touch_region.Union(gfx::Rect(10, 10, 20, 30)); | 108 touch_region.Union(gfx::Rect(10, 10, 20, 30)); |
| 109 touch_region.Union(gfx::Rect(40, 10, 20, 20)); | 109 touch_region.Union(gfx::Rect(40, 10, 20, 20)); |
| 110 touch_layer->SetTouchEventHandlerRegion(touch_region); | 110 touch_layer->SetTouchEventHandlerRegion(touch_region); |
| 111 | 111 |
| 112 root_impl->AddChild(touch_layer.Pass()); | 112 root_impl->AddChild(touch_layer.Pass()); |
| 113 tree->SetRootLayer(root_impl.Pass()); | 113 tree->SetRootLayer(root_impl.Pass()); |
| 114 | 114 |
| 115 std::string json = host_impl.LayerTreeAsJson(); | 115 std::string json = host_impl.LayerTreeAsJson(); |
| 116 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); | 116 scoped_refptr<Layer> root = ParseTreeFromJson(json, nullptr); |
| 117 ASSERT_TRUE(root.get()); | 117 ASSERT_TRUE(root.get()); |
| 118 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); | 118 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace cc | 121 } // namespace cc |
| OLD | NEW |