| 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 9426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9437 // aborted. | 9437 // aborted. |
| 9438 EXPECT_FALSE( | 9438 EXPECT_FALSE( |
| 9439 host_impl_->animation_host()->HasActiveAnimation(scrolling_layer->id())); | 9439 host_impl_->animation_host()->HasActiveAnimation(scrolling_layer->id())); |
| 9440 | 9440 |
| 9441 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), | 9441 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), |
| 9442 scrolling_layer->CurrentScrollOffset()); | 9442 scrolling_layer->CurrentScrollOffset()); |
| 9443 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 9443 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 9444 host_impl_->DidFinishImplFrame(); | 9444 host_impl_->DidFinishImplFrame(); |
| 9445 } | 9445 } |
| 9446 | 9446 |
| 9447 // Test that a smooth scroll offset animation is marked finished when a main |
| 9448 // thread scrolling reason is added. The animation is then finished on the |
| 9449 // main thread. |
| 9450 TEST_F(LayerTreeHostImplTimelinesTest, |
| 9451 ScrollAnimatedFinishedByMainThreadScrollingReason) { |
| 9452 const gfx::Size content_size(1000, 1000); |
| 9453 const gfx::Size viewport_size(500, 500); |
| 9454 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 9455 |
| 9456 DrawFrame(); |
| 9457 |
| 9458 base::TimeTicks start_time = |
| 9459 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 9460 |
| 9461 BeginFrameArgs begin_frame_args = |
| 9462 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
| 9463 |
| 9464 // Perform animated scroll. |
| 9465 EXPECT_EQ( |
| 9466 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9467 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); |
| 9468 |
| 9469 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 9470 |
| 9471 begin_frame_args.frame_time = start_time; |
| 9472 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9473 host_impl_->Animate(); |
| 9474 host_impl_->UpdateAnimationState(true); |
| 9475 |
| 9476 EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty( |
| 9477 scrolling_layer->id(), TargetProperty::SCROLL_OFFSET)); |
| 9478 |
| 9479 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 9480 host_impl_->DidFinishImplFrame(); |
| 9481 |
| 9482 begin_frame_args.frame_time = |
| 9483 start_time + base::TimeDelta::FromMilliseconds(50); |
| 9484 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9485 host_impl_->Animate(); |
| 9486 host_impl_->UpdateAnimationState(true); |
| 9487 |
| 9488 float y = scrolling_layer->CurrentScrollOffset().y(); |
| 9489 EXPECT_TRUE(y > 1 && y < 49); |
| 9490 |
| 9491 // Add main thread scrolling reason. |
| 9492 scrolling_layer->set_main_thread_scrolling_reasons( |
| 9493 MainThreadScrollingReason::kHasNonLayerViewportConstrainedObjects); |
| 9494 host_impl_->UpdateAnimationState(true); |
| 9495 |
| 9496 // The main thread scrolling reason should have marked the smooth scroll |
| 9497 // animation as finished. |
| 9498 EXPECT_FALSE( |
| 9499 host_impl_->animation_host()->HasActiveAnimation(scrolling_layer->id())); |
| 9500 EXPECT_TRUE(y > 1 && y < 49); |
| 9501 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 9502 host_impl_->DidFinishImplFrame(); |
| 9503 } |
| 9504 |
| 9447 // Evolved from LayerTreeHostImplTest.ScrollAnimated. | 9505 // Evolved from LayerTreeHostImplTest.ScrollAnimated. |
| 9448 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { | 9506 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { |
| 9449 const gfx::Size content_size(1000, 1000); | 9507 const gfx::Size content_size(1000, 1000); |
| 9450 const gfx::Size viewport_size(500, 500); | 9508 const gfx::Size viewport_size(500, 500); |
| 9451 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 9509 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 9452 | 9510 |
| 9453 SetNeedsRebuildPropertyTrees(); | 9511 SetNeedsRebuildPropertyTrees(); |
| 9454 DrawFrame(); | 9512 DrawFrame(); |
| 9455 | 9513 |
| 9456 base::TimeTicks start_time = | 9514 base::TimeTicks start_time = |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10134 // There should not be any jitter measured till we hit the fixed point hits | 10192 // There should not be any jitter measured till we hit the fixed point hits |
| 10135 // threshold. | 10193 // threshold. |
| 10136 float expected_jitter = | 10194 float expected_jitter = |
| 10137 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; | 10195 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; |
| 10138 EXPECT_EQ(jitter, expected_jitter); | 10196 EXPECT_EQ(jitter, expected_jitter); |
| 10139 } | 10197 } |
| 10140 } | 10198 } |
| 10141 | 10199 |
| 10142 } // namespace | 10200 } // namespace |
| 10143 } // namespace cc | 10201 } // namespace cc |
| OLD | NEW |