| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 9718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9729 // aborted. | 9729 // aborted. |
| 9730 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( | 9730 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( |
| 9731 scrolling_layer->id())); | 9731 scrolling_layer->id())); |
| 9732 | 9732 |
| 9733 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), | 9733 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), |
| 9734 scrolling_layer->CurrentScrollOffset()); | 9734 scrolling_layer->CurrentScrollOffset()); |
| 9735 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 9735 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 9736 host_impl_->DidFinishImplFrame(); | 9736 host_impl_->DidFinishImplFrame(); |
| 9737 } | 9737 } |
| 9738 | 9738 |
| 9739 // Test that a smooth scroll offset animation is marked finished when a main | 9739 // Test that a smooth scroll offset animation is marked finished when aborted |
| 9740 // thread scrolling reason is added. The animation is then finished on the | 9740 // with the needs_completion flag. The animation is then finished on the |
| 9741 // main thread. | 9741 // main thread. |
| 9742 TEST_F(LayerTreeHostImplTimelinesTest, | 9742 TEST_F(LayerTreeHostImplTimelinesTest, |
| 9743 ScrollAnimatedFinishedByMainThreadScrollingReason) { | 9743 ScrollAnimatedFinishedByMainThreadScrollingReason) { |
| 9744 const gfx::Size content_size(1000, 1000); | 9744 const gfx::Size content_size(1000, 1000); |
| 9745 const gfx::Size viewport_size(500, 500); | 9745 const gfx::Size viewport_size(500, 500); |
| 9746 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 9746 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 9747 | 9747 |
| 9748 DrawFrame(); | 9748 DrawFrame(); |
| 9749 | 9749 |
| 9750 base::TimeTicks start_time = | 9750 base::TimeTicks start_time = |
| (...skipping 22 matching lines...) Expand all Loading... |
| 9773 | 9773 |
| 9774 begin_frame_args.frame_time = | 9774 begin_frame_args.frame_time = |
| 9775 start_time + base::TimeDelta::FromMilliseconds(50); | 9775 start_time + base::TimeDelta::FromMilliseconds(50); |
| 9776 host_impl_->WillBeginImplFrame(begin_frame_args); | 9776 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9777 host_impl_->Animate(); | 9777 host_impl_->Animate(); |
| 9778 host_impl_->UpdateAnimationState(true); | 9778 host_impl_->UpdateAnimationState(true); |
| 9779 | 9779 |
| 9780 float y = scrolling_layer->CurrentScrollOffset().y(); | 9780 float y = scrolling_layer->CurrentScrollOffset().y(); |
| 9781 EXPECT_TRUE(y > 1 && y < 49); | 9781 EXPECT_TRUE(y > 1 && y < 49); |
| 9782 | 9782 |
| 9783 // Add main thread scrolling reason. | 9783 // Abort animation. |
| 9784 scrolling_layer->set_main_thread_scrolling_reasons( | 9784 host_impl_->animation_host()->ScrollAnimationAbort(true /*needs_completion*/); |
| 9785 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); | |
| 9786 host_impl_->UpdateAnimationState(true); | 9785 host_impl_->UpdateAnimationState(true); |
| 9787 | 9786 |
| 9788 // The main thread scrolling reason should have marked the smooth scroll | 9787 // Aborting with the needs completion param should have marked the smooth |
| 9789 // animation as finished. | 9788 // scroll animation as finished. |
| 9790 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( | 9789 EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting( |
| 9791 scrolling_layer->id())); | 9790 scrolling_layer->id())); |
| 9792 EXPECT_TRUE(y > 1 && y < 49); | 9791 EXPECT_TRUE(y > 1 && y < 49); |
| 9793 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 9792 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 9794 host_impl_->DidFinishImplFrame(); | 9793 host_impl_->DidFinishImplFrame(); |
| 9795 } | 9794 } |
| 9796 | 9795 |
| 9797 // Evolved from LayerTreeHostImplTest.ScrollAnimated. | 9796 // Evolved from LayerTreeHostImplTest.ScrollAnimated. |
| 9798 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { | 9797 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { |
| 9799 const gfx::Size content_size(1000, 1000); | 9798 const gfx::Size content_size(1000, 1000); |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10750 | 10749 |
| 10751 // Re-initialize with a software output surface. | 10750 // Re-initialize with a software output surface. |
| 10752 output_surface_ = FakeOutputSurface::CreateSoftware( | 10751 output_surface_ = FakeOutputSurface::CreateSoftware( |
| 10753 base::WrapUnique(new SoftwareOutputDevice)); | 10752 base::WrapUnique(new SoftwareOutputDevice)); |
| 10754 host_impl_->InitializeRenderer(output_surface_.get()); | 10753 host_impl_->InitializeRenderer(output_surface_.get()); |
| 10755 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10754 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 10756 } | 10755 } |
| 10757 | 10756 |
| 10758 } // namespace | 10757 } // namespace |
| 10759 } // namespace cc | 10758 } // namespace cc |
| OLD | NEW |