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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 1950613004: Fix bounds clamping during composited smooth scroll. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add unit test Created 4 years, 7 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 4acad4d61bc9c8caa2e6f07f11bb79e5878272e6..ab68fdc6f8cab8ab74986bc595943eacbb4ad6ac 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -10075,6 +10075,47 @@ TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedNotUserScrollable) {
host_impl_->DidFinishImplFrame();
}
+// Test that smooth scrolls clamp correctly when bounds change mid-animation.
+TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedChangingBounds) {
+ const gfx::Size old_content_size(1000, 1000);
+ const gfx::Size new_content_size(750, 750);
+ const gfx::Size viewport_size(500, 500);
+
+ LayerImpl* content_layer =
+ CreateBasicVirtualViewportLayers(viewport_size, old_content_size);
+ SetNeedsRebuildPropertyTrees();
+ DrawFrame();
+
+ base::TimeTicks start_time =
+ base::TimeTicks() + base::TimeDelta::FromMilliseconds(100);
+ BeginFrameArgs begin_frame_args =
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
+
+ host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(500, 500));
+ LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
+
+ begin_frame_args.frame_time = start_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
+ host_impl_->UpdateAnimationState(true);
+ host_impl_->DidFinishImplFrame();
+
+ content_layer->SetBounds(new_content_size);
+ scrolling_layer->SetBounds(new_content_size);
+ SetNeedsRebuildPropertyTrees();
+ DrawFrame();
+
+ begin_frame_args.frame_time =
+ start_time + base::TimeDelta::FromMilliseconds(200);
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->Animate();
+ host_impl_->UpdateAnimationState(true);
+ host_impl_->DidFinishImplFrame();
+
+ EXPECT_EQ(gfx::ScrollOffset(250, 250),
+ scrolling_layer->CurrentScrollOffset());
+}
+
TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) {
host_impl_->CreatePendingTree();
« 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