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(), | |
enne (OOO)
2013/03/11 21:08:24
Inconsistent formatting here.
wjmaclean
2013/03/12 16:13:07
Done.
| |
339 FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), | |
340 FakeWebScrollbarThemeGeometry::create(true), | |
341 Layer::s_invalidLayerId); | |
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::s_invalidLayerId); | |
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 |