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

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

Issue 1411663002: cc: Split Proxy to eliminate unnecessary dependencies on the impl side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update perf tests. Created 5 years, 2 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
« no previous file with comments | « cc/test/layer_test_common.h ('k') | cc/test/layer_tree_test.cc » ('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 "cc/layers/layer.h" 7 #include "cc/layers/layer.h"
8 #include "cc/test/fake_impl_proxy.h" 8 #include "cc/test/fake_impl_task_runner_provider.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"
11 #include "cc/test/geometry_test_utils.h" 11 #include "cc/test/geometry_test_utils.h"
12 #include "cc/test/test_task_graph_runner.h" 12 #include "cc/test/test_task_graph_runner.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace cc { 15 namespace cc {
16 16
17 namespace { 17 namespace {
18 18
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return true; 56 return true;
57 #undef RETURN_IF_EXPECTATION_FAILS 57 #undef RETURN_IF_EXPECTATION_FAILS
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 FakeImplTaskRunnerProvider task_runner_provider;
67 TestSharedBitmapManager shared_bitmap_manager; 67 TestSharedBitmapManager shared_bitmap_manager;
68 TestTaskGraphRunner task_graph_runner; 68 TestTaskGraphRunner task_graph_runner;
69 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, 69 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
70 &task_graph_runner); 70 &task_graph_runner);
71 LayerTreeImpl* tree = host_impl.active_tree(); 71 LayerTreeImpl* tree = host_impl.active_tree();
72 72
73 scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); 73 scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1));
74 scoped_ptr<LayerImpl> parent(LayerImpl::Create(tree, 2)); 74 scoped_ptr<LayerImpl> parent(LayerImpl::Create(tree, 2));
75 scoped_ptr<LayerImpl> child(LayerImpl::Create(tree, 3)); 75 scoped_ptr<LayerImpl> child(LayerImpl::Create(tree, 3));
76 76
77 root_impl->SetBounds(gfx::Size(100, 100)); 77 root_impl->SetBounds(gfx::Size(100, 100));
78 parent->SetBounds(gfx::Size(50, 50)); 78 parent->SetBounds(gfx::Size(50, 50));
79 child->SetBounds(gfx::Size(40, 40)); 79 child->SetBounds(gfx::Size(40, 40));
80 80
81 parent->SetPosition(gfx::Point(25, 25)); 81 parent->SetPosition(gfx::Point(25, 25));
82 82
83 child->SetHaveWheelEventHandlers(true); 83 child->SetHaveWheelEventHandlers(true);
84 child->SetHaveScrollEventHandlers(true); 84 child->SetHaveScrollEventHandlers(true);
85 85
86 parent->AddChild(child.Pass()); 86 parent->AddChild(child.Pass());
87 root_impl->AddChild(parent.Pass()); 87 root_impl->AddChild(parent.Pass());
88 tree->SetRootLayer(root_impl.Pass()); 88 tree->SetRootLayer(root_impl.Pass());
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(LayerTreesMatch(host_impl.RootLayer(), root.get()));
94 } 94 }
95 95
96 TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) { 96 TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) {
97 FakeImplProxy proxy; 97 FakeImplTaskRunnerProvider task_runner_provider;
98 TestSharedBitmapManager shared_bitmap_manager; 98 TestSharedBitmapManager shared_bitmap_manager;
99 TestTaskGraphRunner task_graph_runner; 99 TestTaskGraphRunner task_graph_runner;
100 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, 100 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
101 &task_graph_runner); 101 &task_graph_runner);
102 LayerTreeImpl* tree = host_impl.active_tree(); 102 LayerTreeImpl* tree = host_impl.active_tree();
103 103
104 scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); 104 scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1));
105 scoped_ptr<LayerImpl> touch_layer(LayerImpl::Create(tree, 2)); 105 scoped_ptr<LayerImpl> touch_layer(LayerImpl::Create(tree, 2));
106 106
107 root_impl->SetBounds(gfx::Size(100, 100)); 107 root_impl->SetBounds(gfx::Size(100, 100));
108 touch_layer->SetBounds(gfx::Size(50, 50)); 108 touch_layer->SetBounds(gfx::Size(50, 50));
109 109
110 Region touch_region; 110 Region touch_region;
111 touch_region.Union(gfx::Rect(10, 10, 20, 30)); 111 touch_region.Union(gfx::Rect(10, 10, 20, 30));
112 touch_region.Union(gfx::Rect(40, 10, 20, 20)); 112 touch_region.Union(gfx::Rect(40, 10, 20, 20));
113 touch_layer->SetTouchEventHandlerRegion(touch_region); 113 touch_layer->SetTouchEventHandlerRegion(touch_region);
114 114
115 root_impl->AddChild(touch_layer.Pass()); 115 root_impl->AddChild(touch_layer.Pass());
116 tree->SetRootLayer(root_impl.Pass()); 116 tree->SetRootLayer(root_impl.Pass());
117 117
118 std::string json = host_impl.LayerTreeAsJson(); 118 std::string json = host_impl.LayerTreeAsJson();
119 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); 119 scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL);
120 ASSERT_TRUE(root.get()); 120 ASSERT_TRUE(root.get());
121 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); 121 EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get()));
122 } 122 }
123 123
124 } // namespace cc 124 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_test_common.h ('k') | cc/test/layer_tree_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698