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

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

Issue 13079003: Fix solid color scrollbars for sublayers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/layers/layer_impl.cc ('k') | no next file » | 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/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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 AppendQuadsData data; 237 AppendQuadsData data;
238 scrollbar_layer_impl->AppendQuads(&quad_culler, &data); 238 scrollbar_layer_impl->AppendQuads(&quad_culler, &data);
239 239
240 const QuadList& quads = quad_culler.quad_list(); 240 const QuadList& quads = quad_culler.quad_list();
241 ASSERT_EQ(1, quads.size()); 241 ASSERT_EQ(1, quads.size());
242 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material); 242 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material);
243 EXPECT_RECT_EQ(gfx::Rect(4, 0, 2, 3), quads[0]->rect); 243 EXPECT_RECT_EQ(gfx::Rect(4, 0, 2, 3), quads[0]->rect);
244 } 244 }
245 } 245 }
246 246
247 TEST(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) {
248 LayerTreeSettings layer_tree_settings;
249 layer_tree_settings.solid_color_scrollbars = true;
250 layer_tree_settings.solid_color_scrollbar_thickness_dip = 3;
251 FakeImplProxy proxy;
252 FakeLayerTreeHostImpl host_impl(layer_tree_settings, &proxy);
253
254 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
255 static_cast<FakeWebScrollbar*>(scrollbar.get())->set_overlay(true);
256 scoped_ptr<LayerImpl> layer_impl_tree_root =
257 LayerImplForScrollAreaAndScrollbar(&host_impl, scrollbar.Pass(), false);
258 ScrollbarLayerImpl* scrollbar_layer_impl =
259 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]);
260
261 // Make sure that this ends up calling SetViewportWithinScrollableArea.
262 layer_impl_tree_root->SetHorizontalScrollbarLayer(scrollbar_layer_impl);
263 layer_impl_tree_root->SetMaxScrollOffset(gfx::Vector2d(8, 8));
264 layer_impl_tree_root->SetBounds(gfx::Size(2, 2));
265 layer_impl_tree_root->ScrollBy(gfx::Vector2dF(4.f, 0.f));
266
267 {
268 MockQuadCuller quad_culler;
269 AppendQuadsData data;
270 scrollbar_layer_impl->AppendQuads(&quad_culler, &data);
271
272 const QuadList& quads = quad_culler.quad_list();
273 ASSERT_EQ(1, quads.size());
274 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material);
275 EXPECT_RECT_EQ(gfx::Rect(4, 0, 2, 3), quads[0]->rect);
276 }
277 }
278
247 class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest { 279 class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest {
248 public: 280 public:
249 ScrollbarLayerTestMaxTextureSize() {} 281 ScrollbarLayerTestMaxTextureSize() {}
250 282
251 void SetScrollbarBounds(gfx::Size bounds) { bounds_ = bounds; } 283 void SetScrollbarBounds(gfx::Size bounds) { bounds_ = bounds; }
252 284
253 virtual void BeginTest() OVERRIDE { 285 virtual void BeginTest() OVERRIDE {
254 layer_tree_host()->InitializeRendererIfNeeded(); 286 layer_tree_host()->InitializeRendererIfNeeded();
255 287
256 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); 288 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 EXPECT_EQ(10.f, pinch_zoom_horizontal->CurrentPos()); 476 EXPECT_EQ(10.f, pinch_zoom_horizontal->CurrentPos());
445 EXPECT_EQ(100, pinch_zoom_horizontal->TotalSize()); 477 EXPECT_EQ(100, pinch_zoom_horizontal->TotalSize());
446 EXPECT_EQ(30, pinch_zoom_horizontal->Maximum()); 478 EXPECT_EQ(30, pinch_zoom_horizontal->Maximum());
447 EXPECT_EQ(20.f, pinch_zoom_vertical->CurrentPos()); 479 EXPECT_EQ(20.f, pinch_zoom_vertical->CurrentPos());
448 EXPECT_EQ(200, pinch_zoom_vertical->TotalSize()); 480 EXPECT_EQ(200, pinch_zoom_vertical->TotalSize());
449 EXPECT_EQ(50, pinch_zoom_vertical->Maximum()); 481 EXPECT_EQ(50, pinch_zoom_vertical->Maximum());
450 } 482 }
451 483
452 } // namespace 484 } // namespace
453 } // namespace cc 485 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698