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

Side by Side Diff: cc/test/layer_tree_json_parser_unittest.cc

Issue 1028333002: Chromium -> Mojo roll. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 } // namespace 60 } // namespace
61 61
62 class LayerTreeJsonParserSanityCheck : public testing::Test { 62 class LayerTreeJsonParserSanityCheck : public testing::Test {
63 }; 63 };
64 64
65 TEST_F(LayerTreeJsonParserSanityCheck, Basic) { 65 TEST_F(LayerTreeJsonParserSanityCheck, Basic) {
66 FakeImplProxy proxy; 66 FakeImplProxy proxy;
67 TestSharedBitmapManager shared_bitmap_manager; 67 TestSharedBitmapManager shared_bitmap_manager;
68 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); 68 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
69 LayerTreeImpl* tree = host_impl.active_tree(); 69 LayerTreeImpl* tree = host_impl.active_tree();
70 70
71 scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); 71 scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1));
72 scoped_ptr<LayerImpl> parent(LayerImpl::Create(tree, 2)); 72 scoped_ptr<LayerImpl> parent(LayerImpl::Create(tree, 2));
73 scoped_ptr<LayerImpl> child(LayerImpl::Create(tree, 3)); 73 scoped_ptr<LayerImpl> child(LayerImpl::Create(tree, 3));
74 74
75 root_impl->SetBounds(gfx::Size(100, 100)); 75 root_impl->SetBounds(gfx::Size(100, 100));
76 parent->SetBounds(gfx::Size(50, 50)); 76 parent->SetBounds(gfx::Size(50, 50));
77 child->SetBounds(gfx::Size(40, 40)); 77 child->SetBounds(gfx::Size(40, 40));
78 78
79 parent->SetPosition(gfx::Point(25, 25)); 79 parent->SetPosition(gfx::Point(25, 25));
80 80
81 child->SetHaveWheelEventHandlers(true); 81 child->SetHaveWheelEventHandlers(true);
82 child->SetHaveScrollEventHandlers(true); 82 child->SetHaveScrollEventHandlers(true);
83 83
84 parent->AddChild(child.Pass()); 84 parent->AddChild(child.Pass());
85 root_impl->AddChild(parent.Pass()); 85 root_impl->AddChild(parent.Pass());
86 tree->SetRootLayer(root_impl.Pass()); 86 tree->SetRootLayer(root_impl.Pass());
87 87
88 std::string json = host_impl.LayerTreeAsJson(); 88 std::string json = host_impl.LayerTreeAsJson();
89 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); 89 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL);
90 ASSERT_TRUE(root.get()); 90 ASSERT_TRUE(root.get());
91 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); 91 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get()));
92 } 92 }
93 93
94 TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) { 94 TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) {
95 FakeImplProxy proxy; 95 FakeImplProxy proxy;
96 TestSharedBitmapManager shared_bitmap_manager; 96 TestSharedBitmapManager shared_bitmap_manager;
97 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); 97 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
98 LayerTreeImpl* tree = host_impl.active_tree(); 98 LayerTreeImpl* tree = host_impl.active_tree();
99 99
100 scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); 100 scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1));
101 scoped_ptr<LayerImpl> touch_layer(LayerImpl::Create(tree, 2)); 101 scoped_ptr<LayerImpl> touch_layer(LayerImpl::Create(tree, 2));
102 102
103 root_impl->SetBounds(gfx::Size(100, 100)); 103 root_impl->SetBounds(gfx::Size(100, 100));
104 touch_layer->SetBounds(gfx::Size(50, 50)); 104 touch_layer->SetBounds(gfx::Size(50, 50));
105 105
106 Region touch_region; 106 Region touch_region;
107 touch_region.Union(gfx::Rect(10, 10, 20, 30)); 107 touch_region.Union(gfx::Rect(10, 10, 20, 30));
108 touch_region.Union(gfx::Rect(40, 10, 20, 20)); 108 touch_region.Union(gfx::Rect(40, 10, 20, 20));
109 touch_layer->SetTouchEventHandlerRegion(touch_region); 109 touch_layer->SetTouchEventHandlerRegion(touch_region);
110 110
111 root_impl->AddChild(touch_layer.Pass()); 111 root_impl->AddChild(touch_layer.Pass());
112 tree->SetRootLayer(root_impl.Pass()); 112 tree->SetRootLayer(root_impl.Pass());
113 113
114 std::string json = host_impl.LayerTreeAsJson(); 114 std::string json = host_impl.LayerTreeAsJson();
115 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); 115 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL);
116 ASSERT_TRUE(root.get()); 116 ASSERT_TRUE(root.get());
117 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); 117 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get()));
118 } 118 }
119 119
120 } // namespace cc 120 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_ui_resource_layer_tree_host_impl.cc ('k') | cc/test/layer_tree_pixel_resource_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698