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/scrollbar_layer.h" | 5 #include "cc/scrollbar_layer.h" |
6 | 6 |
7 #include "cc/append_quads_data.h" | 7 #include "cc/append_quads_data.h" |
| 8 #include "cc/layer_tree_impl.h" |
8 #include "cc/prioritized_resource_manager.h" | 9 #include "cc/prioritized_resource_manager.h" |
9 #include "cc/priority_calculator.h" | 10 #include "cc/priority_calculator.h" |
10 #include "cc/resource_update_queue.h" | 11 #include "cc/resource_update_queue.h" |
11 #include "cc/scrollbar_animation_controller.h" | 12 #include "cc/scrollbar_animation_controller.h" |
12 #include "cc/scrollbar_layer_impl.h" | 13 #include "cc/scrollbar_layer_impl.h" |
13 #include "cc/single_thread_proxy.h" | 14 #include "cc/single_thread_proxy.h" |
14 #include "cc/solid_color_draw_quad.h" | 15 #include "cc/solid_color_draw_quad.h" |
15 #include "cc/test/fake_impl_proxy.h" | 16 #include "cc/test/fake_impl_proxy.h" |
16 #include "cc/test/fake_layer_tree_host_client.h" | 17 #include "cc/test/fake_layer_tree_host_client.h" |
17 #include "cc/test/fake_layer_tree_host_impl.h" | 18 #include "cc/test/fake_layer_tree_host_impl.h" |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 m_layerTreeSettings.solidColorScrollbars = false; | 317 m_layerTreeSettings.solidColorScrollbars = false; |
317 testResourceUpload(2); | 318 testResourceUpload(2); |
318 } | 319 } |
319 | 320 |
320 TEST_F(ScrollbarLayerTestResourceCreation, solidColorNoResourceUpload) | 321 TEST_F(ScrollbarLayerTestResourceCreation, solidColorNoResourceUpload) |
321 { | 322 { |
322 m_layerTreeSettings.solidColorScrollbars = true; | 323 m_layerTreeSettings.solidColorScrollbars = true; |
323 testResourceUpload(0); | 324 testResourceUpload(0); |
324 } | 325 } |
325 | 326 |
| 327 TEST(ScrollbarLayerTest, pinchZoomScrollbarUpdates) |
| 328 { |
| 329 FakeImplProxy proxy; |
| 330 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 331 |
| 332 scoped_refptr<Layer> layerTreeRoot = Layer::Create(); |
| 333 layerTreeRoot->SetScrollable(true); |
| 334 |
| 335 scoped_refptr<Layer> contentLayer = Layer::Create(); |
| 336 scoped_ptr<WebKit::WebScrollbar> scrollbar1(FakeWebScrollbar::Create()); |
| 337 scoped_refptr<Layer> scrollbarLayerHorizontal = |
| 338 ScrollbarLayer::Create(scrollbar1.Pass(), |
| 339 FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>()
, |
| 340 FakeWebScrollbarThemeGeometry::create(true), |
| 341 Layer::PINCH_ZOOM_ROOT_SCROLL_LAYER_ID); |
| 342 scoped_ptr<WebKit::WebScrollbar> scrollbar2(FakeWebScrollbar::Create()); |
| 343 scoped_refptr<Layer> scrollbarLayerVertical = |
| 344 ScrollbarLayer::Create(scrollbar2.Pass(), |
| 345 FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>()
, |
| 346 FakeWebScrollbarThemeGeometry::create(true), |
| 347 Layer::PINCH_ZOOM_ROOT_SCROLL_LAYER_ID); |
| 348 |
| 349 layerTreeRoot->AddChild(contentLayer); |
| 350 layerTreeRoot->AddChild(scrollbarLayerHorizontal); |
| 351 layerTreeRoot->AddChild(scrollbarLayerVertical); |
| 352 |
| 353 layerTreeRoot->SetScrollOffset(gfx::Vector2d(10, 20)); |
| 354 layerTreeRoot->SetMaxScrollOffset(gfx::Vector2d(30, 50)); |
| 355 layerTreeRoot->SetBounds(gfx::Size(100, 200)); |
| 356 contentLayer->SetBounds(gfx::Size(100, 200)); |
| 357 |
| 358 scoped_ptr<LayerImpl> layerImplTreeRoot = |
| 359 TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), |
| 360 scoped_ptr<LayerImpl>(), hostImpl.activeTree()); |
| 361 TreeSynchronizer::pushProperties(layerTreeRoot.get(), |
| 362 layerImplTreeRoot.get()); |
| 363 |
| 364 ScrollbarLayerImpl* pinchZoomHorizontal = static_cast<ScrollbarLayerImpl*>( |
| 365 layerImplTreeRoot->children()[1]); |
| 366 ScrollbarLayerImpl* pinchZoomVertical = static_cast<ScrollbarLayerImpl*>( |
| 367 layerImplTreeRoot->children()[2]); |
| 368 |
| 369 // Need a root layer in the active tree in order for DidUpdateScroll() |
| 370 // to work. |
| 371 hostImpl.activeTree()->SetRootLayer(layerImplTreeRoot.Pass()); |
| 372 hostImpl.activeTree()->FindRootScrollLayer(); |
| 373 |
| 374 // Manually set the pinch-zoom layers: normally this is done by |
| 375 // LayerTreeHost. |
| 376 hostImpl.activeTree()->SetPinchZoomHorizontalLayerId( |
| 377 pinchZoomHorizontal->id()); |
| 378 hostImpl.activeTree()->SetPinchZoomVerticalLayerId( |
| 379 pinchZoomVertical->id()); |
| 380 |
| 381 hostImpl.activeTree()->DidUpdateScroll(); |
| 382 |
| 383 EXPECT_EQ(10, pinchZoomHorizontal->CurrentPos()); |
| 384 EXPECT_EQ(100, pinchZoomHorizontal->TotalSize()); |
| 385 EXPECT_EQ(30, pinchZoomHorizontal->Maximum()); |
| 386 EXPECT_EQ(20, pinchZoomVertical->CurrentPos()); |
| 387 EXPECT_EQ(200, pinchZoomVertical->TotalSize()); |
| 388 EXPECT_EQ(50, pinchZoomVertical->Maximum()); |
| 389 } |
| 390 |
326 } // namespace | 391 } // namespace |
327 } // namespace cc | 392 } // namespace cc |
OLD | NEW |