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

Side by Side Diff: cc/layers/scrollbar_layer_unittest.cc

Issue 17550008: Make IsSolidColor() a property on CC scrollbar layers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Jochen's comments. Created 7 years, 5 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
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/layers/scrollbar_layer.h" 5 #include "cc/layers/scrollbar_layer.h"
6 6
7 #include "cc/animation/scrollbar_animation_controller.h" 7 #include "cc/animation/scrollbar_animation_controller.h"
8 #include "cc/layers/append_quads_data.h" 8 #include "cc/layers/append_quads_data.h"
9 #include "cc/layers/scrollbar_layer_impl.h" 9 #include "cc/layers/scrollbar_layer_impl.h"
10 #include "cc/quads/solid_color_draw_quad.h" 10 #include "cc/quads/solid_color_draw_quad.h"
(...skipping 13 matching lines...) Expand all
24 #include "cc/trees/tree_synchronizer.h" 24 #include "cc/trees/tree_synchronizer.h"
25 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 27
28 namespace cc { 28 namespace cc {
29 namespace { 29 namespace {
30 30
31 scoped_ptr<LayerImpl> LayerImplForScrollAreaAndScrollbar( 31 scoped_ptr<LayerImpl> LayerImplForScrollAreaAndScrollbar(
32 FakeLayerTreeHostImpl* host_impl, 32 FakeLayerTreeHostImpl* host_impl,
33 scoped_ptr<Scrollbar> scrollbar, 33 scoped_ptr<Scrollbar> scrollbar,
34 bool reverse_order) { 34 bool reverse_order,
35 bool is_solid_color) {
35 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 36 scoped_refptr<Layer> layer_tree_root = Layer::Create();
36 scoped_refptr<Layer> child1 = Layer::Create(); 37 scoped_refptr<Layer> child1 = Layer::Create();
37 scoped_refptr<Layer> child2 = 38 scoped_refptr<Layer> child2 =
38 ScrollbarLayer::Create(scrollbar.Pass(), 39 ScrollbarLayer::Create(scrollbar.Pass(),
39 child1->id()); 40 child1->id(), is_solid_color);
40 layer_tree_root->AddChild(child1); 41 layer_tree_root->AddChild(child1);
41 layer_tree_root->InsertChild(child2, reverse_order ? 0 : 1); 42 layer_tree_root->InsertChild(child2, reverse_order ? 0 : 1);
42 scoped_ptr<LayerImpl> layer_impl = 43 scoped_ptr<LayerImpl> layer_impl =
43 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 44 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
44 scoped_ptr<LayerImpl>(), 45 scoped_ptr<LayerImpl>(),
45 host_impl->active_tree()); 46 host_impl->active_tree());
46 TreeSynchronizer::PushProperties(layer_tree_root.get(), layer_impl.get()); 47 TreeSynchronizer::PushProperties(layer_tree_root.get(), layer_impl.get());
47 return layer_impl.Pass(); 48 return layer_impl.Pass();
48 } 49 }
49 50
50 TEST(ScrollbarLayerTest, ResolveScrollLayerPointer) { 51 TEST(ScrollbarLayerTest, ResolveScrollLayerPointer) {
51 FakeImplProxy proxy; 52 FakeImplProxy proxy;
52 FakeLayerTreeHostImpl host_impl(&proxy); 53 FakeLayerTreeHostImpl host_impl(&proxy);
53 54
54 { 55 {
55 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); 56 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar);
56 scoped_ptr<LayerImpl> layer_impl_tree_root = 57 scoped_ptr<LayerImpl> layer_impl_tree_root =
57 LayerImplForScrollAreaAndScrollbar( 58 LayerImplForScrollAreaAndScrollbar(
58 &host_impl, scrollbar.Pass(), false); 59 &host_impl, scrollbar.Pass(), false, false);
59 60
60 LayerImpl* cc_child1 = layer_impl_tree_root->children()[0]; 61 LayerImpl* cc_child1 = layer_impl_tree_root->children()[0];
61 ScrollbarLayerImpl* cc_child2 = static_cast<ScrollbarLayerImpl*>( 62 ScrollbarLayerImpl* cc_child2 = static_cast<ScrollbarLayerImpl*>(
62 layer_impl_tree_root->children()[1]); 63 layer_impl_tree_root->children()[1]);
63 64
64 EXPECT_EQ(cc_child1->horizontal_scrollbar_layer(), cc_child2); 65 EXPECT_EQ(cc_child1->horizontal_scrollbar_layer(), cc_child2);
65 } 66 }
66 { 67 {
67 // another traverse order 68 // another traverse order
68 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); 69 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar);
69 scoped_ptr<LayerImpl> layer_impl_tree_root = 70 scoped_ptr<LayerImpl> layer_impl_tree_root =
70 LayerImplForScrollAreaAndScrollbar( 71 LayerImplForScrollAreaAndScrollbar(
71 &host_impl, scrollbar.Pass(), true); 72 &host_impl, scrollbar.Pass(), true, false);
72 73
73 ScrollbarLayerImpl* cc_child1 = static_cast<ScrollbarLayerImpl*>( 74 ScrollbarLayerImpl* cc_child1 = static_cast<ScrollbarLayerImpl*>(
74 layer_impl_tree_root->children()[0]); 75 layer_impl_tree_root->children()[0]);
75 LayerImpl* cc_child2 = layer_impl_tree_root->children()[1]; 76 LayerImpl* cc_child2 = layer_impl_tree_root->children()[1];
76 77
77 EXPECT_EQ(cc_child2->horizontal_scrollbar_layer(), cc_child1); 78 EXPECT_EQ(cc_child2->horizontal_scrollbar_layer(), cc_child1);
78 } 79 }
79 } 80 }
80 81
81 TEST(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { 82 TEST(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) {
82 FakeImplProxy proxy; 83 FakeImplProxy proxy;
83 FakeLayerTreeHostImpl host_impl(&proxy); 84 FakeLayerTreeHostImpl host_impl(&proxy);
84 85
85 // Create and attach a non-overlay scrollbar. 86 // Create and attach a non-overlay scrollbar.
86 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); 87 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar);
87 scoped_ptr<LayerImpl> layer_impl_tree_root = 88 scoped_ptr<LayerImpl> layer_impl_tree_root =
88 LayerImplForScrollAreaAndScrollbar(&host_impl, scrollbar.Pass(), false); 89 LayerImplForScrollAreaAndScrollbar(
90 &host_impl, scrollbar.Pass(), false, false);
89 ScrollbarLayerImpl* scrollbar_layer_impl = 91 ScrollbarLayerImpl* scrollbar_layer_impl =
90 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); 92 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]);
91 93
92 // When the scrollbar is not an overlay scrollbar, the scroll should be 94 // When the scrollbar is not an overlay scrollbar, the scroll should be
93 // responded to on the main thread as the compositor does not yet implement 95 // responded to on the main thread as the compositor does not yet implement
94 // scrollbar scrolling. 96 // scrollbar scrolling.
95 EXPECT_EQ(InputHandler::ScrollOnMainThread, 97 EXPECT_EQ(InputHandler::ScrollOnMainThread,
96 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0), 98 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0),
97 InputHandler::Gesture)); 99 InputHandler::Gesture));
98 100
99 // Create and attach an overlay scrollbar. 101 // Create and attach an overlay scrollbar.
100 scrollbar.reset(new FakeScrollbar(false, false, true)); 102 scrollbar.reset(new FakeScrollbar(false, false, true));
101 103
102 layer_impl_tree_root = 104 layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar(
103 LayerImplForScrollAreaAndScrollbar(&host_impl, scrollbar.Pass(), false); 105 &host_impl, scrollbar.Pass(), false, false);
104 scrollbar_layer_impl = 106 scrollbar_layer_impl =
105 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); 107 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]);
106 108
107 // The user shouldn't be able to drag an overlay scrollbar and the scroll 109 // The user shouldn't be able to drag an overlay scrollbar and the scroll
108 // may be handled in the compositor. 110 // may be handled in the compositor.
109 EXPECT_EQ(InputHandler::ScrollIgnored, 111 EXPECT_EQ(InputHandler::ScrollIgnored,
110 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0), 112 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0),
111 InputHandler::Gesture)); 113 InputHandler::Gesture));
112 } 114 }
113 115
114 TEST(ScrollbarLayerTest, ScrollOffsetSynchronization) { 116 TEST(ScrollbarLayerTest, ScrollOffsetSynchronization) {
115 FakeImplProxy proxy; 117 FakeImplProxy proxy;
116 FakeLayerTreeHostImpl host_impl(&proxy); 118 FakeLayerTreeHostImpl host_impl(&proxy);
117 119
118 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); 120 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar);
119 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 121 scoped_refptr<Layer> layer_tree_root = Layer::Create();
120 scoped_refptr<Layer> content_layer = Layer::Create(); 122 scoped_refptr<Layer> content_layer = Layer::Create();
121 scoped_refptr<Layer> scrollbar_layer = 123 scoped_refptr<Layer> scrollbar_layer =
122 ScrollbarLayer::Create(scrollbar.Pass(), 124 ScrollbarLayer::Create(scrollbar.Pass(),
123 layer_tree_root->id()); 125 layer_tree_root->id(), false);
124 layer_tree_root->AddChild(content_layer); 126 layer_tree_root->AddChild(content_layer);
125 layer_tree_root->AddChild(scrollbar_layer); 127 layer_tree_root->AddChild(scrollbar_layer);
126 128
127 layer_tree_root->SetScrollOffset(gfx::Vector2d(10, 20)); 129 layer_tree_root->SetScrollOffset(gfx::Vector2d(10, 20));
128 layer_tree_root->SetMaxScrollOffset(gfx::Vector2d(30, 50)); 130 layer_tree_root->SetMaxScrollOffset(gfx::Vector2d(30, 50));
129 layer_tree_root->SetBounds(gfx::Size(100, 200)); 131 layer_tree_root->SetBounds(gfx::Size(100, 200));
130 layer_tree_root->SavePaintProperties(); 132 layer_tree_root->SavePaintProperties();
131 content_layer->SetBounds(gfx::Size(100, 200)); 133 content_layer->SetBounds(gfx::Size(100, 200));
132 content_layer->SavePaintProperties(); 134 content_layer->SavePaintProperties();
133 135
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 EXPECT_EQ(300, cc_scrollbar_layer->Maximum()); 168 EXPECT_EQ(300, cc_scrollbar_layer->Maximum());
167 169
168 layer_impl_tree_root->ScrollBy(gfx::Vector2d(12, 34)); 170 layer_impl_tree_root->ScrollBy(gfx::Vector2d(12, 34));
169 171
170 EXPECT_EQ(112.f, cc_scrollbar_layer->CurrentPos()); 172 EXPECT_EQ(112.f, cc_scrollbar_layer->CurrentPos());
171 EXPECT_EQ(300, cc_scrollbar_layer->Maximum()); 173 EXPECT_EQ(300, cc_scrollbar_layer->Maximum());
172 } 174 }
173 175
174 TEST(ScrollbarLayerTest, SolidColorDrawQuads) { 176 TEST(ScrollbarLayerTest, SolidColorDrawQuads) {
175 LayerTreeSettings layer_tree_settings; 177 LayerTreeSettings layer_tree_settings;
176 layer_tree_settings.solid_color_scrollbars = true; 178 layer_tree_settings.force_solid_color_scrollbars = true;
177 layer_tree_settings.solid_color_scrollbar_thickness_dip = 3; 179 layer_tree_settings.solid_color_scrollbar_thickness_dip = 3;
178 FakeImplProxy proxy; 180 FakeImplProxy proxy;
179 FakeLayerTreeHostImpl host_impl(layer_tree_settings, &proxy); 181 FakeLayerTreeHostImpl host_impl(layer_tree_settings, &proxy);
180 182
181 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); 183 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true));
182 scoped_ptr<LayerImpl> layer_impl_tree_root = 184 scoped_ptr<LayerImpl> layer_impl_tree_root =
183 LayerImplForScrollAreaAndScrollbar(&host_impl, scrollbar.Pass(), false); 185 LayerImplForScrollAreaAndScrollbar(
186 &host_impl,
187 scrollbar.Pass(),
188 false,
189 layer_tree_settings.force_solid_color_scrollbars);
184 ScrollbarLayerImpl* scrollbar_layer_impl = 190 ScrollbarLayerImpl* scrollbar_layer_impl =
185 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); 191 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]);
186 scrollbar_layer_impl->set_thumb_thickness(3); 192 scrollbar_layer_impl->set_thumb_thickness(3);
187 scrollbar_layer_impl->SetCurrentPos(10.f); 193 scrollbar_layer_impl->SetCurrentPos(10.f);
188 scrollbar_layer_impl->SetMaximum(100); 194 scrollbar_layer_impl->SetMaximum(100);
189 scrollbar_layer_impl->set_track_length(100); 195 scrollbar_layer_impl->set_track_length(100);
190 scrollbar_layer_impl->set_visible_to_total_length_ratio(0.4f); 196 scrollbar_layer_impl->set_visible_to_total_length_ratio(0.4f);
191 197
192 // Thickness should be overridden to 3. 198 // Thickness should be overridden to 3.
193 { 199 {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 233
228 const QuadList& quads = quad_culler.quad_list(); 234 const QuadList& quads = quad_culler.quad_list();
229 ASSERT_EQ(1u, quads.size()); 235 ASSERT_EQ(1u, quads.size());
230 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material); 236 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material);
231 EXPECT_RECT_EQ(gfx::Rect(8, 0, 20, 3), quads[0]->rect); 237 EXPECT_RECT_EQ(gfx::Rect(8, 0, 20, 3), quads[0]->rect);
232 } 238 }
233 } 239 }
234 240
235 TEST(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { 241 TEST(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) {
236 LayerTreeSettings layer_tree_settings; 242 LayerTreeSettings layer_tree_settings;
237 layer_tree_settings.solid_color_scrollbars = true; 243 layer_tree_settings.force_solid_color_scrollbars = true;
238 layer_tree_settings.solid_color_scrollbar_thickness_dip = 3; 244 layer_tree_settings.solid_color_scrollbar_thickness_dip = 3;
239 FakeImplProxy proxy; 245 FakeImplProxy proxy;
240 FakeLayerTreeHostImpl host_impl(layer_tree_settings, &proxy); 246 FakeLayerTreeHostImpl host_impl(layer_tree_settings, &proxy);
241 247
242 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); 248 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true));
243 scoped_ptr<LayerImpl> layer_impl_tree_root = 249 scoped_ptr<LayerImpl> layer_impl_tree_root =
244 LayerImplForScrollAreaAndScrollbar(&host_impl, scrollbar.Pass(), false); 250 LayerImplForScrollAreaAndScrollbar(
251 &host_impl,
252 scrollbar.Pass(),
253 false,
254 layer_tree_settings.force_solid_color_scrollbars);
245 ScrollbarLayerImpl* scrollbar_layer_impl = 255 ScrollbarLayerImpl* scrollbar_layer_impl =
246 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); 256 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]);
247 257
248 scrollbar_layer_impl->set_thumb_thickness(3); 258 scrollbar_layer_impl->set_thumb_thickness(3);
249 scrollbar_layer_impl->set_track_length(10); 259 scrollbar_layer_impl->set_track_length(10);
250 scrollbar_layer_impl->SetCurrentPos(4.f); 260 scrollbar_layer_impl->SetCurrentPos(4.f);
251 scrollbar_layer_impl->SetMaximum(8); 261 scrollbar_layer_impl->SetMaximum(8);
252 262
253 layer_impl_tree_root->SetHorizontalScrollbarLayer(scrollbar_layer_impl); 263 layer_impl_tree_root->SetHorizontalScrollbarLayer(scrollbar_layer_impl);
254 layer_impl_tree_root->SetMaxScrollOffset(gfx::Vector2d(8, 8)); 264 layer_impl_tree_root->SetMaxScrollOffset(gfx::Vector2d(8, 8));
255 layer_impl_tree_root->SetBounds(gfx::Size(2, 2)); 265 layer_impl_tree_root->SetBounds(gfx::Size(2, 2));
256 layer_impl_tree_root->ScrollBy(gfx::Vector2dF(4.f, 0.f)); 266 layer_impl_tree_root->ScrollBy(gfx::Vector2dF(4.f, 0.f));
257 267
258 { 268 {
259 MockQuadCuller quad_culler; 269 MockQuadCuller quad_culler;
260 AppendQuadsData data; 270 AppendQuadsData data;
261 scrollbar_layer_impl->AppendQuads(&quad_culler, &data); 271 scrollbar_layer_impl->AppendQuads(&quad_culler, &data);
262 272
263 const QuadList& quads = quad_culler.quad_list(); 273 const QuadList& quads = quad_culler.quad_list();
264 ASSERT_EQ(1u, quads.size()); 274 ASSERT_EQ(1u, quads.size());
265 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material); 275 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material);
266 EXPECT_RECT_EQ(gfx::Rect(3, 0, 3, 3), quads[0]->rect); 276 EXPECT_RECT_EQ(gfx::Rect(3, 0, 3, 3), quads[0]->rect);
267 } 277 }
268 } 278 }
269 279
270 class ScrollbarLayerSolidColorThumbTest : public testing::Test { 280 class ScrollbarLayerSolidColorThumbTest : public testing::Test {
271 public: 281 public:
272 ScrollbarLayerSolidColorThumbTest() { 282 ScrollbarLayerSolidColorThumbTest() {
273 LayerTreeSettings layer_tree_settings; 283 LayerTreeSettings layer_tree_settings;
274 layer_tree_settings.solid_color_scrollbars = true; 284 layer_tree_settings.force_solid_color_scrollbars = true;
275 host_impl_.reset(new FakeLayerTreeHostImpl(layer_tree_settings, &proxy_)); 285 host_impl_.reset(new FakeLayerTreeHostImpl(layer_tree_settings, &proxy_));
276 286
277 horizontal_scrollbar_layer_ = ScrollbarLayerImpl::Create( 287 horizontal_scrollbar_layer_ = ScrollbarLayerImpl::Create(
278 host_impl_->active_tree(), 1, HORIZONTAL); 288 host_impl_->active_tree(),
289 1,
290 HORIZONTAL,
291 layer_tree_settings.force_solid_color_scrollbars);
279 vertical_scrollbar_layer_ = ScrollbarLayerImpl::Create( 292 vertical_scrollbar_layer_ = ScrollbarLayerImpl::Create(
280 host_impl_->active_tree(), 2, VERTICAL); 293 host_impl_->active_tree(),
294 2,
295 VERTICAL,
296 layer_tree_settings.force_solid_color_scrollbars);
281 } 297 }
282 298
283 protected: 299 protected:
284 FakeImplProxy proxy_; 300 FakeImplProxy proxy_;
285 scoped_ptr<FakeLayerTreeHostImpl> host_impl_; 301 scoped_ptr<FakeLayerTreeHostImpl> host_impl_;
286 scoped_ptr<ScrollbarLayerImpl> horizontal_scrollbar_layer_; 302 scoped_ptr<ScrollbarLayerImpl> horizontal_scrollbar_layer_;
287 scoped_ptr<ScrollbarLayerImpl> vertical_scrollbar_layer_; 303 scoped_ptr<ScrollbarLayerImpl> vertical_scrollbar_layer_;
288 }; 304 };
289 305
290 TEST_F(ScrollbarLayerSolidColorThumbTest, SolidColorThumbLength) { 306 TEST_F(ScrollbarLayerSolidColorThumbTest, SolidColorThumbLength) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 } 371 }
356 372
357 class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest { 373 class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest {
358 public: 374 public:
359 ScrollbarLayerTestMaxTextureSize() {} 375 ScrollbarLayerTestMaxTextureSize() {}
360 376
361 void SetScrollbarBounds(gfx::Size bounds) { bounds_ = bounds; } 377 void SetScrollbarBounds(gfx::Size bounds) { bounds_ = bounds; }
362 378
363 virtual void BeginTest() OVERRIDE { 379 virtual void BeginTest() OVERRIDE {
364 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); 380 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar);
365 scrollbar_layer_ = ScrollbarLayer::Create(scrollbar.Pass(), 1); 381 scrollbar_layer_ = ScrollbarLayer::Create(scrollbar.Pass(), 1, false);
366 scrollbar_layer_->SetLayerTreeHost(layer_tree_host()); 382 scrollbar_layer_->SetLayerTreeHost(layer_tree_host());
367 scrollbar_layer_->SetBounds(bounds_); 383 scrollbar_layer_->SetBounds(bounds_);
368 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); 384 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_);
369 385
370 scroll_layer_ = Layer::Create(); 386 scroll_layer_ = Layer::Create();
371 scrollbar_layer_->SetScrollLayerId(scroll_layer_->id()); 387 scrollbar_layer_->SetScrollLayerId(scroll_layer_->id());
372 layer_tree_host()->root_layer()->AddChild(scroll_layer_); 388 layer_tree_host()->root_layer()->AddChild(scroll_layer_);
373 389
374 PostSetNeedsCommitToMainThread(); 390 PostSetNeedsCommitToMainThread();
375 } 391 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 ScrollbarLayerTestResourceCreation() 446 ScrollbarLayerTestResourceCreation()
431 : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} 447 : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {}
432 448
433 void TestResourceUpload(size_t expected_resources) { 449 void TestResourceUpload(size_t expected_resources) {
434 layer_tree_host_.reset( 450 layer_tree_host_.reset(
435 new MockLayerTreeHost(&fake_client_, layer_tree_settings_)); 451 new MockLayerTreeHost(&fake_client_, layer_tree_settings_));
436 452
437 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, false)); 453 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, false));
438 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 454 scoped_refptr<Layer> layer_tree_root = Layer::Create();
439 scoped_refptr<Layer> content_layer = Layer::Create(); 455 scoped_refptr<Layer> content_layer = Layer::Create();
440 scoped_refptr<Layer> scrollbar_layer = 456 scoped_refptr<Layer> scrollbar_layer = ScrollbarLayer::Create(
441 ScrollbarLayer::Create(scrollbar.Pass(), layer_tree_root->id()); 457 scrollbar.Pass(),
458 layer_tree_root->id(),
459 layer_tree_settings_.force_solid_color_scrollbars);
442 layer_tree_root->AddChild(content_layer); 460 layer_tree_root->AddChild(content_layer);
443 layer_tree_root->AddChild(scrollbar_layer); 461 layer_tree_root->AddChild(scrollbar_layer);
444 462
445 layer_tree_host_->InitializeOutputSurfaceIfNeeded(); 463 layer_tree_host_->InitializeOutputSurfaceIfNeeded();
446 layer_tree_host_->contents_texture_manager()-> 464 layer_tree_host_->contents_texture_manager()->
447 SetMaxMemoryLimitBytes(1024 * 1024); 465 SetMaxMemoryLimitBytes(1024 * 1024);
448 layer_tree_host_->SetRootLayer(layer_tree_root); 466 layer_tree_host_->SetRootLayer(layer_tree_root);
449 467
450 scrollbar_layer->SetIsDrawable(true); 468 scrollbar_layer->SetIsDrawable(true);
451 scrollbar_layer->SetBounds(gfx::Size(100, 100)); 469 scrollbar_layer->SetBounds(gfx::Size(100, 100));
(...skipping 23 matching lines...) Expand all
475 testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 493 testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get());
476 } 494 }
477 495
478 protected: 496 protected:
479 FakeLayerTreeHostClient fake_client_; 497 FakeLayerTreeHostClient fake_client_;
480 LayerTreeSettings layer_tree_settings_; 498 LayerTreeSettings layer_tree_settings_;
481 scoped_ptr<MockLayerTreeHost> layer_tree_host_; 499 scoped_ptr<MockLayerTreeHost> layer_tree_host_;
482 }; 500 };
483 501
484 TEST_F(ScrollbarLayerTestResourceCreation, ResourceUpload) { 502 TEST_F(ScrollbarLayerTestResourceCreation, ResourceUpload) {
485 layer_tree_settings_.solid_color_scrollbars = false; 503 layer_tree_settings_.force_solid_color_scrollbars = false;
486 TestResourceUpload(2); 504 TestResourceUpload(2);
487 } 505 }
488 506
489 TEST_F(ScrollbarLayerTestResourceCreation, SolidColorNoResourceUpload) { 507 TEST_F(ScrollbarLayerTestResourceCreation, SolidColorNoResourceUpload) {
490 layer_tree_settings_.solid_color_scrollbars = true; 508 layer_tree_settings_.force_solid_color_scrollbars = true;
491 TestResourceUpload(0); 509 TestResourceUpload(0);
492 } 510 }
493 511
494 class ScaledScrollbarLayerTestResourceCreation : public testing::Test { 512 class ScaledScrollbarLayerTestResourceCreation : public testing::Test {
495 public: 513 public:
496 ScaledScrollbarLayerTestResourceCreation() 514 ScaledScrollbarLayerTestResourceCreation()
497 : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} 515 : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {}
498 516
499 void TestResourceUpload(size_t expected_resources, const float test_scale) { 517 void TestResourceUpload(size_t expected_resources, const float test_scale) {
500 layer_tree_host_.reset( 518 layer_tree_host_.reset(
501 new MockLayerTreeHost(&fake_client_, layer_tree_settings_)); 519 new MockLayerTreeHost(&fake_client_, layer_tree_settings_));
502 520
503 gfx::Point scrollbar_location(0, 185); 521 gfx::Point scrollbar_location(0, 185);
504 scoped_ptr<FakeScrollbar> scrollbar(new FakeScrollbar(false, true, false)); 522 scoped_ptr<FakeScrollbar> scrollbar(new FakeScrollbar(false, true, false));
505 scrollbar->set_location(scrollbar_location); 523 scrollbar->set_location(scrollbar_location);
506 524
507 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 525 scoped_refptr<Layer> layer_tree_root = Layer::Create();
508 scoped_refptr<Layer> content_layer = Layer::Create(); 526 scoped_refptr<Layer> content_layer = Layer::Create();
509 scoped_refptr<Layer> scrollbar_layer = 527 scoped_refptr<Layer> scrollbar_layer = ScrollbarLayer::Create(
510 ScrollbarLayer::Create(scrollbar.PassAs<cc::Scrollbar>(), 528 scrollbar.PassAs<cc::Scrollbar>(),
511 layer_tree_root->id()); 529 layer_tree_root->id(),
530 layer_tree_settings_.force_solid_color_scrollbars);
512 layer_tree_root->AddChild(content_layer); 531 layer_tree_root->AddChild(content_layer);
513 layer_tree_root->AddChild(scrollbar_layer); 532 layer_tree_root->AddChild(scrollbar_layer);
514 533
515 layer_tree_host_->InitializeOutputSurfaceIfNeeded(); 534 layer_tree_host_->InitializeOutputSurfaceIfNeeded();
516 layer_tree_host_->contents_texture_manager()-> 535 layer_tree_host_->contents_texture_manager()->
517 SetMaxMemoryLimitBytes(1024 * 1024); 536 SetMaxMemoryLimitBytes(1024 * 1024);
518 layer_tree_host_->SetRootLayer(layer_tree_root); 537 layer_tree_host_->SetRootLayer(layer_tree_root);
519 538
520 scrollbar_layer->SetIsDrawable(true); 539 scrollbar_layer->SetIsDrawable(true);
521 scrollbar_layer->SetBounds(gfx::Size(100, 15)); 540 scrollbar_layer->SetBounds(gfx::Size(100, 15));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 587 testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get());
569 } 588 }
570 589
571 protected: 590 protected:
572 FakeLayerTreeHostClient fake_client_; 591 FakeLayerTreeHostClient fake_client_;
573 LayerTreeSettings layer_tree_settings_; 592 LayerTreeSettings layer_tree_settings_;
574 scoped_ptr<MockLayerTreeHost> layer_tree_host_; 593 scoped_ptr<MockLayerTreeHost> layer_tree_host_;
575 }; 594 };
576 595
577 TEST_F(ScaledScrollbarLayerTestResourceCreation, ScaledResourceUpload) { 596 TEST_F(ScaledScrollbarLayerTestResourceCreation, ScaledResourceUpload) {
578 layer_tree_settings_.solid_color_scrollbars = false; 597 layer_tree_settings_.force_solid_color_scrollbars = false;
579 // Pick a test scale that moves the scrollbar's (non-zero) position to 598 // Pick a test scale that moves the scrollbar's (non-zero) position to
580 // a non-pixel-aligned location. 599 // a non-pixel-aligned location.
581 TestResourceUpload(2, 1.41f); 600 TestResourceUpload(2, 1.41f);
582 } 601 }
583 602
584 } // namespace 603 } // namespace
585 } // namespace cc 604 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698