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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 LayerImpl* layer_impl_tree_root = | 78 LayerImpl* layer_impl_tree_root = |
79 LayerImplForScrollAreaAndScrollbar(host.get(), scrollbar.Pass(), false); | 79 LayerImplForScrollAreaAndScrollbar(host.get(), scrollbar.Pass(), false); |
80 ScrollbarLayerImpl* scrollbar_layer_impl = | 80 ScrollbarLayerImpl* scrollbar_layer_impl = |
81 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); | 81 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); |
82 | 82 |
83 // When the scrollbar is not an overlay scrollbar, the scroll should be | 83 // When the scrollbar is not an overlay scrollbar, the scroll should be |
84 // responded to on the main thread as the compositor does not yet implement | 84 // responded to on the main thread as the compositor does not yet implement |
85 // scrollbar scrolling. | 85 // scrollbar scrolling. |
86 EXPECT_EQ(InputHandler::ScrollOnMainThread, | 86 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
87 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0), | 87 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0), |
88 InputHandler::Gesture)); | 88 InputHandler::Gesture, |
| 89 true)); |
89 | 90 |
90 // Create and attach an overlay scrollbar. | 91 // Create and attach an overlay scrollbar. |
91 scrollbar.reset(new FakeScrollbar(false, false, true)); | 92 scrollbar.reset(new FakeScrollbar(false, false, true)); |
92 | 93 |
93 layer_impl_tree_root = | 94 layer_impl_tree_root = |
94 LayerImplForScrollAreaAndScrollbar(host.get(), scrollbar.Pass(), false); | 95 LayerImplForScrollAreaAndScrollbar(host.get(), scrollbar.Pass(), false); |
95 scrollbar_layer_impl = | 96 scrollbar_layer_impl = |
96 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); | 97 static_cast<ScrollbarLayerImpl*>(layer_impl_tree_root->children()[1]); |
97 | 98 |
98 // The user shouldn't be able to drag an overlay scrollbar and the scroll | 99 // The user shouldn't be able to drag an overlay scrollbar and the scroll |
99 // may be handled in the compositor. | 100 // may be handled in the compositor. |
100 EXPECT_EQ(InputHandler::ScrollIgnored, | 101 EXPECT_EQ(InputHandler::ScrollIgnored, |
101 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0), | 102 scrollbar_layer_impl->TryScroll(gfx::Point(0, 0), |
102 InputHandler::Gesture)); | 103 InputHandler::Gesture, |
| 104 true)); |
103 } | 105 } |
104 | 106 |
105 TEST(ScrollbarLayerTest, ScrollOffsetSynchronization) { | 107 TEST(ScrollbarLayerTest, ScrollOffsetSynchronization) { |
106 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); | 108 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); |
107 | 109 |
108 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 110 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
109 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 111 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
110 scoped_refptr<Layer> content_layer = Layer::Create(); | 112 scoped_refptr<Layer> content_layer = Layer::Create(); |
111 scoped_refptr<Layer> scrollbar_layer = | 113 scoped_refptr<Layer> scrollbar_layer = |
112 ScrollbarLayer::Create(scrollbar.Pass(), | 114 ScrollbarLayer::Create(scrollbar.Pass(), |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 | 569 |
568 TEST_F(ScaledScrollbarLayerTestResourceCreation, ScaledResourceUpload) { | 570 TEST_F(ScaledScrollbarLayerTestResourceCreation, ScaledResourceUpload) { |
569 layer_tree_settings_.solid_color_scrollbars = false; | 571 layer_tree_settings_.solid_color_scrollbars = false; |
570 // Pick a test scale that moves the scrollbar's (non-zero) position to | 572 // Pick a test scale that moves the scrollbar's (non-zero) position to |
571 // a non-pixel-aligned location. | 573 // a non-pixel-aligned location. |
572 TestResourceUpload(2, 1.41f); | 574 TestResourceUpload(2, 1.41f); |
573 } | 575 } |
574 | 576 |
575 } // namespace | 577 } // namespace |
576 } // namespace cc | 578 } // namespace cc |
OLD | NEW |