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

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

Issue 2452483002: Move GpuMemoryBufferManager and SharedBitmapManager to CompositorFrameSink (Closed)
Patch Set: rebase Created 4 years, 1 month 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
« no previous file with comments | « cc/test/layer_tree_host_remote_for_testing.cc ('k') | cc/test/layer_tree_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 FakeImplTaskRunnerProvider task_runner_provider; 65 FakeImplTaskRunnerProvider task_runner_provider;
66 TestSharedBitmapManager shared_bitmap_manager;
67 TestTaskGraphRunner task_graph_runner; 66 TestTaskGraphRunner task_graph_runner;
68 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 67 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
69 &task_graph_runner);
70 LayerTreeImpl* tree = host_impl.active_tree(); 68 LayerTreeImpl* tree = host_impl.active_tree();
71 69
72 std::unique_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); 70 std::unique_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1));
73 std::unique_ptr<LayerImpl> parent(LayerImpl::Create(tree, 2)); 71 std::unique_ptr<LayerImpl> parent(LayerImpl::Create(tree, 2));
74 std::unique_ptr<LayerImpl> child(LayerImpl::Create(tree, 3)); 72 std::unique_ptr<LayerImpl> child(LayerImpl::Create(tree, 3));
75 73
76 root_impl->SetBounds(gfx::Size(100, 100)); 74 root_impl->SetBounds(gfx::Size(100, 100));
77 parent->SetBounds(gfx::Size(50, 50)); 75 parent->SetBounds(gfx::Size(50, 50));
78 child->SetBounds(gfx::Size(40, 40)); 76 child->SetBounds(gfx::Size(40, 40));
79 77
80 gfx::Transform translate; 78 gfx::Transform translate;
81 translate.Translate(10, 15); 79 translate.Translate(10, 15);
82 child->test_properties()->transform = translate; 80 child->test_properties()->transform = translate;
83 81
84 parent->SetPosition(gfx::PointF(25.f, 25.f)); 82 parent->SetPosition(gfx::PointF(25.f, 25.f));
85 83
86 parent->test_properties()->AddChild(std::move(child)); 84 parent->test_properties()->AddChild(std::move(child));
87 root_impl->test_properties()->AddChild(std::move(parent)); 85 root_impl->test_properties()->AddChild(std::move(parent));
88 tree->SetRootLayerForTesting(std::move(root_impl)); 86 tree->SetRootLayerForTesting(std::move(root_impl));
89 87
90 std::string json = host_impl.LayerTreeAsJson(); 88 std::string json = host_impl.LayerTreeAsJson();
91 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); 89 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL);
92 ASSERT_TRUE(root.get()); 90 ASSERT_TRUE(root.get());
93 EXPECT_TRUE(LayerTreesMatch(host_impl.active_tree()->root_layer_for_testing(), 91 EXPECT_TRUE(LayerTreesMatch(host_impl.active_tree()->root_layer_for_testing(),
94 root.get())); 92 root.get()));
95 } 93 }
96 94
97 TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) { 95 TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) {
98 FakeImplTaskRunnerProvider task_runner_provider; 96 FakeImplTaskRunnerProvider task_runner_provider;
99 TestSharedBitmapManager shared_bitmap_manager;
100 TestTaskGraphRunner task_graph_runner; 97 TestTaskGraphRunner task_graph_runner;
101 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 98 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
102 &task_graph_runner);
103 LayerTreeImpl* tree = host_impl.active_tree(); 99 LayerTreeImpl* tree = host_impl.active_tree();
104 100
105 std::unique_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); 101 std::unique_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1));
106 std::unique_ptr<LayerImpl> touch_layer(LayerImpl::Create(tree, 2)); 102 std::unique_ptr<LayerImpl> touch_layer(LayerImpl::Create(tree, 2));
107 103
108 root_impl->SetBounds(gfx::Size(100, 100)); 104 root_impl->SetBounds(gfx::Size(100, 100));
109 touch_layer->SetBounds(gfx::Size(50, 50)); 105 touch_layer->SetBounds(gfx::Size(50, 50));
110 106
111 Region touch_region; 107 Region touch_region;
112 touch_region.Union(gfx::Rect(10, 10, 20, 30)); 108 touch_region.Union(gfx::Rect(10, 10, 20, 30));
113 touch_region.Union(gfx::Rect(40, 10, 20, 20)); 109 touch_region.Union(gfx::Rect(40, 10, 20, 20));
114 touch_layer->SetTouchEventHandlerRegion(touch_region); 110 touch_layer->SetTouchEventHandlerRegion(touch_region);
115 111
116 root_impl->test_properties()->AddChild(std::move(touch_layer)); 112 root_impl->test_properties()->AddChild(std::move(touch_layer));
117 tree->SetRootLayerForTesting(std::move(root_impl)); 113 tree->SetRootLayerForTesting(std::move(root_impl));
118 114
119 std::string json = host_impl.LayerTreeAsJson(); 115 std::string json = host_impl.LayerTreeAsJson();
120 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); 116 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL);
121 ASSERT_TRUE(root.get()); 117 ASSERT_TRUE(root.get());
122 EXPECT_TRUE(LayerTreesMatch(host_impl.active_tree()->root_layer_for_testing(), 118 EXPECT_TRUE(LayerTreesMatch(host_impl.active_tree()->root_layer_for_testing(),
123 root.get())); 119 root.get()));
124 } 120 }
125 121
126 } // namespace cc 122 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_host_remote_for_testing.cc ('k') | cc/test/layer_tree_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698