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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 646623003: Don't scale fixed container adjustment in pinch virtual viewport. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test Created 6 years, 2 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/layers/layer_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 5694c01aaa37565bec2f4254a0a41db9cb8092da..0614670c8e4d250d188cdcd66635fcb4db4a355c 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -914,19 +914,10 @@ TEST_F(LayerTreeHostImplTest, ImplPinchZoom) {
scroll_layer->SetScrollDelta(gfx::Vector2d());
float page_scale_delta = 2.f;
- gfx::Vector2dF expected_container_size_delta(
- container_layer->bounds().width(), container_layer->bounds().height());
- expected_container_size_delta.Scale((1.f - page_scale_delta) /
- (page_scale_factor * page_scale_delta));
host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture);
host_impl_->PinchGestureBegin();
host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50));
- // While the gesture is still active, the scroll layer should have a
- // container size delta = container->bounds() * ((1.f -
- // page_scale_delta)/())
- EXPECT_EQ(expected_container_size_delta,
- scroll_layer->FixedContainerSizeDelta());
host_impl_->PinchGestureEnd();
host_impl_->ScrollEnd();
EXPECT_FALSE(did_request_animate_);
@@ -2258,6 +2249,7 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest {
clip_size_(layer_size_) {
settings_.calculate_top_controls_position = true;
settings_.top_controls_height = 50;
+ settings_.use_pinch_virtual_viewport = true;
viewport_size_ =
gfx::Size(clip_size_.width(),
@@ -2400,8 +2392,8 @@ TEST_F(LayerTreeHostImplTopControlsTest,
}
TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsByFractionalAmount) {
- CreateHostImpl(settings_, CreateOutputSurface());
- SetupTopControlsAndScrollLayer();
+ SetupTopControlsAndScrollLayerWithVirtualViewport(
+ gfx::Size(10, 10), gfx::Size(10, 10), gfx::Size(10, 10));
DrawFrame();
EXPECT_EQ(InputHandler::ScrollStarted,
@@ -2423,36 +2415,56 @@ TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsByFractionalAmount) {
inner_viewport_scroll_layer->FixedContainerSizeDelta());
}
-TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsWithPageScale) {
- CreateHostImpl(settings_, CreateOutputSurface());
- SetupTopControlsAndScrollLayer();
+// Test that the fixed position container delta is appropriately adjusted
+// by the top controls showing/hiding and page scale doesn't affect it.
+TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) {
+ SetupTopControlsAndScrollLayerWithVirtualViewport(
+ gfx::Size(100, 100), gfx::Size(100, 100), gfx::Size(100, 100));
DrawFrame();
- EXPECT_EQ(InputHandler::ScrollStarted,
- host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
-
float page_scale = 1.5f;
+ float top_controls_height = settings_.top_controls_height;
+ LayerImpl* outer_viewport_scroll_layer =
+ host_impl_->active_tree()->OuterViewportScrollLayer();
+
+ // Zoom in, since the fixed container is the outer viewport, the delta should
+ // not be scaled.
host_impl_->active_tree()->SetPageScaleFactorAndLimits(page_scale, 1.f, 2.f);
- gfx::Vector2dF top_controls_scroll_delta(0.f, 5.f);
- gfx::Vector2dF expected_container_size_delta =
- ScaleVector2d(top_controls_scroll_delta, 1.f / page_scale);
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
+
+ // Scroll down, the top controls hiding should expand the viewport size so
+ // the delta should be equal to the scroll distance.
+ gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f);
host_impl_->top_controls_manager()->ScrollBegin();
host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta);
- host_impl_->top_controls_manager()->ScrollEnd();
+ EXPECT_EQ(top_controls_height - top_controls_scroll_delta.y(),
+ host_impl_->top_controls_manager()->ContentTopOffset());
+ EXPECT_VECTOR_EQ(top_controls_scroll_delta,
+ outer_viewport_scroll_layer->FixedContainerSizeDelta());
+ host_impl_->ScrollEnd();
- LayerImpl* inner_viewport_scroll_layer =
- host_impl_->active_tree()->InnerViewportScrollLayer();
- DCHECK(inner_viewport_scroll_layer);
+ // Scroll past the maximum extent. The delta shouldn't be greater than the
+ // top controls height.
+ host_impl_->top_controls_manager()->ScrollBegin();
+ host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta);
+ host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta);
+ host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta);
+ EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset());
+ EXPECT_VECTOR_EQ(gfx::Vector2dF(0, top_controls_height),
+ outer_viewport_scroll_layer->FixedContainerSizeDelta());
host_impl_->ScrollEnd();
- // Use a tolerance that requires the container size delta to be within 0.01
- // pixels.
- double tolerance = 0.0001;
- EXPECT_LT(
- (expected_container_size_delta -
- inner_viewport_scroll_layer->FixedContainerSizeDelta()).LengthSquared(),
- tolerance);
+ // Scroll in the direction to make the top controls show.
+ host_impl_->top_controls_manager()->ScrollBegin();
+ host_impl_->top_controls_manager()->ScrollBy(-top_controls_scroll_delta);
+ EXPECT_EQ(top_controls_scroll_delta.y(),
+ host_impl_->top_controls_manager()->ContentTopOffset());
+ EXPECT_VECTOR_EQ(
+ gfx::Vector2dF(0, top_controls_height - top_controls_scroll_delta.y()),
+ outer_viewport_scroll_layer->FixedContainerSizeDelta());
+ host_impl_->top_controls_manager()->ScrollEnd();
}
// Ensure setting the top controls position explicitly using the setters on the
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698