| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 UpdateState(gfx::Point(), gfx::Vector2d(-10, 10)).get()) | 1186 UpdateState(gfx::Point(), gfx::Vector2d(-10, 10)).get()) |
| 1187 .did_scroll); | 1187 .did_scroll); |
| 1188 | 1188 |
| 1189 // Trying to scroll more than the available space will also succeed. | 1189 // Trying to scroll more than the available space will also succeed. |
| 1190 EXPECT_TRUE( | 1190 EXPECT_TRUE( |
| 1191 host_impl_->ScrollBy( | 1191 host_impl_->ScrollBy( |
| 1192 UpdateState(gfx::Point(), gfx::Vector2d(5000, 5000)).get()) | 1192 UpdateState(gfx::Point(), gfx::Vector2d(5000, 5000)).get()) |
| 1193 .did_scroll); | 1193 .did_scroll); |
| 1194 } | 1194 } |
| 1195 | 1195 |
| 1196 TEST_F(LayerTreeHostImplTest, ScrollVerticallyByPageReturnsCorrectValue) { | |
| 1197 SetupScrollAndContentsLayers(gfx::Size(200, 2000)); | |
| 1198 host_impl_->SetViewportSize(gfx::Size(100, 1000)); | |
| 1199 | |
| 1200 DrawFrame(); | |
| 1201 | |
| 1202 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | |
| 1203 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | |
| 1204 InputHandler::WHEEL) | |
| 1205 .thread); | |
| 1206 | |
| 1207 // Trying to scroll if not user_scrollable_vertical will fail. | |
| 1208 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(false); | |
| 1209 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | |
| 1210 DrawFrame(); | |
| 1211 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( | |
| 1212 gfx::Point(), SCROLL_FORWARD)); | |
| 1213 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( | |
| 1214 gfx::Point(), SCROLL_BACKWARD)); | |
| 1215 | |
| 1216 host_impl_->InnerViewportScrollLayer()->set_user_scrollable_vertical(true); | |
| 1217 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | |
| 1218 DrawFrame(); | |
| 1219 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( | |
| 1220 gfx::Point(), SCROLL_FORWARD)); | |
| 1221 EXPECT_FLOAT_EQ(875.f, | |
| 1222 ScrollDelta(host_impl_->InnerViewportScrollLayer()).y()); | |
| 1223 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( | |
| 1224 gfx::Point(), SCROLL_BACKWARD)); | |
| 1225 } | |
| 1226 | |
| 1227 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { | 1196 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { |
| 1228 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1197 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1229 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1198 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1230 | 1199 |
| 1231 gfx::Size overflow_size(400, 400); | 1200 gfx::Size overflow_size(400, 400); |
| 1232 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); | 1201 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); |
| 1233 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; | 1202 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; |
| 1234 overflow->SetBounds(overflow_size); | 1203 overflow->SetBounds(overflow_size); |
| 1235 overflow->SetScrollClipLayer( | 1204 overflow->SetScrollClipLayer( |
| 1236 scroll_layer->test_properties()->parent->test_properties()->parent->id()); | 1205 scroll_layer->test_properties()->parent->test_properties()->parent->id()); |
| (...skipping 10017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11254 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11223 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
| 11255 | 11224 |
| 11256 // Re-initialize with a software output surface. | 11225 // Re-initialize with a software output surface. |
| 11257 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); | 11226 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); |
| 11258 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 11227 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
| 11259 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11228 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 11260 } | 11229 } |
| 11261 | 11230 |
| 11262 } // namespace | 11231 } // namespace |
| 11263 } // namespace cc | 11232 } // namespace cc |
| OLD | NEW |