Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2289)

Unified Diff: cc/scrollbar_layer_unittest.cc

Issue 11550035: Implement pinch-zoom scaling for main-frame scrollbars and pinch-zoom overlay scrollbars. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate device scale factor, default to 0 totalSize when no root scroll layer. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/scrollbar_layer_unittest.cc
diff --git a/cc/scrollbar_layer_unittest.cc b/cc/scrollbar_layer_unittest.cc
index c7edef1a92b842ef74366947f51cad9d898ba7d4..f5da90aafdc415196c7a4096976ef9465fa73a6e 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(),
enne (OOO) 2013/03/11 21:08:24 Inconsistent formatting here.
wjmaclean 2013/03/12 16:13:07 Done.
+ FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(),
+ FakeWebScrollbarThemeGeometry::create(true),
+ Layer::s_invalidLayerId);
+ scoped_ptr<WebKit::WebScrollbar> scrollbar2(FakeWebScrollbar::create());
+ scoped_refptr<Layer> scrollbarLayerVertical =
+ ScrollbarLayer::create(scrollbar2.Pass(),
+ FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(),
+ FakeWebScrollbarThemeGeometry::create(true),
+ Layer::s_invalidLayerId);
+
+ 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

Powered by Google App Engine
This is Rietveld 408576698