Remove NavigationRequestInfo::is_showing.
[chromium-blink-merge.git] / cc / layers / solid_color_scrollbar_layer_impl_unittest.cc
blob5f42636307a97837bea971cd925fdc4a34452f6c
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
7 #include "cc/test/layer_test_common.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace cc {
11 namespace {
13 TEST(SolidColorScrollbarLayerImplTest, Occlusion) {
14 gfx::Size layer_size(10, 1000);
15 gfx::Size viewport_size(1000, 1000);
17 LayerTestCommon::LayerImplTest impl;
19 ScrollbarOrientation orientation = VERTICAL;
20 int thumb_thickness = layer_size.width();
21 int track_start = 0;
22 bool is_left_side_vertical_scrollbar = false;
23 bool is_overlay = false;
25 SolidColorScrollbarLayerImpl* scrollbar_layer_impl =
26 impl.AddChildToRoot<SolidColorScrollbarLayerImpl>(
27 orientation,
28 thumb_thickness,
29 track_start,
30 is_left_side_vertical_scrollbar,
31 is_overlay);
32 scrollbar_layer_impl->SetBounds(layer_size);
33 scrollbar_layer_impl->SetContentBounds(layer_size);
34 scrollbar_layer_impl->SetDrawsContent(true);
35 scrollbar_layer_impl->SetCurrentPos(100.f / 4);
36 scrollbar_layer_impl->SetMaximum(100);
37 scrollbar_layer_impl->SetVisibleToTotalLengthRatio(1.f / 2);
38 // SolidColorScrollbarLayers construct with opacity = 0.f, so override.
39 scrollbar_layer_impl->SetOpacity(1.f);
41 impl.CalcDrawProps(viewport_size);
43 gfx::Rect thumb_rect = scrollbar_layer_impl->ComputeThumbQuadRect();
44 EXPECT_EQ(gfx::Rect(0, 500 / 4, 10, layer_size.height() / 2).ToString(),
45 thumb_rect.ToString());
48 SCOPED_TRACE("No occlusion");
49 gfx::Rect occluded;
50 impl.AppendQuadsWithOcclusion(scrollbar_layer_impl, occluded);
52 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), thumb_rect);
53 EXPECT_EQ(1u, impl.quad_list().size());
57 SCOPED_TRACE("Full occlusion");
58 gfx::Rect occluded(scrollbar_layer_impl->visible_content_rect());
59 impl.AppendQuadsWithOcclusion(scrollbar_layer_impl, occluded);
61 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), gfx::Rect());
62 EXPECT_EQ(impl.quad_list().size(), 0u);
66 SCOPED_TRACE("Partial occlusion");
67 gfx::Rect occluded(0, 0, 5, 1000);
68 impl.AppendQuadsWithOcclusion(scrollbar_layer_impl, occluded);
70 size_t partially_occluded_count = 0;
71 LayerTestCommon::VerifyQuadsCoverRectWithOcclusion(
72 impl.quad_list(), thumb_rect, occluded, &partially_occluded_count);
73 // The layer outputs one quad, which is partially occluded.
74 EXPECT_EQ(1u, impl.quad_list().size());
75 EXPECT_EQ(1u, partially_occluded_count);
79 } // namespace
80 } // namespace cc