| 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 92166b9228e33a0e568542e6d81255a70c661711..c193bb633e26c549e82a9b443787ebee155de00f 100644
|
| --- a/cc/trees/layer_tree_host_impl_unittest.cc
|
| +++ b/cc/trees/layer_tree_host_impl_unittest.cc
|
| @@ -6518,6 +6518,61 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) {
|
| host_impl_->ScrollEnd();
|
| }
|
|
|
| +TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) {
|
| + LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
|
| + host_impl_->SetViewportSize(gfx::Size(100, 100));
|
| + float initial_scroll_offset = 50;
|
| + scroll_layer->SetScrollOffset(gfx::Vector2d(0, initial_scroll_offset));
|
| + DrawFrame();
|
| +
|
| + EXPECT_EQ(InputHandler::ScrollStarted,
|
| + host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
|
| + EXPECT_EQ(0, host_impl_->top_controls_manager()->controls_top_offset());
|
| + EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(),
|
| + scroll_layer->TotalScrollOffset().ToString());
|
| +
|
| + // Scroll the top controls partially.
|
| + const float residue = 15;
|
| + float offset = top_controls_height_ - residue;
|
| + EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
|
| + EXPECT_EQ(-offset, host_impl_->top_controls_manager()->controls_top_offset());
|
| + EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(),
|
| + scroll_layer->TotalScrollOffset().ToString());
|
| +
|
| + did_request_redraw_ = false;
|
| + did_request_animate_ = false;
|
| + did_request_commit_ = false;
|
| +
|
| + // End the scroll while the controls are still offset from the limit.
|
| + host_impl_->ScrollEnd();
|
| + ASSERT_TRUE(host_impl_->top_controls_manager()->animation());
|
| + EXPECT_TRUE(did_request_animate_);
|
| + EXPECT_TRUE(did_request_redraw_);
|
| + EXPECT_FALSE(did_request_commit_);
|
| +
|
| + // Animate the top controls to the limit.
|
| + base::TimeTicks animation_time = gfx::FrameTime::Now();
|
| + while (did_request_animate_) {
|
| + did_request_redraw_ = false;
|
| + did_request_animate_ = false;
|
| + did_request_commit_ = false;
|
| +
|
| + float old_offset =
|
| + host_impl_->top_controls_manager()->controls_top_offset();
|
| +
|
| + animation_time += base::TimeDelta::FromMilliseconds(5);
|
| + host_impl_->Animate(animation_time);
|
| +
|
| + float new_offset =
|
| + host_impl_->top_controls_manager()->controls_top_offset();
|
| +
|
| + if (new_offset != old_offset) {
|
| + EXPECT_TRUE(did_request_redraw_);
|
| + EXPECT_TRUE(did_request_commit_);
|
| + }
|
| + }
|
| +}
|
| +
|
| class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest {
|
| public:
|
| void SetupVirtualViewportLayers(const gfx::Size& content_size,
|
|
|