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

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

Issue 308193003: Removed QuadSink and MockQuadCuller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@plumLayerImpl
Patch Set: rebase Created 6 years, 6 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/layers/render_surface_unittest.cc ('k') | cc/layers/solid_color_layer_impl.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 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 "base/containers/hash_tables.h" 5 #include "base/containers/hash_tables.h"
6 #include "cc/animation/scrollbar_animation_controller.h" 6 #include "cc/animation/scrollbar_animation_controller.h"
7 #include "cc/layers/append_quads_data.h" 7 #include "cc/layers/append_quads_data.h"
8 #include "cc/layers/painted_scrollbar_layer.h" 8 #include "cc/layers/painted_scrollbar_layer.h"
9 #include "cc/layers/painted_scrollbar_layer_impl.h" 9 #include "cc/layers/painted_scrollbar_layer_impl.h"
10 #include "cc/layers/scrollbar_layer_interface.h" 10 #include "cc/layers/scrollbar_layer_interface.h"
11 #include "cc/layers/solid_color_scrollbar_layer.h" 11 #include "cc/layers/solid_color_scrollbar_layer.h"
12 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 12 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
13 #include "cc/quads/solid_color_draw_quad.h" 13 #include "cc/quads/solid_color_draw_quad.h"
14 #include "cc/resources/resource_update_queue.h" 14 #include "cc/resources/resource_update_queue.h"
15 #include "cc/test/fake_impl_proxy.h" 15 #include "cc/test/fake_impl_proxy.h"
16 #include "cc/test/fake_layer_tree_host.h" 16 #include "cc/test/fake_layer_tree_host.h"
17 #include "cc/test/fake_layer_tree_host_client.h" 17 #include "cc/test/fake_layer_tree_host_client.h"
18 #include "cc/test/fake_layer_tree_host_impl.h" 18 #include "cc/test/fake_layer_tree_host_impl.h"
19 #include "cc/test/fake_painted_scrollbar_layer.h" 19 #include "cc/test/fake_painted_scrollbar_layer.h"
20 #include "cc/test/fake_scrollbar.h" 20 #include "cc/test/fake_scrollbar.h"
21 #include "cc/test/geometry_test_utils.h" 21 #include "cc/test/geometry_test_utils.h"
22 #include "cc/test/layer_tree_test.h" 22 #include "cc/test/layer_tree_test.h"
23 #include "cc/test/mock_quad_culler.h" 23 #include "cc/test/mock_occlusion_tracker.h"
24 #include "cc/test/test_web_graphics_context_3d.h" 24 #include "cc/test/test_web_graphics_context_3d.h"
25 #include "cc/trees/layer_tree_host.h" 25 #include "cc/trees/layer_tree_host.h"
26 #include "cc/trees/layer_tree_impl.h" 26 #include "cc/trees/layer_tree_impl.h"
27 #include "cc/trees/occlusion_tracker.h" 27 #include "cc/trees/occlusion_tracker.h"
28 #include "cc/trees/single_thread_proxy.h" 28 #include "cc/trees/single_thread_proxy.h"
29 #include "cc/trees/tree_synchronizer.h" 29 #include "cc/trees/tree_synchronizer.h"
30 #include "testing/gmock/include/gmock/gmock.h" 30 #include "testing/gmock/include/gmock/gmock.h"
31 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
32 32
33 namespace cc { 33 namespace cc {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 layer_impl_tree_root->children()[1]); 289 layer_impl_tree_root->children()[1]);
290 scrollbar_layer_impl->SetBounds(gfx::Size(kTrackLength, kThumbThickness)); 290 scrollbar_layer_impl->SetBounds(gfx::Size(kTrackLength, kThumbThickness));
291 scrollbar_layer_impl->SetCurrentPos(10.f); 291 scrollbar_layer_impl->SetCurrentPos(10.f);
292 scrollbar_layer_impl->SetMaximum(100); 292 scrollbar_layer_impl->SetMaximum(100);
293 scrollbar_layer_impl->SetVisibleToTotalLengthRatio(0.4f); 293 scrollbar_layer_impl->SetVisibleToTotalLengthRatio(0.4f);
294 294
295 // Thickness should be overridden to 3. 295 // Thickness should be overridden to 3.
296 { 296 {
297 MockOcclusionTracker<LayerImpl> occlusion_tracker; 297 MockOcclusionTracker<LayerImpl> occlusion_tracker;
298 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 298 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
299 MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker);
300 AppendQuadsData data; 299 AppendQuadsData data;
301 scrollbar_layer_impl->AppendQuads(&quad_culler, &data); 300 scrollbar_layer_impl->AppendQuads(
301 render_pass.get(), occlusion_tracker, &data);
302 302
303 const QuadList& quads = quad_culler.quad_list(); 303 const QuadList& quads = render_pass->quad_list;
304 ASSERT_EQ(1u, quads.size()); 304 ASSERT_EQ(1u, quads.size());
305 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material); 305 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material);
306 EXPECT_RECT_EQ(gfx::Rect(6, 0, 40, 3), quads[0]->rect); 306 EXPECT_RECT_EQ(gfx::Rect(6, 0, 40, 3), quads[0]->rect);
307 } 307 }
308 308
309 // Contents scale should scale the draw quad. 309 // Contents scale should scale the draw quad.
310 scrollbar_layer_impl->draw_properties().contents_scale_x = 2.f; 310 scrollbar_layer_impl->draw_properties().contents_scale_x = 2.f;
311 scrollbar_layer_impl->draw_properties().contents_scale_y = 2.f; 311 scrollbar_layer_impl->draw_properties().contents_scale_y = 2.f;
312 { 312 {
313 MockOcclusionTracker<LayerImpl> occlusion_tracker; 313 MockOcclusionTracker<LayerImpl> occlusion_tracker;
314 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 314 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
315 MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker);
316 AppendQuadsData data; 315 AppendQuadsData data;
317 scrollbar_layer_impl->AppendQuads(&quad_culler, &data); 316 scrollbar_layer_impl->AppendQuads(
317 render_pass.get(), occlusion_tracker, &data);
318 318
319 const QuadList& quads = quad_culler.quad_list(); 319 const QuadList& quads = render_pass->quad_list;
320 ASSERT_EQ(1u, quads.size()); 320 ASSERT_EQ(1u, quads.size());
321 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material); 321 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material);
322 EXPECT_RECT_EQ(gfx::Rect(12, 0, 80, 6), quads[0]->rect); 322 EXPECT_RECT_EQ(gfx::Rect(12, 0, 80, 6), quads[0]->rect);
323 } 323 }
324 scrollbar_layer_impl->draw_properties().contents_scale_x = 1.f; 324 scrollbar_layer_impl->draw_properties().contents_scale_x = 1.f;
325 scrollbar_layer_impl->draw_properties().contents_scale_y = 1.f; 325 scrollbar_layer_impl->draw_properties().contents_scale_y = 1.f;
326 326
327 // For solid color scrollbars, position and size should reflect the 327 // For solid color scrollbars, position and size should reflect the
328 // current viewport state. 328 // current viewport state.
329 scrollbar_layer_impl->SetVisibleToTotalLengthRatio(0.2f); 329 scrollbar_layer_impl->SetVisibleToTotalLengthRatio(0.2f);
330 { 330 {
331 MockOcclusionTracker<LayerImpl> occlusion_tracker; 331 MockOcclusionTracker<LayerImpl> occlusion_tracker;
332 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 332 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
333 MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker);
334 AppendQuadsData data; 333 AppendQuadsData data;
335 scrollbar_layer_impl->AppendQuads(&quad_culler, &data); 334 scrollbar_layer_impl->AppendQuads(
335 render_pass.get(), occlusion_tracker, &data);
336 336
337 const QuadList& quads = quad_culler.quad_list(); 337 const QuadList& quads = render_pass->quad_list;
338 ASSERT_EQ(1u, quads.size()); 338 ASSERT_EQ(1u, quads.size());
339 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material); 339 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material);
340 EXPECT_RECT_EQ(gfx::Rect(8, 0, 20, 3), quads[0]->rect); 340 EXPECT_RECT_EQ(gfx::Rect(8, 0, 20, 3), quads[0]->rect);
341 } 341 }
342 } 342 }
343 343
344 TEST(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { 344 TEST(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) {
345 const int kThumbThickness = 3; 345 const int kThumbThickness = 3;
346 const int kTrackStart = 0; 346 const int kTrackStart = 0;
347 const int kTrackLength = 10; 347 const int kTrackLength = 10;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 scroll_layer_impl->SetBounds(gfx::Size(10, 10)); 382 scroll_layer_impl->SetBounds(gfx::Size(10, 10));
383 scroll_layer_impl->ScrollBy(gfx::Vector2dF(4.f, 0.f)); 383 scroll_layer_impl->ScrollBy(gfx::Vector2dF(4.f, 0.f));
384 384
385 scrollbar_layer_impl->SetBounds(gfx::Size(kTrackLength, kThumbThickness)); 385 scrollbar_layer_impl->SetBounds(gfx::Size(kTrackLength, kThumbThickness));
386 scrollbar_layer_impl->SetCurrentPos(4.f); 386 scrollbar_layer_impl->SetCurrentPos(4.f);
387 scrollbar_layer_impl->SetMaximum(8); 387 scrollbar_layer_impl->SetMaximum(8);
388 388
389 { 389 {
390 MockOcclusionTracker<LayerImpl> occlusion_tracker; 390 MockOcclusionTracker<LayerImpl> occlusion_tracker;
391 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 391 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
392 MockQuadCuller quad_culler(render_pass.get(), &occlusion_tracker);
393 392
394 AppendQuadsData data; 393 AppendQuadsData data;
395 scrollbar_layer_impl->AppendQuads(&quad_culler, &data); 394 scrollbar_layer_impl->AppendQuads(
395 render_pass.get(), occlusion_tracker, &data);
396 396
397 const QuadList& quads = quad_culler.quad_list(); 397 const QuadList& quads = render_pass->quad_list;
398 ASSERT_EQ(1u, quads.size()); 398 ASSERT_EQ(1u, quads.size());
399 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material); 399 EXPECT_EQ(DrawQuad::SOLID_COLOR, quads[0]->material);
400 EXPECT_RECT_EQ(gfx::Rect(3, 0, 3, 3), quads[0]->rect); 400 EXPECT_RECT_EQ(gfx::Rect(3, 0, 3, 3), quads[0]->rect);
401 } 401 }
402 } 402 }
403 403
404 class ScrollbarLayerSolidColorThumbTest : public testing::Test { 404 class ScrollbarLayerSolidColorThumbTest : public testing::Test {
405 public: 405 public:
406 ScrollbarLayerSolidColorThumbTest() { 406 ScrollbarLayerSolidColorThumbTest() {
407 LayerTreeSettings layer_tree_settings; 407 LayerTreeSettings layer_tree_settings;
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); 893 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f);
894 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); 894 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f);
895 895
896 // Horizontal Scrollbars. 896 // Horizontal Scrollbars.
897 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); 897 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f);
898 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); 898 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f);
899 } 899 }
900 900
901 } // namespace 901 } // namespace
902 } // namespace cc 902 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/render_surface_unittest.cc ('k') | cc/layers/solid_color_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698