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 <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 bool did_request_commit_; | 425 bool did_request_commit_; |
426 bool did_request_redraw_; | 426 bool did_request_redraw_; |
427 bool did_request_animate_; | 427 bool did_request_animate_; |
428 bool did_request_prepare_tiles_; | 428 bool did_request_prepare_tiles_; |
429 bool did_complete_page_scale_animation_; | 429 bool did_complete_page_scale_animation_; |
430 bool reduce_memory_result_; | 430 bool reduce_memory_result_; |
431 base::Closure animation_task_; | 431 base::Closure animation_task_; |
432 base::TimeDelta requested_animation_delay_; | 432 base::TimeDelta requested_animation_delay_; |
433 }; | 433 }; |
434 | 434 |
435 // A test fixture for new animation timelines tests. | |
436 class LayerTreeHostImplTimelinesTest : public LayerTreeHostImplTest { | |
437 public: | |
438 void SetUp() override { | |
439 LayerTreeSettings settings = DefaultSettings(); | |
440 settings.use_compositor_animation_timelines = true; | |
441 CreateHostImpl(settings, CreateOutputSurface()); | |
442 } | |
443 }; | |
444 | |
435 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { | 445 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { |
436 bool always_draw = false; | 446 bool always_draw = false; |
437 CheckNotifyCalledIfCanDrawChanged(always_draw); | 447 CheckNotifyCalledIfCanDrawChanged(always_draw); |
438 } | 448 } |
439 | 449 |
440 TEST_F(LayerTreeHostImplTest, CanDrawIncompleteFrames) { | 450 TEST_F(LayerTreeHostImplTest, CanDrawIncompleteFrames) { |
441 CreateHostImpl(DefaultSettings(), | 451 CreateHostImpl(DefaultSettings(), |
442 FakeOutputSurface::CreateAlwaysDrawAndSwap3d()); | 452 FakeOutputSurface::CreateAlwaysDrawAndSwap3d()); |
443 | 453 |
444 bool always_draw = true; | 454 bool always_draw = true; |
(...skipping 7194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7639 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 7649 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); |
7640 | 7650 |
7641 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); | 7651 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); |
7642 host_impl_->UpdateAnimationState(true); | 7652 host_impl_->UpdateAnimationState(true); |
7643 | 7653 |
7644 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 7654 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
7645 scrolling_layer->CurrentScrollOffset()); | 7655 scrolling_layer->CurrentScrollOffset()); |
7646 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 7656 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
7647 } | 7657 } |
7648 | 7658 |
7659 // Evolved from LayerTreeHostImplTest.ScrollAnimated. | |
7660 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { | |
7661 SetupScrollAndContentsLayers(gfx::Size(100, 200)); | |
loyso (OOO)
2015/07/07 04:14:38
This is a copy-paste of LayerTreeHostImplTest.Scro
| |
7662 DrawFrame(); | |
7663 | |
7664 base::TimeTicks start_time = | |
7665 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | |
7666 | |
7667 EXPECT_EQ(InputHandler::SCROLL_STARTED, | |
7668 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); | |
7669 | |
7670 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | |
7671 | |
7672 host_impl_->Animate(start_time); | |
7673 host_impl_->UpdateAnimationState(true); | |
7674 | |
7675 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | |
7676 | |
7677 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50)); | |
7678 host_impl_->UpdateAnimationState(true); | |
7679 | |
7680 float y = scrolling_layer->CurrentScrollOffset().y(); | |
7681 EXPECT_TRUE(y > 1 && y < 49); | |
7682 | |
7683 // Update target. | |
7684 EXPECT_EQ(InputHandler::SCROLL_STARTED, | |
7685 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); | |
7686 | |
7687 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200)); | |
7688 host_impl_->UpdateAnimationState(true); | |
7689 | |
7690 y = scrolling_layer->CurrentScrollOffset().y(); | |
7691 EXPECT_TRUE(y > 50 && y < 100); | |
7692 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | |
7693 | |
7694 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); | |
7695 host_impl_->UpdateAnimationState(true); | |
7696 | |
7697 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | |
7698 scrolling_layer->CurrentScrollOffset()); | |
7699 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | |
7700 } | |
7701 | |
7649 TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) { | 7702 TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) { |
7650 host_impl_->CreatePendingTree(); | 7703 host_impl_->CreatePendingTree(); |
7651 | 7704 |
7652 Region empty_invalidation; | 7705 Region empty_invalidation; |
7653 scoped_refptr<RasterSource> pile_with_tiles( | 7706 scoped_refptr<RasterSource> pile_with_tiles( |
7654 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( | 7707 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( |
7655 gfx::Size(10, 10))); | 7708 gfx::Size(10, 10))); |
7656 | 7709 |
7657 scoped_ptr<FakePictureLayerImpl> layer = | 7710 scoped_ptr<FakePictureLayerImpl> layer = |
7658 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 11); | 7711 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 11); |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8078 // Hold an unowned pointer to the output surface to use for mock expectations. | 8131 // Hold an unowned pointer to the output surface to use for mock expectations. |
8079 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); | 8132 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); |
8080 | 8133 |
8081 CreateHostImpl(DefaultSettings(), output_surface.Pass()); | 8134 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
8082 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); | 8135 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); |
8083 host_impl_->BeginCommit(); | 8136 host_impl_->BeginCommit(); |
8084 } | 8137 } |
8085 | 8138 |
8086 } // namespace | 8139 } // namespace |
8087 } // namespace cc | 8140 } // namespace cc |
OLD | NEW |