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

Side by Side Diff: cc/scrollbar_layer_unittest.cc

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MoreAndroidCompilings Created 7 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 | Annotate | Revision Log
« no previous file with comments | « cc/scrollbar_layer_impl.cc ('k') | cc/shared_quad_state.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/scrollbar_layer.h" 5 #include "cc/scrollbar_layer.h"
6 6
7 #include "cc/append_quads_data.h" 7 #include "cc/append_quads_data.h"
8 #include "cc/prioritized_resource_manager.h" 8 #include "cc/prioritized_resource_manager.h"
9 #include "cc/priority_calculator.h" 9 #include "cc/priority_calculator.h"
10 #include "cc/resource_update_queue.h" 10 #include "cc/resource_update_queue.h"
(...skipping 18 matching lines...) Expand all
29 #include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbarThemeGe ometry.h" 29 #include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbarThemeGe ometry.h"
30 30
31 namespace cc { 31 namespace cc {
32 namespace { 32 namespace {
33 33
34 scoped_ptr<LayerImpl> layerImplForScrollAreaAndScrollbar( 34 scoped_ptr<LayerImpl> layerImplForScrollAreaAndScrollbar(
35 FakeLayerTreeHostImpl* host_impl, 35 FakeLayerTreeHostImpl* host_impl,
36 scoped_ptr<WebKit::WebScrollbar> scrollbar, 36 scoped_ptr<WebKit::WebScrollbar> scrollbar,
37 bool reverse_order) 37 bool reverse_order)
38 { 38 {
39 scoped_refptr<Layer> layerTreeRoot = Layer::create(); 39 scoped_refptr<Layer> layerTreeRoot = Layer::Create();
40 scoped_refptr<Layer> child1 = Layer::create(); 40 scoped_refptr<Layer> child1 = Layer::Create();
41 scoped_refptr<Layer> child2 = ScrollbarLayer::Create(scrollbar.Pass(), FakeS crollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScro llbarThemeGeometry::create(true), child1->id()); 41 scoped_refptr<Layer> child2 = ScrollbarLayer::Create(scrollbar.Pass(), FakeS crollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScro llbarThemeGeometry::create(true), child1->id());
42 layerTreeRoot->addChild(child1); 42 layerTreeRoot->AddChild(child1);
43 layerTreeRoot->insertChild(child2, reverse_order ? 0 : 1); 43 layerTreeRoot->InsertChild(child2, reverse_order ? 0 : 1);
44 scoped_ptr<LayerImpl> layerImpl = TreeSynchronizer::synchronizeTrees(layerTr eeRoot.get(), scoped_ptr<LayerImpl>(), host_impl->activeTree()); 44 scoped_ptr<LayerImpl> layerImpl = TreeSynchronizer::synchronizeTrees(layerTr eeRoot.get(), scoped_ptr<LayerImpl>(), host_impl->activeTree());
45 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImpl.get()); 45 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImpl.get());
46 return layerImpl.Pass(); 46 return layerImpl.Pass();
47 } 47 }
48 48
49 TEST(ScrollbarLayerTest, resolveScrollLayerPointer) 49 TEST(ScrollbarLayerTest, resolveScrollLayerPointer)
50 { 50 {
51 FakeImplProxy proxy; 51 FakeImplProxy proxy;
52 FakeLayerTreeHostImpl hostImpl(&proxy); 52 FakeLayerTreeHostImpl hostImpl(&proxy);
53 53
54 { 54 {
55 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); 55 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
56 scoped_ptr<LayerImpl> layerImplTreeRoot = layerImplForScrollAreaAndScrol lbar(&hostImpl, scrollbar.Pass(), false); 56 scoped_ptr<LayerImpl> layerImplTreeRoot = layerImplForScrollAreaAndScrol lbar(&hostImpl, scrollbar.Pass(), false);
57 57
58 LayerImpl* ccChild1 = layerImplTreeRoot->children()[0]; 58 LayerImpl* ccChild1 = layerImplTreeRoot->children()[0];
59 ScrollbarLayerImpl* ccChild2 = static_cast<ScrollbarLayerImpl*>(layerImp lTreeRoot->children()[1]); 59 ScrollbarLayerImpl* ccChild2 = static_cast<ScrollbarLayerImpl*>(layerImp lTreeRoot->children()[1]);
60 60
61 EXPECT_EQ(ccChild1->horizontalScrollbarLayer(), ccChild2); 61 EXPECT_EQ(ccChild1->horizontal_scrollbar_layer(), ccChild2);
62 } 62 }
63 63
64 { // another traverse order 64 { // another traverse order
65 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); 65 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
66 scoped_ptr<LayerImpl> layerImplTreeRoot = layerImplForScrollAreaAndScrol lbar(&hostImpl, scrollbar.Pass(), true); 66 scoped_ptr<LayerImpl> layerImplTreeRoot = layerImplForScrollAreaAndScrol lbar(&hostImpl, scrollbar.Pass(), true);
67 67
68 ScrollbarLayerImpl* ccChild1 = static_cast<ScrollbarLayerImpl*>(layerImp lTreeRoot->children()[0]); 68 ScrollbarLayerImpl* ccChild1 = static_cast<ScrollbarLayerImpl*>(layerImp lTreeRoot->children()[0]);
69 LayerImpl* ccChild2 = layerImplTreeRoot->children()[1]; 69 LayerImpl* ccChild2 = layerImplTreeRoot->children()[1];
70 70
71 EXPECT_EQ(ccChild2->horizontalScrollbarLayer(), ccChild1); 71 EXPECT_EQ(ccChild2->horizontal_scrollbar_layer(), ccChild1);
72 } 72 }
73 } 73 }
74 74
75 TEST(ScrollbarLayerTest, shouldScrollNonOverlayOnMainThread) 75 TEST(ScrollbarLayerTest, shouldScrollNonOverlayOnMainThread)
76 { 76 {
77 FakeImplProxy proxy; 77 FakeImplProxy proxy;
78 FakeLayerTreeHostImpl hostImpl(&proxy); 78 FakeLayerTreeHostImpl hostImpl(&proxy);
79 79
80 // Create and attach a non-overlay scrollbar. 80 // Create and attach a non-overlay scrollbar.
81 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); 81 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
82 static_cast<FakeWebScrollbar*>(scrollbar.get())->setOverlay(false); 82 static_cast<FakeWebScrollbar*>(scrollbar.get())->setOverlay(false);
83 scoped_ptr<LayerImpl> layerImplTreeRoot = layerImplForScrollAreaAndScrollbar (&hostImpl, scrollbar.Pass(), false); 83 scoped_ptr<LayerImpl> layerImplTreeRoot = layerImplForScrollAreaAndScrollbar (&hostImpl, scrollbar.Pass(), false);
84 ScrollbarLayerImpl* scrollbarLayerImpl = static_cast<ScrollbarLayerImpl*>(la yerImplTreeRoot->children()[1]); 84 ScrollbarLayerImpl* scrollbarLayerImpl = static_cast<ScrollbarLayerImpl*>(la yerImplTreeRoot->children()[1]);
85 85
86 // When the scrollbar is not an overlay scrollbar, the scroll should be 86 // When the scrollbar is not an overlay scrollbar, the scroll should be
87 // responded to on the main thread as the compositor does not yet implement 87 // responded to on the main thread as the compositor does not yet implement
88 // scrollbar scrolling. 88 // scrollbar scrolling.
89 EXPECT_EQ(InputHandlerClient::ScrollOnMainThread, scrollbarLayerImpl->tryScr oll(gfx::Point(0, 0), InputHandlerClient::Gesture)); 89 EXPECT_EQ(InputHandlerClient::ScrollOnMainThread, scrollbarLayerImpl->TryScr oll(gfx::Point(0, 0), InputHandlerClient::Gesture));
90 90
91 // Create and attach an overlay scrollbar. 91 // Create and attach an overlay scrollbar.
92 scrollbar = FakeWebScrollbar::Create(); 92 scrollbar = FakeWebScrollbar::Create();
93 static_cast<FakeWebScrollbar*>(scrollbar.get())->setOverlay(true); 93 static_cast<FakeWebScrollbar*>(scrollbar.get())->setOverlay(true);
94 94
95 layerImplTreeRoot = layerImplForScrollAreaAndScrollbar(&hostImpl, scrollbar. Pass(), false); 95 layerImplTreeRoot = layerImplForScrollAreaAndScrollbar(&hostImpl, scrollbar. Pass(), false);
96 scrollbarLayerImpl = static_cast<ScrollbarLayerImpl*>(layerImplTreeRoot->chi ldren()[1]); 96 scrollbarLayerImpl = static_cast<ScrollbarLayerImpl*>(layerImplTreeRoot->chi ldren()[1]);
97 97
98 // The user shouldn't be able to drag an overlay scrollbar and the scroll 98 // The user shouldn't be able to drag an overlay scrollbar and the scroll
99 // may be handled in the compositor. 99 // may be handled in the compositor.
100 EXPECT_EQ(InputHandlerClient::ScrollIgnored, scrollbarLayerImpl->tryScroll(g fx::Point(0, 0), InputHandlerClient::Gesture)); 100 EXPECT_EQ(InputHandlerClient::ScrollIgnored, scrollbarLayerImpl->TryScroll(g fx::Point(0, 0), InputHandlerClient::Gesture));
101 } 101 }
102 102
103 TEST(ScrollbarLayerTest, scrollOffsetSynchronization) 103 TEST(ScrollbarLayerTest, scrollOffsetSynchronization)
104 { 104 {
105 FakeImplProxy proxy; 105 FakeImplProxy proxy;
106 FakeLayerTreeHostImpl hostImpl(&proxy); 106 FakeLayerTreeHostImpl hostImpl(&proxy);
107 107
108 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); 108 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
109 scoped_refptr<Layer> layerTreeRoot = Layer::create(); 109 scoped_refptr<Layer> layerTreeRoot = Layer::Create();
110 scoped_refptr<Layer> contentLayer = Layer::create(); 110 scoped_refptr<Layer> contentLayer = Layer::Create();
111 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::Create(scrollbar.Pass( ), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), Fak eWebScrollbarThemeGeometry::create(true), layerTreeRoot->id()); 111 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::Create(scrollbar.Pass( ), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), Fak eWebScrollbarThemeGeometry::create(true), layerTreeRoot->id());
112 layerTreeRoot->addChild(contentLayer); 112 layerTreeRoot->AddChild(contentLayer);
113 layerTreeRoot->addChild(scrollbarLayer); 113 layerTreeRoot->AddChild(scrollbarLayer);
114 114
115 layerTreeRoot->setScrollOffset(gfx::Vector2d(10, 20)); 115 layerTreeRoot->SetScrollOffset(gfx::Vector2d(10, 20));
116 layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(30, 50)); 116 layerTreeRoot->SetMaxScrollOffset(gfx::Vector2d(30, 50));
117 layerTreeRoot->setBounds(gfx::Size(100, 200)); 117 layerTreeRoot->SetBounds(gfx::Size(100, 200));
118 contentLayer->setBounds(gfx::Size(100, 200)); 118 contentLayer->SetBounds(gfx::Size(100, 200));
119 119
120 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.activeTree()); 120 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.activeTree());
121 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( )); 121 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( ));
122 122
123 ScrollbarLayerImpl* ccScrollbarLayer = static_cast<ScrollbarLayerImpl*>(laye rImplTreeRoot->children()[1]); 123 ScrollbarLayerImpl* ccScrollbarLayer = static_cast<ScrollbarLayerImpl*>(laye rImplTreeRoot->children()[1]);
124 124
125 EXPECT_EQ(10, ccScrollbarLayer->CurrentPos()); 125 EXPECT_EQ(10, ccScrollbarLayer->CurrentPos());
126 EXPECT_EQ(100, ccScrollbarLayer->TotalSize()); 126 EXPECT_EQ(100, ccScrollbarLayer->TotalSize());
127 EXPECT_EQ(30, ccScrollbarLayer->Maximum()); 127 EXPECT_EQ(30, ccScrollbarLayer->Maximum());
128 128
129 layerTreeRoot->setScrollOffset(gfx::Vector2d(100, 200)); 129 layerTreeRoot->SetScrollOffset(gfx::Vector2d(100, 200));
130 layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(300, 500)); 130 layerTreeRoot->SetMaxScrollOffset(gfx::Vector2d(300, 500));
131 layerTreeRoot->setBounds(gfx::Size(1000, 2000)); 131 layerTreeRoot->SetBounds(gfx::Size(1000, 2000));
132 contentLayer->setBounds(gfx::Size(1000, 2000)); 132 contentLayer->SetBounds(gfx::Size(1000, 2000));
133 133
134 ScrollbarAnimationController* scrollbarController = layerImplTreeRoot->scrol lbarAnimationController(); 134 ScrollbarAnimationController* scrollbarController = layerImplTreeRoot->scrol lbar_animation_controller();
135 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl.activeTree()); 135 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl.activeTree());
136 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( )); 136 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( ));
137 EXPECT_EQ(scrollbarController, layerImplTreeRoot->scrollbarAnimationControll er()); 137 EXPECT_EQ(scrollbarController, layerImplTreeRoot->scrollbar_animation_contro ller());
138 138
139 EXPECT_EQ(100, ccScrollbarLayer->CurrentPos()); 139 EXPECT_EQ(100, ccScrollbarLayer->CurrentPos());
140 EXPECT_EQ(1000, ccScrollbarLayer->TotalSize()); 140 EXPECT_EQ(1000, ccScrollbarLayer->TotalSize());
141 EXPECT_EQ(300, ccScrollbarLayer->Maximum()); 141 EXPECT_EQ(300, ccScrollbarLayer->Maximum());
142 142
143 layerImplTreeRoot->scrollBy(gfx::Vector2d(12, 34)); 143 layerImplTreeRoot->ScrollBy(gfx::Vector2d(12, 34));
144 144
145 EXPECT_EQ(112, ccScrollbarLayer->CurrentPos()); 145 EXPECT_EQ(112, ccScrollbarLayer->CurrentPos());
146 EXPECT_EQ(1000, ccScrollbarLayer->TotalSize()); 146 EXPECT_EQ(1000, ccScrollbarLayer->TotalSize());
147 EXPECT_EQ(300, ccScrollbarLayer->Maximum()); 147 EXPECT_EQ(300, ccScrollbarLayer->Maximum());
148 } 148 }
149 149
150 TEST(ScrollbarLayerTest, solidColorThicknessOverride) 150 TEST(ScrollbarLayerTest, solidColorThicknessOverride)
151 { 151 {
152 LayerTreeSettings layerTreeSettings; 152 LayerTreeSettings layerTreeSettings;
153 layerTreeSettings.solidColorScrollbars = true; 153 layerTreeSettings.solidColorScrollbars = true;
154 layerTreeSettings.solidColorScrollbarThicknessDIP = 3; 154 layerTreeSettings.solidColorScrollbarThicknessDIP = 3;
155 FakeImplProxy proxy; 155 FakeImplProxy proxy;
156 FakeLayerTreeHostImpl hostImpl(layerTreeSettings, &proxy); 156 FakeLayerTreeHostImpl hostImpl(layerTreeSettings, &proxy);
157 157
158 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); 158 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
159 static_cast<FakeWebScrollbar*>(scrollbar.get())->setOverlay(true); 159 static_cast<FakeWebScrollbar*>(scrollbar.get())->setOverlay(true);
160 scoped_ptr<LayerImpl> layerImplTreeRoot = layerImplForScrollAreaAndScrollbar (&hostImpl, scrollbar.Pass(), false); 160 scoped_ptr<LayerImpl> layerImplTreeRoot = layerImplForScrollAreaAndScrollbar (&hostImpl, scrollbar.Pass(), false);
161 ScrollbarLayerImpl* scrollbarLayerImpl = static_cast<ScrollbarLayerImpl*>(la yerImplTreeRoot->children()[1]); 161 ScrollbarLayerImpl* scrollbarLayerImpl = static_cast<ScrollbarLayerImpl*>(la yerImplTreeRoot->children()[1]);
162 scrollbarLayerImpl->SetThumbSize(gfx::Size(4, 4)); 162 scrollbarLayerImpl->SetThumbSize(gfx::Size(4, 4));
163 163
164 // Thickness should be overridden to 3. 164 // Thickness should be overridden to 3.
165 { 165 {
166 MockQuadCuller quadCuller; 166 MockQuadCuller quadCuller;
167 AppendQuadsData data; 167 AppendQuadsData data;
168 scrollbarLayerImpl->appendQuads(quadCuller, data); 168 scrollbarLayerImpl->AppendQuads(&quadCuller, &data);
169 169
170 const QuadList& quads = quadCuller.quadList(); 170 const QuadList& quads = quadCuller.quadList();
171 ASSERT_EQ(1, quads.size()); 171 ASSERT_EQ(1, quads.size());
172 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material); 172 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material);
173 EXPECT_RECT_EQ(gfx::Rect(1, 0, 4, 3), quads[0]->rect); 173 EXPECT_RECT_EQ(gfx::Rect(1, 0, 4, 3), quads[0]->rect);
174 } 174 }
175 175
176 // Contents scale should scale the draw quad. 176 // Contents scale should scale the draw quad.
177 scrollbarLayerImpl->drawProperties().contents_scale_x = 2; 177 scrollbarLayerImpl->draw_properties().contents_scale_x = 2;
178 scrollbarLayerImpl->drawProperties().contents_scale_y = 2; 178 scrollbarLayerImpl->draw_properties().contents_scale_y = 2;
179 { 179 {
180 MockQuadCuller quadCuller; 180 MockQuadCuller quadCuller;
181 AppendQuadsData data; 181 AppendQuadsData data;
182 scrollbarLayerImpl->appendQuads(quadCuller, data); 182 scrollbarLayerImpl->AppendQuads(&quadCuller, &data);
183 183
184 const QuadList& quads = quadCuller.quadList(); 184 const QuadList& quads = quadCuller.quadList();
185 ASSERT_EQ(1, quads.size()); 185 ASSERT_EQ(1, quads.size());
186 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material); 186 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material);
187 EXPECT_RECT_EQ(gfx::Rect(2, 0, 8, 6), quads[0]->rect); 187 EXPECT_RECT_EQ(gfx::Rect(2, 0, 8, 6), quads[0]->rect);
188 } 188 }
189 189
190 } 190 }
191 191
192 class ScrollbarLayerTestMaxTextureSize : public ThreadedTest { 192 class ScrollbarLayerTestMaxTextureSize : public ThreadedTest {
193 public: 193 public:
194 ScrollbarLayerTestMaxTextureSize() {} 194 ScrollbarLayerTestMaxTextureSize() {}
195 195
196 void setScrollbarBounds(gfx::Size bounds) { 196 void setScrollbarBounds(gfx::Size bounds) {
197 m_bounds = bounds; 197 bounds_ = bounds;
198 } 198 }
199 199
200 virtual void beginTest() OVERRIDE 200 virtual void beginTest() OVERRIDE
201 { 201 {
202 m_layerTreeHost->initializeRendererIfNeeded(); 202 m_layerTreeHost->initializeRendererIfNeeded();
203 203
204 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); 204 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
205 m_scrollbarLayer = ScrollbarLayer::Create(scrollbar.Pass(), FakeScrollba rThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarTh emeGeometry::create(true), 1); 205 m_scrollbarLayer = ScrollbarLayer::Create(scrollbar.Pass(), FakeScrollba rThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarTh emeGeometry::create(true), 1);
206 m_scrollbarLayer->setLayerTreeHost(m_layerTreeHost.get()); 206 m_scrollbarLayer->SetLayerTreeHost(m_layerTreeHost.get());
207 m_scrollbarLayer->setBounds(m_bounds); 207 m_scrollbarLayer->SetBounds(bounds_);
208 m_layerTreeHost->rootLayer()->addChild(m_scrollbarLayer); 208 m_layerTreeHost->rootLayer()->AddChild(m_scrollbarLayer);
209 209
210 m_scrollLayer = Layer::create(); 210 m_scrollLayer = Layer::Create();
211 m_scrollbarLayer->SetScrollLayerId(m_scrollLayer->id()); 211 m_scrollbarLayer->SetScrollLayerId(m_scrollLayer->id());
212 m_layerTreeHost->rootLayer()->addChild(m_scrollLayer); 212 m_layerTreeHost->rootLayer()->AddChild(m_scrollLayer);
213 213
214 postSetNeedsCommitToMainThread(); 214 postSetNeedsCommitToMainThread();
215 } 215 }
216 216
217 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE 217 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
218 { 218 {
219 const int kMaxTextureSize = impl->rendererCapabilities().maxTextureSize; 219 const int kMaxTextureSize = impl->rendererCapabilities().maxTextureSize;
220 220
221 // Check first that we're actually testing something. 221 // Check first that we're actually testing something.
222 EXPECT_GT(m_scrollbarLayer->bounds().width(), kMaxTextureSize); 222 EXPECT_GT(m_scrollbarLayer->bounds().width(), kMaxTextureSize);
223 223
224 EXPECT_EQ(m_scrollbarLayer->contentBounds().width(), kMaxTextureSize - 1 ); 224 EXPECT_EQ(m_scrollbarLayer->content_bounds().width(), kMaxTextureSize - 1);
225 EXPECT_EQ(m_scrollbarLayer->contentBounds().height(), kMaxTextureSize - 1); 225 EXPECT_EQ(m_scrollbarLayer->content_bounds().height(), kMaxTextureSize - 1);
226 226
227 endTest(); 227 endTest();
228 } 228 }
229 229
230 virtual void afterTest() OVERRIDE 230 virtual void afterTest() OVERRIDE
231 { 231 {
232 } 232 }
233 233
234 private: 234 private:
235 scoped_refptr<ScrollbarLayer> m_scrollbarLayer; 235 scoped_refptr<ScrollbarLayer> m_scrollbarLayer;
236 scoped_refptr<Layer> m_scrollLayer; 236 scoped_refptr<Layer> m_scrollLayer;
237 gfx::Size m_bounds; 237 gfx::Size bounds_;
238 }; 238 };
239 239
240 TEST_F(ScrollbarLayerTestMaxTextureSize, runTest) { 240 TEST_F(ScrollbarLayerTestMaxTextureSize, runTest) {
241 scoped_ptr<TestWebGraphicsContext3D> context = TestWebGraphicsContext3D::Cre ate(); 241 scoped_ptr<TestWebGraphicsContext3D> context = TestWebGraphicsContext3D::Cre ate();
242 int max_size = 0; 242 int max_size = 0;
243 context->getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); 243 context->getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size);
244 setScrollbarBounds(gfx::Size(max_size + 100, max_size + 100)); 244 setScrollbarBounds(gfx::Size(max_size + 100, max_size + 100));
245 runTest(true); 245 runTest(true);
246 } 246 }
247 247
(...skipping 14 matching lines...) Expand all
262 public: 262 public:
263 ScrollbarLayerTestResourceCreation() 263 ScrollbarLayerTestResourceCreation()
264 { 264 {
265 } 265 }
266 266
267 void testResourceUpload(int expectedResources) 267 void testResourceUpload(int expectedResources)
268 { 268 {
269 m_layerTreeHost.reset(new MockLayerTreeHost(m_layerTreeSettings)); 269 m_layerTreeHost.reset(new MockLayerTreeHost(m_layerTreeSettings));
270 270
271 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); 271 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
272 scoped_refptr<Layer> layerTreeRoot = Layer::create(); 272 scoped_refptr<Layer> layerTreeRoot = Layer::Create();
273 scoped_refptr<Layer> contentLayer = Layer::create(); 273 scoped_refptr<Layer> contentLayer = Layer::Create();
274 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::Create(scrollbar.P ass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::create(true), layerTreeRoot->id()); 274 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::Create(scrollbar.P ass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::create(true), layerTreeRoot->id());
275 layerTreeRoot->addChild(contentLayer); 275 layerTreeRoot->AddChild(contentLayer);
276 layerTreeRoot->addChild(scrollbarLayer); 276 layerTreeRoot->AddChild(scrollbarLayer);
277 277
278 m_layerTreeHost->initializeRendererIfNeeded(); 278 m_layerTreeHost->initializeRendererIfNeeded();
279 m_layerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(1024 * 1024); 279 m_layerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(1024 * 1024);
280 m_layerTreeHost->setRootLayer(layerTreeRoot); 280 m_layerTreeHost->setRootLayer(layerTreeRoot);
281 281
282 scrollbarLayer->setIsDrawable(true); 282 scrollbarLayer->SetIsDrawable(true);
283 scrollbarLayer->setBounds(gfx::Size(100, 100)); 283 scrollbarLayer->SetBounds(gfx::Size(100, 100));
284 layerTreeRoot->setScrollOffset(gfx::Vector2d(10, 20)); 284 layerTreeRoot->SetScrollOffset(gfx::Vector2d(10, 20));
285 layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(30, 50)); 285 layerTreeRoot->SetMaxScrollOffset(gfx::Vector2d(30, 50));
286 layerTreeRoot->setBounds(gfx::Size(100, 200)); 286 layerTreeRoot->SetBounds(gfx::Size(100, 200));
287 contentLayer->setBounds(gfx::Size(100, 200)); 287 contentLayer->SetBounds(gfx::Size(100, 200));
288 scrollbarLayer->drawProperties().content_bounds = gfx::Size(100, 200); 288 scrollbarLayer->draw_properties().content_bounds = gfx::Size(100, 200);
289 scrollbarLayer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200); 289 scrollbarLayer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
290 scrollbarLayer->createRenderSurface(); 290 scrollbarLayer->CreateRenderSurface();
291 scrollbarLayer->drawProperties().render_target = scrollbarLayer; 291 scrollbarLayer->draw_properties().render_target = scrollbarLayer;
292 292
293 testing::Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 293 testing::Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
294 EXPECT_EQ(scrollbarLayer->layerTreeHost(), m_layerTreeHost.get()); 294 EXPECT_EQ(scrollbarLayer->layer_tree_host(), m_layerTreeHost.get());
295 295
296 PriorityCalculator calculator; 296 PriorityCalculator calculator;
297 ResourceUpdateQueue queue; 297 ResourceUpdateQueue queue;
298 OcclusionTracker occlusionTracker(gfx::Rect(), false); 298 OcclusionTracker occlusionTracker(gfx::Rect(), false);
299 299
300 scrollbarLayer->setTexturePriorities(calculator); 300 scrollbarLayer->SetTexturePriorities(calculator);
301 m_layerTreeHost->contentsTextureManager()->prioritizeTextures(); 301 m_layerTreeHost->contentsTextureManager()->prioritizeTextures();
302 scrollbarLayer->update(queue, &occlusionTracker, NULL); 302 scrollbarLayer->Update(&queue, &occlusionTracker, NULL);
303 EXPECT_EQ(0, queue.fullUploadSize()); 303 EXPECT_EQ(0, queue.fullUploadSize());
304 EXPECT_EQ(expectedResources, queue.partialUploadSize()); 304 EXPECT_EQ(expectedResources, queue.partialUploadSize());
305 305
306 testing::Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 306 testing::Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
307 } 307 }
308 308
309 protected: 309 protected:
310 scoped_ptr<MockLayerTreeHost> m_layerTreeHost; 310 scoped_ptr<MockLayerTreeHost> m_layerTreeHost;
311 LayerTreeSettings m_layerTreeSettings; 311 LayerTreeSettings m_layerTreeSettings;
312 }; 312 };
313 313
314 TEST_F(ScrollbarLayerTestResourceCreation, resourceUpload) 314 TEST_F(ScrollbarLayerTestResourceCreation, resourceUpload)
315 { 315 {
316 m_layerTreeSettings.solidColorScrollbars = false; 316 m_layerTreeSettings.solidColorScrollbars = false;
317 testResourceUpload(2); 317 testResourceUpload(2);
318 } 318 }
319 319
320 TEST_F(ScrollbarLayerTestResourceCreation, solidColorNoResourceUpload) 320 TEST_F(ScrollbarLayerTestResourceCreation, solidColorNoResourceUpload)
321 { 321 {
322 m_layerTreeSettings.solidColorScrollbars = true; 322 m_layerTreeSettings.solidColorScrollbars = true;
323 testResourceUpload(0); 323 testResourceUpload(0);
324 } 324 }
325 325
326 } // namespace 326 } // namespace
327 } // namespace cc 327 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scrollbar_layer_impl.cc ('k') | cc/shared_quad_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698