| Index: cc/scrollbar_layer_unittest.cc
|
| diff --git a/cc/scrollbar_layer_unittest.cc b/cc/scrollbar_layer_unittest.cc
|
| index bf37810e972f8c400373fe6edb9267bbdb03daf4..6ec0f8f9e25dd9d8cbdc15ee76275a621877d06e 100644
|
| --- a/cc/scrollbar_layer_unittest.cc
|
| +++ b/cc/scrollbar_layer_unittest.cc
|
| @@ -5,6 +5,7 @@
|
| #include "cc/scrollbar_layer.h"
|
|
|
| #include "cc/append_quads_data.h"
|
| +#include "cc/layer_tree_impl.h"
|
| #include "cc/prioritized_resource_manager.h"
|
| #include "cc/priority_calculator.h"
|
| #include "cc/resource_update_queue.h"
|
| @@ -323,5 +324,69 @@ TEST_F(ScrollbarLayerTestResourceCreation, solidColorNoResourceUpload)
|
| testResourceUpload(0);
|
| }
|
|
|
| +TEST(ScrollbarLayerTest, pinchZoomScrollbarUpdates)
|
| +{
|
| + FakeImplProxy proxy;
|
| + FakeLayerTreeHostImpl hostImpl(&proxy);
|
| +
|
| + scoped_refptr<Layer> layerTreeRoot = Layer::Create();
|
| + layerTreeRoot->SetScrollable(true);
|
| +
|
| + scoped_refptr<Layer> contentLayer = Layer::Create();
|
| + scoped_ptr<WebKit::WebScrollbar> scrollbar1(FakeWebScrollbar::Create());
|
| + scoped_refptr<Layer> scrollbarLayerHorizontal =
|
| + ScrollbarLayer::Create(scrollbar1.Pass(),
|
| + FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(),
|
| + FakeWebScrollbarThemeGeometry::create(true),
|
| + Layer::PINCH_ZOOM_ROOT_SCROLL_LAYER_ID);
|
| + scoped_ptr<WebKit::WebScrollbar> scrollbar2(FakeWebScrollbar::Create());
|
| + scoped_refptr<Layer> scrollbarLayerVertical =
|
| + ScrollbarLayer::Create(scrollbar2.Pass(),
|
| + FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(),
|
| + FakeWebScrollbarThemeGeometry::create(true),
|
| + Layer::PINCH_ZOOM_ROOT_SCROLL_LAYER_ID);
|
| +
|
| + layerTreeRoot->AddChild(contentLayer);
|
| + layerTreeRoot->AddChild(scrollbarLayerHorizontal);
|
| + layerTreeRoot->AddChild(scrollbarLayerVertical);
|
| +
|
| + layerTreeRoot->SetScrollOffset(gfx::Vector2d(10, 20));
|
| + layerTreeRoot->SetMaxScrollOffset(gfx::Vector2d(30, 50));
|
| + layerTreeRoot->SetBounds(gfx::Size(100, 200));
|
| + contentLayer->SetBounds(gfx::Size(100, 200));
|
| +
|
| + scoped_ptr<LayerImpl> layerImplTreeRoot =
|
| + TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(),
|
| + scoped_ptr<LayerImpl>(), hostImpl.activeTree());
|
| + TreeSynchronizer::pushProperties(layerTreeRoot.get(),
|
| + layerImplTreeRoot.get());
|
| +
|
| + ScrollbarLayerImpl* pinchZoomHorizontal = static_cast<ScrollbarLayerImpl*>(
|
| + layerImplTreeRoot->children()[1]);
|
| + ScrollbarLayerImpl* pinchZoomVertical = static_cast<ScrollbarLayerImpl*>(
|
| + layerImplTreeRoot->children()[2]);
|
| +
|
| + // Need a root layer in the active tree in order for DidUpdateScroll()
|
| + // to work.
|
| + hostImpl.activeTree()->SetRootLayer(layerImplTreeRoot.Pass());
|
| + hostImpl.activeTree()->FindRootScrollLayer();
|
| +
|
| + // Manually set the pinch-zoom layers: normally this is done by
|
| + // LayerTreeHost.
|
| + hostImpl.activeTree()->SetPinchZoomHorizontalLayerId(
|
| + pinchZoomHorizontal->id());
|
| + hostImpl.activeTree()->SetPinchZoomVerticalLayerId(
|
| + pinchZoomVertical->id());
|
| +
|
| + hostImpl.activeTree()->DidUpdateScroll();
|
| +
|
| + EXPECT_EQ(10, pinchZoomHorizontal->CurrentPos());
|
| + EXPECT_EQ(100, pinchZoomHorizontal->TotalSize());
|
| + EXPECT_EQ(30, pinchZoomHorizontal->Maximum());
|
| + EXPECT_EQ(20, pinchZoomVertical->CurrentPos());
|
| + EXPECT_EQ(200, pinchZoomVertical->TotalSize());
|
| + EXPECT_EQ(50, pinchZoomVertical->Maximum());
|
| +}
|
| +
|
| } // namespace
|
| } // namespace cc
|
|
|