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

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: Rebase to fix collision with solid colour scrollbars patch. 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
« no previous file with comments | « cc/scrollbar_layer_impl.cc ('k') | cc/tree_synchronizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scrollbar_layer_unittest.cc
diff --git a/cc/scrollbar_layer_unittest.cc b/cc/scrollbar_layer_unittest.cc
index f38bfcba1a033a6255060e139142375f56695dd2..493bf8bf7daae8ed291b4af344b0d264647a5ed4 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"
@@ -342,5 +343,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.active_tree());
+ 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.active_tree()->SetRootLayer(layerImplTreeRoot.Pass());
+ hostImpl.active_tree()->FindRootScrollLayer();
+
+ // Manually set the pinch-zoom layers: normally this is done by
+ // LayerTreeHost.
+ hostImpl.active_tree()->SetPinchZoomHorizontalLayerId(
+ pinchZoomHorizontal->id());
+ hostImpl.active_tree()->SetPinchZoomVerticalLayerId(
+ pinchZoomVertical->id());
+
+ hostImpl.active_tree()->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
« no previous file with comments | « 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