| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/animation/element_animations.h" | 5 #include "cc/animation/element_animations.h" |
| 6 | 6 |
| 7 #include "cc/animation/animation_delegate.h" | 7 #include "cc/animation/animation_delegate.h" |
| 8 #include "cc/animation/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
| 9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
| 10 #include "cc/animation/animation_player.h" | 10 #include "cc/animation/animation_player.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 265 |
| 266 // Animation with initial value set. | 266 // Animation with initial value set. |
| 267 std::unique_ptr<ScrollOffsetAnimationCurve> curve_fixed( | 267 std::unique_ptr<ScrollOffsetAnimationCurve> curve_fixed( |
| 268 ScrollOffsetAnimationCurve::Create( | 268 ScrollOffsetAnimationCurve::Create( |
| 269 target_value, CubicBezierTimingFunction::CreatePreset( | 269 target_value, CubicBezierTimingFunction::CreatePreset( |
| 270 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 270 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 271 curve_fixed->SetInitialValue(initial_value); | 271 curve_fixed->SetInitialValue(initial_value); |
| 272 const int animation1_id = 1; | 272 const int animation1_id = 1; |
| 273 std::unique_ptr<Animation> animation_fixed(Animation::Create( | 273 std::unique_ptr<Animation> animation_fixed(Animation::Create( |
| 274 std::move(curve_fixed), animation1_id, 0, TargetProperty::SCROLL_OFFSET)); | 274 std::move(curve_fixed), animation1_id, 0, TargetProperty::SCROLL_OFFSET)); |
| 275 animations->AddAnimation(std::move(animation_fixed)); | 275 AddAnimationToElementAnimations(animations.get(), std::move(animation_fixed)); |
| 276 animations->PushPropertiesTo(animations_impl.get()); | 276 animations->PushPropertiesTo(animations_impl.get()); |
| 277 EXPECT_VECTOR2DF_EQ(initial_value, | 277 EXPECT_VECTOR2DF_EQ(initial_value, |
| 278 animations_impl->GetAnimationById(animation1_id) | 278 animations_impl->GetAnimationById(animation1_id) |
| 279 ->curve() | 279 ->curve() |
| 280 ->ToScrollOffsetAnimationCurve() | 280 ->ToScrollOffsetAnimationCurve() |
| 281 ->GetValue(base::TimeDelta())); | 281 ->GetValue(base::TimeDelta())); |
| 282 | 282 |
| 283 // Animation without initial value set. | 283 // Animation without initial value set. |
| 284 std::unique_ptr<ScrollOffsetAnimationCurve> curve( | 284 std::unique_ptr<ScrollOffsetAnimationCurve> curve( |
| 285 ScrollOffsetAnimationCurve::Create( | 285 ScrollOffsetAnimationCurve::Create( |
| 286 target_value, CubicBezierTimingFunction::CreatePreset( | 286 target_value, CubicBezierTimingFunction::CreatePreset( |
| 287 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 287 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 288 const int animation2_id = 2; | 288 const int animation2_id = 2; |
| 289 std::unique_ptr<Animation> animation(Animation::Create( | 289 std::unique_ptr<Animation> animation(Animation::Create( |
| 290 std::move(curve), animation2_id, 0, TargetProperty::SCROLL_OFFSET)); | 290 std::move(curve), animation2_id, 0, TargetProperty::SCROLL_OFFSET)); |
| 291 animations->AddAnimation(std::move(animation)); | 291 AddAnimationToElementAnimations(animations.get(), std::move(animation)); |
| 292 animations->PushPropertiesTo(animations_impl.get()); | 292 animations->PushPropertiesTo(animations_impl.get()); |
| 293 EXPECT_VECTOR2DF_EQ(provider_initial_value, | 293 EXPECT_VECTOR2DF_EQ(provider_initial_value, |
| 294 animations_impl->GetAnimationById(animation2_id) | 294 animations_impl->GetAnimationById(animation2_id) |
| 295 ->curve() | 295 ->curve() |
| 296 ->ToScrollOffsetAnimationCurve() | 296 ->ToScrollOffsetAnimationCurve() |
| 297 ->GetValue(base::TimeDelta())); | 297 ->GetValue(base::TimeDelta())); |
| 298 } | 298 } |
| 299 | 299 |
| 300 class TestAnimationDelegateThatDestroysPlayer : public TestAnimationDelegate { | 300 class TestAnimationDelegateThatDestroysPlayer : public TestAnimationDelegate { |
| 301 public: | 301 public: |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 EXPECT_EQ(0.3f, | 571 EXPECT_EQ(0.3f, |
| 572 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 572 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 573 | 573 |
| 574 EXPECT_EQ(kInitialTickTime, | 574 EXPECT_EQ(kInitialTickTime, |
| 575 animations->GetAnimationById(animation_id)->start_time()); | 575 animations->GetAnimationById(animation_id)->start_time()); |
| 576 EXPECT_EQ(kInitialTickTime, | 576 EXPECT_EQ(kInitialTickTime, |
| 577 animations_impl->GetAnimationById(animation_id)->start_time()); | 577 animations_impl->GetAnimationById(animation_id)->start_time()); |
| 578 | 578 |
| 579 // Pause the animation at the middle of the second range so the offset | 579 // Pause the animation at the middle of the second range so the offset |
| 580 // delays animation until the middle of the third range. | 580 // delays animation until the middle of the third range. |
| 581 animations->PauseAnimation(animation_id, TimeDelta::FromSecondsD(1.5)); | 581 PauseAnimationInElementAnimations(animations.get(), animation_id, |
| 582 TimeDelta::FromSecondsD(1.5)); |
| 582 EXPECT_EQ(Animation::PAUSED, | 583 EXPECT_EQ(Animation::PAUSED, |
| 583 animations->GetAnimationById(animation_id)->run_state()); | 584 animations->GetAnimationById(animation_id)->run_state()); |
| 584 | 585 |
| 585 // The pause run state change should make it to the impl thread animations. | 586 // The pause run state change should make it to the impl thread animations. |
| 586 animations->PushPropertiesTo(animations_impl.get()); | 587 animations->PushPropertiesTo(animations_impl.get()); |
| 587 animations_impl->ActivateAnimations(); | 588 animations_impl->ActivateAnimations(); |
| 588 | 589 |
| 589 // Advance time so it stays within the first range. | 590 // Advance time so it stays within the first range. |
| 590 time += TimeDelta::FromMilliseconds(10); | 591 time += TimeDelta::FromMilliseconds(10); |
| 591 animations->Animate(time); | 592 animations->Animate(time); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 | 659 |
| 659 scoped_refptr<ElementAnimations> animations = element_animations(); | 660 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 660 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 661 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 661 | 662 |
| 662 auto events = host_impl_->CreateEvents(); | 663 auto events = host_impl_->CreateEvents(); |
| 663 | 664 |
| 664 AddOpacityTransitionToElementAnimations(animations.get(), 1.0, 0.0f, 1.0f, | 665 AddOpacityTransitionToElementAnimations(animations.get(), 1.0, 0.0f, 1.0f, |
| 665 false); | 666 false); |
| 666 animations->Animate(kInitialTickTime); | 667 animations->Animate(kInitialTickTime); |
| 667 animations->UpdateState(true, nullptr); | 668 animations->UpdateState(true, nullptr); |
| 669 EXPECT_TRUE(animations->needs_push_properties()); |
| 668 animations->PushPropertiesTo(animations_impl.get()); | 670 animations->PushPropertiesTo(animations_impl.get()); |
| 669 animations_impl->ActivateAnimations(); | 671 animations_impl->ActivateAnimations(); |
| 670 | 672 |
| 671 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 673 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 672 animations_impl->UpdateState(true, events.get()); | 674 animations_impl->UpdateState(true, events.get()); |
| 673 | 675 |
| 674 // There should be a STARTED event for the animation. | 676 // There should be a STARTED event for the animation. |
| 675 EXPECT_EQ(1u, events->events_.size()); | 677 EXPECT_EQ(1u, events->events_.size()); |
| 676 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); | 678 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); |
| 677 animations->NotifyAnimationStarted(events->events_[0]); | 679 animations->NotifyAnimationStarted(events->events_[0]); |
| 678 | 680 |
| 679 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 681 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 680 animations->UpdateState(true, nullptr); | 682 animations->UpdateState(true, nullptr); |
| 681 | 683 |
| 682 EXPECT_FALSE(host_->animation_waiting_for_deletion()); | 684 EXPECT_FALSE(host_->needs_push_properties()); |
| 683 EXPECT_FALSE(host_impl_->animation_waiting_for_deletion()); | 685 EXPECT_FALSE(host_impl_->needs_push_properties()); |
| 684 | 686 |
| 685 events = host_impl_->CreateEvents(); | 687 events = host_impl_->CreateEvents(); |
| 686 animations_impl->Animate(kInitialTickTime + | 688 animations_impl->Animate(kInitialTickTime + |
| 687 TimeDelta::FromMilliseconds(2000)); | 689 TimeDelta::FromMilliseconds(2000)); |
| 688 animations_impl->UpdateState(true, events.get()); | 690 animations_impl->UpdateState(true, events.get()); |
| 689 | 691 |
| 690 EXPECT_TRUE(host_impl_->animation_waiting_for_deletion()); | 692 EXPECT_TRUE(host_impl_->needs_push_properties()); |
| 691 | 693 |
| 692 // There should be a FINISHED event for the animation. | 694 // There should be a FINISHED event for the animation. |
| 693 EXPECT_EQ(1u, events->events_.size()); | 695 EXPECT_EQ(1u, events->events_.size()); |
| 694 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); | 696 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); |
| 695 | 697 |
| 696 // Neither animations should have deleted the animation yet. | 698 // Neither animations should have deleted the animation yet. |
| 697 EXPECT_TRUE(animations->GetAnimation(TargetProperty::OPACITY)); | 699 EXPECT_TRUE(animations->GetAnimation(TargetProperty::OPACITY)); |
| 698 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::OPACITY)); | 700 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::OPACITY)); |
| 699 | 701 |
| 700 animations->NotifyAnimationFinished(events->events_[0]); | 702 animations->NotifyAnimationFinished(events->events_[0]); |
| 701 | 703 |
| 702 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); | 704 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
| 703 animations->UpdateState(true, nullptr); | 705 animations->UpdateState(true, nullptr); |
| 704 EXPECT_TRUE(host_->animation_waiting_for_deletion()); | 706 EXPECT_TRUE(host_->needs_push_properties()); |
| 705 | 707 |
| 706 animations->PushPropertiesTo(animations_impl.get()); | 708 animations->PushPropertiesTo(animations_impl.get()); |
| 707 | 709 |
| 708 // Both animationss should now have deleted the animation. The impl animations | 710 // Both animationss should now have deleted the animation. The impl animations |
| 709 // should have deleted the animation even though activation has not occurred, | 711 // should have deleted the animation even though activation has not occurred, |
| 710 // since the animation was already waiting for deletion when | 712 // since the animation was already waiting for deletion when |
| 711 // PushPropertiesTo was called. | 713 // PushPropertiesTo was called. |
| 712 EXPECT_FALSE(animations->has_any_animation()); | 714 EXPECT_FALSE(animations->has_any_animation()); |
| 713 EXPECT_FALSE(animations_impl->has_any_animation()); | 715 EXPECT_FALSE(animations_impl->has_any_animation()); |
| 714 } | 716 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 738 | 740 |
| 739 scoped_refptr<ElementAnimations> animations = element_animations(); | 741 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 740 | 742 |
| 741 auto events = host_impl_->CreateEvents(); | 743 auto events = host_impl_->CreateEvents(); |
| 742 | 744 |
| 743 std::unique_ptr<Animation> to_add(CreateAnimation( | 745 std::unique_ptr<Animation> to_add(CreateAnimation( |
| 744 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 746 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 745 1, TargetProperty::OPACITY)); | 747 1, TargetProperty::OPACITY)); |
| 746 | 748 |
| 747 EXPECT_FALSE(animations->needs_to_start_animations_for_testing()); | 749 EXPECT_FALSE(animations->needs_to_start_animations_for_testing()); |
| 748 animations->AddAnimation(std::move(to_add)); | 750 AddAnimationToElementAnimations(animations.get(), std::move(to_add)); |
| 749 EXPECT_TRUE(animations->needs_to_start_animations_for_testing()); | 751 EXPECT_TRUE(animations->needs_to_start_animations_for_testing()); |
| 750 animations->Animate(kInitialTickTime); | 752 animations->Animate(kInitialTickTime); |
| 751 EXPECT_FALSE(animations->needs_to_start_animations_for_testing()); | 753 EXPECT_FALSE(animations->needs_to_start_animations_for_testing()); |
| 752 animations->UpdateState(true, events.get()); | 754 animations->UpdateState(true, events.get()); |
| 753 EXPECT_TRUE(animations->HasActiveAnimation()); | 755 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 754 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 756 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 755 // A non-impl-only animation should not generate property updates. | 757 // A non-impl-only animation should not generate property updates. |
| 756 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 758 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 757 EXPECT_FALSE(event); | 759 EXPECT_FALSE(event); |
| 758 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 760 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 778 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); | 780 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); |
| 779 curve->AddKeyframe( | 781 curve->AddKeyframe( |
| 780 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); | 782 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); |
| 781 FilterOperations end_filters; | 783 FilterOperations end_filters; |
| 782 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); | 784 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); |
| 783 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), | 785 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), |
| 784 end_filters, nullptr)); | 786 end_filters, nullptr)); |
| 785 | 787 |
| 786 std::unique_ptr<Animation> animation( | 788 std::unique_ptr<Animation> animation( |
| 787 Animation::Create(std::move(curve), 1, 0, TargetProperty::FILTER)); | 789 Animation::Create(std::move(curve), 1, 0, TargetProperty::FILTER)); |
| 788 animations->AddAnimation(std::move(animation)); | 790 AddAnimationToElementAnimations(animations.get(), std::move(animation)); |
| 789 | 791 |
| 790 animations->Animate(kInitialTickTime); | 792 animations->Animate(kInitialTickTime); |
| 791 animations->UpdateState(true, events.get()); | 793 animations->UpdateState(true, events.get()); |
| 792 EXPECT_TRUE(animations->HasActiveAnimation()); | 794 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 793 EXPECT_EQ(start_filters, | 795 EXPECT_EQ(start_filters, |
| 794 client_.GetFilters(element_id_, ElementListType::ACTIVE)); | 796 client_.GetFilters(element_id_, ElementListType::ACTIVE)); |
| 795 // A non-impl-only animation should not generate property updates. | 797 // A non-impl-only animation should not generate property updates. |
| 796 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 798 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 797 EXPECT_FALSE(event); | 799 EXPECT_FALSE(event); |
| 798 | 800 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 827 gfx::ScrollOffset initial_value(100.f, 300.f); | 829 gfx::ScrollOffset initial_value(100.f, 300.f); |
| 828 gfx::ScrollOffset target_value(300.f, 200.f); | 830 gfx::ScrollOffset target_value(300.f, 200.f); |
| 829 std::unique_ptr<ScrollOffsetAnimationCurve> curve( | 831 std::unique_ptr<ScrollOffsetAnimationCurve> curve( |
| 830 ScrollOffsetAnimationCurve::Create( | 832 ScrollOffsetAnimationCurve::Create( |
| 831 target_value, CubicBezierTimingFunction::CreatePreset( | 833 target_value, CubicBezierTimingFunction::CreatePreset( |
| 832 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 834 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 833 | 835 |
| 834 std::unique_ptr<Animation> animation( | 836 std::unique_ptr<Animation> animation( |
| 835 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); | 837 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); |
| 836 animation->set_needs_synchronized_start_time(true); | 838 animation->set_needs_synchronized_start_time(true); |
| 837 animations->AddAnimation(std::move(animation)); | 839 AddAnimationToElementAnimations(animations.get(), std::move(animation)); |
| 838 | 840 |
| 839 client_impl_.SetScrollOffsetForAnimation(initial_value); | 841 client_impl_.SetScrollOffsetForAnimation(initial_value); |
| 840 animations->PushPropertiesTo(animations_impl.get()); | 842 animations->PushPropertiesTo(animations_impl.get()); |
| 841 animations_impl->ActivateAnimations(); | 843 animations_impl->ActivateAnimations(); |
| 842 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)); | 844 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)); |
| 843 TimeDelta duration = | 845 TimeDelta duration = |
| 844 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) | 846 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| 845 ->curve() | 847 ->curve() |
| 846 ->Duration(); | 848 ->Duration(); |
| 847 EXPECT_EQ(duration, animations->GetAnimation(TargetProperty::SCROLL_OFFSET) | 849 EXPECT_EQ(duration, animations->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 std::unique_ptr<ScrollOffsetAnimationCurve> curve( | 910 std::unique_ptr<ScrollOffsetAnimationCurve> curve( |
| 909 ScrollOffsetAnimationCurve::Create( | 911 ScrollOffsetAnimationCurve::Create( |
| 910 target_value, CubicBezierTimingFunction::CreatePreset( | 912 target_value, CubicBezierTimingFunction::CreatePreset( |
| 911 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 913 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 912 curve->SetInitialValue(initial_value); | 914 curve->SetInitialValue(initial_value); |
| 913 double duration_in_seconds = curve->Duration().InSecondsF(); | 915 double duration_in_seconds = curve->Duration().InSecondsF(); |
| 914 | 916 |
| 915 std::unique_ptr<Animation> animation( | 917 std::unique_ptr<Animation> animation( |
| 916 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); | 918 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); |
| 917 animation->set_is_impl_only(true); | 919 animation->set_is_impl_only(true); |
| 918 animations_impl->AddAnimation(std::move(animation)); | 920 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
| 919 | 921 |
| 920 animations_impl->Animate(kInitialTickTime); | 922 animations_impl->Animate(kInitialTickTime); |
| 921 animations_impl->UpdateState(true, events.get()); | 923 animations_impl->UpdateState(true, events.get()); |
| 922 EXPECT_TRUE(animations_impl->HasActiveAnimation()); | 924 EXPECT_TRUE(animations_impl->HasActiveAnimation()); |
| 923 EXPECT_EQ(initial_value, | 925 EXPECT_EQ(initial_value, |
| 924 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); | 926 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); |
| 925 // Scroll offset animations should not generate property updates. | 927 // Scroll offset animations should not generate property updates. |
| 926 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 928 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 927 EXPECT_FALSE(event); | 929 EXPECT_FALSE(event); |
| 928 | 930 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 gfx::ScrollOffset initial_value(500.f, 100.f); | 1025 gfx::ScrollOffset initial_value(500.f, 100.f); |
| 1024 gfx::ScrollOffset target_value(300.f, 200.f); | 1026 gfx::ScrollOffset target_value(300.f, 200.f); |
| 1025 std::unique_ptr<ScrollOffsetAnimationCurve> curve( | 1027 std::unique_ptr<ScrollOffsetAnimationCurve> curve( |
| 1026 ScrollOffsetAnimationCurve::Create( | 1028 ScrollOffsetAnimationCurve::Create( |
| 1027 target_value, CubicBezierTimingFunction::CreatePreset( | 1029 target_value, CubicBezierTimingFunction::CreatePreset( |
| 1028 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 1030 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 1029 | 1031 |
| 1030 std::unique_ptr<Animation> animation( | 1032 std::unique_ptr<Animation> animation( |
| 1031 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); | 1033 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); |
| 1032 animation->set_needs_synchronized_start_time(true); | 1034 animation->set_needs_synchronized_start_time(true); |
| 1033 animations->AddAnimation(std::move(animation)); | 1035 AddAnimationToElementAnimations(animations.get(), std::move(animation)); |
| 1034 | 1036 |
| 1035 client_.SetScrollOffsetForAnimation(initial_value); | 1037 client_.SetScrollOffsetForAnimation(initial_value); |
| 1036 animations->PushPropertiesTo(animations_impl.get()); | 1038 animations->PushPropertiesTo(animations_impl.get()); |
| 1037 animations_impl->ActivateAnimations(); | 1039 animations_impl->ActivateAnimations(); |
| 1038 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)); | 1040 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)); |
| 1039 TimeDelta duration = | 1041 TimeDelta duration = |
| 1040 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) | 1042 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| 1041 ->curve() | 1043 ->curve() |
| 1042 ->Duration(); | 1044 ->Duration(); |
| 1043 EXPECT_EQ(duration, animations->GetAnimation(TargetProperty::SCROLL_OFFSET) | 1045 EXPECT_EQ(duration, animations->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 gfx::ScrollOffset target_value(300.f, 200.f); | 1115 gfx::ScrollOffset target_value(300.f, 200.f); |
| 1114 std::unique_ptr<ScrollOffsetAnimationCurve> curve( | 1116 std::unique_ptr<ScrollOffsetAnimationCurve> curve( |
| 1115 ScrollOffsetAnimationCurve::Create( | 1117 ScrollOffsetAnimationCurve::Create( |
| 1116 target_value, CubicBezierTimingFunction::CreatePreset( | 1118 target_value, CubicBezierTimingFunction::CreatePreset( |
| 1117 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 1119 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 1118 | 1120 |
| 1119 int animation_id = 1; | 1121 int animation_id = 1; |
| 1120 std::unique_ptr<Animation> animation(Animation::Create( | 1122 std::unique_ptr<Animation> animation(Animation::Create( |
| 1121 std::move(curve), animation_id, 0, TargetProperty::SCROLL_OFFSET)); | 1123 std::move(curve), animation_id, 0, TargetProperty::SCROLL_OFFSET)); |
| 1122 animation->set_needs_synchronized_start_time(true); | 1124 animation->set_needs_synchronized_start_time(true); |
| 1123 animations->AddAnimation(std::move(animation)); | 1125 AddAnimationToElementAnimations(animations.get(), std::move(animation)); |
| 1124 animations->PushPropertiesTo(animations_impl.get()); | 1126 animations->PushPropertiesTo(animations_impl.get()); |
| 1125 animations_impl->ActivateAnimations(); | 1127 animations_impl->ActivateAnimations(); |
| 1126 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1128 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1127 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1129 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1128 | 1130 |
| 1129 animations->RemoveAnimation(animation_id); | 1131 RemoveAnimationFromElementAnimations(animations.get(), animation_id); |
| 1130 EXPECT_TRUE(animations->scroll_offset_animation_was_interrupted()); | 1132 EXPECT_TRUE(animations->scroll_offset_animation_was_interrupted()); |
| 1131 | 1133 |
| 1132 animations->PushPropertiesTo(animations_impl.get()); | 1134 animations->PushPropertiesTo(animations_impl.get()); |
| 1133 EXPECT_TRUE(animations_impl->scroll_offset_animation_was_interrupted()); | 1135 EXPECT_TRUE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1134 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1136 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1135 | 1137 |
| 1136 animations_impl->ActivateAnimations(); | 1138 animations_impl->ActivateAnimations(); |
| 1137 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1139 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1138 | 1140 |
| 1139 // Now, test the 2-argument version of RemoveAnimation. | 1141 // Now, test the 2-argument version of RemoveAnimation. |
| 1140 curve = ScrollOffsetAnimationCurve::Create( | 1142 curve = ScrollOffsetAnimationCurve::Create( |
| 1141 target_value, CubicBezierTimingFunction::CreatePreset( | 1143 target_value, CubicBezierTimingFunction::CreatePreset( |
| 1142 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)); | 1144 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)); |
| 1143 animation = Animation::Create(std::move(curve), animation_id, 0, | 1145 animation = Animation::Create(std::move(curve), animation_id, 0, |
| 1144 TargetProperty::SCROLL_OFFSET); | 1146 TargetProperty::SCROLL_OFFSET); |
| 1145 animation->set_needs_synchronized_start_time(true); | 1147 animation->set_needs_synchronized_start_time(true); |
| 1146 animations->AddAnimation(std::move(animation)); | 1148 AddAnimationToElementAnimations(animations.get(), std::move(animation)); |
| 1147 animations->PushPropertiesTo(animations_impl.get()); | 1149 animations->PushPropertiesTo(animations_impl.get()); |
| 1148 animations_impl->ActivateAnimations(); | 1150 animations_impl->ActivateAnimations(); |
| 1149 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1151 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1150 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1152 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1151 | 1153 |
| 1152 animations->RemoveAnimation(animation_id); | 1154 RemoveAnimationFromElementAnimations(animations.get(), animation_id); |
| 1153 EXPECT_TRUE(animations->scroll_offset_animation_was_interrupted()); | 1155 EXPECT_TRUE(animations->scroll_offset_animation_was_interrupted()); |
| 1154 | 1156 |
| 1155 animations->PushPropertiesTo(animations_impl.get()); | 1157 animations->PushPropertiesTo(animations_impl.get()); |
| 1156 EXPECT_TRUE(animations_impl->scroll_offset_animation_was_interrupted()); | 1158 EXPECT_TRUE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1157 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1159 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1158 | 1160 |
| 1159 animations_impl->ActivateAnimations(); | 1161 animations_impl->ActivateAnimations(); |
| 1160 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1162 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1161 | 1163 |
| 1162 // Check that removing non-scroll-offset animations does not cause | 1164 // Check that removing non-scroll-offset animations does not cause |
| 1163 // scroll_offset_animation_was_interrupted() to get set. | 1165 // scroll_offset_animation_was_interrupted() to get set. |
| 1164 animation_id = | 1166 animation_id = |
| 1165 AddAnimatedTransformToElementAnimations(animations.get(), 1.0, 1, 2); | 1167 AddAnimatedTransformToElementAnimations(animations.get(), 1.0, 1, 2); |
| 1166 animations->PushPropertiesTo(animations_impl.get()); | 1168 animations->PushPropertiesTo(animations_impl.get()); |
| 1167 animations_impl->ActivateAnimations(); | 1169 animations_impl->ActivateAnimations(); |
| 1168 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1170 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1169 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1171 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1170 | 1172 |
| 1171 animations->RemoveAnimation(animation_id); | 1173 RemoveAnimationFromElementAnimations(animations.get(), animation_id); |
| 1172 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1174 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1173 | 1175 |
| 1174 animations->PushPropertiesTo(animations_impl.get()); | 1176 animations->PushPropertiesTo(animations_impl.get()); |
| 1175 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1177 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1176 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1178 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1177 | 1179 |
| 1178 animations_impl->ActivateAnimations(); | 1180 animations_impl->ActivateAnimations(); |
| 1179 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1181 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1180 | 1182 |
| 1181 animation_id = | 1183 animation_id = |
| 1182 AddAnimatedFilterToElementAnimations(animations.get(), 1.0, 0.1f, 0.2f); | 1184 AddAnimatedFilterToElementAnimations(animations.get(), 1.0, 0.1f, 0.2f); |
| 1183 animations->PushPropertiesTo(animations_impl.get()); | 1185 animations->PushPropertiesTo(animations_impl.get()); |
| 1184 animations_impl->ActivateAnimations(); | 1186 animations_impl->ActivateAnimations(); |
| 1185 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1187 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1186 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1188 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1187 | 1189 |
| 1188 animations->RemoveAnimation(animation_id); | 1190 RemoveAnimationFromElementAnimations(animations.get(), animation_id); |
| 1189 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1191 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1190 | 1192 |
| 1191 animations->PushPropertiesTo(animations_impl.get()); | 1193 animations->PushPropertiesTo(animations_impl.get()); |
| 1192 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1194 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1193 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1195 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1194 | 1196 |
| 1195 animations_impl->ActivateAnimations(); | 1197 animations_impl->ActivateAnimations(); |
| 1196 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1198 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1197 } | 1199 } |
| 1198 | 1200 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1216 gfx::ScrollOffset target_value(300.f, 200.f); | 1218 gfx::ScrollOffset target_value(300.f, 200.f); |
| 1217 std::unique_ptr<ScrollOffsetAnimationCurve> curve( | 1219 std::unique_ptr<ScrollOffsetAnimationCurve> curve( |
| 1218 ScrollOffsetAnimationCurve::Create( | 1220 ScrollOffsetAnimationCurve::Create( |
| 1219 target_value, CubicBezierTimingFunction::CreatePreset( | 1221 target_value, CubicBezierTimingFunction::CreatePreset( |
| 1220 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 1222 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 1221 curve->SetInitialValue(initial_value); | 1223 curve->SetInitialValue(initial_value); |
| 1222 TimeDelta duration = curve->Duration(); | 1224 TimeDelta duration = curve->Duration(); |
| 1223 std::unique_ptr<Animation> to_add( | 1225 std::unique_ptr<Animation> to_add( |
| 1224 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); | 1226 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); |
| 1225 to_add->set_is_impl_only(true); | 1227 to_add->set_is_impl_only(true); |
| 1226 animations_impl->AddAnimation(std::move(to_add)); | 1228 AddAnimationToElementAnimations(animations_impl.get(), std::move(to_add)); |
| 1227 | 1229 |
| 1228 EXPECT_FALSE(delegate.started()); | 1230 EXPECT_FALSE(delegate.started()); |
| 1229 EXPECT_FALSE(delegate.finished()); | 1231 EXPECT_FALSE(delegate.finished()); |
| 1230 | 1232 |
| 1231 animations_impl->Animate(kInitialTickTime); | 1233 animations_impl->Animate(kInitialTickTime); |
| 1232 animations_impl->UpdateState(true, events.get()); | 1234 animations_impl->UpdateState(true, events.get()); |
| 1233 | 1235 |
| 1234 EXPECT_TRUE(delegate.started()); | 1236 EXPECT_TRUE(delegate.started()); |
| 1235 EXPECT_FALSE(delegate.finished()); | 1237 EXPECT_FALSE(delegate.finished()); |
| 1236 | 1238 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1294 | 1296 |
| 1295 auto events = host_impl_->CreateEvents(); | 1297 auto events = host_impl_->CreateEvents(); |
| 1296 | 1298 |
| 1297 std::unique_ptr<Animation> to_add(CreateAnimation( | 1299 std::unique_ptr<Animation> to_add(CreateAnimation( |
| 1298 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 1300 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 1299 1, TargetProperty::OPACITY)); | 1301 1, TargetProperty::OPACITY)); |
| 1300 to_add->set_needs_synchronized_start_time(true); | 1302 to_add->set_needs_synchronized_start_time(true); |
| 1301 | 1303 |
| 1302 // We should pause at the first keyframe indefinitely waiting for that | 1304 // We should pause at the first keyframe indefinitely waiting for that |
| 1303 // animation to start. | 1305 // animation to start. |
| 1304 animations->AddAnimation(std::move(to_add)); | 1306 AddAnimationToElementAnimations(animations.get(), std::move(to_add)); |
| 1305 animations->Animate(kInitialTickTime); | 1307 animations->Animate(kInitialTickTime); |
| 1306 animations->UpdateState(true, events.get()); | 1308 animations->UpdateState(true, events.get()); |
| 1307 EXPECT_TRUE(animations->HasActiveAnimation()); | 1309 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 1308 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1310 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1309 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1311 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1310 animations->UpdateState(true, events.get()); | 1312 animations->UpdateState(true, events.get()); |
| 1311 EXPECT_TRUE(animations->HasActiveAnimation()); | 1313 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 1312 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1314 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1313 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1315 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 1314 animations->UpdateState(true, events.get()); | 1316 animations->UpdateState(true, events.get()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 1, TargetProperty::OPACITY)); | 1383 1, TargetProperty::OPACITY)); |
| 1382 animations->Animate(kInitialTickTime); | 1384 animations->Animate(kInitialTickTime); |
| 1383 animations->UpdateState(true, events.get()); | 1385 animations->UpdateState(true, events.get()); |
| 1384 EXPECT_TRUE(animations->HasActiveAnimation()); | 1386 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 1385 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1387 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1386 | 1388 |
| 1387 std::unique_ptr<Animation> to_add(CreateAnimation( | 1389 std::unique_ptr<Animation> to_add(CreateAnimation( |
| 1388 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), | 1390 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), |
| 1389 2, TargetProperty::OPACITY)); | 1391 2, TargetProperty::OPACITY)); |
| 1390 animations->AbortAnimations(TargetProperty::OPACITY); | 1392 animations->AbortAnimations(TargetProperty::OPACITY); |
| 1391 animations->AddAnimation(std::move(to_add)); | 1393 AddAnimationToElementAnimations(animations.get(), std::move(to_add)); |
| 1392 | 1394 |
| 1393 // Since the previous animation was aborted, the new animation should start | 1395 // Since the previous animation was aborted, the new animation should start |
| 1394 // right in this call to animate. | 1396 // right in this call to animate. |
| 1395 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1397 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 1396 animations->UpdateState(true, events.get()); | 1398 animations->UpdateState(true, events.get()); |
| 1397 EXPECT_TRUE(animations->HasActiveAnimation()); | 1399 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 1398 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1400 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1399 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); | 1401 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); |
| 1400 animations->UpdateState(true, events.get()); | 1402 animations->UpdateState(true, events.get()); |
| 1401 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1403 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 AttachTimelinePlayerLayer(); | 1489 AttachTimelinePlayerLayer(); |
| 1488 | 1490 |
| 1489 scoped_refptr<ElementAnimations> animations = element_animations(); | 1491 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 1490 | 1492 |
| 1491 auto events = host_impl_->CreateEvents(); | 1493 auto events = host_impl_->CreateEvents(); |
| 1492 | 1494 |
| 1493 std::unique_ptr<Animation> to_add(CreateAnimation( | 1495 std::unique_ptr<Animation> to_add(CreateAnimation( |
| 1494 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 1496 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 1495 1, TargetProperty::OPACITY)); | 1497 1, TargetProperty::OPACITY)); |
| 1496 to_add->set_iterations(3); | 1498 to_add->set_iterations(3); |
| 1497 animations->AddAnimation(std::move(to_add)); | 1499 AddAnimationToElementAnimations(animations.get(), std::move(to_add)); |
| 1498 | 1500 |
| 1499 animations->Animate(kInitialTickTime); | 1501 animations->Animate(kInitialTickTime); |
| 1500 animations->UpdateState(true, events.get()); | 1502 animations->UpdateState(true, events.get()); |
| 1501 EXPECT_TRUE(animations->HasActiveAnimation()); | 1503 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 1502 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1504 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1503 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); | 1505 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); |
| 1504 animations->UpdateState(true, events.get()); | 1506 animations->UpdateState(true, events.get()); |
| 1505 EXPECT_TRUE(animations->HasActiveAnimation()); | 1507 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 1506 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1508 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1507 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); | 1509 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1533 AttachTimelinePlayerLayer(); | 1535 AttachTimelinePlayerLayer(); |
| 1534 | 1536 |
| 1535 scoped_refptr<ElementAnimations> animations = element_animations(); | 1537 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 1536 | 1538 |
| 1537 auto events = host_impl_->CreateEvents(); | 1539 auto events = host_impl_->CreateEvents(); |
| 1538 | 1540 |
| 1539 std::unique_ptr<Animation> to_add(CreateAnimation( | 1541 std::unique_ptr<Animation> to_add(CreateAnimation( |
| 1540 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 1542 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 1541 1, TargetProperty::OPACITY)); | 1543 1, TargetProperty::OPACITY)); |
| 1542 to_add->set_iterations(-1); | 1544 to_add->set_iterations(-1); |
| 1543 animations->AddAnimation(std::move(to_add)); | 1545 AddAnimationToElementAnimations(animations.get(), std::move(to_add)); |
| 1544 | 1546 |
| 1545 animations->Animate(kInitialTickTime); | 1547 animations->Animate(kInitialTickTime); |
| 1546 animations->UpdateState(true, events.get()); | 1548 animations->UpdateState(true, events.get()); |
| 1547 EXPECT_TRUE(animations->HasActiveAnimation()); | 1549 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 1548 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1550 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1549 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); | 1551 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); |
| 1550 animations->UpdateState(true, events.get()); | 1552 animations->UpdateState(true, events.get()); |
| 1551 EXPECT_TRUE(animations->HasActiveAnimation()); | 1553 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 1552 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1554 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1553 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); | 1555 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1670 | 1672 |
| 1671 scoped_refptr<ElementAnimations> animations = element_animations(); | 1673 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 1672 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 1674 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 1673 | 1675 |
| 1674 auto events = host_impl_->CreateEvents(); | 1676 auto events = host_impl_->CreateEvents(); |
| 1675 | 1677 |
| 1676 std::unique_ptr<Animation> to_add(CreateAnimation( | 1678 std::unique_ptr<Animation> to_add(CreateAnimation( |
| 1677 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)), | 1679 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)), |
| 1678 0, TargetProperty::OPACITY)); | 1680 0, TargetProperty::OPACITY)); |
| 1679 to_add->set_needs_synchronized_start_time(true); | 1681 to_add->set_needs_synchronized_start_time(true); |
| 1680 animations->AddAnimation(std::move(to_add)); | 1682 AddAnimationToElementAnimations(animations.get(), std::move(to_add)); |
| 1681 | 1683 |
| 1682 animations->Animate(kInitialTickTime); | 1684 animations->Animate(kInitialTickTime); |
| 1683 animations->UpdateState(true, events.get()); | 1685 animations->UpdateState(true, events.get()); |
| 1684 EXPECT_TRUE(animations->HasActiveAnimation()); | 1686 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 1685 Animation* active_animation = | 1687 Animation* active_animation = |
| 1686 animations->GetAnimation(TargetProperty::OPACITY); | 1688 animations->GetAnimation(TargetProperty::OPACITY); |
| 1687 EXPECT_TRUE(active_animation); | 1689 EXPECT_TRUE(active_animation); |
| 1688 EXPECT_TRUE(active_animation->needs_synchronized_start_time()); | 1690 EXPECT_TRUE(active_animation->needs_synchronized_start_time()); |
| 1689 | 1691 |
| 1692 EXPECT_TRUE(animations->needs_push_properties()); |
| 1690 animations->PushPropertiesTo(animations_impl.get()); | 1693 animations->PushPropertiesTo(animations_impl.get()); |
| 1691 animations_impl->ActivateAnimations(); | 1694 animations_impl->ActivateAnimations(); |
| 1692 | 1695 |
| 1693 active_animation = animations_impl->GetAnimation(TargetProperty::OPACITY); | 1696 active_animation = animations_impl->GetAnimation(TargetProperty::OPACITY); |
| 1694 EXPECT_TRUE(active_animation); | 1697 EXPECT_TRUE(active_animation); |
| 1695 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1698 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 1696 active_animation->run_state()); | 1699 active_animation->run_state()); |
| 1697 } | 1700 } |
| 1698 | 1701 |
| 1699 // Tests that skipping a call to UpdateState works as expected. | 1702 // Tests that skipping a call to UpdateState works as expected. |
| 1700 TEST_F(ElementAnimationsTest, SkipUpdateState) { | 1703 TEST_F(ElementAnimationsTest, SkipUpdateState) { |
| 1701 CreateTestLayer(true, false); | 1704 CreateTestLayer(true, false); |
| 1702 AttachTimelinePlayerLayer(); | 1705 AttachTimelinePlayerLayer(); |
| 1703 | 1706 |
| 1704 scoped_refptr<ElementAnimations> animations = element_animations(); | 1707 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 1705 | 1708 |
| 1706 auto events = host_impl_->CreateEvents(); | 1709 auto events = host_impl_->CreateEvents(); |
| 1707 | 1710 |
| 1708 std::unique_ptr<Animation> first_animation(CreateAnimation( | 1711 std::unique_ptr<Animation> first_animation(CreateAnimation( |
| 1709 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, | 1712 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, |
| 1710 TargetProperty::TRANSFORM)); | 1713 TargetProperty::TRANSFORM)); |
| 1711 first_animation->set_is_controlling_instance_for_test(true); | 1714 first_animation->set_is_controlling_instance_for_test(true); |
| 1712 animations->AddAnimation(std::move(first_animation)); | 1715 AddAnimationToElementAnimations(animations.get(), std::move(first_animation)); |
| 1713 | 1716 |
| 1714 animations->Animate(kInitialTickTime); | 1717 animations->Animate(kInitialTickTime); |
| 1715 animations->UpdateState(true, events.get()); | 1718 animations->UpdateState(true, events.get()); |
| 1716 | 1719 |
| 1717 std::unique_ptr<Animation> second_animation(CreateAnimation( | 1720 std::unique_ptr<Animation> second_animation(CreateAnimation( |
| 1718 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 1721 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 1719 2, TargetProperty::OPACITY)); | 1722 2, TargetProperty::OPACITY)); |
| 1720 second_animation->set_is_controlling_instance_for_test(true); | 1723 second_animation->set_is_controlling_instance_for_test(true); |
| 1721 animations->AddAnimation(std::move(second_animation)); | 1724 AddAnimationToElementAnimations(animations.get(), |
| 1725 std::move(second_animation)); |
| 1722 | 1726 |
| 1723 // Animate but don't UpdateState. | 1727 // Animate but don't UpdateState. |
| 1724 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1728 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1725 | 1729 |
| 1726 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1730 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 1727 events = host_impl_->CreateEvents(); | 1731 events = host_impl_->CreateEvents(); |
| 1728 animations->UpdateState(true, events.get()); | 1732 animations->UpdateState(true, events.get()); |
| 1729 | 1733 |
| 1730 // Should have one STARTED event and one FINISHED event. | 1734 // Should have one STARTED event and one FINISHED event. |
| 1731 EXPECT_EQ(2u, events->events_.size()); | 1735 EXPECT_EQ(2u, events->events_.size()); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1822 | 1826 |
| 1823 TransformOperations operations1; | 1827 TransformOperations operations1; |
| 1824 curve1->AddKeyframe( | 1828 curve1->AddKeyframe( |
| 1825 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 1829 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 1826 operations1.AppendTranslate(10.0, 15.0, 0.0); | 1830 operations1.AppendTranslate(10.0, 15.0, 0.0); |
| 1827 curve1->AddKeyframe(TransformKeyframe::Create( | 1831 curve1->AddKeyframe(TransformKeyframe::Create( |
| 1828 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 1832 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
| 1829 | 1833 |
| 1830 std::unique_ptr<Animation> animation( | 1834 std::unique_ptr<Animation> animation( |
| 1831 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); | 1835 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); |
| 1832 animations_impl->AddAnimation(std::move(animation)); | 1836 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
| 1833 | 1837 |
| 1834 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( | 1838 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( |
| 1835 KeyframedTransformAnimationCurve::Create()); | 1839 KeyframedTransformAnimationCurve::Create()); |
| 1836 | 1840 |
| 1837 TransformOperations operations2; | 1841 TransformOperations operations2; |
| 1838 curve2->AddKeyframe( | 1842 curve2->AddKeyframe( |
| 1839 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 1843 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
| 1840 operations2.AppendScale(2.0, 3.0, 4.0); | 1844 operations2.AppendScale(2.0, 3.0, 4.0); |
| 1841 curve2->AddKeyframe(TransformKeyframe::Create( | 1845 curve2->AddKeyframe(TransformKeyframe::Create( |
| 1842 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 1846 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
| 1843 | 1847 |
| 1844 animation = | 1848 animation = |
| 1845 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); | 1849 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); |
| 1846 animations_impl->AddAnimation(std::move(animation)); | 1850 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
| 1847 | 1851 |
| 1848 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); | 1852 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); |
| 1849 gfx::BoxF bounds; | 1853 gfx::BoxF bounds; |
| 1850 | 1854 |
| 1851 EXPECT_TRUE(animations_impl->TransformAnimationBoundsForBox(box, &bounds)); | 1855 EXPECT_TRUE(animations_impl->TransformAnimationBoundsForBox(box, &bounds)); |
| 1852 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), | 1856 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), |
| 1853 bounds.ToString()); | 1857 bounds.ToString()); |
| 1854 | 1858 |
| 1855 animations_impl->GetAnimationById(1)->SetRunState(Animation::FINISHED, | 1859 animations_impl->GetAnimationById(1)->SetRunState(Animation::FINISHED, |
| 1856 TicksFromSecondsF(0.0)); | 1860 TicksFromSecondsF(0.0)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1872 TransformOperations operations3; | 1876 TransformOperations operations3; |
| 1873 gfx::Transform transform3; | 1877 gfx::Transform transform3; |
| 1874 transform3.Scale3d(1.0, 2.0, 3.0); | 1878 transform3.Scale3d(1.0, 2.0, 3.0); |
| 1875 curve3->AddKeyframe( | 1879 curve3->AddKeyframe( |
| 1876 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); | 1880 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); |
| 1877 operations3.AppendMatrix(transform3); | 1881 operations3.AppendMatrix(transform3); |
| 1878 curve3->AddKeyframe(TransformKeyframe::Create( | 1882 curve3->AddKeyframe(TransformKeyframe::Create( |
| 1879 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); | 1883 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); |
| 1880 animation = | 1884 animation = |
| 1881 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); | 1885 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); |
| 1882 animations_impl->AddAnimation(std::move(animation)); | 1886 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
| 1883 EXPECT_FALSE(animations_impl->TransformAnimationBoundsForBox(box, &bounds)); | 1887 EXPECT_FALSE(animations_impl->TransformAnimationBoundsForBox(box, &bounds)); |
| 1884 } | 1888 } |
| 1885 | 1889 |
| 1886 // Tests that AbortAnimations aborts all animations targeting the specified | 1890 // Tests that AbortAnimations aborts all animations targeting the specified |
| 1887 // property. | 1891 // property. |
| 1888 TEST_F(ElementAnimationsTest, AbortAnimations) { | 1892 TEST_F(ElementAnimationsTest, AbortAnimations) { |
| 1889 CreateTestLayer(false, false); | 1893 CreateTestLayer(false, false); |
| 1890 AttachTimelinePlayerLayer(); | 1894 AttachTimelinePlayerLayer(); |
| 1891 | 1895 |
| 1892 scoped_refptr<ElementAnimations> animations = element_animations(); | 1896 scoped_refptr<ElementAnimations> animations = element_animations(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1940 scoped_refptr<ElementAnimations> animations = element_animations(); | 1944 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 1941 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 1945 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 1942 | 1946 |
| 1943 int animation_id = AddOpacityTransitionToElementAnimations( | 1947 int animation_id = AddOpacityTransitionToElementAnimations( |
| 1944 animations.get(), 1.0, 0.f, 1.f, false); | 1948 animations.get(), 1.0, 0.f, 1.f, false); |
| 1945 | 1949 |
| 1946 animations->PushPropertiesTo(animations_impl.get()); | 1950 animations->PushPropertiesTo(animations_impl.get()); |
| 1947 animations_impl->ActivateAnimations(); | 1951 animations_impl->ActivateAnimations(); |
| 1948 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 1952 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
| 1949 | 1953 |
| 1950 animations->AbortAnimations(TargetProperty::OPACITY); | 1954 AbortAnimationsInElementAnimations(animations.get(), TargetProperty::OPACITY, |
| 1955 false); |
| 1951 EXPECT_EQ(Animation::ABORTED, | 1956 EXPECT_EQ(Animation::ABORTED, |
| 1952 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1957 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1953 EXPECT_FALSE(host_->animation_waiting_for_deletion()); | 1958 EXPECT_FALSE(host_->needs_push_properties()); |
| 1954 EXPECT_FALSE(host_impl_->animation_waiting_for_deletion()); | 1959 EXPECT_FALSE(host_impl_->needs_push_properties()); |
| 1955 | 1960 |
| 1956 animations->Animate(kInitialTickTime); | 1961 animations->Animate(kInitialTickTime); |
| 1957 animations->UpdateState(true, nullptr); | 1962 animations->UpdateState(true, nullptr); |
| 1958 EXPECT_FALSE(host_->animation_waiting_for_deletion()); | 1963 EXPECT_FALSE(host_->needs_push_properties()); |
| 1959 EXPECT_EQ(Animation::ABORTED, | 1964 EXPECT_EQ(Animation::ABORTED, |
| 1960 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1965 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1961 | 1966 |
| 1967 EXPECT_TRUE(animations->needs_push_properties()); |
| 1962 animations->PushPropertiesTo(animations_impl.get()); | 1968 animations->PushPropertiesTo(animations_impl.get()); |
| 1963 EXPECT_FALSE(animations->GetAnimationById(animation_id)); | 1969 EXPECT_FALSE(animations->GetAnimationById(animation_id)); |
| 1964 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); | 1970 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); |
| 1965 } | 1971 } |
| 1966 | 1972 |
| 1967 // An animation aborted on the impl thread should get deleted on both threads. | 1973 // An animation aborted on the impl thread should get deleted on both threads. |
| 1968 TEST_F(ElementAnimationsTest, ImplThreadAbortedAnimationGetsDeleted) { | 1974 TEST_F(ElementAnimationsTest, ImplThreadAbortedAnimationGetsDeleted) { |
| 1969 CreateTestLayer(true, false); | 1975 CreateTestLayer(true, false); |
| 1970 AttachTimelinePlayerLayer(); | 1976 AttachTimelinePlayerLayer(); |
| 1971 CreateImplTimelineAndPlayer(); | 1977 CreateImplTimelineAndPlayer(); |
| 1972 | 1978 |
| 1973 scoped_refptr<ElementAnimations> animations = element_animations(); | 1979 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 1974 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 1980 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 1975 | 1981 |
| 1976 TestAnimationDelegate delegate; | 1982 TestAnimationDelegate delegate; |
| 1977 player_->set_animation_delegate(&delegate); | 1983 player_->set_animation_delegate(&delegate); |
| 1978 | 1984 |
| 1979 int animation_id = AddOpacityTransitionToElementAnimations( | 1985 int animation_id = AddOpacityTransitionToElementAnimations( |
| 1980 animations.get(), 1.0, 0.f, 1.f, false); | 1986 animations.get(), 1.0, 0.f, 1.f, false); |
| 1981 | 1987 |
| 1982 animations->PushPropertiesTo(animations_impl.get()); | 1988 animations->PushPropertiesTo(animations_impl.get()); |
| 1983 animations_impl->ActivateAnimations(); | 1989 animations_impl->ActivateAnimations(); |
| 1984 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 1990 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
| 1985 | 1991 |
| 1986 animations_impl->AbortAnimations(TargetProperty::OPACITY); | 1992 animations_impl->AbortAnimations(TargetProperty::OPACITY); |
| 1987 EXPECT_EQ( | 1993 EXPECT_EQ( |
| 1988 Animation::ABORTED, | 1994 Animation::ABORTED, |
| 1989 animations_impl->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1995 animations_impl->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1990 EXPECT_FALSE(host_->animation_waiting_for_deletion()); | 1996 EXPECT_FALSE(host_->needs_push_properties()); |
| 1991 EXPECT_FALSE(host_impl_->animation_waiting_for_deletion()); | 1997 EXPECT_FALSE(host_impl_->needs_push_properties()); |
| 1992 | 1998 |
| 1993 auto events = host_impl_->CreateEvents(); | 1999 auto events = host_impl_->CreateEvents(); |
| 1994 animations_impl->Animate(kInitialTickTime); | 2000 animations_impl->Animate(kInitialTickTime); |
| 1995 animations_impl->UpdateState(true, events.get()); | 2001 animations_impl->UpdateState(true, events.get()); |
| 1996 EXPECT_TRUE(host_impl_->animation_waiting_for_deletion()); | 2002 EXPECT_TRUE(host_impl_->needs_push_properties()); |
| 1997 EXPECT_EQ(1u, events->events_.size()); | 2003 EXPECT_EQ(1u, events->events_.size()); |
| 1998 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[0].type); | 2004 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[0].type); |
| 1999 EXPECT_EQ( | 2005 EXPECT_EQ( |
| 2000 Animation::WAITING_FOR_DELETION, | 2006 Animation::WAITING_FOR_DELETION, |
| 2001 animations_impl->GetAnimation(TargetProperty::OPACITY)->run_state()); | 2007 animations_impl->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 2002 | 2008 |
| 2003 animations->NotifyAnimationAborted(events->events_[0]); | 2009 animations->NotifyAnimationAborted(events->events_[0]); |
| 2004 EXPECT_EQ(Animation::ABORTED, | 2010 EXPECT_EQ(Animation::ABORTED, |
| 2005 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); | 2011 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 2006 EXPECT_TRUE(delegate.aborted()); | 2012 EXPECT_TRUE(delegate.aborted()); |
| 2007 | 2013 |
| 2008 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 2014 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 2009 animations->UpdateState(true, nullptr); | 2015 animations->UpdateState(true, nullptr); |
| 2010 EXPECT_TRUE(host_->animation_waiting_for_deletion()); | 2016 EXPECT_TRUE(host_->needs_push_properties()); |
| 2011 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 2017 EXPECT_EQ(Animation::WAITING_FOR_DELETION, |
| 2012 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); | 2018 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 2013 | 2019 |
| 2014 animations->PushPropertiesTo(animations_impl.get()); | 2020 animations->PushPropertiesTo(animations_impl.get()); |
| 2015 animations_impl->ActivateAnimations(); | 2021 animations_impl->ActivateAnimations(); |
| 2016 EXPECT_FALSE(animations->GetAnimationById(animation_id)); | 2022 EXPECT_FALSE(animations->GetAnimationById(animation_id)); |
| 2017 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); | 2023 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); |
| 2018 } | 2024 } |
| 2019 | 2025 |
| 2020 // Test that an impl-only scroll offset animation that needs to be completed on | 2026 // Test that an impl-only scroll offset animation that needs to be completed on |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2038 gfx::ScrollOffset target_value(300.f, 200.f); | 2044 gfx::ScrollOffset target_value(300.f, 200.f); |
| 2039 std::unique_ptr<ScrollOffsetAnimationCurve> curve( | 2045 std::unique_ptr<ScrollOffsetAnimationCurve> curve( |
| 2040 ScrollOffsetAnimationCurve::Create( | 2046 ScrollOffsetAnimationCurve::Create( |
| 2041 target_value, CubicBezierTimingFunction::CreatePreset( | 2047 target_value, CubicBezierTimingFunction::CreatePreset( |
| 2042 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 2048 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 2043 curve->SetInitialValue(initial_value); | 2049 curve->SetInitialValue(initial_value); |
| 2044 std::unique_ptr<Animation> animation(Animation::Create( | 2050 std::unique_ptr<Animation> animation(Animation::Create( |
| 2045 std::move(curve), animation_id, 0, TargetProperty::SCROLL_OFFSET)); | 2051 std::move(curve), animation_id, 0, TargetProperty::SCROLL_OFFSET)); |
| 2046 animation->set_start_time(TicksFromSecondsF(123)); | 2052 animation->set_start_time(TicksFromSecondsF(123)); |
| 2047 animation->set_is_impl_only(true); | 2053 animation->set_is_impl_only(true); |
| 2048 animations_impl->AddAnimation(std::move(animation)); | 2054 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
| 2049 | 2055 |
| 2050 animations->PushPropertiesTo(animations_impl.get()); | 2056 animations->PushPropertiesTo(animations_impl.get()); |
| 2051 animations_impl->ActivateAnimations(); | 2057 animations_impl->ActivateAnimations(); |
| 2052 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 2058 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
| 2053 | 2059 |
| 2054 const bool needs_completion = true; | 2060 const bool needs_completion = true; |
| 2055 animations_impl->AbortAnimations(TargetProperty::SCROLL_OFFSET, | 2061 AbortAnimationsInElementAnimations( |
| 2056 needs_completion); | 2062 animations_impl.get(), TargetProperty::SCROLL_OFFSET, needs_completion); |
| 2057 EXPECT_EQ(Animation::ABORTED_BUT_NEEDS_COMPLETION, | 2063 EXPECT_EQ(Animation::ABORTED_BUT_NEEDS_COMPLETION, |
| 2058 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) | 2064 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| 2059 ->run_state()); | 2065 ->run_state()); |
| 2060 EXPECT_FALSE(host_->animation_waiting_for_deletion()); | 2066 EXPECT_FALSE(host_->needs_push_properties()); |
| 2061 EXPECT_FALSE(host_impl_->animation_waiting_for_deletion()); | 2067 EXPECT_FALSE(host_impl_->needs_push_properties()); |
| 2062 | 2068 |
| 2063 auto events = host_impl_->CreateEvents(); | 2069 auto events = host_impl_->CreateEvents(); |
| 2064 animations_impl->Animate(kInitialTickTime); | 2070 animations_impl->Animate(kInitialTickTime); |
| 2065 animations_impl->UpdateState(true, events.get()); | 2071 animations_impl->UpdateState(true, events.get()); |
| 2066 EXPECT_TRUE(delegate_impl.finished()); | 2072 EXPECT_TRUE(delegate_impl.finished()); |
| 2067 EXPECT_TRUE(host_impl_->animation_waiting_for_deletion()); | 2073 EXPECT_TRUE(host_impl_->needs_push_properties()); |
| 2068 EXPECT_EQ(1u, events->events_.size()); | 2074 EXPECT_EQ(1u, events->events_.size()); |
| 2069 EXPECT_EQ(AnimationEvent::TAKEOVER, events->events_[0].type); | 2075 EXPECT_EQ(AnimationEvent::TAKEOVER, events->events_[0].type); |
| 2070 EXPECT_EQ(123, events->events_[0].animation_start_time); | 2076 EXPECT_EQ(123, events->events_[0].animation_start_time); |
| 2071 EXPECT_EQ( | 2077 EXPECT_EQ( |
| 2072 target_value, | 2078 target_value, |
| 2073 events->events_[0].curve->ToScrollOffsetAnimationCurve()->target_value()); | 2079 events->events_[0].curve->ToScrollOffsetAnimationCurve()->target_value()); |
| 2074 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 2080 EXPECT_EQ(Animation::WAITING_FOR_DELETION, |
| 2075 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) | 2081 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| 2076 ->run_state()); | 2082 ->run_state()); |
| 2077 | 2083 |
| 2084 // MT receives the event to take over. |
| 2078 animations->NotifyAnimationTakeover(events->events_[0]); | 2085 animations->NotifyAnimationTakeover(events->events_[0]); |
| 2079 EXPECT_TRUE(delegate.takeover()); | 2086 EXPECT_TRUE(delegate.takeover()); |
| 2080 | 2087 |
| 2088 // AnimationPlayer::NotifyAnimationTakeover requests SetNeedsPushProperties |
| 2089 // to purge CT animations marked for deletion. |
| 2090 EXPECT_TRUE(animations->needs_push_properties()); |
| 2091 |
| 2092 // ElementAnimations::PurgeAnimationsMarkedForDeletion call happens only in |
| 2093 // ElementAnimations::PushPropertiesTo. |
| 2081 animations->PushPropertiesTo(animations_impl.get()); | 2094 animations->PushPropertiesTo(animations_impl.get()); |
| 2082 animations_impl->ActivateAnimations(); | 2095 animations_impl->ActivateAnimations(); |
| 2083 EXPECT_FALSE(animations->GetAnimationById(animation_id)); | 2096 EXPECT_FALSE(animations->GetAnimationById(animation_id)); |
| 2084 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); | 2097 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); |
| 2085 } | 2098 } |
| 2086 | 2099 |
| 2087 // Ensure that we only generate FINISHED events for animations in a group | 2100 // Ensure that we only generate FINISHED events for animations in a group |
| 2088 // once all animations in that group are finished. | 2101 // once all animations in that group are finished. |
| 2089 TEST_F(ElementAnimationsTest, FinishedEventsForGroup) { | 2102 TEST_F(ElementAnimationsTest, FinishedEventsForGroup) { |
| 2090 CreateTestLayer(true, false); | 2103 CreateTestLayer(true, false); |
| 2091 AttachTimelinePlayerLayer(); | 2104 AttachTimelinePlayerLayer(); |
| 2092 CreateImplTimelineAndPlayer(); | 2105 CreateImplTimelineAndPlayer(); |
| 2093 | 2106 |
| 2094 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 2107 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 2095 | 2108 |
| 2096 auto events = host_impl_->CreateEvents(); | 2109 auto events = host_impl_->CreateEvents(); |
| 2097 | 2110 |
| 2098 const int group_id = 1; | 2111 const int group_id = 1; |
| 2099 | 2112 |
| 2100 // Add two animations with the same group id but different durations. | 2113 // Add two animations with the same group id but different durations. |
| 2101 std::unique_ptr<Animation> first_animation(Animation::Create( | 2114 std::unique_ptr<Animation> first_animation(Animation::Create( |
| 2102 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(2.0)), 1, | 2115 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(2.0)), 1, |
| 2103 group_id, TargetProperty::TRANSFORM)); | 2116 group_id, TargetProperty::TRANSFORM)); |
| 2104 first_animation->set_is_controlling_instance_for_test(true); | 2117 first_animation->set_is_controlling_instance_for_test(true); |
| 2105 animations_impl->AddAnimation(std::move(first_animation)); | 2118 AddAnimationToElementAnimations(animations_impl.get(), |
| 2119 std::move(first_animation)); |
| 2106 | 2120 |
| 2107 std::unique_ptr<Animation> second_animation(Animation::Create( | 2121 std::unique_ptr<Animation> second_animation(Animation::Create( |
| 2108 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 2122 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 2109 2, group_id, TargetProperty::OPACITY)); | 2123 2, group_id, TargetProperty::OPACITY)); |
| 2110 second_animation->set_is_controlling_instance_for_test(true); | 2124 second_animation->set_is_controlling_instance_for_test(true); |
| 2111 animations_impl->AddAnimation(std::move(second_animation)); | 2125 AddAnimationToElementAnimations(animations_impl.get(), |
| 2126 std::move(second_animation)); |
| 2112 | 2127 |
| 2113 animations_impl->Animate(kInitialTickTime); | 2128 animations_impl->Animate(kInitialTickTime); |
| 2114 animations_impl->UpdateState(true, events.get()); | 2129 animations_impl->UpdateState(true, events.get()); |
| 2115 | 2130 |
| 2116 // Both animations should have started. | 2131 // Both animations should have started. |
| 2117 EXPECT_EQ(2u, events->events_.size()); | 2132 EXPECT_EQ(2u, events->events_.size()); |
| 2118 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); | 2133 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); |
| 2119 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); | 2134 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); |
| 2120 | 2135 |
| 2121 events = host_impl_->CreateEvents(); | 2136 events = host_impl_->CreateEvents(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2151 | 2166 |
| 2152 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 2167 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 2153 | 2168 |
| 2154 auto events = host_impl_->CreateEvents(); | 2169 auto events = host_impl_->CreateEvents(); |
| 2155 | 2170 |
| 2156 // Add two animations with the same group id. | 2171 // Add two animations with the same group id. |
| 2157 std::unique_ptr<Animation> first_animation(CreateAnimation( | 2172 std::unique_ptr<Animation> first_animation(CreateAnimation( |
| 2158 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 1, | 2173 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 1, |
| 2159 TargetProperty::TRANSFORM)); | 2174 TargetProperty::TRANSFORM)); |
| 2160 first_animation->set_is_controlling_instance_for_test(true); | 2175 first_animation->set_is_controlling_instance_for_test(true); |
| 2161 animations_impl->AddAnimation(std::move(first_animation)); | 2176 AddAnimationToElementAnimations(animations_impl.get(), |
| 2177 std::move(first_animation)); |
| 2162 | 2178 |
| 2163 std::unique_ptr<Animation> second_animation(CreateAnimation( | 2179 std::unique_ptr<Animation> second_animation(CreateAnimation( |
| 2164 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 2180 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 2165 1, TargetProperty::OPACITY)); | 2181 1, TargetProperty::OPACITY)); |
| 2166 second_animation->set_is_controlling_instance_for_test(true); | 2182 second_animation->set_is_controlling_instance_for_test(true); |
| 2167 animations_impl->AddAnimation(std::move(second_animation)); | 2183 AddAnimationToElementAnimations(animations_impl.get(), |
| 2184 std::move(second_animation)); |
| 2168 | 2185 |
| 2169 animations_impl->Animate(kInitialTickTime); | 2186 animations_impl->Animate(kInitialTickTime); |
| 2170 animations_impl->UpdateState(true, events.get()); | 2187 animations_impl->UpdateState(true, events.get()); |
| 2171 | 2188 |
| 2172 // Both animations should have started. | 2189 // Both animations should have started. |
| 2173 EXPECT_EQ(2u, events->events_.size()); | 2190 EXPECT_EQ(2u, events->events_.size()); |
| 2174 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); | 2191 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); |
| 2175 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); | 2192 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); |
| 2176 | 2193 |
| 2177 animations_impl->AbortAnimations(TargetProperty::OPACITY); | 2194 animations_impl->AbortAnimations(TargetProperty::OPACITY); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2211 | 2228 |
| 2212 TransformOperations operations1; | 2229 TransformOperations operations1; |
| 2213 curve1->AddKeyframe( | 2230 curve1->AddKeyframe( |
| 2214 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2231 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 2215 operations1.AppendTranslate(10.0, 15.0, 0.0); | 2232 operations1.AppendTranslate(10.0, 15.0, 0.0); |
| 2216 curve1->AddKeyframe(TransformKeyframe::Create( | 2233 curve1->AddKeyframe(TransformKeyframe::Create( |
| 2217 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 2234 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
| 2218 | 2235 |
| 2219 std::unique_ptr<Animation> animation( | 2236 std::unique_ptr<Animation> animation( |
| 2220 Animation::Create(std::move(curve1), 2, 2, TargetProperty::TRANSFORM)); | 2237 Animation::Create(std::move(curve1), 2, 2, TargetProperty::TRANSFORM)); |
| 2221 animations_impl->AddAnimation(std::move(animation)); | 2238 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
| 2222 | 2239 |
| 2223 // Translations don't affect scale. | 2240 // Translations don't affect scale. |
| 2224 EXPECT_FALSE(animations_impl->HasAnimationThatAffectsScale()); | 2241 EXPECT_FALSE(animations_impl->HasAnimationThatAffectsScale()); |
| 2225 | 2242 |
| 2226 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( | 2243 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( |
| 2227 KeyframedTransformAnimationCurve::Create()); | 2244 KeyframedTransformAnimationCurve::Create()); |
| 2228 | 2245 |
| 2229 TransformOperations operations2; | 2246 TransformOperations operations2; |
| 2230 curve2->AddKeyframe( | 2247 curve2->AddKeyframe( |
| 2231 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 2248 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
| 2232 operations2.AppendScale(2.0, 3.0, 4.0); | 2249 operations2.AppendScale(2.0, 3.0, 4.0); |
| 2233 curve2->AddKeyframe(TransformKeyframe::Create( | 2250 curve2->AddKeyframe(TransformKeyframe::Create( |
| 2234 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2251 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
| 2235 | 2252 |
| 2236 animation = | 2253 animation = |
| 2237 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM); | 2254 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM); |
| 2238 animations_impl->AddAnimation(std::move(animation)); | 2255 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
| 2239 | 2256 |
| 2240 EXPECT_TRUE(animations_impl->HasAnimationThatAffectsScale()); | 2257 EXPECT_TRUE(animations_impl->HasAnimationThatAffectsScale()); |
| 2241 | 2258 |
| 2242 animations_impl->GetAnimationById(3)->SetRunState(Animation::FINISHED, | 2259 animations_impl->GetAnimationById(3)->SetRunState(Animation::FINISHED, |
| 2243 TicksFromSecondsF(0.0)); | 2260 TicksFromSecondsF(0.0)); |
| 2244 | 2261 |
| 2245 // Only unfinished animations should be considered by | 2262 // Only unfinished animations should be considered by |
| 2246 // HasAnimationThatAffectsScale. | 2263 // HasAnimationThatAffectsScale. |
| 2247 EXPECT_FALSE(animations_impl->HasAnimationThatAffectsScale()); | 2264 EXPECT_FALSE(animations_impl->HasAnimationThatAffectsScale()); |
| 2248 } | 2265 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2274 | 2291 |
| 2275 TransformOperations operations1; | 2292 TransformOperations operations1; |
| 2276 curve1->AddKeyframe( | 2293 curve1->AddKeyframe( |
| 2277 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2294 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 2278 operations1.AppendTranslate(10.0, 15.0, 0.0); | 2295 operations1.AppendTranslate(10.0, 15.0, 0.0); |
| 2279 curve1->AddKeyframe(TransformKeyframe::Create( | 2296 curve1->AddKeyframe(TransformKeyframe::Create( |
| 2280 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 2297 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
| 2281 | 2298 |
| 2282 std::unique_ptr<Animation> animation( | 2299 std::unique_ptr<Animation> animation( |
| 2283 Animation::Create(std::move(curve1), 2, 2, TargetProperty::TRANSFORM)); | 2300 Animation::Create(std::move(curve1), 2, 2, TargetProperty::TRANSFORM)); |
| 2284 animations_impl->AddAnimation(std::move(animation)); | 2301 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
| 2285 | 2302 |
| 2286 // The only transform animation we've added is a translation. | 2303 // The only transform animation we've added is a translation. |
| 2287 EXPECT_TRUE( | 2304 EXPECT_TRUE( |
| 2288 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE)); | 2305 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE)); |
| 2289 EXPECT_TRUE( | 2306 EXPECT_TRUE( |
| 2290 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING)); | 2307 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING)); |
| 2291 | 2308 |
| 2292 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( | 2309 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( |
| 2293 KeyframedTransformAnimationCurve::Create()); | 2310 KeyframedTransformAnimationCurve::Create()); |
| 2294 | 2311 |
| 2295 TransformOperations operations2; | 2312 TransformOperations operations2; |
| 2296 curve2->AddKeyframe( | 2313 curve2->AddKeyframe( |
| 2297 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 2314 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
| 2298 operations2.AppendScale(2.0, 3.0, 4.0); | 2315 operations2.AppendScale(2.0, 3.0, 4.0); |
| 2299 curve2->AddKeyframe(TransformKeyframe::Create( | 2316 curve2->AddKeyframe(TransformKeyframe::Create( |
| 2300 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2317 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
| 2301 | 2318 |
| 2302 animation = | 2319 animation = |
| 2303 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM); | 2320 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM); |
| 2304 animation->set_affects_active_elements(false); | 2321 animation->set_affects_active_elements(false); |
| 2305 animations_impl->AddAnimation(std::move(animation)); | 2322 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
| 2306 | 2323 |
| 2307 // A scale animation is not a translation. | 2324 // A scale animation is not a translation. |
| 2308 EXPECT_FALSE( | 2325 EXPECT_FALSE( |
| 2309 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING)); | 2326 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING)); |
| 2310 EXPECT_TRUE( | 2327 EXPECT_TRUE( |
| 2311 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE)); | 2328 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE)); |
| 2312 | 2329 |
| 2313 animations_impl->ActivateAnimations(); | 2330 animations_impl->ActivateAnimations(); |
| 2314 EXPECT_FALSE( | 2331 EXPECT_FALSE( |
| 2315 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING)); | 2332 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING)); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2346 TransformOperations operations1; | 2363 TransformOperations operations1; |
| 2347 operations1.AppendScale(2.0, 3.0, 4.0); | 2364 operations1.AppendScale(2.0, 3.0, 4.0); |
| 2348 curve1->AddKeyframe( | 2365 curve1->AddKeyframe( |
| 2349 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2366 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 2350 TransformOperations operations2; | 2367 TransformOperations operations2; |
| 2351 curve1->AddKeyframe(TransformKeyframe::Create( | 2368 curve1->AddKeyframe(TransformKeyframe::Create( |
| 2352 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2369 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
| 2353 std::unique_ptr<Animation> animation( | 2370 std::unique_ptr<Animation> animation( |
| 2354 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); | 2371 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); |
| 2355 animation->set_affects_active_elements(false); | 2372 animation->set_affects_active_elements(false); |
| 2356 animations_impl->AddAnimation(std::move(animation)); | 2373 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
| 2357 | 2374 |
| 2358 float start_scale = 0.f; | 2375 float start_scale = 0.f; |
| 2359 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, | 2376 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, |
| 2360 &start_scale)); | 2377 &start_scale)); |
| 2361 EXPECT_EQ(4.f, start_scale); | 2378 EXPECT_EQ(4.f, start_scale); |
| 2362 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE, | 2379 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE, |
| 2363 &start_scale)); | 2380 &start_scale)); |
| 2364 EXPECT_EQ(0.f, start_scale); | 2381 EXPECT_EQ(0.f, start_scale); |
| 2365 | 2382 |
| 2366 animations_impl->ActivateAnimations(); | 2383 animations_impl->ActivateAnimations(); |
| 2367 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, | 2384 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, |
| 2368 &start_scale)); | 2385 &start_scale)); |
| 2369 EXPECT_EQ(4.f, start_scale); | 2386 EXPECT_EQ(4.f, start_scale); |
| 2370 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE, | 2387 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE, |
| 2371 &start_scale)); | 2388 &start_scale)); |
| 2372 EXPECT_EQ(4.f, start_scale); | 2389 EXPECT_EQ(4.f, start_scale); |
| 2373 | 2390 |
| 2374 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( | 2391 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( |
| 2375 KeyframedTransformAnimationCurve::Create()); | 2392 KeyframedTransformAnimationCurve::Create()); |
| 2376 | 2393 |
| 2377 TransformOperations operations3; | 2394 TransformOperations operations3; |
| 2378 curve2->AddKeyframe( | 2395 curve2->AddKeyframe( |
| 2379 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); | 2396 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); |
| 2380 operations3.AppendScale(6.0, 5.0, 4.0); | 2397 operations3.AppendScale(6.0, 5.0, 4.0); |
| 2381 curve2->AddKeyframe(TransformKeyframe::Create( | 2398 curve2->AddKeyframe(TransformKeyframe::Create( |
| 2382 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); | 2399 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); |
| 2383 | 2400 |
| 2384 animations_impl->RemoveAnimation(1); | 2401 RemoveAnimationFromElementAnimations(animations_impl.get(), 1); |
| 2385 animation = | 2402 animation = |
| 2386 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); | 2403 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); |
| 2387 | 2404 |
| 2388 // Reverse Direction | 2405 // Reverse Direction |
| 2389 animation->set_direction(Animation::Direction::REVERSE); | 2406 animation->set_direction(Animation::Direction::REVERSE); |
| 2390 animation->set_affects_active_elements(false); | 2407 animation->set_affects_active_elements(false); |
| 2391 animations_impl->AddAnimation(std::move(animation)); | 2408 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
| 2392 | 2409 |
| 2393 std::unique_ptr<KeyframedTransformAnimationCurve> curve3( | 2410 std::unique_ptr<KeyframedTransformAnimationCurve> curve3( |
| 2394 KeyframedTransformAnimationCurve::Create()); | 2411 KeyframedTransformAnimationCurve::Create()); |
| 2395 | 2412 |
| 2396 TransformOperations operations4; | 2413 TransformOperations operations4; |
| 2397 operations4.AppendScale(5.0, 3.0, 1.0); | 2414 operations4.AppendScale(5.0, 3.0, 1.0); |
| 2398 curve3->AddKeyframe( | 2415 curve3->AddKeyframe( |
| 2399 TransformKeyframe::Create(base::TimeDelta(), operations4, nullptr)); | 2416 TransformKeyframe::Create(base::TimeDelta(), operations4, nullptr)); |
| 2400 TransformOperations operations5; | 2417 TransformOperations operations5; |
| 2401 curve3->AddKeyframe(TransformKeyframe::Create( | 2418 curve3->AddKeyframe(TransformKeyframe::Create( |
| 2402 base::TimeDelta::FromSecondsD(1.0), operations5, nullptr)); | 2419 base::TimeDelta::FromSecondsD(1.0), operations5, nullptr)); |
| 2403 | 2420 |
| 2404 animation = | 2421 animation = |
| 2405 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); | 2422 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); |
| 2406 animation->set_affects_active_elements(false); | 2423 animation->set_affects_active_elements(false); |
| 2407 animations_impl->AddAnimation(std::move(animation)); | 2424 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
| 2408 | 2425 |
| 2409 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, | 2426 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, |
| 2410 &start_scale)); | 2427 &start_scale)); |
| 2411 EXPECT_EQ(6.f, start_scale); | 2428 EXPECT_EQ(6.f, start_scale); |
| 2412 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE, | 2429 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE, |
| 2413 &start_scale)); | 2430 &start_scale)); |
| 2414 EXPECT_EQ(0.f, start_scale); | 2431 EXPECT_EQ(0.f, start_scale); |
| 2415 | 2432 |
| 2416 animations_impl->ActivateAnimations(); | 2433 animations_impl->ActivateAnimations(); |
| 2417 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, | 2434 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2455 TransformOperations operations1; | 2472 TransformOperations operations1; |
| 2456 curve1->AddKeyframe( | 2473 curve1->AddKeyframe( |
| 2457 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2474 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 2458 operations1.AppendScale(2.0, 3.0, 4.0); | 2475 operations1.AppendScale(2.0, 3.0, 4.0); |
| 2459 curve1->AddKeyframe(TransformKeyframe::Create( | 2476 curve1->AddKeyframe(TransformKeyframe::Create( |
| 2460 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 2477 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
| 2461 | 2478 |
| 2462 std::unique_ptr<Animation> animation( | 2479 std::unique_ptr<Animation> animation( |
| 2463 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); | 2480 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); |
| 2464 animation->set_affects_active_elements(false); | 2481 animation->set_affects_active_elements(false); |
| 2465 animations_impl->AddAnimation(std::move(animation)); | 2482 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
| 2466 | 2483 |
| 2467 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, | 2484 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, |
| 2468 &max_scale)); | 2485 &max_scale)); |
| 2469 EXPECT_EQ(4.f, max_scale); | 2486 EXPECT_EQ(4.f, max_scale); |
| 2470 EXPECT_TRUE( | 2487 EXPECT_TRUE( |
| 2471 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); | 2488 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); |
| 2472 EXPECT_EQ(0.f, max_scale); | 2489 EXPECT_EQ(0.f, max_scale); |
| 2473 | 2490 |
| 2474 animations_impl->ActivateAnimations(); | 2491 animations_impl->ActivateAnimations(); |
| 2475 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, | 2492 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, |
| 2476 &max_scale)); | 2493 &max_scale)); |
| 2477 EXPECT_EQ(4.f, max_scale); | 2494 EXPECT_EQ(4.f, max_scale); |
| 2478 EXPECT_TRUE( | 2495 EXPECT_TRUE( |
| 2479 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); | 2496 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); |
| 2480 EXPECT_EQ(4.f, max_scale); | 2497 EXPECT_EQ(4.f, max_scale); |
| 2481 | 2498 |
| 2482 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( | 2499 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( |
| 2483 KeyframedTransformAnimationCurve::Create()); | 2500 KeyframedTransformAnimationCurve::Create()); |
| 2484 | 2501 |
| 2485 TransformOperations operations2; | 2502 TransformOperations operations2; |
| 2486 curve2->AddKeyframe( | 2503 curve2->AddKeyframe( |
| 2487 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 2504 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
| 2488 operations2.AppendScale(6.0, 5.0, 4.0); | 2505 operations2.AppendScale(6.0, 5.0, 4.0); |
| 2489 curve2->AddKeyframe(TransformKeyframe::Create( | 2506 curve2->AddKeyframe(TransformKeyframe::Create( |
| 2490 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2507 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
| 2491 | 2508 |
| 2492 animation = | 2509 animation = |
| 2493 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); | 2510 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); |
| 2494 animation->set_affects_active_elements(false); | 2511 animation->set_affects_active_elements(false); |
| 2495 animations_impl->AddAnimation(std::move(animation)); | 2512 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
| 2496 | 2513 |
| 2497 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, | 2514 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, |
| 2498 &max_scale)); | 2515 &max_scale)); |
| 2499 EXPECT_EQ(6.f, max_scale); | 2516 EXPECT_EQ(6.f, max_scale); |
| 2500 EXPECT_TRUE( | 2517 EXPECT_TRUE( |
| 2501 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); | 2518 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); |
| 2502 EXPECT_EQ(4.f, max_scale); | 2519 EXPECT_EQ(4.f, max_scale); |
| 2503 | 2520 |
| 2504 animations_impl->ActivateAnimations(); | 2521 animations_impl->ActivateAnimations(); |
| 2505 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, | 2522 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, |
| 2506 &max_scale)); | 2523 &max_scale)); |
| 2507 EXPECT_EQ(6.f, max_scale); | 2524 EXPECT_EQ(6.f, max_scale); |
| 2508 EXPECT_TRUE( | 2525 EXPECT_TRUE( |
| 2509 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); | 2526 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); |
| 2510 EXPECT_EQ(6.f, max_scale); | 2527 EXPECT_EQ(6.f, max_scale); |
| 2511 | 2528 |
| 2512 std::unique_ptr<KeyframedTransformAnimationCurve> curve3( | 2529 std::unique_ptr<KeyframedTransformAnimationCurve> curve3( |
| 2513 KeyframedTransformAnimationCurve::Create()); | 2530 KeyframedTransformAnimationCurve::Create()); |
| 2514 | 2531 |
| 2515 TransformOperations operations3; | 2532 TransformOperations operations3; |
| 2516 curve3->AddKeyframe( | 2533 curve3->AddKeyframe( |
| 2517 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); | 2534 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); |
| 2518 operations3.AppendPerspective(6.0); | 2535 operations3.AppendPerspective(6.0); |
| 2519 curve3->AddKeyframe(TransformKeyframe::Create( | 2536 curve3->AddKeyframe(TransformKeyframe::Create( |
| 2520 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); | 2537 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); |
| 2521 | 2538 |
| 2522 animation = | 2539 animation = |
| 2523 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); | 2540 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); |
| 2524 animation->set_affects_active_elements(false); | 2541 animation->set_affects_active_elements(false); |
| 2525 animations_impl->AddAnimation(std::move(animation)); | 2542 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
| 2526 | 2543 |
| 2527 EXPECT_FALSE(animations_impl->MaximumTargetScale(ElementListType::PENDING, | 2544 EXPECT_FALSE(animations_impl->MaximumTargetScale(ElementListType::PENDING, |
| 2528 &max_scale)); | 2545 &max_scale)); |
| 2529 EXPECT_TRUE( | 2546 EXPECT_TRUE( |
| 2530 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); | 2547 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); |
| 2531 EXPECT_EQ(6.f, max_scale); | 2548 EXPECT_EQ(6.f, max_scale); |
| 2532 | 2549 |
| 2533 animations_impl->ActivateAnimations(); | 2550 animations_impl->ActivateAnimations(); |
| 2534 EXPECT_FALSE(animations_impl->MaximumTargetScale(ElementListType::PENDING, | 2551 EXPECT_FALSE(animations_impl->MaximumTargetScale(ElementListType::PENDING, |
| 2535 &max_scale)); | 2552 &max_scale)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2565 curve1->AddKeyframe( | 2582 curve1->AddKeyframe( |
| 2566 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2583 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 2567 TransformOperations operations2; | 2584 TransformOperations operations2; |
| 2568 operations2.AppendScale(4.0, 5.0, 6.0); | 2585 operations2.AppendScale(4.0, 5.0, 6.0); |
| 2569 curve1->AddKeyframe(TransformKeyframe::Create( | 2586 curve1->AddKeyframe(TransformKeyframe::Create( |
| 2570 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2587 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
| 2571 | 2588 |
| 2572 std::unique_ptr<Animation> animation_owned( | 2589 std::unique_ptr<Animation> animation_owned( |
| 2573 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); | 2590 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); |
| 2574 Animation* animation = animation_owned.get(); | 2591 Animation* animation = animation_owned.get(); |
| 2575 animations_impl->AddAnimation(std::move(animation_owned)); | 2592 AddAnimationToElementAnimations(animations_impl.get(), |
| 2593 std::move(animation_owned)); |
| 2576 | 2594 |
| 2577 float max_scale = 0.f; | 2595 float max_scale = 0.f; |
| 2578 | 2596 |
| 2579 EXPECT_GT(animation->playback_rate(), 0.0); | 2597 EXPECT_GT(animation->playback_rate(), 0.0); |
| 2580 | 2598 |
| 2581 // NORMAL direction with positive playback rate. | 2599 // NORMAL direction with positive playback rate. |
| 2582 animation->set_direction(Animation::Direction::NORMAL); | 2600 animation->set_direction(Animation::Direction::NORMAL); |
| 2583 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, | 2601 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, |
| 2584 &max_scale)); | 2602 &max_scale)); |
| 2585 EXPECT_EQ(6.f, max_scale); | 2603 EXPECT_EQ(6.f, max_scale); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2880 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( | 2898 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2881 element_id_, ElementListType::ACTIVE)); | 2899 element_id_, ElementListType::ACTIVE)); |
| 2882 | 2900 |
| 2883 animations_impl->Animate(kInitialTickTime + | 2901 animations_impl->Animate(kInitialTickTime + |
| 2884 TimeDelta::FromMilliseconds(2000)); | 2902 TimeDelta::FromMilliseconds(2000)); |
| 2885 animations_impl->UpdateState(true, events.get()); | 2903 animations_impl->UpdateState(true, events.get()); |
| 2886 | 2904 |
| 2887 animations->NotifyAnimationStarted(events->events_[0]); | 2905 animations->NotifyAnimationStarted(events->events_[0]); |
| 2888 events->events_.clear(); | 2906 events->events_.clear(); |
| 2889 | 2907 |
| 2890 animations->RemoveAnimation(animation_id); | 2908 RemoveAnimationFromElementAnimations(animations.get(), animation_id); |
| 2891 EXPECT_FALSE(client_.GetHasPotentialTransformAnimation( | 2909 EXPECT_FALSE(client_.GetHasPotentialTransformAnimation( |
| 2892 element_id_, ElementListType::ACTIVE)); | 2910 element_id_, ElementListType::ACTIVE)); |
| 2893 EXPECT_FALSE(client_.GetTransformIsCurrentlyAnimating( | 2911 EXPECT_FALSE(client_.GetTransformIsCurrentlyAnimating( |
| 2894 element_id_, ElementListType::ACTIVE)); | 2912 element_id_, ElementListType::ACTIVE)); |
| 2895 | 2913 |
| 2896 animations->PushPropertiesTo(animations_impl.get()); | 2914 animations->PushPropertiesTo(animations_impl.get()); |
| 2897 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( | 2915 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( |
| 2898 element_id_, ElementListType::PENDING)); | 2916 element_id_, ElementListType::PENDING)); |
| 2899 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( | 2917 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2900 element_id_, ElementListType::PENDING)); | 2918 element_id_, ElementListType::PENDING)); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3098 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3116 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3099 element_id_, ElementListType::ACTIVE)); | 3117 element_id_, ElementListType::ACTIVE)); |
| 3100 | 3118 |
| 3101 animations_impl->Animate(kInitialTickTime + | 3119 animations_impl->Animate(kInitialTickTime + |
| 3102 TimeDelta::FromMilliseconds(2000)); | 3120 TimeDelta::FromMilliseconds(2000)); |
| 3103 animations_impl->UpdateState(true, events.get()); | 3121 animations_impl->UpdateState(true, events.get()); |
| 3104 | 3122 |
| 3105 animations->NotifyAnimationStarted(events->events_[0]); | 3123 animations->NotifyAnimationStarted(events->events_[0]); |
| 3106 events->events_.clear(); | 3124 events->events_.clear(); |
| 3107 | 3125 |
| 3108 animations->RemoveAnimation(animation_id); | 3126 RemoveAnimationFromElementAnimations(animations.get(), animation_id); |
| 3109 EXPECT_FALSE(client_.GetHasPotentialOpacityAnimation( | 3127 EXPECT_FALSE(client_.GetHasPotentialOpacityAnimation( |
| 3110 element_id_, ElementListType::ACTIVE)); | 3128 element_id_, ElementListType::ACTIVE)); |
| 3111 EXPECT_FALSE(client_.GetOpacityIsCurrentlyAnimating(element_id_, | 3129 EXPECT_FALSE(client_.GetOpacityIsCurrentlyAnimating(element_id_, |
| 3112 ElementListType::ACTIVE)); | 3130 ElementListType::ACTIVE)); |
| 3113 | 3131 |
| 3114 animations->PushPropertiesTo(animations_impl.get()); | 3132 animations->PushPropertiesTo(animations_impl.get()); |
| 3115 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( | 3133 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( |
| 3116 element_id_, ElementListType::PENDING)); | 3134 element_id_, ElementListType::PENDING)); |
| 3117 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3135 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3118 element_id_, ElementListType::PENDING)); | 3136 element_id_, ElementListType::PENDING)); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3315 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( | 3333 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3316 element_id_, ElementListType::ACTIVE)); | 3334 element_id_, ElementListType::ACTIVE)); |
| 3317 | 3335 |
| 3318 animations_impl->Animate(kInitialTickTime + | 3336 animations_impl->Animate(kInitialTickTime + |
| 3319 TimeDelta::FromMilliseconds(2000)); | 3337 TimeDelta::FromMilliseconds(2000)); |
| 3320 animations_impl->UpdateState(true, events.get()); | 3338 animations_impl->UpdateState(true, events.get()); |
| 3321 | 3339 |
| 3322 animations->NotifyAnimationStarted(events->events_[0]); | 3340 animations->NotifyAnimationStarted(events->events_[0]); |
| 3323 events->events_.clear(); | 3341 events->events_.clear(); |
| 3324 | 3342 |
| 3325 animations->RemoveAnimation(animation_id); | 3343 RemoveAnimationFromElementAnimations(animations.get(), animation_id); |
| 3326 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_, | 3344 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_, |
| 3327 ElementListType::ACTIVE)); | 3345 ElementListType::ACTIVE)); |
| 3328 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_, | 3346 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_, |
| 3329 ElementListType::ACTIVE)); | 3347 ElementListType::ACTIVE)); |
| 3330 | 3348 |
| 3331 animations->PushPropertiesTo(animations_impl.get()); | 3349 animations->PushPropertiesTo(animations_impl.get()); |
| 3332 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( | 3350 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( |
| 3333 element_id_, ElementListType::PENDING)); | 3351 element_id_, ElementListType::PENDING)); |
| 3334 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3352 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3335 element_id_, ElementListType::PENDING)); | 3353 element_id_, ElementListType::PENDING)); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3475 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); | 3493 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); |
| 3476 EXPECT_EQ(0.5f, | 3494 EXPECT_EQ(0.5f, |
| 3477 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 3495 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 3478 | 3496 |
| 3479 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) | 3497 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) |
| 3480 ->affects_pending_elements()); | 3498 ->affects_pending_elements()); |
| 3481 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) | 3499 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) |
| 3482 ->affects_active_elements()); | 3500 ->affects_active_elements()); |
| 3483 | 3501 |
| 3484 // Delete the animation on the main-thread animations. | 3502 // Delete the animation on the main-thread animations. |
| 3485 animations->RemoveAnimation( | 3503 RemoveAnimationFromElementAnimations( |
| 3504 animations.get(), |
| 3486 animations->GetAnimation(TargetProperty::OPACITY)->id()); | 3505 animations->GetAnimation(TargetProperty::OPACITY)->id()); |
| 3487 animations->PushPropertiesTo(animations_impl.get()); | 3506 animations->PushPropertiesTo(animations_impl.get()); |
| 3488 | 3507 |
| 3489 // The animation should no longer affect pending elements. | 3508 // The animation should no longer affect pending elements. |
| 3490 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id) | 3509 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id) |
| 3491 ->affects_pending_elements()); | 3510 ->affects_pending_elements()); |
| 3492 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) | 3511 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) |
| 3493 ->affects_active_elements()); | 3512 ->affects_active_elements()); |
| 3494 | 3513 |
| 3495 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 3514 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3522 const int first_animation_id = AddOpacityTransitionToElementAnimations( | 3541 const int first_animation_id = AddOpacityTransitionToElementAnimations( |
| 3523 animations.get(), 1, 0.f, 1.f, true); | 3542 animations.get(), 1, 0.f, 1.f, true); |
| 3524 | 3543 |
| 3525 animations->PushPropertiesTo(animations_impl.get()); | 3544 animations->PushPropertiesTo(animations_impl.get()); |
| 3526 animations_impl->ActivateAnimations(); | 3545 animations_impl->ActivateAnimations(); |
| 3527 animations_impl->Animate(kInitialTickTime); | 3546 animations_impl->Animate(kInitialTickTime); |
| 3528 animations_impl->UpdateState(true, events.get()); | 3547 animations_impl->UpdateState(true, events.get()); |
| 3529 | 3548 |
| 3530 // Remove the first animation from the main-thread animations, and add a | 3549 // Remove the first animation from the main-thread animations, and add a |
| 3531 // new animation affecting the same property. | 3550 // new animation affecting the same property. |
| 3532 animations->RemoveAnimation( | 3551 RemoveAnimationFromElementAnimations( |
| 3552 animations.get(), |
| 3533 animations->GetAnimation(TargetProperty::OPACITY)->id()); | 3553 animations->GetAnimation(TargetProperty::OPACITY)->id()); |
| 3534 const int second_animation_id = AddOpacityTransitionToElementAnimations( | 3554 const int second_animation_id = AddOpacityTransitionToElementAnimations( |
| 3535 animations.get(), 1, 1.f, 0.5f, true); | 3555 animations.get(), 1, 1.f, 0.5f, true); |
| 3536 animations->PushPropertiesTo(animations_impl.get()); | 3556 animations->PushPropertiesTo(animations_impl.get()); |
| 3537 | 3557 |
| 3538 // The original animation should only affect active elements, and the new | 3558 // The original animation should only affect active elements, and the new |
| 3539 // animation should only affect pending elements. | 3559 // animation should only affect pending elements. |
| 3540 EXPECT_FALSE(animations_impl->GetAnimationById(first_animation_id) | 3560 EXPECT_FALSE(animations_impl->GetAnimationById(first_animation_id) |
| 3541 ->affects_pending_elements()); | 3561 ->affects_pending_elements()); |
| 3542 EXPECT_TRUE(animations_impl->GetAnimationById(first_animation_id) | 3562 EXPECT_TRUE(animations_impl->GetAnimationById(first_animation_id) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3593 AttachTimelinePlayerLayer(); | 3613 AttachTimelinePlayerLayer(); |
| 3594 | 3614 |
| 3595 scoped_refptr<ElementAnimations> animations = element_animations(); | 3615 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 3596 | 3616 |
| 3597 // Create an animation that initially affects only pending elements. | 3617 // Create an animation that initially affects only pending elements. |
| 3598 std::unique_ptr<Animation> animation(CreateAnimation( | 3618 std::unique_ptr<Animation> animation(CreateAnimation( |
| 3599 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 3619 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 3600 1, TargetProperty::OPACITY)); | 3620 1, TargetProperty::OPACITY)); |
| 3601 animation->set_affects_active_elements(false); | 3621 animation->set_affects_active_elements(false); |
| 3602 | 3622 |
| 3603 animations->AddAnimation(std::move(animation)); | 3623 AddAnimationToElementAnimations(animations.get(), std::move(animation)); |
| 3604 animations->Animate(kInitialTickTime); | 3624 animations->Animate(kInitialTickTime); |
| 3605 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( | 3625 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( |
| 3606 TargetProperty::OPACITY, ElementListType::PENDING)); | 3626 TargetProperty::OPACITY, ElementListType::PENDING)); |
| 3607 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3627 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
| 3608 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3628 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
| 3609 animations->UpdateState(true, nullptr); | 3629 animations->UpdateState(true, nullptr); |
| 3610 EXPECT_TRUE(animations->HasActiveAnimation()); | 3630 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 3611 | 3631 |
| 3612 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( | 3632 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( |
| 3613 TargetProperty::OPACITY, ElementListType::PENDING)); | 3633 TargetProperty::OPACITY, ElementListType::PENDING)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3667 | 3687 |
| 3668 // Create an animation that initially affects only pending elements, and has | 3688 // Create an animation that initially affects only pending elements, and has |
| 3669 // a start delay of 2 seconds. | 3689 // a start delay of 2 seconds. |
| 3670 std::unique_ptr<Animation> animation(CreateAnimation( | 3690 std::unique_ptr<Animation> animation(CreateAnimation( |
| 3671 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 3691 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 3672 1, TargetProperty::OPACITY)); | 3692 1, TargetProperty::OPACITY)); |
| 3673 animation->set_fill_mode(Animation::FillMode::NONE); | 3693 animation->set_fill_mode(Animation::FillMode::NONE); |
| 3674 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000)); | 3694 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000)); |
| 3675 animation->set_affects_active_elements(false); | 3695 animation->set_affects_active_elements(false); |
| 3676 | 3696 |
| 3677 animations->AddAnimation(std::move(animation)); | 3697 AddAnimationToElementAnimations(animations.get(), std::move(animation)); |
| 3678 | 3698 |
| 3679 animations->Animate(kInitialTickTime); | 3699 animations->Animate(kInitialTickTime); |
| 3680 | 3700 |
| 3681 // Since the animation has a start delay, the elements it affects have a | 3701 // Since the animation has a start delay, the elements it affects have a |
| 3682 // potentially running transform animation but aren't currently animating | 3702 // potentially running transform animation but aren't currently animating |
| 3683 // transform. | 3703 // transform. |
| 3684 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( | 3704 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( |
| 3685 TargetProperty::OPACITY, ElementListType::PENDING)); | 3705 TargetProperty::OPACITY, ElementListType::PENDING)); |
| 3686 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( | 3706 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( |
| 3687 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3707 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3735 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( | 3755 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( |
| 3736 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3756 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
| 3737 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3757 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
| 3738 TargetProperty::OPACITY, ElementListType::PENDING)); | 3758 TargetProperty::OPACITY, ElementListType::PENDING)); |
| 3739 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3759 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
| 3740 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3760 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
| 3741 } | 3761 } |
| 3742 | 3762 |
| 3743 } // namespace | 3763 } // namespace |
| 3744 } // namespace cc | 3764 } // namespace cc |
| OLD | NEW |