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)); |
1683 // AddAnimationToElementAnimations(animations.get(), std::move(to_add)); | |
1681 | 1684 |
1682 animations->Animate(kInitialTickTime); | 1685 animations->Animate(kInitialTickTime); |
1683 animations->UpdateState(true, events.get()); | 1686 animations->UpdateState(true, events.get()); |
1684 EXPECT_TRUE(animations->HasActiveAnimation()); | 1687 EXPECT_TRUE(animations->HasActiveAnimation()); |
1685 Animation* active_animation = | 1688 Animation* active_animation = |
1686 animations->GetAnimation(TargetProperty::OPACITY); | 1689 animations->GetAnimation(TargetProperty::OPACITY); |
1687 EXPECT_TRUE(active_animation); | 1690 EXPECT_TRUE(active_animation); |
1688 EXPECT_TRUE(active_animation->needs_synchronized_start_time()); | 1691 EXPECT_TRUE(active_animation->needs_synchronized_start_time()); |
1689 | 1692 |
1693 EXPECT_TRUE(animations->needs_push_properties()); | |
1690 animations->PushPropertiesTo(animations_impl.get()); | 1694 animations->PushPropertiesTo(animations_impl.get()); |
1691 animations_impl->ActivateAnimations(); | 1695 animations_impl->ActivateAnimations(); |
1692 | 1696 |
1693 active_animation = animations_impl->GetAnimation(TargetProperty::OPACITY); | 1697 active_animation = animations_impl->GetAnimation(TargetProperty::OPACITY); |
1694 EXPECT_TRUE(active_animation); | 1698 EXPECT_TRUE(active_animation); |
1695 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1699 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
1696 active_animation->run_state()); | 1700 active_animation->run_state()); |
1697 } | 1701 } |
1698 | 1702 |
1699 // Tests that skipping a call to UpdateState works as expected. | 1703 // Tests that skipping a call to UpdateState works as expected. |
1700 TEST_F(ElementAnimationsTest, SkipUpdateState) { | 1704 TEST_F(ElementAnimationsTest, SkipUpdateState) { |
1701 CreateTestLayer(true, false); | 1705 CreateTestLayer(true, false); |
1702 AttachTimelinePlayerLayer(); | 1706 AttachTimelinePlayerLayer(); |
1703 | 1707 |
1704 scoped_refptr<ElementAnimations> animations = element_animations(); | 1708 scoped_refptr<ElementAnimations> animations = element_animations(); |
1705 | 1709 |
1706 auto events = host_impl_->CreateEvents(); | 1710 auto events = host_impl_->CreateEvents(); |
1707 | 1711 |
1708 std::unique_ptr<Animation> first_animation(CreateAnimation( | 1712 std::unique_ptr<Animation> first_animation(CreateAnimation( |
1709 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, | 1713 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, |
1710 TargetProperty::TRANSFORM)); | 1714 TargetProperty::TRANSFORM)); |
1711 first_animation->set_is_controlling_instance_for_test(true); | 1715 first_animation->set_is_controlling_instance_for_test(true); |
1712 animations->AddAnimation(std::move(first_animation)); | 1716 AddAnimationToElementAnimations(animations.get(), std::move(first_animation)); |
1713 | 1717 |
1714 animations->Animate(kInitialTickTime); | 1718 animations->Animate(kInitialTickTime); |
1715 animations->UpdateState(true, events.get()); | 1719 animations->UpdateState(true, events.get()); |
1716 | 1720 |
1717 std::unique_ptr<Animation> second_animation(CreateAnimation( | 1721 std::unique_ptr<Animation> second_animation(CreateAnimation( |
1718 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 1722 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
1719 2, TargetProperty::OPACITY)); | 1723 2, TargetProperty::OPACITY)); |
1720 second_animation->set_is_controlling_instance_for_test(true); | 1724 second_animation->set_is_controlling_instance_for_test(true); |
1721 animations->AddAnimation(std::move(second_animation)); | 1725 AddAnimationToElementAnimations(animations.get(), |
1726 std::move(second_animation)); | |
1722 | 1727 |
1723 // Animate but don't UpdateState. | 1728 // Animate but don't UpdateState. |
1724 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1729 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1725 | 1730 |
1726 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1731 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
1727 events = host_impl_->CreateEvents(); | 1732 events = host_impl_->CreateEvents(); |
1728 animations->UpdateState(true, events.get()); | 1733 animations->UpdateState(true, events.get()); |
1729 | 1734 |
1730 // Should have one STARTED event and one FINISHED event. | 1735 // Should have one STARTED event and one FINISHED event. |
1731 EXPECT_EQ(2u, events->events_.size()); | 1736 EXPECT_EQ(2u, events->events_.size()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1822 | 1827 |
1823 TransformOperations operations1; | 1828 TransformOperations operations1; |
1824 curve1->AddKeyframe( | 1829 curve1->AddKeyframe( |
1825 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 1830 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
1826 operations1.AppendTranslate(10.0, 15.0, 0.0); | 1831 operations1.AppendTranslate(10.0, 15.0, 0.0); |
1827 curve1->AddKeyframe(TransformKeyframe::Create( | 1832 curve1->AddKeyframe(TransformKeyframe::Create( |
1828 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 1833 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
1829 | 1834 |
1830 std::unique_ptr<Animation> animation( | 1835 std::unique_ptr<Animation> animation( |
1831 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); | 1836 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); |
1832 animations_impl->AddAnimation(std::move(animation)); | 1837 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
1833 | 1838 |
1834 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( | 1839 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( |
1835 KeyframedTransformAnimationCurve::Create()); | 1840 KeyframedTransformAnimationCurve::Create()); |
1836 | 1841 |
1837 TransformOperations operations2; | 1842 TransformOperations operations2; |
1838 curve2->AddKeyframe( | 1843 curve2->AddKeyframe( |
1839 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 1844 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
1840 operations2.AppendScale(2.0, 3.0, 4.0); | 1845 operations2.AppendScale(2.0, 3.0, 4.0); |
1841 curve2->AddKeyframe(TransformKeyframe::Create( | 1846 curve2->AddKeyframe(TransformKeyframe::Create( |
1842 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 1847 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
1843 | 1848 |
1844 animation = | 1849 animation = |
1845 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); | 1850 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); |
1846 animations_impl->AddAnimation(std::move(animation)); | 1851 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
1847 | 1852 |
1848 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); | 1853 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); |
1849 gfx::BoxF bounds; | 1854 gfx::BoxF bounds; |
1850 | 1855 |
1851 EXPECT_TRUE(animations_impl->TransformAnimationBoundsForBox(box, &bounds)); | 1856 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(), | 1857 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), |
1853 bounds.ToString()); | 1858 bounds.ToString()); |
1854 | 1859 |
1855 animations_impl->GetAnimationById(1)->SetRunState(Animation::FINISHED, | 1860 animations_impl->GetAnimationById(1)->SetRunState(Animation::FINISHED, |
1856 TicksFromSecondsF(0.0)); | 1861 TicksFromSecondsF(0.0)); |
(...skipping 15 matching lines...) Expand all Loading... | |
1872 TransformOperations operations3; | 1877 TransformOperations operations3; |
1873 gfx::Transform transform3; | 1878 gfx::Transform transform3; |
1874 transform3.Scale3d(1.0, 2.0, 3.0); | 1879 transform3.Scale3d(1.0, 2.0, 3.0); |
1875 curve3->AddKeyframe( | 1880 curve3->AddKeyframe( |
1876 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); | 1881 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); |
1877 operations3.AppendMatrix(transform3); | 1882 operations3.AppendMatrix(transform3); |
1878 curve3->AddKeyframe(TransformKeyframe::Create( | 1883 curve3->AddKeyframe(TransformKeyframe::Create( |
1879 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); | 1884 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); |
1880 animation = | 1885 animation = |
1881 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); | 1886 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); |
1882 animations_impl->AddAnimation(std::move(animation)); | 1887 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
1883 EXPECT_FALSE(animations_impl->TransformAnimationBoundsForBox(box, &bounds)); | 1888 EXPECT_FALSE(animations_impl->TransformAnimationBoundsForBox(box, &bounds)); |
1884 } | 1889 } |
1885 | 1890 |
1886 // Tests that AbortAnimations aborts all animations targeting the specified | 1891 // Tests that AbortAnimations aborts all animations targeting the specified |
1887 // property. | 1892 // property. |
1888 TEST_F(ElementAnimationsTest, AbortAnimations) { | 1893 TEST_F(ElementAnimationsTest, AbortAnimations) { |
1889 CreateTestLayer(false, false); | 1894 CreateTestLayer(false, false); |
1890 AttachTimelinePlayerLayer(); | 1895 AttachTimelinePlayerLayer(); |
1891 | 1896 |
1892 scoped_refptr<ElementAnimations> animations = element_animations(); | 1897 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(); | 1945 scoped_refptr<ElementAnimations> animations = element_animations(); |
1941 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 1946 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
1942 | 1947 |
1943 int animation_id = AddOpacityTransitionToElementAnimations( | 1948 int animation_id = AddOpacityTransitionToElementAnimations( |
1944 animations.get(), 1.0, 0.f, 1.f, false); | 1949 animations.get(), 1.0, 0.f, 1.f, false); |
1945 | 1950 |
1946 animations->PushPropertiesTo(animations_impl.get()); | 1951 animations->PushPropertiesTo(animations_impl.get()); |
1947 animations_impl->ActivateAnimations(); | 1952 animations_impl->ActivateAnimations(); |
1948 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 1953 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
1949 | 1954 |
1950 animations->AbortAnimations(TargetProperty::OPACITY); | 1955 AbortAnimationsInElementAnimations(animations.get(), TargetProperty::OPACITY, |
1956 false); | |
1951 EXPECT_EQ(Animation::ABORTED, | 1957 EXPECT_EQ(Animation::ABORTED, |
1952 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1958 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); |
1953 EXPECT_FALSE(host_->animation_waiting_for_deletion()); | 1959 EXPECT_FALSE(host_->needs_push_properties()); |
1954 EXPECT_FALSE(host_impl_->animation_waiting_for_deletion()); | 1960 EXPECT_FALSE(host_impl_->needs_push_properties()); |
1955 | 1961 |
1956 animations->Animate(kInitialTickTime); | 1962 animations->Animate(kInitialTickTime); |
1957 animations->UpdateState(true, nullptr); | 1963 animations->UpdateState(true, nullptr); |
1958 EXPECT_FALSE(host_->animation_waiting_for_deletion()); | 1964 EXPECT_FALSE(host_->needs_push_properties()); |
1959 EXPECT_EQ(Animation::ABORTED, | 1965 EXPECT_EQ(Animation::ABORTED, |
1960 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1966 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); |
1961 | 1967 |
1968 EXPECT_TRUE(animations->needs_push_properties()); | |
1962 animations->PushPropertiesTo(animations_impl.get()); | 1969 animations->PushPropertiesTo(animations_impl.get()); |
1963 EXPECT_FALSE(animations->GetAnimationById(animation_id)); | 1970 EXPECT_FALSE(animations->GetAnimationById(animation_id)); |
1964 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); | 1971 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); |
1965 } | 1972 } |
1966 | 1973 |
1967 // An animation aborted on the impl thread should get deleted on both threads. | 1974 // An animation aborted on the impl thread should get deleted on both threads. |
1968 TEST_F(ElementAnimationsTest, ImplThreadAbortedAnimationGetsDeleted) { | 1975 TEST_F(ElementAnimationsTest, ImplThreadAbortedAnimationGetsDeleted) { |
1969 CreateTestLayer(true, false); | 1976 CreateTestLayer(true, false); |
1970 AttachTimelinePlayerLayer(); | 1977 AttachTimelinePlayerLayer(); |
1971 CreateImplTimelineAndPlayer(); | 1978 CreateImplTimelineAndPlayer(); |
1972 | 1979 |
1973 scoped_refptr<ElementAnimations> animations = element_animations(); | 1980 scoped_refptr<ElementAnimations> animations = element_animations(); |
1974 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 1981 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
1975 | 1982 |
1976 TestAnimationDelegate delegate; | 1983 TestAnimationDelegate delegate; |
1977 player_->set_animation_delegate(&delegate); | 1984 player_->set_animation_delegate(&delegate); |
1978 | 1985 |
1979 int animation_id = AddOpacityTransitionToElementAnimations( | 1986 int animation_id = AddOpacityTransitionToElementAnimations( |
1980 animations.get(), 1.0, 0.f, 1.f, false); | 1987 animations.get(), 1.0, 0.f, 1.f, false); |
1981 | 1988 |
1982 animations->PushPropertiesTo(animations_impl.get()); | 1989 animations->PushPropertiesTo(animations_impl.get()); |
1983 animations_impl->ActivateAnimations(); | 1990 animations_impl->ActivateAnimations(); |
1984 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 1991 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
1985 | 1992 |
1986 animations_impl->AbortAnimations(TargetProperty::OPACITY); | 1993 animations_impl->AbortAnimations(TargetProperty::OPACITY); |
1987 EXPECT_EQ( | 1994 EXPECT_EQ( |
1988 Animation::ABORTED, | 1995 Animation::ABORTED, |
1989 animations_impl->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1996 animations_impl->GetAnimation(TargetProperty::OPACITY)->run_state()); |
1990 EXPECT_FALSE(host_->animation_waiting_for_deletion()); | 1997 EXPECT_FALSE(host_->needs_push_properties()); |
1991 EXPECT_FALSE(host_impl_->animation_waiting_for_deletion()); | 1998 EXPECT_FALSE(host_impl_->needs_push_properties()); |
1992 | 1999 |
1993 auto events = host_impl_->CreateEvents(); | 2000 auto events = host_impl_->CreateEvents(); |
1994 animations_impl->Animate(kInitialTickTime); | 2001 animations_impl->Animate(kInitialTickTime); |
1995 animations_impl->UpdateState(true, events.get()); | 2002 animations_impl->UpdateState(true, events.get()); |
1996 EXPECT_TRUE(host_impl_->animation_waiting_for_deletion()); | 2003 EXPECT_TRUE(host_impl_->needs_push_properties()); |
1997 EXPECT_EQ(1u, events->events_.size()); | 2004 EXPECT_EQ(1u, events->events_.size()); |
1998 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[0].type); | 2005 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[0].type); |
1999 EXPECT_EQ( | 2006 EXPECT_EQ( |
2000 Animation::WAITING_FOR_DELETION, | 2007 Animation::WAITING_FOR_DELETION, |
2001 animations_impl->GetAnimation(TargetProperty::OPACITY)->run_state()); | 2008 animations_impl->GetAnimation(TargetProperty::OPACITY)->run_state()); |
2002 | 2009 |
2003 animations->NotifyAnimationAborted(events->events_[0]); | 2010 animations->NotifyAnimationAborted(events->events_[0]); |
2004 EXPECT_EQ(Animation::ABORTED, | 2011 EXPECT_EQ(Animation::ABORTED, |
2005 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); | 2012 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); |
2006 EXPECT_TRUE(delegate.aborted()); | 2013 EXPECT_TRUE(delegate.aborted()); |
2007 | 2014 |
2008 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 2015 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
2009 animations->UpdateState(true, nullptr); | 2016 animations->UpdateState(true, nullptr); |
2010 EXPECT_TRUE(host_->animation_waiting_for_deletion()); | 2017 EXPECT_TRUE(host_->needs_push_properties()); |
2011 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 2018 EXPECT_EQ(Animation::WAITING_FOR_DELETION, |
2012 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); | 2019 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); |
2013 | 2020 |
2014 animations->PushPropertiesTo(animations_impl.get()); | 2021 animations->PushPropertiesTo(animations_impl.get()); |
2015 animations_impl->ActivateAnimations(); | 2022 animations_impl->ActivateAnimations(); |
2016 EXPECT_FALSE(animations->GetAnimationById(animation_id)); | 2023 EXPECT_FALSE(animations->GetAnimationById(animation_id)); |
2017 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); | 2024 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); |
2018 } | 2025 } |
2019 | 2026 |
2020 // Test that an impl-only scroll offset animation that needs to be completed on | 2027 // 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); | 2045 gfx::ScrollOffset target_value(300.f, 200.f); |
2039 std::unique_ptr<ScrollOffsetAnimationCurve> curve( | 2046 std::unique_ptr<ScrollOffsetAnimationCurve> curve( |
2040 ScrollOffsetAnimationCurve::Create( | 2047 ScrollOffsetAnimationCurve::Create( |
2041 target_value, CubicBezierTimingFunction::CreatePreset( | 2048 target_value, CubicBezierTimingFunction::CreatePreset( |
2042 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 2049 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
2043 curve->SetInitialValue(initial_value); | 2050 curve->SetInitialValue(initial_value); |
2044 std::unique_ptr<Animation> animation(Animation::Create( | 2051 std::unique_ptr<Animation> animation(Animation::Create( |
2045 std::move(curve), animation_id, 0, TargetProperty::SCROLL_OFFSET)); | 2052 std::move(curve), animation_id, 0, TargetProperty::SCROLL_OFFSET)); |
2046 animation->set_start_time(TicksFromSecondsF(123)); | 2053 animation->set_start_time(TicksFromSecondsF(123)); |
2047 animation->set_is_impl_only(true); | 2054 animation->set_is_impl_only(true); |
2048 animations_impl->AddAnimation(std::move(animation)); | 2055 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
2049 | 2056 |
2050 animations->PushPropertiesTo(animations_impl.get()); | 2057 animations->PushPropertiesTo(animations_impl.get()); |
2051 animations_impl->ActivateAnimations(); | 2058 animations_impl->ActivateAnimations(); |
2052 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 2059 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
2053 | 2060 |
2054 const bool needs_completion = true; | 2061 const bool needs_completion = true; |
2055 animations_impl->AbortAnimations(TargetProperty::SCROLL_OFFSET, | 2062 AbortAnimationsInElementAnimations( |
2056 needs_completion); | 2063 animations_impl.get(), TargetProperty::SCROLL_OFFSET, needs_completion); |
2057 EXPECT_EQ(Animation::ABORTED_BUT_NEEDS_COMPLETION, | 2064 EXPECT_EQ(Animation::ABORTED_BUT_NEEDS_COMPLETION, |
2058 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) | 2065 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) |
2059 ->run_state()); | 2066 ->run_state()); |
2060 EXPECT_FALSE(host_->animation_waiting_for_deletion()); | 2067 EXPECT_FALSE(host_->needs_push_properties()); |
2061 EXPECT_FALSE(host_impl_->animation_waiting_for_deletion()); | 2068 EXPECT_FALSE(host_impl_->needs_push_properties()); |
2062 | 2069 |
2063 auto events = host_impl_->CreateEvents(); | 2070 auto events = host_impl_->CreateEvents(); |
2064 animations_impl->Animate(kInitialTickTime); | 2071 animations_impl->Animate(kInitialTickTime); |
2065 animations_impl->UpdateState(true, events.get()); | 2072 animations_impl->UpdateState(true, events.get()); |
2066 EXPECT_TRUE(delegate_impl.finished()); | 2073 EXPECT_TRUE(delegate_impl.finished()); |
2067 EXPECT_TRUE(host_impl_->animation_waiting_for_deletion()); | 2074 EXPECT_TRUE(host_impl_->needs_push_properties()); |
2068 EXPECT_EQ(1u, events->events_.size()); | 2075 EXPECT_EQ(1u, events->events_.size()); |
2069 EXPECT_EQ(AnimationEvent::TAKEOVER, events->events_[0].type); | 2076 EXPECT_EQ(AnimationEvent::TAKEOVER, events->events_[0].type); |
2070 EXPECT_EQ(123, events->events_[0].animation_start_time); | 2077 EXPECT_EQ(123, events->events_[0].animation_start_time); |
2071 EXPECT_EQ( | 2078 EXPECT_EQ( |
2072 target_value, | 2079 target_value, |
2073 events->events_[0].curve->ToScrollOffsetAnimationCurve()->target_value()); | 2080 events->events_[0].curve->ToScrollOffsetAnimationCurve()->target_value()); |
2074 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 2081 EXPECT_EQ(Animation::WAITING_FOR_DELETION, |
2075 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) | 2082 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) |
2076 ->run_state()); | 2083 ->run_state()); |
2077 | 2084 |
2078 animations->NotifyAnimationTakeover(events->events_[0]); | 2085 animations->NotifyAnimationTakeover(events->events_[0]); |
2079 EXPECT_TRUE(delegate.takeover()); | 2086 EXPECT_TRUE(delegate.takeover()); |
2087 // TODO(ymalik): How does it work? | |
2088 animations->SetNeedsPushProperties(); | |
loyso (OOO)
2016/08/22 07:48:27
It notifies blink about takover and then suddenly
ymalik
2016/08/22 14:40:01
The purpose of the Takeover notification is to con
| |
2080 | 2089 |
2090 EXPECT_TRUE(animations->needs_push_properties()); | |
2081 animations->PushPropertiesTo(animations_impl.get()); | 2091 animations->PushPropertiesTo(animations_impl.get()); |
2082 animations_impl->ActivateAnimations(); | 2092 animations_impl->ActivateAnimations(); |
2083 EXPECT_FALSE(animations->GetAnimationById(animation_id)); | 2093 EXPECT_FALSE(animations->GetAnimationById(animation_id)); |
2084 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); | 2094 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); |
2085 } | 2095 } |
2086 | 2096 |
2087 // Ensure that we only generate FINISHED events for animations in a group | 2097 // Ensure that we only generate FINISHED events for animations in a group |
2088 // once all animations in that group are finished. | 2098 // once all animations in that group are finished. |
2089 TEST_F(ElementAnimationsTest, FinishedEventsForGroup) { | 2099 TEST_F(ElementAnimationsTest, FinishedEventsForGroup) { |
2090 CreateTestLayer(true, false); | 2100 CreateTestLayer(true, false); |
2091 AttachTimelinePlayerLayer(); | 2101 AttachTimelinePlayerLayer(); |
2092 CreateImplTimelineAndPlayer(); | 2102 CreateImplTimelineAndPlayer(); |
2093 | 2103 |
2094 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 2104 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
2095 | 2105 |
2096 auto events = host_impl_->CreateEvents(); | 2106 auto events = host_impl_->CreateEvents(); |
2097 | 2107 |
2098 const int group_id = 1; | 2108 const int group_id = 1; |
2099 | 2109 |
2100 // Add two animations with the same group id but different durations. | 2110 // Add two animations with the same group id but different durations. |
2101 std::unique_ptr<Animation> first_animation(Animation::Create( | 2111 std::unique_ptr<Animation> first_animation(Animation::Create( |
2102 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(2.0)), 1, | 2112 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(2.0)), 1, |
2103 group_id, TargetProperty::TRANSFORM)); | 2113 group_id, TargetProperty::TRANSFORM)); |
2104 first_animation->set_is_controlling_instance_for_test(true); | 2114 first_animation->set_is_controlling_instance_for_test(true); |
2105 animations_impl->AddAnimation(std::move(first_animation)); | 2115 AddAnimationToElementAnimations(animations_impl.get(), |
2116 std::move(first_animation)); | |
2106 | 2117 |
2107 std::unique_ptr<Animation> second_animation(Animation::Create( | 2118 std::unique_ptr<Animation> second_animation(Animation::Create( |
2108 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 2119 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
2109 2, group_id, TargetProperty::OPACITY)); | 2120 2, group_id, TargetProperty::OPACITY)); |
2110 second_animation->set_is_controlling_instance_for_test(true); | 2121 second_animation->set_is_controlling_instance_for_test(true); |
2111 animations_impl->AddAnimation(std::move(second_animation)); | 2122 AddAnimationToElementAnimations(animations_impl.get(), |
2123 std::move(second_animation)); | |
2112 | 2124 |
2113 animations_impl->Animate(kInitialTickTime); | 2125 animations_impl->Animate(kInitialTickTime); |
2114 animations_impl->UpdateState(true, events.get()); | 2126 animations_impl->UpdateState(true, events.get()); |
2115 | 2127 |
2116 // Both animations should have started. | 2128 // Both animations should have started. |
2117 EXPECT_EQ(2u, events->events_.size()); | 2129 EXPECT_EQ(2u, events->events_.size()); |
2118 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); | 2130 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); |
2119 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); | 2131 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); |
2120 | 2132 |
2121 events = host_impl_->CreateEvents(); | 2133 events = host_impl_->CreateEvents(); |
(...skipping 29 matching lines...) Expand all Loading... | |
2151 | 2163 |
2152 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 2164 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
2153 | 2165 |
2154 auto events = host_impl_->CreateEvents(); | 2166 auto events = host_impl_->CreateEvents(); |
2155 | 2167 |
2156 // Add two animations with the same group id. | 2168 // Add two animations with the same group id. |
2157 std::unique_ptr<Animation> first_animation(CreateAnimation( | 2169 std::unique_ptr<Animation> first_animation(CreateAnimation( |
2158 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 1, | 2170 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 1, |
2159 TargetProperty::TRANSFORM)); | 2171 TargetProperty::TRANSFORM)); |
2160 first_animation->set_is_controlling_instance_for_test(true); | 2172 first_animation->set_is_controlling_instance_for_test(true); |
2161 animations_impl->AddAnimation(std::move(first_animation)); | 2173 AddAnimationToElementAnimations(animations_impl.get(), |
2174 std::move(first_animation)); | |
2162 | 2175 |
2163 std::unique_ptr<Animation> second_animation(CreateAnimation( | 2176 std::unique_ptr<Animation> second_animation(CreateAnimation( |
2164 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 2177 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
2165 1, TargetProperty::OPACITY)); | 2178 1, TargetProperty::OPACITY)); |
2166 second_animation->set_is_controlling_instance_for_test(true); | 2179 second_animation->set_is_controlling_instance_for_test(true); |
2167 animations_impl->AddAnimation(std::move(second_animation)); | 2180 AddAnimationToElementAnimations(animations_impl.get(), |
2181 std::move(second_animation)); | |
2168 | 2182 |
2169 animations_impl->Animate(kInitialTickTime); | 2183 animations_impl->Animate(kInitialTickTime); |
2170 animations_impl->UpdateState(true, events.get()); | 2184 animations_impl->UpdateState(true, events.get()); |
2171 | 2185 |
2172 // Both animations should have started. | 2186 // Both animations should have started. |
2173 EXPECT_EQ(2u, events->events_.size()); | 2187 EXPECT_EQ(2u, events->events_.size()); |
2174 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); | 2188 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); |
2175 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); | 2189 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); |
2176 | 2190 |
2177 animations_impl->AbortAnimations(TargetProperty::OPACITY); | 2191 animations_impl->AbortAnimations(TargetProperty::OPACITY); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2211 | 2225 |
2212 TransformOperations operations1; | 2226 TransformOperations operations1; |
2213 curve1->AddKeyframe( | 2227 curve1->AddKeyframe( |
2214 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2228 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
2215 operations1.AppendTranslate(10.0, 15.0, 0.0); | 2229 operations1.AppendTranslate(10.0, 15.0, 0.0); |
2216 curve1->AddKeyframe(TransformKeyframe::Create( | 2230 curve1->AddKeyframe(TransformKeyframe::Create( |
2217 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 2231 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
2218 | 2232 |
2219 std::unique_ptr<Animation> animation( | 2233 std::unique_ptr<Animation> animation( |
2220 Animation::Create(std::move(curve1), 2, 2, TargetProperty::TRANSFORM)); | 2234 Animation::Create(std::move(curve1), 2, 2, TargetProperty::TRANSFORM)); |
2221 animations_impl->AddAnimation(std::move(animation)); | 2235 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
2222 | 2236 |
2223 // Translations don't affect scale. | 2237 // Translations don't affect scale. |
2224 EXPECT_FALSE(animations_impl->HasAnimationThatAffectsScale()); | 2238 EXPECT_FALSE(animations_impl->HasAnimationThatAffectsScale()); |
2225 | 2239 |
2226 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( | 2240 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( |
2227 KeyframedTransformAnimationCurve::Create()); | 2241 KeyframedTransformAnimationCurve::Create()); |
2228 | 2242 |
2229 TransformOperations operations2; | 2243 TransformOperations operations2; |
2230 curve2->AddKeyframe( | 2244 curve2->AddKeyframe( |
2231 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 2245 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
2232 operations2.AppendScale(2.0, 3.0, 4.0); | 2246 operations2.AppendScale(2.0, 3.0, 4.0); |
2233 curve2->AddKeyframe(TransformKeyframe::Create( | 2247 curve2->AddKeyframe(TransformKeyframe::Create( |
2234 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2248 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
2235 | 2249 |
2236 animation = | 2250 animation = |
2237 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM); | 2251 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM); |
2238 animations_impl->AddAnimation(std::move(animation)); | 2252 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
2239 | 2253 |
2240 EXPECT_TRUE(animations_impl->HasAnimationThatAffectsScale()); | 2254 EXPECT_TRUE(animations_impl->HasAnimationThatAffectsScale()); |
2241 | 2255 |
2242 animations_impl->GetAnimationById(3)->SetRunState(Animation::FINISHED, | 2256 animations_impl->GetAnimationById(3)->SetRunState(Animation::FINISHED, |
2243 TicksFromSecondsF(0.0)); | 2257 TicksFromSecondsF(0.0)); |
2244 | 2258 |
2245 // Only unfinished animations should be considered by | 2259 // Only unfinished animations should be considered by |
2246 // HasAnimationThatAffectsScale. | 2260 // HasAnimationThatAffectsScale. |
2247 EXPECT_FALSE(animations_impl->HasAnimationThatAffectsScale()); | 2261 EXPECT_FALSE(animations_impl->HasAnimationThatAffectsScale()); |
2248 } | 2262 } |
(...skipping 25 matching lines...) Expand all Loading... | |
2274 | 2288 |
2275 TransformOperations operations1; | 2289 TransformOperations operations1; |
2276 curve1->AddKeyframe( | 2290 curve1->AddKeyframe( |
2277 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2291 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
2278 operations1.AppendTranslate(10.0, 15.0, 0.0); | 2292 operations1.AppendTranslate(10.0, 15.0, 0.0); |
2279 curve1->AddKeyframe(TransformKeyframe::Create( | 2293 curve1->AddKeyframe(TransformKeyframe::Create( |
2280 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 2294 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
2281 | 2295 |
2282 std::unique_ptr<Animation> animation( | 2296 std::unique_ptr<Animation> animation( |
2283 Animation::Create(std::move(curve1), 2, 2, TargetProperty::TRANSFORM)); | 2297 Animation::Create(std::move(curve1), 2, 2, TargetProperty::TRANSFORM)); |
2284 animations_impl->AddAnimation(std::move(animation)); | 2298 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
2285 | 2299 |
2286 // The only transform animation we've added is a translation. | 2300 // The only transform animation we've added is a translation. |
2287 EXPECT_TRUE( | 2301 EXPECT_TRUE( |
2288 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE)); | 2302 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE)); |
2289 EXPECT_TRUE( | 2303 EXPECT_TRUE( |
2290 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING)); | 2304 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING)); |
2291 | 2305 |
2292 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( | 2306 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( |
2293 KeyframedTransformAnimationCurve::Create()); | 2307 KeyframedTransformAnimationCurve::Create()); |
2294 | 2308 |
2295 TransformOperations operations2; | 2309 TransformOperations operations2; |
2296 curve2->AddKeyframe( | 2310 curve2->AddKeyframe( |
2297 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 2311 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
2298 operations2.AppendScale(2.0, 3.0, 4.0); | 2312 operations2.AppendScale(2.0, 3.0, 4.0); |
2299 curve2->AddKeyframe(TransformKeyframe::Create( | 2313 curve2->AddKeyframe(TransformKeyframe::Create( |
2300 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2314 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
2301 | 2315 |
2302 animation = | 2316 animation = |
2303 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM); | 2317 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM); |
2304 animation->set_affects_active_elements(false); | 2318 animation->set_affects_active_elements(false); |
2305 animations_impl->AddAnimation(std::move(animation)); | 2319 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
2306 | 2320 |
2307 // A scale animation is not a translation. | 2321 // A scale animation is not a translation. |
2308 EXPECT_FALSE( | 2322 EXPECT_FALSE( |
2309 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING)); | 2323 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING)); |
2310 EXPECT_TRUE( | 2324 EXPECT_TRUE( |
2311 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE)); | 2325 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE)); |
2312 | 2326 |
2313 animations_impl->ActivateAnimations(); | 2327 animations_impl->ActivateAnimations(); |
2314 EXPECT_FALSE( | 2328 EXPECT_FALSE( |
2315 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING)); | 2329 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING)); |
(...skipping 30 matching lines...) Expand all Loading... | |
2346 TransformOperations operations1; | 2360 TransformOperations operations1; |
2347 operations1.AppendScale(2.0, 3.0, 4.0); | 2361 operations1.AppendScale(2.0, 3.0, 4.0); |
2348 curve1->AddKeyframe( | 2362 curve1->AddKeyframe( |
2349 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2363 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
2350 TransformOperations operations2; | 2364 TransformOperations operations2; |
2351 curve1->AddKeyframe(TransformKeyframe::Create( | 2365 curve1->AddKeyframe(TransformKeyframe::Create( |
2352 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2366 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
2353 std::unique_ptr<Animation> animation( | 2367 std::unique_ptr<Animation> animation( |
2354 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); | 2368 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); |
2355 animation->set_affects_active_elements(false); | 2369 animation->set_affects_active_elements(false); |
2356 animations_impl->AddAnimation(std::move(animation)); | 2370 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
2357 | 2371 |
2358 float start_scale = 0.f; | 2372 float start_scale = 0.f; |
2359 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, | 2373 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, |
2360 &start_scale)); | 2374 &start_scale)); |
2361 EXPECT_EQ(4.f, start_scale); | 2375 EXPECT_EQ(4.f, start_scale); |
2362 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE, | 2376 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE, |
2363 &start_scale)); | 2377 &start_scale)); |
2364 EXPECT_EQ(0.f, start_scale); | 2378 EXPECT_EQ(0.f, start_scale); |
2365 | 2379 |
2366 animations_impl->ActivateAnimations(); | 2380 animations_impl->ActivateAnimations(); |
2367 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, | 2381 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, |
2368 &start_scale)); | 2382 &start_scale)); |
2369 EXPECT_EQ(4.f, start_scale); | 2383 EXPECT_EQ(4.f, start_scale); |
2370 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE, | 2384 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE, |
2371 &start_scale)); | 2385 &start_scale)); |
2372 EXPECT_EQ(4.f, start_scale); | 2386 EXPECT_EQ(4.f, start_scale); |
2373 | 2387 |
2374 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( | 2388 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( |
2375 KeyframedTransformAnimationCurve::Create()); | 2389 KeyframedTransformAnimationCurve::Create()); |
2376 | 2390 |
2377 TransformOperations operations3; | 2391 TransformOperations operations3; |
2378 curve2->AddKeyframe( | 2392 curve2->AddKeyframe( |
2379 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); | 2393 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); |
2380 operations3.AppendScale(6.0, 5.0, 4.0); | 2394 operations3.AppendScale(6.0, 5.0, 4.0); |
2381 curve2->AddKeyframe(TransformKeyframe::Create( | 2395 curve2->AddKeyframe(TransformKeyframe::Create( |
2382 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); | 2396 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); |
2383 | 2397 |
2384 animations_impl->RemoveAnimation(1); | 2398 RemoveAnimationFromElementAnimations(animations_impl.get(), 1); |
2385 animation = | 2399 animation = |
2386 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); | 2400 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); |
2387 | 2401 |
2388 // Reverse Direction | 2402 // Reverse Direction |
2389 animation->set_direction(Animation::Direction::REVERSE); | 2403 animation->set_direction(Animation::Direction::REVERSE); |
2390 animation->set_affects_active_elements(false); | 2404 animation->set_affects_active_elements(false); |
2391 animations_impl->AddAnimation(std::move(animation)); | 2405 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
2392 | 2406 |
2393 std::unique_ptr<KeyframedTransformAnimationCurve> curve3( | 2407 std::unique_ptr<KeyframedTransformAnimationCurve> curve3( |
2394 KeyframedTransformAnimationCurve::Create()); | 2408 KeyframedTransformAnimationCurve::Create()); |
2395 | 2409 |
2396 TransformOperations operations4; | 2410 TransformOperations operations4; |
2397 operations4.AppendScale(5.0, 3.0, 1.0); | 2411 operations4.AppendScale(5.0, 3.0, 1.0); |
2398 curve3->AddKeyframe( | 2412 curve3->AddKeyframe( |
2399 TransformKeyframe::Create(base::TimeDelta(), operations4, nullptr)); | 2413 TransformKeyframe::Create(base::TimeDelta(), operations4, nullptr)); |
2400 TransformOperations operations5; | 2414 TransformOperations operations5; |
2401 curve3->AddKeyframe(TransformKeyframe::Create( | 2415 curve3->AddKeyframe(TransformKeyframe::Create( |
2402 base::TimeDelta::FromSecondsD(1.0), operations5, nullptr)); | 2416 base::TimeDelta::FromSecondsD(1.0), operations5, nullptr)); |
2403 | 2417 |
2404 animation = | 2418 animation = |
2405 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); | 2419 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); |
2406 animation->set_affects_active_elements(false); | 2420 animation->set_affects_active_elements(false); |
2407 animations_impl->AddAnimation(std::move(animation)); | 2421 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
2408 | 2422 |
2409 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, | 2423 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, |
2410 &start_scale)); | 2424 &start_scale)); |
2411 EXPECT_EQ(6.f, start_scale); | 2425 EXPECT_EQ(6.f, start_scale); |
2412 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE, | 2426 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE, |
2413 &start_scale)); | 2427 &start_scale)); |
2414 EXPECT_EQ(0.f, start_scale); | 2428 EXPECT_EQ(0.f, start_scale); |
2415 | 2429 |
2416 animations_impl->ActivateAnimations(); | 2430 animations_impl->ActivateAnimations(); |
2417 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, | 2431 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2455 TransformOperations operations1; | 2469 TransformOperations operations1; |
2456 curve1->AddKeyframe( | 2470 curve1->AddKeyframe( |
2457 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2471 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
2458 operations1.AppendScale(2.0, 3.0, 4.0); | 2472 operations1.AppendScale(2.0, 3.0, 4.0); |
2459 curve1->AddKeyframe(TransformKeyframe::Create( | 2473 curve1->AddKeyframe(TransformKeyframe::Create( |
2460 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 2474 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
2461 | 2475 |
2462 std::unique_ptr<Animation> animation( | 2476 std::unique_ptr<Animation> animation( |
2463 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); | 2477 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); |
2464 animation->set_affects_active_elements(false); | 2478 animation->set_affects_active_elements(false); |
2465 animations_impl->AddAnimation(std::move(animation)); | 2479 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
2466 | 2480 |
2467 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, | 2481 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, |
2468 &max_scale)); | 2482 &max_scale)); |
2469 EXPECT_EQ(4.f, max_scale); | 2483 EXPECT_EQ(4.f, max_scale); |
2470 EXPECT_TRUE( | 2484 EXPECT_TRUE( |
2471 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); | 2485 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); |
2472 EXPECT_EQ(0.f, max_scale); | 2486 EXPECT_EQ(0.f, max_scale); |
2473 | 2487 |
2474 animations_impl->ActivateAnimations(); | 2488 animations_impl->ActivateAnimations(); |
2475 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, | 2489 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, |
2476 &max_scale)); | 2490 &max_scale)); |
2477 EXPECT_EQ(4.f, max_scale); | 2491 EXPECT_EQ(4.f, max_scale); |
2478 EXPECT_TRUE( | 2492 EXPECT_TRUE( |
2479 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); | 2493 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); |
2480 EXPECT_EQ(4.f, max_scale); | 2494 EXPECT_EQ(4.f, max_scale); |
2481 | 2495 |
2482 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( | 2496 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( |
2483 KeyframedTransformAnimationCurve::Create()); | 2497 KeyframedTransformAnimationCurve::Create()); |
2484 | 2498 |
2485 TransformOperations operations2; | 2499 TransformOperations operations2; |
2486 curve2->AddKeyframe( | 2500 curve2->AddKeyframe( |
2487 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 2501 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
2488 operations2.AppendScale(6.0, 5.0, 4.0); | 2502 operations2.AppendScale(6.0, 5.0, 4.0); |
2489 curve2->AddKeyframe(TransformKeyframe::Create( | 2503 curve2->AddKeyframe(TransformKeyframe::Create( |
2490 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2504 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
2491 | 2505 |
2492 animation = | 2506 animation = |
2493 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); | 2507 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); |
2494 animation->set_affects_active_elements(false); | 2508 animation->set_affects_active_elements(false); |
2495 animations_impl->AddAnimation(std::move(animation)); | 2509 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
2496 | 2510 |
2497 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, | 2511 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, |
2498 &max_scale)); | 2512 &max_scale)); |
2499 EXPECT_EQ(6.f, max_scale); | 2513 EXPECT_EQ(6.f, max_scale); |
2500 EXPECT_TRUE( | 2514 EXPECT_TRUE( |
2501 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); | 2515 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); |
2502 EXPECT_EQ(4.f, max_scale); | 2516 EXPECT_EQ(4.f, max_scale); |
2503 | 2517 |
2504 animations_impl->ActivateAnimations(); | 2518 animations_impl->ActivateAnimations(); |
2505 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, | 2519 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, |
2506 &max_scale)); | 2520 &max_scale)); |
2507 EXPECT_EQ(6.f, max_scale); | 2521 EXPECT_EQ(6.f, max_scale); |
2508 EXPECT_TRUE( | 2522 EXPECT_TRUE( |
2509 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); | 2523 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); |
2510 EXPECT_EQ(6.f, max_scale); | 2524 EXPECT_EQ(6.f, max_scale); |
2511 | 2525 |
2512 std::unique_ptr<KeyframedTransformAnimationCurve> curve3( | 2526 std::unique_ptr<KeyframedTransformAnimationCurve> curve3( |
2513 KeyframedTransformAnimationCurve::Create()); | 2527 KeyframedTransformAnimationCurve::Create()); |
2514 | 2528 |
2515 TransformOperations operations3; | 2529 TransformOperations operations3; |
2516 curve3->AddKeyframe( | 2530 curve3->AddKeyframe( |
2517 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); | 2531 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); |
2518 operations3.AppendPerspective(6.0); | 2532 operations3.AppendPerspective(6.0); |
2519 curve3->AddKeyframe(TransformKeyframe::Create( | 2533 curve3->AddKeyframe(TransformKeyframe::Create( |
2520 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); | 2534 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); |
2521 | 2535 |
2522 animation = | 2536 animation = |
2523 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); | 2537 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); |
2524 animation->set_affects_active_elements(false); | 2538 animation->set_affects_active_elements(false); |
2525 animations_impl->AddAnimation(std::move(animation)); | 2539 AddAnimationToElementAnimations(animations_impl.get(), std::move(animation)); |
2526 | 2540 |
2527 EXPECT_FALSE(animations_impl->MaximumTargetScale(ElementListType::PENDING, | 2541 EXPECT_FALSE(animations_impl->MaximumTargetScale(ElementListType::PENDING, |
2528 &max_scale)); | 2542 &max_scale)); |
2529 EXPECT_TRUE( | 2543 EXPECT_TRUE( |
2530 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); | 2544 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale)); |
2531 EXPECT_EQ(6.f, max_scale); | 2545 EXPECT_EQ(6.f, max_scale); |
2532 | 2546 |
2533 animations_impl->ActivateAnimations(); | 2547 animations_impl->ActivateAnimations(); |
2534 EXPECT_FALSE(animations_impl->MaximumTargetScale(ElementListType::PENDING, | 2548 EXPECT_FALSE(animations_impl->MaximumTargetScale(ElementListType::PENDING, |
2535 &max_scale)); | 2549 &max_scale)); |
(...skipping 29 matching lines...) Expand all Loading... | |
2565 curve1->AddKeyframe( | 2579 curve1->AddKeyframe( |
2566 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2580 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
2567 TransformOperations operations2; | 2581 TransformOperations operations2; |
2568 operations2.AppendScale(4.0, 5.0, 6.0); | 2582 operations2.AppendScale(4.0, 5.0, 6.0); |
2569 curve1->AddKeyframe(TransformKeyframe::Create( | 2583 curve1->AddKeyframe(TransformKeyframe::Create( |
2570 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2584 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
2571 | 2585 |
2572 std::unique_ptr<Animation> animation_owned( | 2586 std::unique_ptr<Animation> animation_owned( |
2573 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); | 2587 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); |
2574 Animation* animation = animation_owned.get(); | 2588 Animation* animation = animation_owned.get(); |
2575 animations_impl->AddAnimation(std::move(animation_owned)); | 2589 AddAnimationToElementAnimations(animations_impl.get(), |
2590 std::move(animation_owned)); | |
2576 | 2591 |
2577 float max_scale = 0.f; | 2592 float max_scale = 0.f; |
2578 | 2593 |
2579 EXPECT_GT(animation->playback_rate(), 0.0); | 2594 EXPECT_GT(animation->playback_rate(), 0.0); |
2580 | 2595 |
2581 // NORMAL direction with positive playback rate. | 2596 // NORMAL direction with positive playback rate. |
2582 animation->set_direction(Animation::Direction::NORMAL); | 2597 animation->set_direction(Animation::Direction::NORMAL); |
2583 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, | 2598 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING, |
2584 &max_scale)); | 2599 &max_scale)); |
2585 EXPECT_EQ(6.f, max_scale); | 2600 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( | 2895 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( |
2881 element_id_, ElementListType::ACTIVE)); | 2896 element_id_, ElementListType::ACTIVE)); |
2882 | 2897 |
2883 animations_impl->Animate(kInitialTickTime + | 2898 animations_impl->Animate(kInitialTickTime + |
2884 TimeDelta::FromMilliseconds(2000)); | 2899 TimeDelta::FromMilliseconds(2000)); |
2885 animations_impl->UpdateState(true, events.get()); | 2900 animations_impl->UpdateState(true, events.get()); |
2886 | 2901 |
2887 animations->NotifyAnimationStarted(events->events_[0]); | 2902 animations->NotifyAnimationStarted(events->events_[0]); |
2888 events->events_.clear(); | 2903 events->events_.clear(); |
2889 | 2904 |
2890 animations->RemoveAnimation(animation_id); | 2905 RemoveAnimationFromElementAnimations(animations.get(), animation_id); |
2891 EXPECT_FALSE(client_.GetHasPotentialTransformAnimation( | 2906 EXPECT_FALSE(client_.GetHasPotentialTransformAnimation( |
2892 element_id_, ElementListType::ACTIVE)); | 2907 element_id_, ElementListType::ACTIVE)); |
2893 EXPECT_FALSE(client_.GetTransformIsCurrentlyAnimating( | 2908 EXPECT_FALSE(client_.GetTransformIsCurrentlyAnimating( |
2894 element_id_, ElementListType::ACTIVE)); | 2909 element_id_, ElementListType::ACTIVE)); |
2895 | 2910 |
2896 animations->PushPropertiesTo(animations_impl.get()); | 2911 animations->PushPropertiesTo(animations_impl.get()); |
2897 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( | 2912 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( |
2898 element_id_, ElementListType::PENDING)); | 2913 element_id_, ElementListType::PENDING)); |
2899 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( | 2914 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( |
2900 element_id_, ElementListType::PENDING)); | 2915 element_id_, ElementListType::PENDING)); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3098 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3113 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( |
3099 element_id_, ElementListType::ACTIVE)); | 3114 element_id_, ElementListType::ACTIVE)); |
3100 | 3115 |
3101 animations_impl->Animate(kInitialTickTime + | 3116 animations_impl->Animate(kInitialTickTime + |
3102 TimeDelta::FromMilliseconds(2000)); | 3117 TimeDelta::FromMilliseconds(2000)); |
3103 animations_impl->UpdateState(true, events.get()); | 3118 animations_impl->UpdateState(true, events.get()); |
3104 | 3119 |
3105 animations->NotifyAnimationStarted(events->events_[0]); | 3120 animations->NotifyAnimationStarted(events->events_[0]); |
3106 events->events_.clear(); | 3121 events->events_.clear(); |
3107 | 3122 |
3108 animations->RemoveAnimation(animation_id); | 3123 RemoveAnimationFromElementAnimations(animations.get(), animation_id); |
3109 EXPECT_FALSE(client_.GetHasPotentialOpacityAnimation( | 3124 EXPECT_FALSE(client_.GetHasPotentialOpacityAnimation( |
3110 element_id_, ElementListType::ACTIVE)); | 3125 element_id_, ElementListType::ACTIVE)); |
3111 EXPECT_FALSE(client_.GetOpacityIsCurrentlyAnimating(element_id_, | 3126 EXPECT_FALSE(client_.GetOpacityIsCurrentlyAnimating(element_id_, |
3112 ElementListType::ACTIVE)); | 3127 ElementListType::ACTIVE)); |
3113 | 3128 |
3114 animations->PushPropertiesTo(animations_impl.get()); | 3129 animations->PushPropertiesTo(animations_impl.get()); |
3115 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( | 3130 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( |
3116 element_id_, ElementListType::PENDING)); | 3131 element_id_, ElementListType::PENDING)); |
3117 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3132 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( |
3118 element_id_, ElementListType::PENDING)); | 3133 element_id_, ElementListType::PENDING)); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3315 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( | 3330 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( |
3316 element_id_, ElementListType::ACTIVE)); | 3331 element_id_, ElementListType::ACTIVE)); |
3317 | 3332 |
3318 animations_impl->Animate(kInitialTickTime + | 3333 animations_impl->Animate(kInitialTickTime + |
3319 TimeDelta::FromMilliseconds(2000)); | 3334 TimeDelta::FromMilliseconds(2000)); |
3320 animations_impl->UpdateState(true, events.get()); | 3335 animations_impl->UpdateState(true, events.get()); |
3321 | 3336 |
3322 animations->NotifyAnimationStarted(events->events_[0]); | 3337 animations->NotifyAnimationStarted(events->events_[0]); |
3323 events->events_.clear(); | 3338 events->events_.clear(); |
3324 | 3339 |
3325 animations->RemoveAnimation(animation_id); | 3340 RemoveAnimationFromElementAnimations(animations.get(), animation_id); |
3326 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_, | 3341 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_, |
3327 ElementListType::ACTIVE)); | 3342 ElementListType::ACTIVE)); |
3328 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_, | 3343 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_, |
3329 ElementListType::ACTIVE)); | 3344 ElementListType::ACTIVE)); |
3330 | 3345 |
3331 animations->PushPropertiesTo(animations_impl.get()); | 3346 animations->PushPropertiesTo(animations_impl.get()); |
3332 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( | 3347 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( |
3333 element_id_, ElementListType::PENDING)); | 3348 element_id_, ElementListType::PENDING)); |
3334 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3349 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
3335 element_id_, ElementListType::PENDING)); | 3350 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)); | 3490 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); |
3476 EXPECT_EQ(0.5f, | 3491 EXPECT_EQ(0.5f, |
3477 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 3492 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
3478 | 3493 |
3479 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) | 3494 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) |
3480 ->affects_pending_elements()); | 3495 ->affects_pending_elements()); |
3481 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) | 3496 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) |
3482 ->affects_active_elements()); | 3497 ->affects_active_elements()); |
3483 | 3498 |
3484 // Delete the animation on the main-thread animations. | 3499 // Delete the animation on the main-thread animations. |
3485 animations->RemoveAnimation( | 3500 RemoveAnimationFromElementAnimations( |
3501 animations.get(), | |
3486 animations->GetAnimation(TargetProperty::OPACITY)->id()); | 3502 animations->GetAnimation(TargetProperty::OPACITY)->id()); |
3487 animations->PushPropertiesTo(animations_impl.get()); | 3503 animations->PushPropertiesTo(animations_impl.get()); |
3488 | 3504 |
3489 // The animation should no longer affect pending elements. | 3505 // The animation should no longer affect pending elements. |
3490 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id) | 3506 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id) |
3491 ->affects_pending_elements()); | 3507 ->affects_pending_elements()); |
3492 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) | 3508 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) |
3493 ->affects_active_elements()); | 3509 ->affects_active_elements()); |
3494 | 3510 |
3495 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 3511 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
(...skipping 26 matching lines...) Expand all Loading... | |
3522 const int first_animation_id = AddOpacityTransitionToElementAnimations( | 3538 const int first_animation_id = AddOpacityTransitionToElementAnimations( |
3523 animations.get(), 1, 0.f, 1.f, true); | 3539 animations.get(), 1, 0.f, 1.f, true); |
3524 | 3540 |
3525 animations->PushPropertiesTo(animations_impl.get()); | 3541 animations->PushPropertiesTo(animations_impl.get()); |
3526 animations_impl->ActivateAnimations(); | 3542 animations_impl->ActivateAnimations(); |
3527 animations_impl->Animate(kInitialTickTime); | 3543 animations_impl->Animate(kInitialTickTime); |
3528 animations_impl->UpdateState(true, events.get()); | 3544 animations_impl->UpdateState(true, events.get()); |
3529 | 3545 |
3530 // Remove the first animation from the main-thread animations, and add a | 3546 // Remove the first animation from the main-thread animations, and add a |
3531 // new animation affecting the same property. | 3547 // new animation affecting the same property. |
3532 animations->RemoveAnimation( | 3548 RemoveAnimationFromElementAnimations( |
3549 animations.get(), | |
3533 animations->GetAnimation(TargetProperty::OPACITY)->id()); | 3550 animations->GetAnimation(TargetProperty::OPACITY)->id()); |
3534 const int second_animation_id = AddOpacityTransitionToElementAnimations( | 3551 const int second_animation_id = AddOpacityTransitionToElementAnimations( |
3535 animations.get(), 1, 1.f, 0.5f, true); | 3552 animations.get(), 1, 1.f, 0.5f, true); |
3536 animations->PushPropertiesTo(animations_impl.get()); | 3553 animations->PushPropertiesTo(animations_impl.get()); |
3537 | 3554 |
3538 // The original animation should only affect active elements, and the new | 3555 // The original animation should only affect active elements, and the new |
3539 // animation should only affect pending elements. | 3556 // animation should only affect pending elements. |
3540 EXPECT_FALSE(animations_impl->GetAnimationById(first_animation_id) | 3557 EXPECT_FALSE(animations_impl->GetAnimationById(first_animation_id) |
3541 ->affects_pending_elements()); | 3558 ->affects_pending_elements()); |
3542 EXPECT_TRUE(animations_impl->GetAnimationById(first_animation_id) | 3559 EXPECT_TRUE(animations_impl->GetAnimationById(first_animation_id) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3593 AttachTimelinePlayerLayer(); | 3610 AttachTimelinePlayerLayer(); |
3594 | 3611 |
3595 scoped_refptr<ElementAnimations> animations = element_animations(); | 3612 scoped_refptr<ElementAnimations> animations = element_animations(); |
3596 | 3613 |
3597 // Create an animation that initially affects only pending elements. | 3614 // Create an animation that initially affects only pending elements. |
3598 std::unique_ptr<Animation> animation(CreateAnimation( | 3615 std::unique_ptr<Animation> animation(CreateAnimation( |
3599 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 3616 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
3600 1, TargetProperty::OPACITY)); | 3617 1, TargetProperty::OPACITY)); |
3601 animation->set_affects_active_elements(false); | 3618 animation->set_affects_active_elements(false); |
3602 | 3619 |
3603 animations->AddAnimation(std::move(animation)); | 3620 AddAnimationToElementAnimations(animations.get(), std::move(animation)); |
3604 animations->Animate(kInitialTickTime); | 3621 animations->Animate(kInitialTickTime); |
3605 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( | 3622 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( |
3606 TargetProperty::OPACITY, ElementListType::PENDING)); | 3623 TargetProperty::OPACITY, ElementListType::PENDING)); |
3607 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3624 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
3608 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3625 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
3609 animations->UpdateState(true, nullptr); | 3626 animations->UpdateState(true, nullptr); |
3610 EXPECT_TRUE(animations->HasActiveAnimation()); | 3627 EXPECT_TRUE(animations->HasActiveAnimation()); |
3611 | 3628 |
3612 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( | 3629 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( |
3613 TargetProperty::OPACITY, ElementListType::PENDING)); | 3630 TargetProperty::OPACITY, ElementListType::PENDING)); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3667 | 3684 |
3668 // Create an animation that initially affects only pending elements, and has | 3685 // Create an animation that initially affects only pending elements, and has |
3669 // a start delay of 2 seconds. | 3686 // a start delay of 2 seconds. |
3670 std::unique_ptr<Animation> animation(CreateAnimation( | 3687 std::unique_ptr<Animation> animation(CreateAnimation( |
3671 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 3688 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
3672 1, TargetProperty::OPACITY)); | 3689 1, TargetProperty::OPACITY)); |
3673 animation->set_fill_mode(Animation::FillMode::NONE); | 3690 animation->set_fill_mode(Animation::FillMode::NONE); |
3674 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000)); | 3691 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000)); |
3675 animation->set_affects_active_elements(false); | 3692 animation->set_affects_active_elements(false); |
3676 | 3693 |
3677 animations->AddAnimation(std::move(animation)); | 3694 AddAnimationToElementAnimations(animations.get(), std::move(animation)); |
3678 | 3695 |
3679 animations->Animate(kInitialTickTime); | 3696 animations->Animate(kInitialTickTime); |
3680 | 3697 |
3681 // Since the animation has a start delay, the elements it affects have a | 3698 // Since the animation has a start delay, the elements it affects have a |
3682 // potentially running transform animation but aren't currently animating | 3699 // potentially running transform animation but aren't currently animating |
3683 // transform. | 3700 // transform. |
3684 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( | 3701 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( |
3685 TargetProperty::OPACITY, ElementListType::PENDING)); | 3702 TargetProperty::OPACITY, ElementListType::PENDING)); |
3686 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( | 3703 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( |
3687 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3704 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3735 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( | 3752 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( |
3736 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3753 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
3737 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3754 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
3738 TargetProperty::OPACITY, ElementListType::PENDING)); | 3755 TargetProperty::OPACITY, ElementListType::PENDING)); |
3739 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3756 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
3740 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3757 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
3741 } | 3758 } |
3742 | 3759 |
3743 } // namespace | 3760 } // namespace |
3744 } // namespace cc | 3761 } // namespace cc |
OLD | NEW |