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

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: Make OpacityIsAnimating() virtual. 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 147fb58601aebf05fbf431893fb9379eb0e051a0..5c0575ad4ed31a06a22b0c83130d6acda05b9d4b 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
« cc/scrollbar_layer.cc ('K') | « cc/scrollbar_layer_impl.cc ('k') | cc/tree_synchronizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698