OLD | NEW |
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 EXPECT_EQ(cc_child2->horizontal_scrollbar_layer(), cc_child1); | 84 EXPECT_EQ(cc_child2->horizontal_scrollbar_layer(), cc_child1); |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 TEST(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { | 88 TEST(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { |
89 FakeImplProxy proxy; | 89 FakeImplProxy proxy; |
90 FakeLayerTreeHostImpl host_impl(&proxy); | 90 FakeLayerTreeHostImpl host_impl(&proxy); |
91 | 91 |
92 // Create and attach a non-overlay scrollbar. | 92 // Create and attach a non-overlay scrollbar. |
93 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); | 93 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); |
94 static_cast<FakeWebScrollbar*>(scrollbar.get())->setOverlay(false); | 94 static_cast<FakeWebScrollbar*>(scrollbar.get())->set_overlay(false); |
95 scoped_ptr<LayerImpl> layer_impl_tree_root = | 95 scoped_ptr<LayerImpl> layer_impl_tree_root = |
96 LayerImplForScrollAreaAndScrollbar(&host_impl, scrollbar.Pass(), false); | 96 LayerImplForScrollAreaAndScrollbar(&host_impl, scrollbar.Pass(), false); |
97 ScrollbarLayerImpl* scrollbar_layer_impl = | 97 ScrollbarLayerImpl* scrollbar_layer_impl = |
98 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); | 98 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); |
99 | 99 |
100 // When the scrollbar is not an overlay scrollbar, the scroll should be | 100 // When the scrollbar is not an overlay scrollbar, the scroll should be |
101 // responded to on the main thread as the compositor does not yet implement | 101 // responded to on the main thread as the compositor does not yet implement |
102 // scrollbar scrolling. | 102 // scrollbar scrolling. |
103 EXPECT_EQ(InputHandlerClient::ScrollOnMainThread, | 103 EXPECT_EQ(InputHandlerClient::ScrollOnMainThread, |
104 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0), | 104 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0), |
105 InputHandlerClient::Gesture)); | 105 InputHandlerClient::Gesture)); |
106 | 106 |
107 // Create and attach an overlay scrollbar. | 107 // Create and attach an overlay scrollbar. |
108 scrollbar = FakeWebScrollbar::Create(); | 108 scrollbar = FakeWebScrollbar::Create(); |
109 static_cast<FakeWebScrollbar*>(scrollbar.get())->setOverlay(true); | 109 static_cast<FakeWebScrollbar*>(scrollbar.get())->set_overlay(true); |
110 | 110 |
111 layer_impl_tree_root = | 111 layer_impl_tree_root = |
112 LayerImplForScrollAreaAndScrollbar(&host_impl, scrollbar.Pass(), false); | 112 LayerImplForScrollAreaAndScrollbar(&host_impl, scrollbar.Pass(), false); |
113 scrollbar_layer_impl = | 113 scrollbar_layer_impl = |
114 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); | 114 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); |
115 | 115 |
116 // The user shouldn't be able to drag an overlay scrollbar and the scroll | 116 // The user shouldn't be able to drag an overlay scrollbar and the scroll |
117 // may be handled in the compositor. | 117 // may be handled in the compositor. |
118 EXPECT_EQ(InputHandlerClient::ScrollIgnored, | 118 EXPECT_EQ(InputHandlerClient::ScrollIgnored, |
119 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0), | 119 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0), |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 } | 183 } |
184 | 184 |
185 TEST(ScrollbarLayerTest, SolidColorDrawQuads) { | 185 TEST(ScrollbarLayerTest, SolidColorDrawQuads) { |
186 LayerTreeSettings layer_tree_settings; | 186 LayerTreeSettings layer_tree_settings; |
187 layer_tree_settings.solid_color_scrollbars = true; | 187 layer_tree_settings.solid_color_scrollbars = true; |
188 layer_tree_settings.solid_color_scrollbar_thickness_dip = 3; | 188 layer_tree_settings.solid_color_scrollbar_thickness_dip = 3; |
189 FakeImplProxy proxy; | 189 FakeImplProxy proxy; |
190 FakeLayerTreeHostImpl host_impl(layer_tree_settings, &proxy); | 190 FakeLayerTreeHostImpl host_impl(layer_tree_settings, &proxy); |
191 | 191 |
192 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); | 192 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); |
193 static_cast<FakeWebScrollbar*>(scrollbar.get())->setOverlay(true); | 193 static_cast<FakeWebScrollbar*>(scrollbar.get())->set_overlay(true); |
194 scoped_ptr<LayerImpl> layer_impl_tree_root = | 194 scoped_ptr<LayerImpl> layer_impl_tree_root = |
195 LayerImplForScrollAreaAndScrollbar(&host_impl, scrollbar.Pass(), false); | 195 LayerImplForScrollAreaAndScrollbar(&host_impl, scrollbar.Pass(), false); |
196 ScrollbarLayerImpl* scrollbar_layer_impl = | 196 ScrollbarLayerImpl* scrollbar_layer_impl = |
197 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); | 197 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); |
198 scrollbar_layer_impl->SetThumbSize(gfx::Size(4, 4)); | 198 scrollbar_layer_impl->SetThumbSize(gfx::Size(4, 4)); |
199 scrollbar_layer_impl->SetViewportWithinScrollableArea( | 199 scrollbar_layer_impl->SetViewportWithinScrollableArea( |
200 gfx::RectF(10.f, 0.f, 40.f, 0.f), gfx::SizeF(100.f, 100.f)); | 200 gfx::RectF(10.f, 0.f, 40.f, 0.f), gfx::SizeF(100.f, 100.f)); |
201 | 201 |
202 // Thickness should be overridden to 3. | 202 // Thickness should be overridden to 3. |
203 { | 203 { |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 EXPECT_EQ(10.f, pinch_zoom_horizontal->CurrentPos()); | 444 EXPECT_EQ(10.f, pinch_zoom_horizontal->CurrentPos()); |
445 EXPECT_EQ(100, pinch_zoom_horizontal->TotalSize()); | 445 EXPECT_EQ(100, pinch_zoom_horizontal->TotalSize()); |
446 EXPECT_EQ(30, pinch_zoom_horizontal->Maximum()); | 446 EXPECT_EQ(30, pinch_zoom_horizontal->Maximum()); |
447 EXPECT_EQ(20.f, pinch_zoom_vertical->CurrentPos()); | 447 EXPECT_EQ(20.f, pinch_zoom_vertical->CurrentPos()); |
448 EXPECT_EQ(200, pinch_zoom_vertical->TotalSize()); | 448 EXPECT_EQ(200, pinch_zoom_vertical->TotalSize()); |
449 EXPECT_EQ(50, pinch_zoom_vertical->Maximum()); | 449 EXPECT_EQ(50, pinch_zoom_vertical->Maximum()); |
450 } | 450 } |
451 | 451 |
452 } // namespace | 452 } // namespace |
453 } // namespace cc | 453 } // namespace cc |
OLD | NEW |