| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #undef RETURN_IF_EXPECTATION_FAILS | 56 #undef RETURN_IF_EXPECTATION_FAILS |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| 61 class LayerTreeJsonParserSanityCheck : public testing::Test { | 61 class LayerTreeJsonParserSanityCheck : public testing::Test { |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 TEST_F(LayerTreeJsonParserSanityCheck, Basic) { | 64 TEST_F(LayerTreeJsonParserSanityCheck, Basic) { |
| 65 FakeImplProxy proxy; | 65 FakeImplProxy proxy; |
| 66 FakeLayerTreeHostImpl host_impl(&proxy); | 66 TestSharedBitmapManager shared_bitmap_manager; |
| 67 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 67 LayerTreeImpl* tree = host_impl.active_tree(); | 68 LayerTreeImpl* tree = host_impl.active_tree(); |
| 68 | 69 |
| 69 scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); | 70 scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); |
| 70 scoped_ptr<LayerImpl> parent(LayerImpl::Create(tree, 2)); | 71 scoped_ptr<LayerImpl> parent(LayerImpl::Create(tree, 2)); |
| 71 scoped_ptr<LayerImpl> child(LayerImpl::Create(tree, 3)); | 72 scoped_ptr<LayerImpl> child(LayerImpl::Create(tree, 3)); |
| 72 | 73 |
| 73 root_impl->SetBounds(gfx::Size(100, 100)); | 74 root_impl->SetBounds(gfx::Size(100, 100)); |
| 74 parent->SetBounds(gfx::Size(50, 50)); | 75 parent->SetBounds(gfx::Size(50, 50)); |
| 75 child->SetBounds(gfx::Size(40, 40)); | 76 child->SetBounds(gfx::Size(40, 40)); |
| 76 | 77 |
| 77 parent->SetPosition(gfx::Point(25, 25)); | 78 parent->SetPosition(gfx::Point(25, 25)); |
| 78 | 79 |
| 79 child->SetHaveWheelEventHandlers(true); | 80 child->SetHaveWheelEventHandlers(true); |
| 80 | 81 |
| 81 parent->AddChild(child.Pass()); | 82 parent->AddChild(child.Pass()); |
| 82 root_impl->AddChild(parent.Pass()); | 83 root_impl->AddChild(parent.Pass()); |
| 83 tree->SetRootLayer(root_impl.Pass()); | 84 tree->SetRootLayer(root_impl.Pass()); |
| 84 | 85 |
| 85 std::string json = host_impl.LayerTreeAsJson(); | 86 std::string json = host_impl.LayerTreeAsJson(); |
| 86 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); | 87 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); |
| 87 ASSERT_TRUE(root); | 88 ASSERT_TRUE(root); |
| 88 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); | 89 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); |
| 89 } | 90 } |
| 90 | 91 |
| 91 TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) { | 92 TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) { |
| 92 FakeImplProxy proxy; | 93 FakeImplProxy proxy; |
| 93 FakeLayerTreeHostImpl host_impl(&proxy); | 94 TestSharedBitmapManager shared_bitmap_manager; |
| 95 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
| 94 LayerTreeImpl* tree = host_impl.active_tree(); | 96 LayerTreeImpl* tree = host_impl.active_tree(); |
| 95 | 97 |
| 96 scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); | 98 scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); |
| 97 scoped_ptr<LayerImpl> touch_layer(LayerImpl::Create(tree, 2)); | 99 scoped_ptr<LayerImpl> touch_layer(LayerImpl::Create(tree, 2)); |
| 98 | 100 |
| 99 root_impl->SetBounds(gfx::Size(100, 100)); | 101 root_impl->SetBounds(gfx::Size(100, 100)); |
| 100 touch_layer->SetBounds(gfx::Size(50, 50)); | 102 touch_layer->SetBounds(gfx::Size(50, 50)); |
| 101 | 103 |
| 102 Region touch_region; | 104 Region touch_region; |
| 103 touch_region.Union(gfx::Rect(10, 10, 20, 30)); | 105 touch_region.Union(gfx::Rect(10, 10, 20, 30)); |
| 104 touch_region.Union(gfx::Rect(40, 10, 20, 20)); | 106 touch_region.Union(gfx::Rect(40, 10, 20, 20)); |
| 105 touch_layer->SetTouchEventHandlerRegion(touch_region); | 107 touch_layer->SetTouchEventHandlerRegion(touch_region); |
| 106 | 108 |
| 107 root_impl->AddChild(touch_layer.Pass()); | 109 root_impl->AddChild(touch_layer.Pass()); |
| 108 tree->SetRootLayer(root_impl.Pass()); | 110 tree->SetRootLayer(root_impl.Pass()); |
| 109 | 111 |
| 110 std::string json = host_impl.LayerTreeAsJson(); | 112 std::string json = host_impl.LayerTreeAsJson(); |
| 111 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); | 113 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); |
| 112 ASSERT_TRUE(root); | 114 ASSERT_TRUE(root); |
| 113 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); | 115 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); |
| 114 } | 116 } |
| 115 | 117 |
| 116 } // namespace cc | 118 } // namespace cc |
| OLD | NEW |