OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 6500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6511 | 6511 |
6512 // And attempt to scroll past the end | 6512 // And attempt to scroll past the end |
6513 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset))); | 6513 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset))); |
6514 EXPECT_EQ(0, host_impl_->top_controls_manager()->controls_top_offset()); | 6514 EXPECT_EQ(0, host_impl_->top_controls_manager()->controls_top_offset()); |
6515 EXPECT_EQ(gfx::Vector2dF().ToString(), | 6515 EXPECT_EQ(gfx::Vector2dF().ToString(), |
6516 scroll_layer->TotalScrollOffset().ToString()); | 6516 scroll_layer->TotalScrollOffset().ToString()); |
6517 | 6517 |
6518 host_impl_->ScrollEnd(); | 6518 host_impl_->ScrollEnd(); |
6519 } | 6519 } |
6520 | 6520 |
| 6521 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { |
| 6522 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 6523 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 6524 float initial_scroll_offset = 50; |
| 6525 scroll_layer->SetScrollOffset(gfx::Vector2d(0, initial_scroll_offset)); |
| 6526 DrawFrame(); |
| 6527 |
| 6528 EXPECT_EQ(InputHandler::ScrollStarted, |
| 6529 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 6530 EXPECT_EQ(0, host_impl_->top_controls_manager()->controls_top_offset()); |
| 6531 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
| 6532 scroll_layer->TotalScrollOffset().ToString()); |
| 6533 |
| 6534 // Scroll the top controls partially. |
| 6535 const float residue = 15; |
| 6536 float offset = top_controls_height_ - residue; |
| 6537 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset))); |
| 6538 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->controls_top_offset()); |
| 6539 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
| 6540 scroll_layer->TotalScrollOffset().ToString()); |
| 6541 |
| 6542 did_request_redraw_ = false; |
| 6543 did_request_animate_ = false; |
| 6544 did_request_commit_ = false; |
| 6545 |
| 6546 // End the scroll while the controls are still offset from the limit. |
| 6547 host_impl_->ScrollEnd(); |
| 6548 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); |
| 6549 EXPECT_TRUE(did_request_animate_); |
| 6550 EXPECT_TRUE(did_request_redraw_); |
| 6551 EXPECT_FALSE(did_request_commit_); |
| 6552 |
| 6553 // Animate the top controls to the limit. |
| 6554 base::TimeTicks animation_time = gfx::FrameTime::Now(); |
| 6555 while (did_request_animate_) { |
| 6556 did_request_redraw_ = false; |
| 6557 did_request_animate_ = false; |
| 6558 did_request_commit_ = false; |
| 6559 |
| 6560 float old_offset = |
| 6561 host_impl_->top_controls_manager()->controls_top_offset(); |
| 6562 |
| 6563 animation_time += base::TimeDelta::FromMilliseconds(5); |
| 6564 host_impl_->Animate(animation_time); |
| 6565 |
| 6566 float new_offset = |
| 6567 host_impl_->top_controls_manager()->controls_top_offset(); |
| 6568 |
| 6569 if (new_offset != old_offset) { |
| 6570 EXPECT_TRUE(did_request_redraw_); |
| 6571 EXPECT_TRUE(did_request_commit_); |
| 6572 } |
| 6573 } |
| 6574 } |
| 6575 |
6521 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { | 6576 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { |
6522 public: | 6577 public: |
6523 void SetupVirtualViewportLayers(const gfx::Size& content_size, | 6578 void SetupVirtualViewportLayers(const gfx::Size& content_size, |
6524 const gfx::Size& outer_viewport, | 6579 const gfx::Size& outer_viewport, |
6525 const gfx::Size& inner_viewport) { | 6580 const gfx::Size& inner_viewport) { |
6526 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); | 6581 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); |
6527 const int kOuterViewportClipLayerId = 6; | 6582 const int kOuterViewportClipLayerId = 6; |
6528 const int kOuterViewportScrollLayerId = 7; | 6583 const int kOuterViewportScrollLayerId = 7; |
6529 const int kInnerViewportScrollLayerId = 2; | 6584 const int kInnerViewportScrollLayerId = 2; |
6530 const int kInnerViewportClipLayerId = 4; | 6585 const int kInnerViewportClipLayerId = 4; |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6845 host_impl_->DidLoseOutputSurface(); | 6900 host_impl_->DidLoseOutputSurface(); |
6846 EXPECT_TRUE(host_impl_->IsContextLost()); | 6901 EXPECT_TRUE(host_impl_->IsContextLost()); |
6847 EXPECT_EQ(1, num_lost_surfaces_); | 6902 EXPECT_EQ(1, num_lost_surfaces_); |
6848 host_impl_->DidLoseOutputSurface(); | 6903 host_impl_->DidLoseOutputSurface(); |
6849 EXPECT_TRUE(host_impl_->IsContextLost()); | 6904 EXPECT_TRUE(host_impl_->IsContextLost()); |
6850 EXPECT_EQ(1, num_lost_surfaces_); | 6905 EXPECT_EQ(1, num_lost_surfaces_); |
6851 } | 6906 } |
6852 | 6907 |
6853 } // namespace | 6908 } // namespace |
6854 } // namespace cc | 6909 } // namespace cc |
OLD | NEW |