Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Side by Side Diff: cc/animation/element_animations_unittest.cc

Issue 1921583003: CC Animation: Let MutatorHostClient deals with elements instead of layers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@elementid
Patch Set: Rename methods in ElementAnimations Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/element_animations.cc ('k') | cc/test/animation_test_common.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 25 matching lines...) Expand all
36 public: 36 public:
37 ElementAnimationsTest() {} 37 ElementAnimationsTest() {}
38 ~ElementAnimationsTest() override {} 38 ~ElementAnimationsTest() override {}
39 }; 39 };
40 40
41 // See animation_player_unittest.cc for integration with AnimationPlayer. 41 // See animation_player_unittest.cc for integration with AnimationPlayer.
42 42
43 TEST_F(ElementAnimationsTest, AttachToLayerInActiveTree) { 43 TEST_F(ElementAnimationsTest, AttachToLayerInActiveTree) {
44 // Set up the layer which is in active tree for main thread and not 44 // Set up the layer which is in active tree for main thread and not
45 // yet passed onto the impl thread. 45 // yet passed onto the impl thread.
46 client_.RegisterLayer(element_id_, LayerTreeType::ACTIVE); 46 client_.RegisterElement(element_id_, ElementListType::ACTIVE);
47 client_impl_.RegisterLayer(element_id_, LayerTreeType::PENDING); 47 client_impl_.RegisterElement(element_id_, ElementListType::PENDING);
48 48
49 EXPECT_TRUE(client_.IsLayerInTree(element_id_, LayerTreeType::ACTIVE)); 49 EXPECT_TRUE(client_.IsElementInList(element_id_, ElementListType::ACTIVE));
50 EXPECT_FALSE(client_.IsLayerInTree(element_id_, LayerTreeType::PENDING)); 50 EXPECT_FALSE(client_.IsElementInList(element_id_, ElementListType::PENDING));
51 51
52 host_->AddAnimationTimeline(timeline_); 52 host_->AddAnimationTimeline(timeline_);
53 53
54 timeline_->AttachPlayer(player_); 54 timeline_->AttachPlayer(player_);
55 player_->AttachLayer(element_id_); 55 player_->AttachLayer(element_id_);
56 56
57 scoped_refptr<ElementAnimations> element_animations = 57 scoped_refptr<ElementAnimations> element_animations =
58 player_->element_animations(); 58 player_->element_animations();
59 EXPECT_TRUE(element_animations); 59 EXPECT_TRUE(element_animations);
60 60
61 EXPECT_TRUE(element_animations->has_element_in_active_list()); 61 EXPECT_TRUE(element_animations->has_element_in_active_list());
62 EXPECT_FALSE(element_animations->has_element_in_pending_list()); 62 EXPECT_FALSE(element_animations->has_element_in_pending_list());
63 63
64 host_->PushPropertiesTo(host_impl_); 64 host_->PushPropertiesTo(host_impl_);
65 65
66 GetImplTimelineAndPlayerByID(); 66 GetImplTimelineAndPlayerByID();
67 67
68 scoped_refptr<ElementAnimations> element_animations_impl = 68 scoped_refptr<ElementAnimations> element_animations_impl =
69 player_impl_->element_animations(); 69 player_impl_->element_animations();
70 EXPECT_TRUE(element_animations_impl); 70 EXPECT_TRUE(element_animations_impl);
71 71
72 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); 72 EXPECT_FALSE(element_animations_impl->has_element_in_active_list());
73 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list()); 73 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list());
74 74
75 // Create the layer in the impl active tree. 75 // Create the layer in the impl active tree.
76 client_impl_.RegisterLayer(element_id_, LayerTreeType::ACTIVE); 76 client_impl_.RegisterElement(element_id_, ElementListType::ACTIVE);
77 EXPECT_TRUE(element_animations_impl->has_element_in_active_list()); 77 EXPECT_TRUE(element_animations_impl->has_element_in_active_list());
78 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list()); 78 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list());
79 79
80 EXPECT_TRUE(client_impl_.IsLayerInTree(element_id_, LayerTreeType::ACTIVE)); 80 EXPECT_TRUE(
81 EXPECT_TRUE(client_impl_.IsLayerInTree(element_id_, LayerTreeType::PENDING)); 81 client_impl_.IsElementInList(element_id_, ElementListType::ACTIVE));
82 EXPECT_TRUE(
83 client_impl_.IsElementInList(element_id_, ElementListType::PENDING));
82 84
83 // kill layer on main thread. 85 // kill layer on main thread.
84 client_.UnregisterLayer(element_id_, LayerTreeType::ACTIVE); 86 client_.UnregisterElement(element_id_, ElementListType::ACTIVE);
85 EXPECT_EQ(element_animations, player_->element_animations()); 87 EXPECT_EQ(element_animations, player_->element_animations());
86 EXPECT_FALSE(element_animations->has_element_in_active_list()); 88 EXPECT_FALSE(element_animations->has_element_in_active_list());
87 EXPECT_FALSE(element_animations->has_element_in_pending_list()); 89 EXPECT_FALSE(element_animations->has_element_in_pending_list());
88 90
89 // Sync doesn't detach LayerImpl. 91 // Sync doesn't detach LayerImpl.
90 host_->PushPropertiesTo(host_impl_); 92 host_->PushPropertiesTo(host_impl_);
91 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); 93 EXPECT_EQ(element_animations_impl, player_impl_->element_animations());
92 EXPECT_TRUE(element_animations_impl->has_element_in_active_list()); 94 EXPECT_TRUE(element_animations_impl->has_element_in_active_list());
93 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list()); 95 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list());
94 96
95 // Kill layer on impl thread in pending tree. 97 // Kill layer on impl thread in pending tree.
96 client_impl_.UnregisterLayer(element_id_, LayerTreeType::PENDING); 98 client_impl_.UnregisterElement(element_id_, ElementListType::PENDING);
97 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); 99 EXPECT_EQ(element_animations_impl, player_impl_->element_animations());
98 EXPECT_TRUE(element_animations_impl->has_element_in_active_list()); 100 EXPECT_TRUE(element_animations_impl->has_element_in_active_list());
99 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); 101 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list());
100 102
101 // Kill layer on impl thread in active tree. 103 // Kill layer on impl thread in active tree.
102 client_impl_.UnregisterLayer(element_id_, LayerTreeType::ACTIVE); 104 client_impl_.UnregisterElement(element_id_, ElementListType::ACTIVE);
103 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); 105 EXPECT_EQ(element_animations_impl, player_impl_->element_animations());
104 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); 106 EXPECT_FALSE(element_animations_impl->has_element_in_active_list());
105 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); 107 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list());
106 108
107 // Sync doesn't change anything. 109 // Sync doesn't change anything.
108 host_->PushPropertiesTo(host_impl_); 110 host_->PushPropertiesTo(host_impl_);
109 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); 111 EXPECT_EQ(element_animations_impl, player_impl_->element_animations());
110 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); 112 EXPECT_FALSE(element_animations_impl->has_element_in_active_list());
111 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); 113 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list());
112 114
(...skipping 24 matching lines...) Expand all
137 host_->PushPropertiesTo(host_impl_); 139 host_->PushPropertiesTo(host_impl_);
138 140
139 scoped_refptr<ElementAnimations> element_animations_impl = 141 scoped_refptr<ElementAnimations> element_animations_impl =
140 player_impl_->element_animations(); 142 player_impl_->element_animations();
141 EXPECT_TRUE(element_animations_impl); 143 EXPECT_TRUE(element_animations_impl);
142 144
143 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); 145 EXPECT_FALSE(element_animations_impl->has_element_in_active_list());
144 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); 146 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list());
145 147
146 // Create layer. 148 // Create layer.
147 client_.RegisterLayer(element_id_, LayerTreeType::ACTIVE); 149 client_.RegisterElement(element_id_, ElementListType::ACTIVE);
148 EXPECT_TRUE(element_animations->has_element_in_active_list()); 150 EXPECT_TRUE(element_animations->has_element_in_active_list());
149 EXPECT_FALSE(element_animations->has_element_in_pending_list()); 151 EXPECT_FALSE(element_animations->has_element_in_pending_list());
150 152
151 client_impl_.RegisterLayer(element_id_, LayerTreeType::PENDING); 153 client_impl_.RegisterElement(element_id_, ElementListType::PENDING);
152 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); 154 EXPECT_FALSE(element_animations_impl->has_element_in_active_list());
153 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list()); 155 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list());
154 156
155 client_impl_.RegisterLayer(element_id_, LayerTreeType::ACTIVE); 157 client_impl_.RegisterElement(element_id_, ElementListType::ACTIVE);
156 EXPECT_TRUE(element_animations_impl->has_element_in_active_list()); 158 EXPECT_TRUE(element_animations_impl->has_element_in_active_list());
157 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list()); 159 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list());
158 } 160 }
159 161
160 TEST_F(ElementAnimationsTest, AddRemovePlayers) { 162 TEST_F(ElementAnimationsTest, AddRemovePlayers) {
161 host_->AddAnimationTimeline(timeline_); 163 host_->AddAnimationTimeline(timeline_);
162 timeline_->AttachPlayer(player_); 164 timeline_->AttachPlayer(player_);
163 player_->AttachLayer(element_id_); 165 player_->AttachLayer(element_id_);
164 166
165 scoped_refptr<ElementAnimations> element_animations = 167 scoped_refptr<ElementAnimations> element_animations =
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 495
494 animations->Animate(time); 496 animations->Animate(time);
495 animations->UpdateState(true, nullptr); 497 animations->UpdateState(true, nullptr);
496 animations->NotifyAnimationStarted(events->events_[0]); 498 animations->NotifyAnimationStarted(events->events_[0]);
497 499
498 EXPECT_EQ(Animation::RUNNING, 500 EXPECT_EQ(Animation::RUNNING,
499 animations_impl->GetAnimationById(animation_id)->run_state()); 501 animations_impl->GetAnimationById(animation_id)->run_state());
500 EXPECT_EQ(Animation::RUNNING, 502 EXPECT_EQ(Animation::RUNNING,
501 animations->GetAnimationById(animation_id)->run_state()); 503 animations->GetAnimationById(animation_id)->run_state());
502 504
503 EXPECT_EQ(0.3f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 505 EXPECT_EQ(0.3f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
504 EXPECT_EQ(0.3f, client_impl_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 506 EXPECT_EQ(0.3f,
507 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE));
505 508
506 EXPECT_EQ(kInitialTickTime, 509 EXPECT_EQ(kInitialTickTime,
507 animations->GetAnimationById(animation_id)->start_time()); 510 animations->GetAnimationById(animation_id)->start_time());
508 EXPECT_EQ(kInitialTickTime, 511 EXPECT_EQ(kInitialTickTime,
509 animations_impl->GetAnimationById(animation_id)->start_time()); 512 animations_impl->GetAnimationById(animation_id)->start_time());
510 513
511 // Pause the animation at the middle of the second range so the offset 514 // Pause the animation at the middle of the second range so the offset
512 // delays animation until the middle of the third range. 515 // delays animation until the middle of the third range.
513 animations->PauseAnimation(animation_id, TimeDelta::FromSecondsD(1.5)); 516 animations->PauseAnimation(animation_id, TimeDelta::FromSecondsD(1.5));
514 EXPECT_EQ(Animation::PAUSED, 517 EXPECT_EQ(Animation::PAUSED,
515 animations->GetAnimationById(animation_id)->run_state()); 518 animations->GetAnimationById(animation_id)->run_state());
516 519
517 // The pause run state change should make it to the impl thread animations. 520 // The pause run state change should make it to the impl thread animations.
518 animations->PushPropertiesTo(animations_impl.get()); 521 animations->PushPropertiesTo(animations_impl.get());
519 animations_impl->ActivateAnimations(); 522 animations_impl->ActivateAnimations();
520 523
521 // Advance time so it stays within the first range. 524 // Advance time so it stays within the first range.
522 time += TimeDelta::FromMilliseconds(10); 525 time += TimeDelta::FromMilliseconds(10);
523 animations->Animate(time); 526 animations->Animate(time);
524 animations_impl->Animate(time); 527 animations_impl->Animate(time);
525 528
526 EXPECT_EQ(Animation::PAUSED, 529 EXPECT_EQ(Animation::PAUSED,
527 animations_impl->GetAnimationById(animation_id)->run_state()); 530 animations_impl->GetAnimationById(animation_id)->run_state());
528 531
529 // Opacity value doesn't depend on time if paused at specified time offset. 532 // Opacity value doesn't depend on time if paused at specified time offset.
530 EXPECT_EQ(0.4f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 533 EXPECT_EQ(0.4f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
531 EXPECT_EQ(0.4f, client_impl_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 534 EXPECT_EQ(0.4f,
535 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE));
532 } 536 }
533 537
534 TEST_F(ElementAnimationsTest, DoNotSyncFinishedAnimation) { 538 TEST_F(ElementAnimationsTest, DoNotSyncFinishedAnimation) {
535 CreateTestLayer(true, false); 539 CreateTestLayer(true, false);
536 AttachTimelinePlayerLayer(); 540 AttachTimelinePlayerLayer();
537 CreateImplTimelineAndPlayer(); 541 CreateImplTimelineAndPlayer();
538 542
539 scoped_refptr<ElementAnimations> animations = element_animations(); 543 scoped_refptr<ElementAnimations> animations = element_animations();
540 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 544 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
541 545
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 679 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
676 1, TargetProperty::OPACITY)); 680 1, TargetProperty::OPACITY));
677 681
678 EXPECT_FALSE(animations->needs_to_start_animations_for_testing()); 682 EXPECT_FALSE(animations->needs_to_start_animations_for_testing());
679 animations->AddAnimation(std::move(to_add)); 683 animations->AddAnimation(std::move(to_add));
680 EXPECT_TRUE(animations->needs_to_start_animations_for_testing()); 684 EXPECT_TRUE(animations->needs_to_start_animations_for_testing());
681 animations->Animate(kInitialTickTime); 685 animations->Animate(kInitialTickTime);
682 EXPECT_FALSE(animations->needs_to_start_animations_for_testing()); 686 EXPECT_FALSE(animations->needs_to_start_animations_for_testing());
683 animations->UpdateState(true, events.get()); 687 animations->UpdateState(true, events.get());
684 EXPECT_TRUE(animations->HasActiveAnimation()); 688 EXPECT_TRUE(animations->HasActiveAnimation());
685 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 689 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
686 // A non-impl-only animation should not generate property updates. 690 // A non-impl-only animation should not generate property updates.
687 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 691 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
688 EXPECT_FALSE(event); 692 EXPECT_FALSE(event);
689 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 693 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
690 animations->UpdateState(true, events.get()); 694 animations->UpdateState(true, events.get());
691 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 695 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
692 EXPECT_FALSE(animations->HasActiveAnimation()); 696 EXPECT_FALSE(animations->HasActiveAnimation());
693 event = GetMostRecentPropertyUpdateEvent(events.get()); 697 event = GetMostRecentPropertyUpdateEvent(events.get());
694 EXPECT_FALSE(event); 698 EXPECT_FALSE(event);
695 } 699 }
696 700
697 TEST_F(ElementAnimationsTest, TrivialTransitionOnImpl) { 701 TEST_F(ElementAnimationsTest, TrivialTransitionOnImpl) {
698 CreateTestLayer(true, false); 702 CreateTestLayer(true, false);
699 AttachTimelinePlayerLayer(); 703 AttachTimelinePlayerLayer();
700 CreateImplTimelineAndPlayer(); 704 CreateImplTimelineAndPlayer();
701 705
702 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 706 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
703 707
704 auto events = host_impl_->CreateEvents(); 708 auto events = host_impl_->CreateEvents();
705 709
706 std::unique_ptr<Animation> to_add(CreateAnimation( 710 std::unique_ptr<Animation> to_add(CreateAnimation(
707 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 711 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
708 1, TargetProperty::OPACITY)); 712 1, TargetProperty::OPACITY));
709 to_add->set_is_impl_only(true); 713 to_add->set_is_impl_only(true);
710 714
711 animations_impl->AddAnimation(std::move(to_add)); 715 animations_impl->AddAnimation(std::move(to_add));
712 animations_impl->Animate(kInitialTickTime); 716 animations_impl->Animate(kInitialTickTime);
713 animations_impl->UpdateState(true, events.get()); 717 animations_impl->UpdateState(true, events.get());
714 EXPECT_TRUE(animations_impl->HasActiveAnimation()); 718 EXPECT_TRUE(animations_impl->HasActiveAnimation());
715 EXPECT_EQ(0.f, client_impl_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 719 EXPECT_EQ(0.f, client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE));
716 EXPECT_EQ(1u, events->events_.size()); 720 EXPECT_EQ(1u, events->events_.size());
717 const AnimationEvent* start_opacity_event = 721 const AnimationEvent* start_opacity_event =
718 GetMostRecentPropertyUpdateEvent(events.get()); 722 GetMostRecentPropertyUpdateEvent(events.get());
719 EXPECT_EQ(0.f, start_opacity_event->opacity); 723 EXPECT_EQ(0.f, start_opacity_event->opacity);
720 724
721 animations_impl->Animate(kInitialTickTime + 725 animations_impl->Animate(kInitialTickTime +
722 TimeDelta::FromMilliseconds(1000)); 726 TimeDelta::FromMilliseconds(1000));
723 animations_impl->UpdateState(true, events.get()); 727 animations_impl->UpdateState(true, events.get());
724 EXPECT_EQ(1.f, client_impl_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 728 EXPECT_EQ(1.f, client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE));
725 EXPECT_FALSE(animations_impl->HasActiveAnimation()); 729 EXPECT_FALSE(animations_impl->HasActiveAnimation());
726 EXPECT_EQ(2u, events->events_.size()); 730 EXPECT_EQ(2u, events->events_.size());
727 const AnimationEvent* end_opacity_event = 731 const AnimationEvent* end_opacity_event =
728 GetMostRecentPropertyUpdateEvent(events.get()); 732 GetMostRecentPropertyUpdateEvent(events.get());
729 EXPECT_EQ(1.f, end_opacity_event->opacity); 733 EXPECT_EQ(1.f, end_opacity_event->opacity);
730 } 734 }
731 735
732 TEST_F(ElementAnimationsTest, TrivialTransformOnImpl) { 736 TEST_F(ElementAnimationsTest, TrivialTransformOnImpl) {
733 CreateTestLayer(true, false); 737 CreateTestLayer(true, false);
734 AttachTimelinePlayerLayer(); 738 AttachTimelinePlayerLayer();
(...skipping 22 matching lines...) Expand all
757 std::unique_ptr<Animation> animation( 761 std::unique_ptr<Animation> animation(
758 Animation::Create(std::move(curve), 1, 0, TargetProperty::TRANSFORM)); 762 Animation::Create(std::move(curve), 1, 0, TargetProperty::TRANSFORM));
759 animation->set_is_impl_only(true); 763 animation->set_is_impl_only(true);
760 animations_impl->AddAnimation(std::move(animation)); 764 animations_impl->AddAnimation(std::move(animation));
761 765
762 // Run animation. 766 // Run animation.
763 animations_impl->Animate(kInitialTickTime); 767 animations_impl->Animate(kInitialTickTime);
764 animations_impl->UpdateState(true, events.get()); 768 animations_impl->UpdateState(true, events.get());
765 EXPECT_TRUE(animations_impl->HasActiveAnimation()); 769 EXPECT_TRUE(animations_impl->HasActiveAnimation());
766 EXPECT_EQ(gfx::Transform(), 770 EXPECT_EQ(gfx::Transform(),
767 client_impl_.GetTransform(element_id_, LayerTreeType::ACTIVE)); 771 client_impl_.GetTransform(element_id_, ElementListType::ACTIVE));
768 EXPECT_EQ(1u, events->events_.size()); 772 EXPECT_EQ(1u, events->events_.size());
769 const AnimationEvent* start_transform_event = 773 const AnimationEvent* start_transform_event =
770 GetMostRecentPropertyUpdateEvent(events.get()); 774 GetMostRecentPropertyUpdateEvent(events.get());
771 ASSERT_TRUE(start_transform_event); 775 ASSERT_TRUE(start_transform_event);
772 EXPECT_EQ(gfx::Transform(), start_transform_event->transform); 776 EXPECT_EQ(gfx::Transform(), start_transform_event->transform);
773 EXPECT_TRUE(start_transform_event->is_impl_only); 777 EXPECT_TRUE(start_transform_event->is_impl_only);
774 778
775 gfx::Transform expected_transform; 779 gfx::Transform expected_transform;
776 expected_transform.Translate(delta_x, delta_y); 780 expected_transform.Translate(delta_x, delta_y);
777 781
778 animations_impl->Animate(kInitialTickTime + 782 animations_impl->Animate(kInitialTickTime +
779 TimeDelta::FromMilliseconds(1000)); 783 TimeDelta::FromMilliseconds(1000));
780 animations_impl->UpdateState(true, events.get()); 784 animations_impl->UpdateState(true, events.get());
781 EXPECT_EQ(expected_transform, 785 EXPECT_EQ(expected_transform,
782 client_impl_.GetTransform(element_id_, LayerTreeType::ACTIVE)); 786 client_impl_.GetTransform(element_id_, ElementListType::ACTIVE));
783 EXPECT_FALSE(animations_impl->HasActiveAnimation()); 787 EXPECT_FALSE(animations_impl->HasActiveAnimation());
784 EXPECT_EQ(2u, events->events_.size()); 788 EXPECT_EQ(2u, events->events_.size());
785 const AnimationEvent* end_transform_event = 789 const AnimationEvent* end_transform_event =
786 GetMostRecentPropertyUpdateEvent(events.get()); 790 GetMostRecentPropertyUpdateEvent(events.get());
787 EXPECT_EQ(expected_transform, end_transform_event->transform); 791 EXPECT_EQ(expected_transform, end_transform_event->transform);
788 EXPECT_TRUE(end_transform_event->is_impl_only); 792 EXPECT_TRUE(end_transform_event->is_impl_only);
789 } 793 }
790 794
791 TEST_F(ElementAnimationsTest, FilterTransition) { 795 TEST_F(ElementAnimationsTest, FilterTransition) {
792 CreateTestLayer(true, false); 796 CreateTestLayer(true, false);
(...skipping 16 matching lines...) Expand all
809 end_filters, nullptr)); 813 end_filters, nullptr));
810 814
811 std::unique_ptr<Animation> animation( 815 std::unique_ptr<Animation> animation(
812 Animation::Create(std::move(curve), 1, 0, TargetProperty::FILTER)); 816 Animation::Create(std::move(curve), 1, 0, TargetProperty::FILTER));
813 animations->AddAnimation(std::move(animation)); 817 animations->AddAnimation(std::move(animation));
814 818
815 animations->Animate(kInitialTickTime); 819 animations->Animate(kInitialTickTime);
816 animations->UpdateState(true, events.get()); 820 animations->UpdateState(true, events.get());
817 EXPECT_TRUE(animations->HasActiveAnimation()); 821 EXPECT_TRUE(animations->HasActiveAnimation());
818 EXPECT_EQ(start_filters, 822 EXPECT_EQ(start_filters,
819 client_.GetFilters(element_id_, LayerTreeType::ACTIVE)); 823 client_.GetFilters(element_id_, ElementListType::ACTIVE));
820 // A non-impl-only animation should not generate property updates. 824 // A non-impl-only animation should not generate property updates.
821 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 825 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
822 EXPECT_FALSE(event); 826 EXPECT_FALSE(event);
823 827
824 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); 828 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
825 animations->UpdateState(true, events.get()); 829 animations->UpdateState(true, events.get());
826 EXPECT_EQ(1u, client_.GetFilters(element_id_, LayerTreeType::ACTIVE).size()); 830 EXPECT_EQ(1u,
831 client_.GetFilters(element_id_, ElementListType::ACTIVE).size());
827 EXPECT_EQ(FilterOperation::CreateBrightnessFilter(1.5f), 832 EXPECT_EQ(FilterOperation::CreateBrightnessFilter(1.5f),
828 client_.GetFilters(element_id_, LayerTreeType::ACTIVE).at(0)); 833 client_.GetFilters(element_id_, ElementListType::ACTIVE).at(0));
829 event = GetMostRecentPropertyUpdateEvent(events.get()); 834 event = GetMostRecentPropertyUpdateEvent(events.get());
830 EXPECT_FALSE(event); 835 EXPECT_FALSE(event);
831 836
832 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 837 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
833 animations->UpdateState(true, events.get()); 838 animations->UpdateState(true, events.get());
834 EXPECT_EQ(end_filters, 839 EXPECT_EQ(end_filters,
835 client_.GetFilters(element_id_, LayerTreeType::ACTIVE)); 840 client_.GetFilters(element_id_, ElementListType::ACTIVE));
836 EXPECT_FALSE(animations->HasActiveAnimation()); 841 EXPECT_FALSE(animations->HasActiveAnimation());
837 event = GetMostRecentPropertyUpdateEvent(events.get()); 842 event = GetMostRecentPropertyUpdateEvent(events.get());
838 EXPECT_FALSE(event); 843 EXPECT_FALSE(event);
839 } 844 }
840 845
841 TEST_F(ElementAnimationsTest, FilterTransitionOnImplOnly) { 846 TEST_F(ElementAnimationsTest, FilterTransitionOnImplOnly) {
842 CreateTestLayer(true, false); 847 CreateTestLayer(true, false);
843 AttachTimelinePlayerLayer(); 848 AttachTimelinePlayerLayer();
844 CreateImplTimelineAndPlayer(); 849 CreateImplTimelineAndPlayer();
845 850
(...skipping 17 matching lines...) Expand all
863 std::unique_ptr<Animation> animation( 868 std::unique_ptr<Animation> animation(
864 Animation::Create(std::move(curve), 1, 0, TargetProperty::FILTER)); 869 Animation::Create(std::move(curve), 1, 0, TargetProperty::FILTER));
865 animation->set_is_impl_only(true); 870 animation->set_is_impl_only(true);
866 animations_impl->AddAnimation(std::move(animation)); 871 animations_impl->AddAnimation(std::move(animation));
867 872
868 // Run animation. 873 // Run animation.
869 animations_impl->Animate(kInitialTickTime); 874 animations_impl->Animate(kInitialTickTime);
870 animations_impl->UpdateState(true, events.get()); 875 animations_impl->UpdateState(true, events.get());
871 EXPECT_TRUE(animations_impl->HasActiveAnimation()); 876 EXPECT_TRUE(animations_impl->HasActiveAnimation());
872 EXPECT_EQ(start_filters, 877 EXPECT_EQ(start_filters,
873 client_impl_.GetFilters(element_id_, LayerTreeType::ACTIVE)); 878 client_impl_.GetFilters(element_id_, ElementListType::ACTIVE));
874 EXPECT_EQ(1u, events->events_.size()); 879 EXPECT_EQ(1u, events->events_.size());
875 const AnimationEvent* start_filter_event = 880 const AnimationEvent* start_filter_event =
876 GetMostRecentPropertyUpdateEvent(events.get()); 881 GetMostRecentPropertyUpdateEvent(events.get());
877 EXPECT_TRUE(start_filter_event); 882 EXPECT_TRUE(start_filter_event);
878 EXPECT_EQ(start_filters, start_filter_event->filters); 883 EXPECT_EQ(start_filters, start_filter_event->filters);
879 EXPECT_TRUE(start_filter_event->is_impl_only); 884 EXPECT_TRUE(start_filter_event->is_impl_only);
880 885
881 animations_impl->Animate(kInitialTickTime + 886 animations_impl->Animate(kInitialTickTime +
882 TimeDelta::FromMilliseconds(1000)); 887 TimeDelta::FromMilliseconds(1000));
883 animations_impl->UpdateState(true, events.get()); 888 animations_impl->UpdateState(true, events.get());
884 EXPECT_EQ(end_filters, 889 EXPECT_EQ(end_filters,
885 client_impl_.GetFilters(element_id_, LayerTreeType::ACTIVE)); 890 client_impl_.GetFilters(element_id_, ElementListType::ACTIVE));
886 EXPECT_FALSE(animations_impl->HasActiveAnimation()); 891 EXPECT_FALSE(animations_impl->HasActiveAnimation());
887 EXPECT_EQ(2u, events->events_.size()); 892 EXPECT_EQ(2u, events->events_.size());
888 const AnimationEvent* end_filter_event = 893 const AnimationEvent* end_filter_event =
889 GetMostRecentPropertyUpdateEvent(events.get()); 894 GetMostRecentPropertyUpdateEvent(events.get());
890 EXPECT_TRUE(end_filter_event); 895 EXPECT_TRUE(end_filter_event);
891 EXPECT_EQ(end_filters, end_filter_event->filters); 896 EXPECT_EQ(end_filters, end_filter_event->filters);
892 EXPECT_TRUE(end_filter_event->is_impl_only); 897 EXPECT_TRUE(end_filter_event->is_impl_only);
893 } 898 }
894 899
895 TEST_F(ElementAnimationsTest, ScrollOffsetTransition) { 900 TEST_F(ElementAnimationsTest, ScrollOffsetTransition) {
(...skipping 26 matching lines...) Expand all
922 ->curve() 927 ->curve()
923 ->Duration(); 928 ->Duration();
924 EXPECT_EQ(duration, animations->GetAnimation(TargetProperty::SCROLL_OFFSET) 929 EXPECT_EQ(duration, animations->GetAnimation(TargetProperty::SCROLL_OFFSET)
925 ->curve() 930 ->curve()
926 ->Duration()); 931 ->Duration());
927 932
928 animations->Animate(kInitialTickTime); 933 animations->Animate(kInitialTickTime);
929 animations->UpdateState(true, nullptr); 934 animations->UpdateState(true, nullptr);
930 EXPECT_TRUE(animations->HasActiveAnimation()); 935 EXPECT_TRUE(animations->HasActiveAnimation());
931 EXPECT_EQ(initial_value, 936 EXPECT_EQ(initial_value,
932 client_.GetScrollOffset(element_id_, LayerTreeType::ACTIVE)); 937 client_.GetScrollOffset(element_id_, ElementListType::ACTIVE));
933 938
934 animations_impl->Animate(kInitialTickTime); 939 animations_impl->Animate(kInitialTickTime);
935 animations_impl->UpdateState(true, events.get()); 940 animations_impl->UpdateState(true, events.get());
936 EXPECT_TRUE(animations_impl->HasActiveAnimation()); 941 EXPECT_TRUE(animations_impl->HasActiveAnimation());
937 EXPECT_EQ(initial_value, 942 EXPECT_EQ(initial_value,
938 client_impl_.GetScrollOffset(element_id_, LayerTreeType::ACTIVE)); 943 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE));
939 // Scroll offset animations should not generate property updates. 944 // Scroll offset animations should not generate property updates.
940 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 945 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
941 EXPECT_FALSE(event); 946 EXPECT_FALSE(event);
942 947
943 animations->NotifyAnimationStarted(events->events_[0]); 948 animations->NotifyAnimationStarted(events->events_[0]);
944 animations->Animate(kInitialTickTime + duration / 2); 949 animations->Animate(kInitialTickTime + duration / 2);
945 animations->UpdateState(true, nullptr); 950 animations->UpdateState(true, nullptr);
946 EXPECT_TRUE(animations->HasActiveAnimation()); 951 EXPECT_TRUE(animations->HasActiveAnimation());
947 EXPECT_VECTOR2DF_EQ( 952 EXPECT_VECTOR2DF_EQ(
948 gfx::Vector2dF(200.f, 250.f), 953 gfx::Vector2dF(200.f, 250.f),
949 client_.GetScrollOffset(element_id_, LayerTreeType::ACTIVE)); 954 client_.GetScrollOffset(element_id_, ElementListType::ACTIVE));
950 955
951 animations_impl->Animate(kInitialTickTime + duration / 2); 956 animations_impl->Animate(kInitialTickTime + duration / 2);
952 animations_impl->UpdateState(true, events.get()); 957 animations_impl->UpdateState(true, events.get());
953 EXPECT_VECTOR2DF_EQ( 958 EXPECT_VECTOR2DF_EQ(
954 gfx::Vector2dF(200.f, 250.f), 959 gfx::Vector2dF(200.f, 250.f),
955 client_impl_.GetScrollOffset(element_id_, LayerTreeType::ACTIVE)); 960 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE));
956 event = GetMostRecentPropertyUpdateEvent(events.get()); 961 event = GetMostRecentPropertyUpdateEvent(events.get());
957 EXPECT_FALSE(event); 962 EXPECT_FALSE(event);
958 963
959 animations_impl->Animate(kInitialTickTime + duration); 964 animations_impl->Animate(kInitialTickTime + duration);
960 animations_impl->UpdateState(true, events.get()); 965 animations_impl->UpdateState(true, events.get());
961 EXPECT_VECTOR2DF_EQ(target_value, client_impl_.GetScrollOffset( 966 EXPECT_VECTOR2DF_EQ(target_value, client_impl_.GetScrollOffset(
962 element_id_, LayerTreeType::ACTIVE)); 967 element_id_, ElementListType::ACTIVE));
963 EXPECT_FALSE(animations_impl->HasActiveAnimation()); 968 EXPECT_FALSE(animations_impl->HasActiveAnimation());
964 event = GetMostRecentPropertyUpdateEvent(events.get()); 969 event = GetMostRecentPropertyUpdateEvent(events.get());
965 EXPECT_FALSE(event); 970 EXPECT_FALSE(event);
966 971
967 animations->Animate(kInitialTickTime + duration); 972 animations->Animate(kInitialTickTime + duration);
968 animations->UpdateState(true, nullptr); 973 animations->UpdateState(true, nullptr);
969 EXPECT_VECTOR2DF_EQ(target_value, client_.GetScrollOffset( 974 EXPECT_VECTOR2DF_EQ(target_value, client_.GetScrollOffset(
970 element_id_, LayerTreeType::ACTIVE)); 975 element_id_, ElementListType::ACTIVE));
971 EXPECT_FALSE(animations->HasActiveAnimation()); 976 EXPECT_FALSE(animations->HasActiveAnimation());
972 } 977 }
973 978
974 TEST_F(ElementAnimationsTest, ScrollOffsetTransitionOnImplOnly) { 979 TEST_F(ElementAnimationsTest, ScrollOffsetTransitionOnImplOnly) {
975 CreateTestLayer(true, false); 980 CreateTestLayer(true, false);
976 AttachTimelinePlayerLayer(); 981 AttachTimelinePlayerLayer();
977 CreateImplTimelineAndPlayer(); 982 CreateImplTimelineAndPlayer();
978 983
979 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 984 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
980 985
981 auto events = host_impl_->CreateEvents(); 986 auto events = host_impl_->CreateEvents();
982 987
983 gfx::ScrollOffset initial_value(100.f, 300.f); 988 gfx::ScrollOffset initial_value(100.f, 300.f);
984 gfx::ScrollOffset target_value(300.f, 200.f); 989 gfx::ScrollOffset target_value(300.f, 200.f);
985 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 990 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
986 ScrollOffsetAnimationCurve::Create(target_value, 991 ScrollOffsetAnimationCurve::Create(target_value,
987 EaseInOutTimingFunction::Create())); 992 EaseInOutTimingFunction::Create()));
988 curve->SetInitialValue(initial_value); 993 curve->SetInitialValue(initial_value);
989 double duration_in_seconds = curve->Duration().InSecondsF(); 994 double duration_in_seconds = curve->Duration().InSecondsF();
990 995
991 std::unique_ptr<Animation> animation( 996 std::unique_ptr<Animation> animation(
992 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); 997 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET));
993 animation->set_is_impl_only(true); 998 animation->set_is_impl_only(true);
994 animations_impl->AddAnimation(std::move(animation)); 999 animations_impl->AddAnimation(std::move(animation));
995 1000
996 animations_impl->Animate(kInitialTickTime); 1001 animations_impl->Animate(kInitialTickTime);
997 animations_impl->UpdateState(true, events.get()); 1002 animations_impl->UpdateState(true, events.get());
998 EXPECT_TRUE(animations_impl->HasActiveAnimation()); 1003 EXPECT_TRUE(animations_impl->HasActiveAnimation());
999 EXPECT_EQ(initial_value, 1004 EXPECT_EQ(initial_value,
1000 client_impl_.GetScrollOffset(element_id_, LayerTreeType::ACTIVE)); 1005 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE));
1001 // Scroll offset animations should not generate property updates. 1006 // Scroll offset animations should not generate property updates.
1002 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 1007 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
1003 EXPECT_FALSE(event); 1008 EXPECT_FALSE(event);
1004 1009
1005 TimeDelta duration = TimeDelta::FromMicroseconds( 1010 TimeDelta duration = TimeDelta::FromMicroseconds(
1006 duration_in_seconds * base::Time::kMicrosecondsPerSecond); 1011 duration_in_seconds * base::Time::kMicrosecondsPerSecond);
1007 1012
1008 animations_impl->Animate(kInitialTickTime + duration / 2); 1013 animations_impl->Animate(kInitialTickTime + duration / 2);
1009 animations_impl->UpdateState(true, events.get()); 1014 animations_impl->UpdateState(true, events.get());
1010 EXPECT_VECTOR2DF_EQ( 1015 EXPECT_VECTOR2DF_EQ(
1011 gfx::Vector2dF(200.f, 250.f), 1016 gfx::Vector2dF(200.f, 250.f),
1012 client_impl_.GetScrollOffset(element_id_, LayerTreeType::ACTIVE)); 1017 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE));
1013 event = GetMostRecentPropertyUpdateEvent(events.get()); 1018 event = GetMostRecentPropertyUpdateEvent(events.get());
1014 EXPECT_FALSE(event); 1019 EXPECT_FALSE(event);
1015 1020
1016 animations_impl->Animate(kInitialTickTime + duration); 1021 animations_impl->Animate(kInitialTickTime + duration);
1017 animations_impl->UpdateState(true, events.get()); 1022 animations_impl->UpdateState(true, events.get());
1018 EXPECT_VECTOR2DF_EQ(target_value, client_impl_.GetScrollOffset( 1023 EXPECT_VECTOR2DF_EQ(target_value, client_impl_.GetScrollOffset(
1019 element_id_, LayerTreeType::ACTIVE)); 1024 element_id_, ElementListType::ACTIVE));
1020 EXPECT_FALSE(animations_impl->HasActiveAnimation()); 1025 EXPECT_FALSE(animations_impl->HasActiveAnimation());
1021 event = GetMostRecentPropertyUpdateEvent(events.get()); 1026 event = GetMostRecentPropertyUpdateEvent(events.get());
1022 EXPECT_FALSE(event); 1027 EXPECT_FALSE(event);
1023 } 1028 }
1024 1029
1025 // Ensure that when the impl animations doesn't have a value provider, 1030 // Ensure that when the impl animations doesn't have a value provider,
1026 // the main-thread animations's value provider is used to obtain the intial 1031 // the main-thread animations's value provider is used to obtain the intial
1027 // scroll offset. 1032 // scroll offset.
1028 TEST_F(ElementAnimationsTest, ScrollOffsetTransitionNoImplProvider) { 1033 TEST_F(ElementAnimationsTest, ScrollOffsetTransitionNoImplProvider) {
1029 CreateTestLayer(false, false); 1034 CreateTestLayer(false, false);
1030 CreateTestImplLayer(LayerTreeType::PENDING); 1035 CreateTestImplLayer(ElementListType::PENDING);
1031 AttachTimelinePlayerLayer(); 1036 AttachTimelinePlayerLayer();
1032 CreateImplTimelineAndPlayer(); 1037 CreateImplTimelineAndPlayer();
1033 1038
1034 scoped_refptr<ElementAnimations> animations = element_animations(); 1039 scoped_refptr<ElementAnimations> animations = element_animations();
1035 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 1040 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
1036 1041
1037 EXPECT_TRUE(animations_impl->has_element_in_pending_list()); 1042 EXPECT_TRUE(animations_impl->has_element_in_pending_list());
1038 EXPECT_FALSE(animations_impl->has_element_in_active_list()); 1043 EXPECT_FALSE(animations_impl->has_element_in_active_list());
1039 1044
1040 auto events = host_impl_->CreateEvents(); 1045 auto events = host_impl_->CreateEvents();
(...skipping 19 matching lines...) Expand all
1060 ->Duration(); 1065 ->Duration();
1061 EXPECT_EQ(duration, animations->GetAnimation(TargetProperty::SCROLL_OFFSET) 1066 EXPECT_EQ(duration, animations->GetAnimation(TargetProperty::SCROLL_OFFSET)
1062 ->curve() 1067 ->curve()
1063 ->Duration()); 1068 ->Duration());
1064 1069
1065 animations->Animate(kInitialTickTime); 1070 animations->Animate(kInitialTickTime);
1066 animations->UpdateState(true, nullptr); 1071 animations->UpdateState(true, nullptr);
1067 1072
1068 EXPECT_TRUE(animations->HasActiveAnimation()); 1073 EXPECT_TRUE(animations->HasActiveAnimation());
1069 EXPECT_EQ(initial_value, 1074 EXPECT_EQ(initial_value,
1070 client_.GetScrollOffset(element_id_, LayerTreeType::ACTIVE)); 1075 client_.GetScrollOffset(element_id_, ElementListType::ACTIVE));
1071 EXPECT_EQ(gfx::ScrollOffset(), 1076 EXPECT_EQ(gfx::ScrollOffset(), client_impl_.GetScrollOffset(
1072 client_impl_.GetScrollOffset(element_id_, LayerTreeType::PENDING)); 1077 element_id_, ElementListType::PENDING));
1073 1078
1074 animations_impl->Animate(kInitialTickTime); 1079 animations_impl->Animate(kInitialTickTime);
1075 1080
1076 EXPECT_TRUE(animations_impl->HasActiveAnimation()); 1081 EXPECT_TRUE(animations_impl->HasActiveAnimation());
1077 EXPECT_EQ(initial_value, 1082 EXPECT_EQ(initial_value, client_impl_.GetScrollOffset(
1078 client_impl_.GetScrollOffset(element_id_, LayerTreeType::PENDING)); 1083 element_id_, ElementListType::PENDING));
1079 1084
1080 CreateTestImplLayer(LayerTreeType::ACTIVE); 1085 CreateTestImplLayer(ElementListType::ACTIVE);
1081 1086
1082 animations_impl->UpdateState(true, events.get()); 1087 animations_impl->UpdateState(true, events.get());
1083 DCHECK_EQ(1UL, events->events_.size()); 1088 DCHECK_EQ(1UL, events->events_.size());
1084 1089
1085 // Scroll offset animations should not generate property updates. 1090 // Scroll offset animations should not generate property updates.
1086 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 1091 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
1087 EXPECT_FALSE(event); 1092 EXPECT_FALSE(event);
1088 1093
1089 animations->NotifyAnimationStarted(events->events_[0]); 1094 animations->NotifyAnimationStarted(events->events_[0]);
1090 animations->Animate(kInitialTickTime + duration / 2); 1095 animations->Animate(kInitialTickTime + duration / 2);
1091 animations->UpdateState(true, nullptr); 1096 animations->UpdateState(true, nullptr);
1092 EXPECT_TRUE(animations->HasActiveAnimation()); 1097 EXPECT_TRUE(animations->HasActiveAnimation());
1093 EXPECT_VECTOR2DF_EQ( 1098 EXPECT_VECTOR2DF_EQ(
1094 gfx::Vector2dF(400.f, 150.f), 1099 gfx::Vector2dF(400.f, 150.f),
1095 client_.GetScrollOffset(element_id_, LayerTreeType::ACTIVE)); 1100 client_.GetScrollOffset(element_id_, ElementListType::ACTIVE));
1096 1101
1097 animations_impl->Animate(kInitialTickTime + duration / 2); 1102 animations_impl->Animate(kInitialTickTime + duration / 2);
1098 animations_impl->UpdateState(true, events.get()); 1103 animations_impl->UpdateState(true, events.get());
1099 EXPECT_VECTOR2DF_EQ( 1104 EXPECT_VECTOR2DF_EQ(
1100 gfx::Vector2dF(400.f, 150.f), 1105 gfx::Vector2dF(400.f, 150.f),
1101 client_impl_.GetScrollOffset(element_id_, LayerTreeType::PENDING)); 1106 client_impl_.GetScrollOffset(element_id_, ElementListType::PENDING));
1102 event = GetMostRecentPropertyUpdateEvent(events.get()); 1107 event = GetMostRecentPropertyUpdateEvent(events.get());
1103 EXPECT_FALSE(event); 1108 EXPECT_FALSE(event);
1104 1109
1105 animations_impl->Animate(kInitialTickTime + duration); 1110 animations_impl->Animate(kInitialTickTime + duration);
1106 animations_impl->UpdateState(true, events.get()); 1111 animations_impl->UpdateState(true, events.get());
1107 EXPECT_VECTOR2DF_EQ(target_value, client_impl_.GetScrollOffset( 1112 EXPECT_VECTOR2DF_EQ(target_value, client_impl_.GetScrollOffset(
1108 element_id_, LayerTreeType::PENDING)); 1113 element_id_, ElementListType::PENDING));
1109 EXPECT_FALSE(animations_impl->HasActiveAnimation()); 1114 EXPECT_FALSE(animations_impl->HasActiveAnimation());
1110 event = GetMostRecentPropertyUpdateEvent(events.get()); 1115 event = GetMostRecentPropertyUpdateEvent(events.get());
1111 EXPECT_FALSE(event); 1116 EXPECT_FALSE(event);
1112 1117
1113 animations->Animate(kInitialTickTime + duration); 1118 animations->Animate(kInitialTickTime + duration);
1114 animations->UpdateState(true, nullptr); 1119 animations->UpdateState(true, nullptr);
1115 EXPECT_VECTOR2DF_EQ(target_value, client_.GetScrollOffset( 1120 EXPECT_VECTOR2DF_EQ(target_value, client_.GetScrollOffset(
1116 element_id_, LayerTreeType::ACTIVE)); 1121 element_id_, ElementListType::ACTIVE));
1117 EXPECT_FALSE(animations->HasActiveAnimation()); 1122 EXPECT_FALSE(animations->HasActiveAnimation());
1118 } 1123 }
1119 1124
1120 TEST_F(ElementAnimationsTest, ScrollOffsetRemovalClearsScrollDelta) { 1125 TEST_F(ElementAnimationsTest, ScrollOffsetRemovalClearsScrollDelta) {
1121 CreateTestLayer(true, false); 1126 CreateTestLayer(true, false);
1122 AttachTimelinePlayerLayer(); 1127 AttachTimelinePlayerLayer();
1123 CreateImplTimelineAndPlayer(); 1128 CreateImplTimelineAndPlayer();
1124 1129
1125 scoped_refptr<ElementAnimations> animations = element_animations(); 1130 scoped_refptr<ElementAnimations> animations = element_animations();
1126 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 1131 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1309 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
1305 1, TargetProperty::OPACITY)); 1310 1, TargetProperty::OPACITY));
1306 to_add->set_needs_synchronized_start_time(true); 1311 to_add->set_needs_synchronized_start_time(true);
1307 1312
1308 // We should pause at the first keyframe indefinitely waiting for that 1313 // We should pause at the first keyframe indefinitely waiting for that
1309 // animation to start. 1314 // animation to start.
1310 animations->AddAnimation(std::move(to_add)); 1315 animations->AddAnimation(std::move(to_add));
1311 animations->Animate(kInitialTickTime); 1316 animations->Animate(kInitialTickTime);
1312 animations->UpdateState(true, events.get()); 1317 animations->UpdateState(true, events.get());
1313 EXPECT_TRUE(animations->HasActiveAnimation()); 1318 EXPECT_TRUE(animations->HasActiveAnimation());
1314 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1319 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1315 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 1320 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1316 animations->UpdateState(true, events.get()); 1321 animations->UpdateState(true, events.get());
1317 EXPECT_TRUE(animations->HasActiveAnimation()); 1322 EXPECT_TRUE(animations->HasActiveAnimation());
1318 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1323 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1319 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 1324 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1320 animations->UpdateState(true, events.get()); 1325 animations->UpdateState(true, events.get());
1321 EXPECT_TRUE(animations->HasActiveAnimation()); 1326 EXPECT_TRUE(animations->HasActiveAnimation());
1322 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1327 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1323 1328
1324 // Send the synchronized start time. 1329 // Send the synchronized start time.
1325 animations->NotifyAnimationStarted( 1330 animations->NotifyAnimationStarted(
1326 AnimationEvent(AnimationEvent::STARTED, 0, 1, TargetProperty::OPACITY, 1331 AnimationEvent(AnimationEvent::STARTED, 0, 1, TargetProperty::OPACITY,
1327 kInitialTickTime + TimeDelta::FromMilliseconds(2000))); 1332 kInitialTickTime + TimeDelta::FromMilliseconds(2000)));
1328 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(5000)); 1333 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(5000));
1329 animations->UpdateState(true, events.get()); 1334 animations->UpdateState(true, events.get());
1330 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1335 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1331 EXPECT_FALSE(animations->HasActiveAnimation()); 1336 EXPECT_FALSE(animations->HasActiveAnimation());
1332 } 1337 }
1333 1338
1334 // Tests that two queued animations affecting the same property run in sequence. 1339 // Tests that two queued animations affecting the same property run in sequence.
1335 TEST_F(ElementAnimationsTest, TrivialQueuing) { 1340 TEST_F(ElementAnimationsTest, TrivialQueuing) {
1336 CreateTestLayer(false, false); 1341 CreateTestLayer(false, false);
1337 AttachTimelinePlayerLayer(); 1342 AttachTimelinePlayerLayer();
1338 1343
1339 scoped_refptr<ElementAnimations> animations = element_animations(); 1344 scoped_refptr<ElementAnimations> animations = element_animations();
1340 1345
(...skipping 10 matching lines...) Expand all
1351 1356
1352 EXPECT_TRUE(animations->needs_to_start_animations_for_testing()); 1357 EXPECT_TRUE(animations->needs_to_start_animations_for_testing());
1353 1358
1354 animations->Animate(kInitialTickTime); 1359 animations->Animate(kInitialTickTime);
1355 1360
1356 // The second animation still needs to be started. 1361 // The second animation still needs to be started.
1357 EXPECT_TRUE(animations->needs_to_start_animations_for_testing()); 1362 EXPECT_TRUE(animations->needs_to_start_animations_for_testing());
1358 1363
1359 animations->UpdateState(true, events.get()); 1364 animations->UpdateState(true, events.get());
1360 EXPECT_TRUE(animations->HasActiveAnimation()); 1365 EXPECT_TRUE(animations->HasActiveAnimation());
1361 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1366 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1362 1367
1363 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 1368 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1364 EXPECT_TRUE(animations->needs_to_start_animations_for_testing()); 1369 EXPECT_TRUE(animations->needs_to_start_animations_for_testing());
1365 animations->UpdateState(true, events.get()); 1370 animations->UpdateState(true, events.get());
1366 EXPECT_FALSE(animations->needs_to_start_animations_for_testing()); 1371 EXPECT_FALSE(animations->needs_to_start_animations_for_testing());
1367 1372
1368 EXPECT_TRUE(animations->HasActiveAnimation()); 1373 EXPECT_TRUE(animations->HasActiveAnimation());
1369 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1374 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1370 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 1375 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1371 animations->UpdateState(true, events.get()); 1376 animations->UpdateState(true, events.get());
1372 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1377 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1373 EXPECT_FALSE(animations->HasActiveAnimation()); 1378 EXPECT_FALSE(animations->HasActiveAnimation());
1374 } 1379 }
1375 1380
1376 // Tests interrupting a transition with another transition. 1381 // Tests interrupting a transition with another transition.
1377 TEST_F(ElementAnimationsTest, Interrupt) { 1382 TEST_F(ElementAnimationsTest, Interrupt) {
1378 CreateTestLayer(false, false); 1383 CreateTestLayer(false, false);
1379 AttachTimelinePlayerLayer(); 1384 AttachTimelinePlayerLayer();
1380 1385
1381 scoped_refptr<ElementAnimations> animations = element_animations(); 1386 scoped_refptr<ElementAnimations> animations = element_animations();
1382 1387
1383 auto events = host_impl_->CreateEvents(); 1388 auto events = host_impl_->CreateEvents();
1384 1389
1385 animations->AddAnimation(CreateAnimation( 1390 animations->AddAnimation(CreateAnimation(
1386 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1391 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
1387 1, TargetProperty::OPACITY)); 1392 1, TargetProperty::OPACITY));
1388 animations->Animate(kInitialTickTime); 1393 animations->Animate(kInitialTickTime);
1389 animations->UpdateState(true, events.get()); 1394 animations->UpdateState(true, events.get());
1390 EXPECT_TRUE(animations->HasActiveAnimation()); 1395 EXPECT_TRUE(animations->HasActiveAnimation());
1391 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1396 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1392 1397
1393 std::unique_ptr<Animation> to_add(CreateAnimation( 1398 std::unique_ptr<Animation> to_add(CreateAnimation(
1394 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), 1399 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)),
1395 2, TargetProperty::OPACITY)); 1400 2, TargetProperty::OPACITY));
1396 animations->AbortAnimations(TargetProperty::OPACITY); 1401 animations->AbortAnimations(TargetProperty::OPACITY);
1397 animations->AddAnimation(std::move(to_add)); 1402 animations->AddAnimation(std::move(to_add));
1398 1403
1399 // Since the previous animation was aborted, the new animation should start 1404 // Since the previous animation was aborted, the new animation should start
1400 // right in this call to animate. 1405 // right in this call to animate.
1401 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); 1406 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
1402 animations->UpdateState(true, events.get()); 1407 animations->UpdateState(true, events.get());
1403 EXPECT_TRUE(animations->HasActiveAnimation()); 1408 EXPECT_TRUE(animations->HasActiveAnimation());
1404 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1409 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1405 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); 1410 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500));
1406 animations->UpdateState(true, events.get()); 1411 animations->UpdateState(true, events.get());
1407 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1412 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1408 EXPECT_FALSE(animations->HasActiveAnimation()); 1413 EXPECT_FALSE(animations->HasActiveAnimation());
1409 } 1414 }
1410 1415
1411 // Tests scheduling two animations to run together when only one property is 1416 // Tests scheduling two animations to run together when only one property is
1412 // free. 1417 // free.
1413 TEST_F(ElementAnimationsTest, ScheduleTogetherWhenAPropertyIsBlocked) { 1418 TEST_F(ElementAnimationsTest, ScheduleTogetherWhenAPropertyIsBlocked) {
1414 CreateTestLayer(false, false); 1419 CreateTestLayer(false, false);
1415 AttachTimelinePlayerLayer(); 1420 AttachTimelinePlayerLayer();
1416 1421
1417 scoped_refptr<ElementAnimations> animations = element_animations(); 1422 scoped_refptr<ElementAnimations> animations = element_animations();
1418 1423
1419 auto events = host_impl_->CreateEvents(); 1424 auto events = host_impl_->CreateEvents();
1420 1425
1421 animations->AddAnimation(CreateAnimation( 1426 animations->AddAnimation(CreateAnimation(
1422 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, 1427 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1,
1423 TargetProperty::TRANSFORM)); 1428 TargetProperty::TRANSFORM));
1424 animations->AddAnimation(CreateAnimation( 1429 animations->AddAnimation(CreateAnimation(
1425 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 2, 1430 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 2,
1426 TargetProperty::TRANSFORM)); 1431 TargetProperty::TRANSFORM));
1427 animations->AddAnimation(CreateAnimation( 1432 animations->AddAnimation(CreateAnimation(
1428 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1433 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
1429 2, TargetProperty::OPACITY)); 1434 2, TargetProperty::OPACITY));
1430 1435
1431 animations->Animate(kInitialTickTime); 1436 animations->Animate(kInitialTickTime);
1432 animations->UpdateState(true, events.get()); 1437 animations->UpdateState(true, events.get());
1433 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1438 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1434 EXPECT_TRUE(animations->HasActiveAnimation()); 1439 EXPECT_TRUE(animations->HasActiveAnimation());
1435 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 1440 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1436 animations->UpdateState(true, events.get()); 1441 animations->UpdateState(true, events.get());
1437 // Should not have started the float transition yet. 1442 // Should not have started the float transition yet.
1438 EXPECT_TRUE(animations->HasActiveAnimation()); 1443 EXPECT_TRUE(animations->HasActiveAnimation());
1439 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1444 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1440 // The float animation should have started at time 1 and should be done. 1445 // The float animation should have started at time 1 and should be done.
1441 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 1446 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1442 animations->UpdateState(true, events.get()); 1447 animations->UpdateState(true, events.get());
1443 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1448 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1444 EXPECT_FALSE(animations->HasActiveAnimation()); 1449 EXPECT_FALSE(animations->HasActiveAnimation());
1445 } 1450 }
1446 1451
1447 // Tests scheduling two animations to run together with different lengths and 1452 // Tests scheduling two animations to run together with different lengths and
1448 // another animation queued to start when the shorter animation finishes (should 1453 // another animation queued to start when the shorter animation finishes (should
1449 // wait for both to finish). 1454 // wait for both to finish).
1450 TEST_F(ElementAnimationsTest, ScheduleTogetherWithAnAnimWaiting) { 1455 TEST_F(ElementAnimationsTest, ScheduleTogetherWithAnAnimWaiting) {
1451 CreateTestLayer(false, false); 1456 CreateTestLayer(false, false);
1452 AttachTimelinePlayerLayer(); 1457 AttachTimelinePlayerLayer();
1453 1458
1454 scoped_refptr<ElementAnimations> animations = element_animations(); 1459 scoped_refptr<ElementAnimations> animations = element_animations();
1455 1460
1456 auto events = host_impl_->CreateEvents(); 1461 auto events = host_impl_->CreateEvents();
1457 1462
1458 animations->AddAnimation(CreateAnimation( 1463 animations->AddAnimation(CreateAnimation(
1459 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(2)), 1, 1464 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(2)), 1,
1460 TargetProperty::TRANSFORM)); 1465 TargetProperty::TRANSFORM));
1461 animations->AddAnimation(CreateAnimation( 1466 animations->AddAnimation(CreateAnimation(
1462 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1467 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
1463 1, TargetProperty::OPACITY)); 1468 1, TargetProperty::OPACITY));
1464 animations->AddAnimation(CreateAnimation( 1469 animations->AddAnimation(CreateAnimation(
1465 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), 1470 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)),
1466 2, TargetProperty::OPACITY)); 1471 2, TargetProperty::OPACITY));
1467 1472
1468 // Animations with id 1 should both start now. 1473 // Animations with id 1 should both start now.
1469 animations->Animate(kInitialTickTime); 1474 animations->Animate(kInitialTickTime);
1470 animations->UpdateState(true, events.get()); 1475 animations->UpdateState(true, events.get());
1471 EXPECT_TRUE(animations->HasActiveAnimation()); 1476 EXPECT_TRUE(animations->HasActiveAnimation());
1472 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1477 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1473 // The opacity animation should have finished at time 1, but the group 1478 // The opacity animation should have finished at time 1, but the group
1474 // of animations with id 1 don't finish until time 2 because of the length 1479 // of animations with id 1 don't finish until time 2 because of the length
1475 // of the transform animation. 1480 // of the transform animation.
1476 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 1481 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1477 animations->UpdateState(true, events.get()); 1482 animations->UpdateState(true, events.get());
1478 // Should not have started the float transition yet. 1483 // Should not have started the float transition yet.
1479 EXPECT_TRUE(animations->HasActiveAnimation()); 1484 EXPECT_TRUE(animations->HasActiveAnimation());
1480 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1485 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1481 1486
1482 // The second opacity animation should start at time 2 and should be done by 1487 // The second opacity animation should start at time 2 and should be done by
1483 // time 3. 1488 // time 3.
1484 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); 1489 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
1485 animations->UpdateState(true, events.get()); 1490 animations->UpdateState(true, events.get());
1486 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1491 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1487 EXPECT_FALSE(animations->HasActiveAnimation()); 1492 EXPECT_FALSE(animations->HasActiveAnimation());
1488 } 1493 }
1489 1494
1490 // Test that a looping animation loops and for the correct number of iterations. 1495 // Test that a looping animation loops and for the correct number of iterations.
1491 TEST_F(ElementAnimationsTest, TrivialLooping) { 1496 TEST_F(ElementAnimationsTest, TrivialLooping) {
1492 CreateTestLayer(false, false); 1497 CreateTestLayer(false, false);
1493 AttachTimelinePlayerLayer(); 1498 AttachTimelinePlayerLayer();
1494 1499
1495 scoped_refptr<ElementAnimations> animations = element_animations(); 1500 scoped_refptr<ElementAnimations> animations = element_animations();
1496 1501
1497 auto events = host_impl_->CreateEvents(); 1502 auto events = host_impl_->CreateEvents();
1498 1503
1499 std::unique_ptr<Animation> to_add(CreateAnimation( 1504 std::unique_ptr<Animation> to_add(CreateAnimation(
1500 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1505 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
1501 1, TargetProperty::OPACITY)); 1506 1, TargetProperty::OPACITY));
1502 to_add->set_iterations(3); 1507 to_add->set_iterations(3);
1503 animations->AddAnimation(std::move(to_add)); 1508 animations->AddAnimation(std::move(to_add));
1504 1509
1505 animations->Animate(kInitialTickTime); 1510 animations->Animate(kInitialTickTime);
1506 animations->UpdateState(true, events.get()); 1511 animations->UpdateState(true, events.get());
1507 EXPECT_TRUE(animations->HasActiveAnimation()); 1512 EXPECT_TRUE(animations->HasActiveAnimation());
1508 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1513 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1509 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); 1514 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250));
1510 animations->UpdateState(true, events.get()); 1515 animations->UpdateState(true, events.get());
1511 EXPECT_TRUE(animations->HasActiveAnimation()); 1516 EXPECT_TRUE(animations->HasActiveAnimation());
1512 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1517 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1513 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); 1518 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750));
1514 animations->UpdateState(true, events.get()); 1519 animations->UpdateState(true, events.get());
1515 EXPECT_TRUE(animations->HasActiveAnimation()); 1520 EXPECT_TRUE(animations->HasActiveAnimation());
1516 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1521 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1517 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2250)); 1522 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2250));
1518 animations->UpdateState(true, events.get()); 1523 animations->UpdateState(true, events.get());
1519 EXPECT_TRUE(animations->HasActiveAnimation()); 1524 EXPECT_TRUE(animations->HasActiveAnimation());
1520 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1525 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1521 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2750)); 1526 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2750));
1522 animations->UpdateState(true, events.get()); 1527 animations->UpdateState(true, events.get());
1523 EXPECT_TRUE(animations->HasActiveAnimation()); 1528 EXPECT_TRUE(animations->HasActiveAnimation());
1524 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1529 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1525 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); 1530 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
1526 animations->UpdateState(true, events.get()); 1531 animations->UpdateState(true, events.get());
1527 EXPECT_FALSE(animations->HasActiveAnimation()); 1532 EXPECT_FALSE(animations->HasActiveAnimation());
1528 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1533 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1529 1534
1530 // Just be extra sure. 1535 // Just be extra sure.
1531 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); 1536 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000));
1532 animations->UpdateState(true, events.get()); 1537 animations->UpdateState(true, events.get());
1533 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1538 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1534 } 1539 }
1535 1540
1536 // Test that an infinitely looping animation does indeed go until aborted. 1541 // Test that an infinitely looping animation does indeed go until aborted.
1537 TEST_F(ElementAnimationsTest, InfiniteLooping) { 1542 TEST_F(ElementAnimationsTest, InfiniteLooping) {
1538 CreateTestLayer(false, false); 1543 CreateTestLayer(false, false);
1539 AttachTimelinePlayerLayer(); 1544 AttachTimelinePlayerLayer();
1540 1545
1541 scoped_refptr<ElementAnimations> animations = element_animations(); 1546 scoped_refptr<ElementAnimations> animations = element_animations();
1542 1547
1543 auto events = host_impl_->CreateEvents(); 1548 auto events = host_impl_->CreateEvents();
1544 1549
1545 std::unique_ptr<Animation> to_add(CreateAnimation( 1550 std::unique_ptr<Animation> to_add(CreateAnimation(
1546 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1551 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
1547 1, TargetProperty::OPACITY)); 1552 1, TargetProperty::OPACITY));
1548 to_add->set_iterations(-1); 1553 to_add->set_iterations(-1);
1549 animations->AddAnimation(std::move(to_add)); 1554 animations->AddAnimation(std::move(to_add));
1550 1555
1551 animations->Animate(kInitialTickTime); 1556 animations->Animate(kInitialTickTime);
1552 animations->UpdateState(true, events.get()); 1557 animations->UpdateState(true, events.get());
1553 EXPECT_TRUE(animations->HasActiveAnimation()); 1558 EXPECT_TRUE(animations->HasActiveAnimation());
1554 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1559 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1555 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); 1560 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250));
1556 animations->UpdateState(true, events.get()); 1561 animations->UpdateState(true, events.get());
1557 EXPECT_TRUE(animations->HasActiveAnimation()); 1562 EXPECT_TRUE(animations->HasActiveAnimation());
1558 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1563 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1559 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); 1564 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750));
1560 animations->UpdateState(true, events.get()); 1565 animations->UpdateState(true, events.get());
1561 EXPECT_TRUE(animations->HasActiveAnimation()); 1566 EXPECT_TRUE(animations->HasActiveAnimation());
1562 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1567 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1563 1568
1564 animations->Animate(kInitialTickTime + 1569 animations->Animate(kInitialTickTime +
1565 TimeDelta::FromMilliseconds(1073741824250)); 1570 TimeDelta::FromMilliseconds(1073741824250));
1566 animations->UpdateState(true, events.get()); 1571 animations->UpdateState(true, events.get());
1567 EXPECT_TRUE(animations->HasActiveAnimation()); 1572 EXPECT_TRUE(animations->HasActiveAnimation());
1568 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1573 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1569 animations->Animate(kInitialTickTime + 1574 animations->Animate(kInitialTickTime +
1570 TimeDelta::FromMilliseconds(1073741824750)); 1575 TimeDelta::FromMilliseconds(1073741824750));
1571 animations->UpdateState(true, events.get()); 1576 animations->UpdateState(true, events.get());
1572 EXPECT_TRUE(animations->HasActiveAnimation()); 1577 EXPECT_TRUE(animations->HasActiveAnimation());
1573 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1578 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1574 1579
1575 EXPECT_TRUE(animations->GetAnimation(TargetProperty::OPACITY)); 1580 EXPECT_TRUE(animations->GetAnimation(TargetProperty::OPACITY));
1576 animations->GetAnimation(TargetProperty::OPACITY) 1581 animations->GetAnimation(TargetProperty::OPACITY)
1577 ->SetRunState(Animation::ABORTED, 1582 ->SetRunState(Animation::ABORTED,
1578 kInitialTickTime + TimeDelta::FromMilliseconds(750)); 1583 kInitialTickTime + TimeDelta::FromMilliseconds(750));
1579 EXPECT_FALSE(animations->HasActiveAnimation()); 1584 EXPECT_FALSE(animations->HasActiveAnimation());
1580 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1585 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1581 } 1586 }
1582 1587
1583 // Test that pausing and resuming work as expected. 1588 // Test that pausing and resuming work as expected.
1584 TEST_F(ElementAnimationsTest, PauseResume) { 1589 TEST_F(ElementAnimationsTest, PauseResume) {
1585 CreateTestLayer(false, false); 1590 CreateTestLayer(false, false);
1586 AttachTimelinePlayerLayer(); 1591 AttachTimelinePlayerLayer();
1587 1592
1588 scoped_refptr<ElementAnimations> animations = element_animations(); 1593 scoped_refptr<ElementAnimations> animations = element_animations();
1589 1594
1590 auto events = host_impl_->CreateEvents(); 1595 auto events = host_impl_->CreateEvents();
1591 1596
1592 animations->AddAnimation(CreateAnimation( 1597 animations->AddAnimation(CreateAnimation(
1593 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1598 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
1594 1, TargetProperty::OPACITY)); 1599 1, TargetProperty::OPACITY));
1595 1600
1596 animations->Animate(kInitialTickTime); 1601 animations->Animate(kInitialTickTime);
1597 animations->UpdateState(true, events.get()); 1602 animations->UpdateState(true, events.get());
1598 EXPECT_TRUE(animations->HasActiveAnimation()); 1603 EXPECT_TRUE(animations->HasActiveAnimation());
1599 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1604 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1600 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); 1605 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
1601 animations->UpdateState(true, events.get()); 1606 animations->UpdateState(true, events.get());
1602 EXPECT_TRUE(animations->HasActiveAnimation()); 1607 EXPECT_TRUE(animations->HasActiveAnimation());
1603 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1608 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1604 1609
1605 EXPECT_TRUE(animations->GetAnimation(TargetProperty::OPACITY)); 1610 EXPECT_TRUE(animations->GetAnimation(TargetProperty::OPACITY));
1606 animations->GetAnimation(TargetProperty::OPACITY) 1611 animations->GetAnimation(TargetProperty::OPACITY)
1607 ->SetRunState(Animation::PAUSED, 1612 ->SetRunState(Animation::PAUSED,
1608 kInitialTickTime + TimeDelta::FromMilliseconds(500)); 1613 kInitialTickTime + TimeDelta::FromMilliseconds(500));
1609 1614
1610 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); 1615 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024000));
1611 animations->UpdateState(true, events.get()); 1616 animations->UpdateState(true, events.get());
1612 EXPECT_TRUE(animations->HasActiveAnimation()); 1617 EXPECT_TRUE(animations->HasActiveAnimation());
1613 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1618 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1614 1619
1615 EXPECT_TRUE(animations->GetAnimation(TargetProperty::OPACITY)); 1620 EXPECT_TRUE(animations->GetAnimation(TargetProperty::OPACITY));
1616 animations->GetAnimation(TargetProperty::OPACITY) 1621 animations->GetAnimation(TargetProperty::OPACITY)
1617 ->SetRunState(Animation::RUNNING, 1622 ->SetRunState(Animation::RUNNING,
1618 kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); 1623 kInitialTickTime + TimeDelta::FromMilliseconds(1024000));
1619 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024250)); 1624 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024250));
1620 animations->UpdateState(true, events.get()); 1625 animations->UpdateState(true, events.get());
1621 EXPECT_TRUE(animations->HasActiveAnimation()); 1626 EXPECT_TRUE(animations->HasActiveAnimation());
1622 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1627 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1623 1628
1624 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024500)); 1629 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024500));
1625 animations->UpdateState(true, events.get()); 1630 animations->UpdateState(true, events.get());
1626 EXPECT_FALSE(animations->HasActiveAnimation()); 1631 EXPECT_FALSE(animations->HasActiveAnimation());
1627 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1632 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1628 } 1633 }
1629 1634
1630 TEST_F(ElementAnimationsTest, AbortAGroupedAnimation) { 1635 TEST_F(ElementAnimationsTest, AbortAGroupedAnimation) {
1631 CreateTestLayer(false, false); 1636 CreateTestLayer(false, false);
1632 AttachTimelinePlayerLayer(); 1637 AttachTimelinePlayerLayer();
1633 1638
1634 scoped_refptr<ElementAnimations> animations = element_animations(); 1639 scoped_refptr<ElementAnimations> animations = element_animations();
1635 1640
1636 auto events = host_impl_->CreateEvents(); 1641 auto events = host_impl_->CreateEvents();
1637 1642
1638 const int animation_id = 2; 1643 const int animation_id = 2;
1639 animations->AddAnimation(Animation::Create( 1644 animations->AddAnimation(Animation::Create(
1640 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, 1, 1645 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, 1,
1641 TargetProperty::TRANSFORM)); 1646 TargetProperty::TRANSFORM));
1642 animations->AddAnimation(Animation::Create( 1647 animations->AddAnimation(Animation::Create(
1643 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)), 1648 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)),
1644 animation_id, 1, TargetProperty::OPACITY)); 1649 animation_id, 1, TargetProperty::OPACITY));
1645 animations->AddAnimation(Animation::Create( 1650 animations->AddAnimation(Animation::Create(
1646 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.75f)), 1651 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.75f)),
1647 3, 2, TargetProperty::OPACITY)); 1652 3, 2, TargetProperty::OPACITY));
1648 1653
1649 animations->Animate(kInitialTickTime); 1654 animations->Animate(kInitialTickTime);
1650 animations->UpdateState(true, events.get()); 1655 animations->UpdateState(true, events.get());
1651 EXPECT_TRUE(animations->HasActiveAnimation()); 1656 EXPECT_TRUE(animations->HasActiveAnimation());
1652 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1657 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1653 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 1658 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1654 animations->UpdateState(true, events.get()); 1659 animations->UpdateState(true, events.get());
1655 EXPECT_TRUE(animations->HasActiveAnimation()); 1660 EXPECT_TRUE(animations->HasActiveAnimation());
1656 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1661 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1657 1662
1658 EXPECT_TRUE(animations->GetAnimationById(animation_id)); 1663 EXPECT_TRUE(animations->GetAnimationById(animation_id));
1659 animations->GetAnimationById(animation_id) 1664 animations->GetAnimationById(animation_id)
1660 ->SetRunState(Animation::ABORTED, 1665 ->SetRunState(Animation::ABORTED,
1661 kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 1666 kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1662 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 1667 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1663 animations->UpdateState(true, events.get()); 1668 animations->UpdateState(true, events.get());
1664 EXPECT_TRUE(animations->HasActiveAnimation()); 1669 EXPECT_TRUE(animations->HasActiveAnimation());
1665 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1670 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1666 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 1671 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1667 animations->UpdateState(true, events.get()); 1672 animations->UpdateState(true, events.get());
1668 EXPECT_TRUE(!animations->HasActiveAnimation()); 1673 EXPECT_TRUE(!animations->HasActiveAnimation());
1669 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1674 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1670 } 1675 }
1671 1676
1672 TEST_F(ElementAnimationsTest, PushUpdatesWhenSynchronizedStartTimeNeeded) { 1677 TEST_F(ElementAnimationsTest, PushUpdatesWhenSynchronizedStartTimeNeeded) {
1673 CreateTestLayer(true, false); 1678 CreateTestLayer(true, false);
1674 AttachTimelinePlayerLayer(); 1679 AttachTimelinePlayerLayer();
1675 CreateImplTimelineAndPlayer(); 1680 CreateImplTimelineAndPlayer();
1676 1681
1677 scoped_refptr<ElementAnimations> animations = element_animations(); 1682 scoped_refptr<ElementAnimations> animations = element_animations();
1678 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 1683 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
1679 1684
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 1737 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1733 events = host_impl_->CreateEvents(); 1738 events = host_impl_->CreateEvents();
1734 animations->UpdateState(true, events.get()); 1739 animations->UpdateState(true, events.get());
1735 1740
1736 // Should have one STARTED event and one FINISHED event. 1741 // Should have one STARTED event and one FINISHED event.
1737 EXPECT_EQ(2u, events->events_.size()); 1742 EXPECT_EQ(2u, events->events_.size());
1738 EXPECT_NE(events->events_[0].type, events->events_[1].type); 1743 EXPECT_NE(events->events_[0].type, events->events_[1].type);
1739 1744
1740 // The float transition should still be at its starting point. 1745 // The float transition should still be at its starting point.
1741 EXPECT_TRUE(animations->HasActiveAnimation()); 1746 EXPECT_TRUE(animations->HasActiveAnimation());
1742 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1747 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1743 1748
1744 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); 1749 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
1745 animations->UpdateState(true, events.get()); 1750 animations->UpdateState(true, events.get());
1746 1751
1747 // The float tranisition should now be done. 1752 // The float tranisition should now be done.
1748 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1753 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
1749 EXPECT_FALSE(animations->HasActiveAnimation()); 1754 EXPECT_FALSE(animations->HasActiveAnimation());
1750 } 1755 }
1751 1756
1752 // Tests that an animation animations with only a pending observer gets ticked 1757 // Tests that an animation animations with only a pending observer gets ticked
1753 // but doesn't progress animations past the STARTING state. 1758 // but doesn't progress animations past the STARTING state.
1754 TEST_F(ElementAnimationsTest, InactiveObserverGetsTicked) { 1759 TEST_F(ElementAnimationsTest, InactiveObserverGetsTicked) {
1755 AttachTimelinePlayerLayer(); 1760 AttachTimelinePlayerLayer();
1756 CreateImplTimelineAndPlayer(); 1761 CreateImplTimelineAndPlayer();
1757 1762
1758 scoped_refptr<ElementAnimations> animations = element_animations_impl(); 1763 scoped_refptr<ElementAnimations> animations = element_animations_impl();
1759 1764
1760 auto events = host_impl_->CreateEvents(); 1765 auto events = host_impl_->CreateEvents();
1761 1766
1762 const int id = 1; 1767 const int id = 1;
1763 animations->AddAnimation(CreateAnimation( 1768 animations->AddAnimation(CreateAnimation(
1764 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.5f, 1.f)), 1769 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.5f, 1.f)),
1765 id, TargetProperty::OPACITY)); 1770 id, TargetProperty::OPACITY));
1766 1771
1767 // Without an observer, the animation shouldn't progress to the STARTING 1772 // Without an observer, the animation shouldn't progress to the STARTING
1768 // state. 1773 // state.
1769 animations->Animate(kInitialTickTime); 1774 animations->Animate(kInitialTickTime);
1770 animations->UpdateState(true, events.get()); 1775 animations->UpdateState(true, events.get());
1771 EXPECT_EQ(0u, events->events_.size()); 1776 EXPECT_EQ(0u, events->events_.size());
1772 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, 1777 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY,
1773 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); 1778 animations->GetAnimation(TargetProperty::OPACITY)->run_state());
1774 1779
1775 CreateTestImplLayer(LayerTreeType::PENDING); 1780 CreateTestImplLayer(ElementListType::PENDING);
1776 1781
1777 // With only a pending observer, the animation should progress to the 1782 // With only a pending observer, the animation should progress to the
1778 // STARTING state and get ticked at its starting point, but should not 1783 // STARTING state and get ticked at its starting point, but should not
1779 // progress to RUNNING. 1784 // progress to RUNNING.
1780 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 1785 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1781 animations->UpdateState(true, events.get()); 1786 animations->UpdateState(true, events.get());
1782 EXPECT_EQ(0u, events->events_.size()); 1787 EXPECT_EQ(0u, events->events_.size());
1783 EXPECT_EQ(Animation::STARTING, 1788 EXPECT_EQ(Animation::STARTING,
1784 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); 1789 animations->GetAnimation(TargetProperty::OPACITY)->run_state());
1785 EXPECT_EQ(0.5f, client_impl_.GetOpacity(element_id_, LayerTreeType::PENDING)); 1790 EXPECT_EQ(0.5f,
1791 client_impl_.GetOpacity(element_id_, ElementListType::PENDING));
1786 1792
1787 // Even when already in the STARTING state, the animation should stay 1793 // Even when already in the STARTING state, the animation should stay
1788 // there, and shouldn't be ticked past its starting point. 1794 // there, and shouldn't be ticked past its starting point.
1789 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 1795 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1790 animations->UpdateState(true, events.get()); 1796 animations->UpdateState(true, events.get());
1791 EXPECT_EQ(0u, events->events_.size()); 1797 EXPECT_EQ(0u, events->events_.size());
1792 EXPECT_EQ(Animation::STARTING, 1798 EXPECT_EQ(Animation::STARTING,
1793 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); 1799 animations->GetAnimation(TargetProperty::OPACITY)->run_state());
1794 EXPECT_EQ(0.5f, client_impl_.GetOpacity(element_id_, LayerTreeType::PENDING)); 1800 EXPECT_EQ(0.5f,
1801 client_impl_.GetOpacity(element_id_, ElementListType::PENDING));
1795 1802
1796 CreateTestImplLayer(LayerTreeType::ACTIVE); 1803 CreateTestImplLayer(ElementListType::ACTIVE);
1797 1804
1798 // Now that an active observer has been added, the animation should still 1805 // Now that an active observer has been added, the animation should still
1799 // initially tick at its starting point, but should now progress to RUNNING. 1806 // initially tick at its starting point, but should now progress to RUNNING.
1800 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); 1807 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
1801 animations->UpdateState(true, events.get()); 1808 animations->UpdateState(true, events.get());
1802 EXPECT_EQ(1u, events->events_.size()); 1809 EXPECT_EQ(1u, events->events_.size());
1803 EXPECT_EQ(Animation::RUNNING, 1810 EXPECT_EQ(Animation::RUNNING,
1804 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); 1811 animations->GetAnimation(TargetProperty::OPACITY)->run_state());
1805 EXPECT_EQ(0.5f, client_impl_.GetOpacity(element_id_, LayerTreeType::PENDING)); 1812 EXPECT_EQ(0.5f,
1806 EXPECT_EQ(0.5f, client_impl_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1813 client_impl_.GetOpacity(element_id_, ElementListType::PENDING));
1814 EXPECT_EQ(0.5f,
1815 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE));
1807 1816
1808 // The animation should now tick past its starting point. 1817 // The animation should now tick past its starting point.
1809 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3500)); 1818 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3500));
1810 EXPECT_NE(0.5f, client_impl_.GetOpacity(element_id_, LayerTreeType::PENDING)); 1819 EXPECT_NE(0.5f,
1811 EXPECT_NE(0.5f, client_impl_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 1820 client_impl_.GetOpacity(element_id_, ElementListType::PENDING));
1821 EXPECT_NE(0.5f,
1822 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE));
1812 } 1823 }
1813 1824
1814 TEST_F(ElementAnimationsTest, TransformAnimationBounds) { 1825 TEST_F(ElementAnimationsTest, TransformAnimationBounds) {
1815 AttachTimelinePlayerLayer(); 1826 AttachTimelinePlayerLayer();
1816 CreateImplTimelineAndPlayer(); 1827 CreateImplTimelineAndPlayer();
1817 1828
1818 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 1829 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
1819 1830
1820 std::unique_ptr<KeyframedTransformAnimationCurve> curve1( 1831 std::unique_ptr<KeyframedTransformAnimationCurve> curve1(
1821 KeyframedTransformAnimationCurve::Create()); 1832 KeyframedTransformAnimationCurve::Create());
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
2247 } 2258 }
2248 2259
2249 TEST_F(ElementAnimationsTest, HasOnlyTranslationTransforms) { 2260 TEST_F(ElementAnimationsTest, HasOnlyTranslationTransforms) {
2250 CreateTestLayer(true, false); 2261 CreateTestLayer(true, false);
2251 AttachTimelinePlayerLayer(); 2262 AttachTimelinePlayerLayer();
2252 CreateImplTimelineAndPlayer(); 2263 CreateImplTimelineAndPlayer();
2253 2264
2254 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 2265 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
2255 2266
2256 EXPECT_TRUE( 2267 EXPECT_TRUE(
2257 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); 2268 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE));
2258 EXPECT_TRUE( 2269 EXPECT_TRUE(
2259 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); 2270 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING));
2260 2271
2261 animations_impl->AddAnimation(CreateAnimation( 2272 animations_impl->AddAnimation(CreateAnimation(
2262 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2273 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
2263 1, TargetProperty::OPACITY)); 2274 1, TargetProperty::OPACITY));
2264 2275
2265 // Opacity animations aren't non-translation transforms. 2276 // Opacity animations aren't non-translation transforms.
2266 EXPECT_TRUE( 2277 EXPECT_TRUE(
2267 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); 2278 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE));
2268 EXPECT_TRUE( 2279 EXPECT_TRUE(
2269 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); 2280 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING));
2270 2281
2271 std::unique_ptr<KeyframedTransformAnimationCurve> curve1( 2282 std::unique_ptr<KeyframedTransformAnimationCurve> curve1(
2272 KeyframedTransformAnimationCurve::Create()); 2283 KeyframedTransformAnimationCurve::Create());
2273 2284
2274 TransformOperations operations1; 2285 TransformOperations operations1;
2275 curve1->AddKeyframe( 2286 curve1->AddKeyframe(
2276 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); 2287 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr));
2277 operations1.AppendTranslate(10.0, 15.0, 0.0); 2288 operations1.AppendTranslate(10.0, 15.0, 0.0);
2278 curve1->AddKeyframe(TransformKeyframe::Create( 2289 curve1->AddKeyframe(TransformKeyframe::Create(
2279 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); 2290 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr));
2280 2291
2281 std::unique_ptr<Animation> animation( 2292 std::unique_ptr<Animation> animation(
2282 Animation::Create(std::move(curve1), 2, 2, TargetProperty::TRANSFORM)); 2293 Animation::Create(std::move(curve1), 2, 2, TargetProperty::TRANSFORM));
2283 animations_impl->AddAnimation(std::move(animation)); 2294 animations_impl->AddAnimation(std::move(animation));
2284 2295
2285 // The only transform animation we've added is a translation. 2296 // The only transform animation we've added is a translation.
2286 EXPECT_TRUE( 2297 EXPECT_TRUE(
2287 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); 2298 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE));
2288 EXPECT_TRUE( 2299 EXPECT_TRUE(
2289 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); 2300 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING));
2290 2301
2291 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( 2302 std::unique_ptr<KeyframedTransformAnimationCurve> curve2(
2292 KeyframedTransformAnimationCurve::Create()); 2303 KeyframedTransformAnimationCurve::Create());
2293 2304
2294 TransformOperations operations2; 2305 TransformOperations operations2;
2295 curve2->AddKeyframe( 2306 curve2->AddKeyframe(
2296 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); 2307 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr));
2297 operations2.AppendScale(2.0, 3.0, 4.0); 2308 operations2.AppendScale(2.0, 3.0, 4.0);
2298 curve2->AddKeyframe(TransformKeyframe::Create( 2309 curve2->AddKeyframe(TransformKeyframe::Create(
2299 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); 2310 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr));
2300 2311
2301 animation = 2312 animation =
2302 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM); 2313 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM);
2303 animation->set_affects_active_elements(false); 2314 animation->set_affects_active_elements(false);
2304 animations_impl->AddAnimation(std::move(animation)); 2315 animations_impl->AddAnimation(std::move(animation));
2305 2316
2306 // A scale animation is not a translation. 2317 // A scale animation is not a translation.
2307 EXPECT_FALSE( 2318 EXPECT_FALSE(
2308 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); 2319 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING));
2309 EXPECT_TRUE( 2320 EXPECT_TRUE(
2310 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); 2321 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE));
2311 2322
2312 animations_impl->ActivateAnimations(); 2323 animations_impl->ActivateAnimations();
2313 EXPECT_FALSE( 2324 EXPECT_FALSE(
2314 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); 2325 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING));
2315 EXPECT_FALSE( 2326 EXPECT_FALSE(
2316 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); 2327 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE));
2317 2328
2318 animations_impl->GetAnimationById(3)->set_affects_pending_elements(false); 2329 animations_impl->GetAnimationById(3)->set_affects_pending_elements(false);
2319 EXPECT_TRUE( 2330 EXPECT_TRUE(
2320 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); 2331 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING));
2321 EXPECT_FALSE( 2332 EXPECT_FALSE(
2322 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); 2333 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE));
2323 2334
2324 animations_impl->GetAnimationById(3)->SetRunState(Animation::FINISHED, 2335 animations_impl->GetAnimationById(3)->SetRunState(Animation::FINISHED,
2325 TicksFromSecondsF(0.0)); 2336 TicksFromSecondsF(0.0));
2326 2337
2327 // Only unfinished animations should be considered by 2338 // Only unfinished animations should be considered by
2328 // HasOnlyTranslationTransforms. 2339 // HasOnlyTranslationTransforms.
2329 EXPECT_TRUE( 2340 EXPECT_TRUE(
2330 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); 2341 animations_impl->HasOnlyTranslationTransforms(ElementListType::PENDING));
2331 EXPECT_TRUE( 2342 EXPECT_TRUE(
2332 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); 2343 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE));
2333 } 2344 }
2334 2345
2335 TEST_F(ElementAnimationsTest, AnimationStartScale) { 2346 TEST_F(ElementAnimationsTest, AnimationStartScale) {
2336 CreateTestLayer(true, false); 2347 CreateTestLayer(true, false);
2337 AttachTimelinePlayerLayer(); 2348 AttachTimelinePlayerLayer();
2338 CreateImplTimelineAndPlayer(); 2349 CreateImplTimelineAndPlayer();
2339 2350
2340 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 2351 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
2341 2352
2342 std::unique_ptr<KeyframedTransformAnimationCurve> curve1( 2353 std::unique_ptr<KeyframedTransformAnimationCurve> curve1(
2343 KeyframedTransformAnimationCurve::Create()); 2354 KeyframedTransformAnimationCurve::Create());
2344 2355
2345 TransformOperations operations1; 2356 TransformOperations operations1;
2346 operations1.AppendScale(2.0, 3.0, 4.0); 2357 operations1.AppendScale(2.0, 3.0, 4.0);
2347 curve1->AddKeyframe( 2358 curve1->AddKeyframe(
2348 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); 2359 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr));
2349 TransformOperations operations2; 2360 TransformOperations operations2;
2350 curve1->AddKeyframe(TransformKeyframe::Create( 2361 curve1->AddKeyframe(TransformKeyframe::Create(
2351 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); 2362 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr));
2352 std::unique_ptr<Animation> animation( 2363 std::unique_ptr<Animation> animation(
2353 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); 2364 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM));
2354 animation->set_affects_active_elements(false); 2365 animation->set_affects_active_elements(false);
2355 animations_impl->AddAnimation(std::move(animation)); 2366 animations_impl->AddAnimation(std::move(animation));
2356 2367
2357 float start_scale = 0.f; 2368 float start_scale = 0.f;
2358 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::PENDING, 2369 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING,
2359 &start_scale)); 2370 &start_scale));
2360 EXPECT_EQ(4.f, start_scale); 2371 EXPECT_EQ(4.f, start_scale);
2361 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::ACTIVE, 2372 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE,
2362 &start_scale)); 2373 &start_scale));
2363 EXPECT_EQ(0.f, start_scale); 2374 EXPECT_EQ(0.f, start_scale);
2364 2375
2365 animations_impl->ActivateAnimations(); 2376 animations_impl->ActivateAnimations();
2366 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::PENDING, 2377 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING,
2367 &start_scale)); 2378 &start_scale));
2368 EXPECT_EQ(4.f, start_scale); 2379 EXPECT_EQ(4.f, start_scale);
2369 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::ACTIVE, 2380 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE,
2370 &start_scale)); 2381 &start_scale));
2371 EXPECT_EQ(4.f, start_scale); 2382 EXPECT_EQ(4.f, start_scale);
2372 2383
2373 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( 2384 std::unique_ptr<KeyframedTransformAnimationCurve> curve2(
2374 KeyframedTransformAnimationCurve::Create()); 2385 KeyframedTransformAnimationCurve::Create());
2375 2386
2376 TransformOperations operations3; 2387 TransformOperations operations3;
2377 curve2->AddKeyframe( 2388 curve2->AddKeyframe(
2378 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); 2389 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr));
2379 operations3.AppendScale(6.0, 5.0, 4.0); 2390 operations3.AppendScale(6.0, 5.0, 4.0);
(...skipping 18 matching lines...) Expand all
2398 TransformKeyframe::Create(base::TimeDelta(), operations4, nullptr)); 2409 TransformKeyframe::Create(base::TimeDelta(), operations4, nullptr));
2399 TransformOperations operations5; 2410 TransformOperations operations5;
2400 curve3->AddKeyframe(TransformKeyframe::Create( 2411 curve3->AddKeyframe(TransformKeyframe::Create(
2401 base::TimeDelta::FromSecondsD(1.0), operations5, nullptr)); 2412 base::TimeDelta::FromSecondsD(1.0), operations5, nullptr));
2402 2413
2403 animation = 2414 animation =
2404 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); 2415 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM);
2405 animation->set_affects_active_elements(false); 2416 animation->set_affects_active_elements(false);
2406 animations_impl->AddAnimation(std::move(animation)); 2417 animations_impl->AddAnimation(std::move(animation));
2407 2418
2408 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::PENDING, 2419 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING,
2409 &start_scale)); 2420 &start_scale));
2410 EXPECT_EQ(6.f, start_scale); 2421 EXPECT_EQ(6.f, start_scale);
2411 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::ACTIVE, 2422 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE,
2412 &start_scale)); 2423 &start_scale));
2413 EXPECT_EQ(0.f, start_scale); 2424 EXPECT_EQ(0.f, start_scale);
2414 2425
2415 animations_impl->ActivateAnimations(); 2426 animations_impl->ActivateAnimations();
2416 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::PENDING, 2427 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING,
2417 &start_scale)); 2428 &start_scale));
2418 EXPECT_EQ(6.f, start_scale); 2429 EXPECT_EQ(6.f, start_scale);
2419 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::ACTIVE, 2430 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE,
2420 &start_scale)); 2431 &start_scale));
2421 EXPECT_EQ(6.f, start_scale); 2432 EXPECT_EQ(6.f, start_scale);
2422 2433
2423 animations_impl->GetAnimationById(2)->SetRunState(Animation::FINISHED, 2434 animations_impl->GetAnimationById(2)->SetRunState(Animation::FINISHED,
2424 TicksFromSecondsF(0.0)); 2435 TicksFromSecondsF(0.0));
2425 2436
2426 // Only unfinished animations should be considered by 2437 // Only unfinished animations should be considered by
2427 // AnimationStartScale. 2438 // AnimationStartScale.
2428 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::PENDING, 2439 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::PENDING,
2429 &start_scale)); 2440 &start_scale));
2430 EXPECT_EQ(5.f, start_scale); 2441 EXPECT_EQ(5.f, start_scale);
2431 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::ACTIVE, 2442 EXPECT_TRUE(animations_impl->AnimationStartScale(ElementListType::ACTIVE,
2432 &start_scale)); 2443 &start_scale));
2433 EXPECT_EQ(5.f, start_scale); 2444 EXPECT_EQ(5.f, start_scale);
2434 } 2445 }
2435 2446
2436 TEST_F(ElementAnimationsTest, MaximumTargetScale) { 2447 TEST_F(ElementAnimationsTest, MaximumTargetScale) {
2437 CreateTestLayer(true, false); 2448 CreateTestLayer(true, false);
2438 AttachTimelinePlayerLayer(); 2449 AttachTimelinePlayerLayer();
2439 CreateImplTimelineAndPlayer(); 2450 CreateImplTimelineAndPlayer();
2440 2451
2441 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 2452 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
2442 2453
2443 float max_scale = 0.f; 2454 float max_scale = 0.f;
2444 EXPECT_TRUE( 2455 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2445 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2456 &max_scale));
2446 EXPECT_EQ(0.f, max_scale); 2457 EXPECT_EQ(0.f, max_scale);
2447 EXPECT_TRUE( 2458 EXPECT_TRUE(
2448 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2459 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2449 EXPECT_EQ(0.f, max_scale); 2460 EXPECT_EQ(0.f, max_scale);
2450 2461
2451 std::unique_ptr<KeyframedTransformAnimationCurve> curve1( 2462 std::unique_ptr<KeyframedTransformAnimationCurve> curve1(
2452 KeyframedTransformAnimationCurve::Create()); 2463 KeyframedTransformAnimationCurve::Create());
2453 2464
2454 TransformOperations operations1; 2465 TransformOperations operations1;
2455 curve1->AddKeyframe( 2466 curve1->AddKeyframe(
2456 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); 2467 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr));
2457 operations1.AppendScale(2.0, 3.0, 4.0); 2468 operations1.AppendScale(2.0, 3.0, 4.0);
2458 curve1->AddKeyframe(TransformKeyframe::Create( 2469 curve1->AddKeyframe(TransformKeyframe::Create(
2459 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); 2470 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr));
2460 2471
2461 std::unique_ptr<Animation> animation( 2472 std::unique_ptr<Animation> animation(
2462 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); 2473 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM));
2463 animation->set_affects_active_elements(false); 2474 animation->set_affects_active_elements(false);
2464 animations_impl->AddAnimation(std::move(animation)); 2475 animations_impl->AddAnimation(std::move(animation));
2465 2476
2466 EXPECT_TRUE( 2477 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2467 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2478 &max_scale));
2468 EXPECT_EQ(4.f, max_scale); 2479 EXPECT_EQ(4.f, max_scale);
2469 EXPECT_TRUE( 2480 EXPECT_TRUE(
2470 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2481 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2471 EXPECT_EQ(0.f, max_scale); 2482 EXPECT_EQ(0.f, max_scale);
2472 2483
2473 animations_impl->ActivateAnimations(); 2484 animations_impl->ActivateAnimations();
2474 EXPECT_TRUE( 2485 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2475 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2486 &max_scale));
2476 EXPECT_EQ(4.f, max_scale); 2487 EXPECT_EQ(4.f, max_scale);
2477 EXPECT_TRUE( 2488 EXPECT_TRUE(
2478 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2489 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2479 EXPECT_EQ(4.f, max_scale); 2490 EXPECT_EQ(4.f, max_scale);
2480 2491
2481 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( 2492 std::unique_ptr<KeyframedTransformAnimationCurve> curve2(
2482 KeyframedTransformAnimationCurve::Create()); 2493 KeyframedTransformAnimationCurve::Create());
2483 2494
2484 TransformOperations operations2; 2495 TransformOperations operations2;
2485 curve2->AddKeyframe( 2496 curve2->AddKeyframe(
2486 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); 2497 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr));
2487 operations2.AppendScale(6.0, 5.0, 4.0); 2498 operations2.AppendScale(6.0, 5.0, 4.0);
2488 curve2->AddKeyframe(TransformKeyframe::Create( 2499 curve2->AddKeyframe(TransformKeyframe::Create(
2489 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); 2500 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr));
2490 2501
2491 animation = 2502 animation =
2492 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); 2503 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM);
2493 animation->set_affects_active_elements(false); 2504 animation->set_affects_active_elements(false);
2494 animations_impl->AddAnimation(std::move(animation)); 2505 animations_impl->AddAnimation(std::move(animation));
2495 2506
2496 EXPECT_TRUE( 2507 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2497 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2508 &max_scale));
2498 EXPECT_EQ(6.f, max_scale); 2509 EXPECT_EQ(6.f, max_scale);
2499 EXPECT_TRUE( 2510 EXPECT_TRUE(
2500 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2511 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2501 EXPECT_EQ(4.f, max_scale); 2512 EXPECT_EQ(4.f, max_scale);
2502 2513
2503 animations_impl->ActivateAnimations(); 2514 animations_impl->ActivateAnimations();
2504 EXPECT_TRUE( 2515 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2505 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2516 &max_scale));
2506 EXPECT_EQ(6.f, max_scale); 2517 EXPECT_EQ(6.f, max_scale);
2507 EXPECT_TRUE( 2518 EXPECT_TRUE(
2508 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2519 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2509 EXPECT_EQ(6.f, max_scale); 2520 EXPECT_EQ(6.f, max_scale);
2510 2521
2511 std::unique_ptr<KeyframedTransformAnimationCurve> curve3( 2522 std::unique_ptr<KeyframedTransformAnimationCurve> curve3(
2512 KeyframedTransformAnimationCurve::Create()); 2523 KeyframedTransformAnimationCurve::Create());
2513 2524
2514 TransformOperations operations3; 2525 TransformOperations operations3;
2515 curve3->AddKeyframe( 2526 curve3->AddKeyframe(
2516 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); 2527 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr));
2517 operations3.AppendPerspective(6.0); 2528 operations3.AppendPerspective(6.0);
2518 curve3->AddKeyframe(TransformKeyframe::Create( 2529 curve3->AddKeyframe(TransformKeyframe::Create(
2519 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); 2530 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr));
2520 2531
2521 animation = 2532 animation =
2522 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); 2533 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM);
2523 animation->set_affects_active_elements(false); 2534 animation->set_affects_active_elements(false);
2524 animations_impl->AddAnimation(std::move(animation)); 2535 animations_impl->AddAnimation(std::move(animation));
2525 2536
2526 EXPECT_FALSE( 2537 EXPECT_FALSE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2527 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2538 &max_scale));
2528 EXPECT_TRUE( 2539 EXPECT_TRUE(
2529 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2540 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2530 EXPECT_EQ(6.f, max_scale); 2541 EXPECT_EQ(6.f, max_scale);
2531 2542
2532 animations_impl->ActivateAnimations(); 2543 animations_impl->ActivateAnimations();
2544 EXPECT_FALSE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2545 &max_scale));
2533 EXPECT_FALSE( 2546 EXPECT_FALSE(
2534 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2547 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2535 EXPECT_FALSE(
2536 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale));
2537 2548
2538 animations_impl->GetAnimationById(3)->SetRunState(Animation::FINISHED, 2549 animations_impl->GetAnimationById(3)->SetRunState(Animation::FINISHED,
2539 TicksFromSecondsF(0.0)); 2550 TicksFromSecondsF(0.0));
2540 animations_impl->GetAnimationById(2)->SetRunState(Animation::FINISHED, 2551 animations_impl->GetAnimationById(2)->SetRunState(Animation::FINISHED,
2541 TicksFromSecondsF(0.0)); 2552 TicksFromSecondsF(0.0));
2542 2553
2543 // Only unfinished animations should be considered by 2554 // Only unfinished animations should be considered by
2544 // MaximumTargetScale. 2555 // MaximumTargetScale.
2545 EXPECT_TRUE( 2556 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2546 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2557 &max_scale));
2547 EXPECT_EQ(4.f, max_scale); 2558 EXPECT_EQ(4.f, max_scale);
2548 EXPECT_TRUE( 2559 EXPECT_TRUE(
2549 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2560 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2550 EXPECT_EQ(4.f, max_scale); 2561 EXPECT_EQ(4.f, max_scale);
2551 } 2562 }
2552 2563
2553 TEST_F(ElementAnimationsTest, MaximumTargetScaleWithDirection) { 2564 TEST_F(ElementAnimationsTest, MaximumTargetScaleWithDirection) {
2554 CreateTestLayer(true, false); 2565 CreateTestLayer(true, false);
2555 AttachTimelinePlayerLayer(); 2566 AttachTimelinePlayerLayer();
2556 CreateImplTimelineAndPlayer(); 2567 CreateImplTimelineAndPlayer();
2557 2568
2558 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 2569 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
2559 2570
(...skipping 12 matching lines...) Expand all
2572 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); 2583 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM));
2573 Animation* animation = animation_owned.get(); 2584 Animation* animation = animation_owned.get();
2574 animations_impl->AddAnimation(std::move(animation_owned)); 2585 animations_impl->AddAnimation(std::move(animation_owned));
2575 2586
2576 float max_scale = 0.f; 2587 float max_scale = 0.f;
2577 2588
2578 EXPECT_GT(animation->playback_rate(), 0.0); 2589 EXPECT_GT(animation->playback_rate(), 0.0);
2579 2590
2580 // NORMAL direction with positive playback rate. 2591 // NORMAL direction with positive playback rate.
2581 animation->set_direction(Animation::DIRECTION_NORMAL); 2592 animation->set_direction(Animation::DIRECTION_NORMAL);
2582 EXPECT_TRUE( 2593 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2583 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2594 &max_scale));
2584 EXPECT_EQ(6.f, max_scale); 2595 EXPECT_EQ(6.f, max_scale);
2585 EXPECT_TRUE( 2596 EXPECT_TRUE(
2586 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2597 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2587 EXPECT_EQ(6.f, max_scale); 2598 EXPECT_EQ(6.f, max_scale);
2588 2599
2589 // ALTERNATE direction with positive playback rate. 2600 // ALTERNATE direction with positive playback rate.
2590 animation->set_direction(Animation::DIRECTION_ALTERNATE); 2601 animation->set_direction(Animation::DIRECTION_ALTERNATE);
2591 EXPECT_TRUE( 2602 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2592 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2603 &max_scale));
2593 EXPECT_EQ(6.f, max_scale); 2604 EXPECT_EQ(6.f, max_scale);
2594 EXPECT_TRUE( 2605 EXPECT_TRUE(
2595 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2606 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2596 EXPECT_EQ(6.f, max_scale); 2607 EXPECT_EQ(6.f, max_scale);
2597 2608
2598 // REVERSE direction with positive playback rate. 2609 // REVERSE direction with positive playback rate.
2599 animation->set_direction(Animation::DIRECTION_REVERSE); 2610 animation->set_direction(Animation::DIRECTION_REVERSE);
2600 EXPECT_TRUE( 2611 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2601 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2612 &max_scale));
2602 EXPECT_EQ(3.f, max_scale); 2613 EXPECT_EQ(3.f, max_scale);
2603 EXPECT_TRUE( 2614 EXPECT_TRUE(
2604 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2615 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2605 EXPECT_EQ(3.f, max_scale); 2616 EXPECT_EQ(3.f, max_scale);
2606 2617
2607 // ALTERNATE reverse direction. 2618 // ALTERNATE reverse direction.
2608 animation->set_direction(Animation::DIRECTION_REVERSE); 2619 animation->set_direction(Animation::DIRECTION_REVERSE);
2609 EXPECT_TRUE( 2620 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2610 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2621 &max_scale));
2611 EXPECT_EQ(3.f, max_scale); 2622 EXPECT_EQ(3.f, max_scale);
2612 EXPECT_TRUE( 2623 EXPECT_TRUE(
2613 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2624 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2614 EXPECT_EQ(3.f, max_scale); 2625 EXPECT_EQ(3.f, max_scale);
2615 2626
2616 animation->set_playback_rate(-1.0); 2627 animation->set_playback_rate(-1.0);
2617 2628
2618 // NORMAL direction with negative playback rate. 2629 // NORMAL direction with negative playback rate.
2619 animation->set_direction(Animation::DIRECTION_NORMAL); 2630 animation->set_direction(Animation::DIRECTION_NORMAL);
2620 EXPECT_TRUE( 2631 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2621 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2632 &max_scale));
2622 EXPECT_EQ(3.f, max_scale); 2633 EXPECT_EQ(3.f, max_scale);
2623 EXPECT_TRUE( 2634 EXPECT_TRUE(
2624 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2635 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2625 EXPECT_EQ(3.f, max_scale); 2636 EXPECT_EQ(3.f, max_scale);
2626 2637
2627 // ALTERNATE direction with negative playback rate. 2638 // ALTERNATE direction with negative playback rate.
2628 animation->set_direction(Animation::DIRECTION_ALTERNATE); 2639 animation->set_direction(Animation::DIRECTION_ALTERNATE);
2629 EXPECT_TRUE( 2640 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2630 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2641 &max_scale));
2631 EXPECT_EQ(3.f, max_scale); 2642 EXPECT_EQ(3.f, max_scale);
2632 EXPECT_TRUE( 2643 EXPECT_TRUE(
2633 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2644 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2634 EXPECT_EQ(3.f, max_scale); 2645 EXPECT_EQ(3.f, max_scale);
2635 2646
2636 // REVERSE direction with negative playback rate. 2647 // REVERSE direction with negative playback rate.
2637 animation->set_direction(Animation::DIRECTION_REVERSE); 2648 animation->set_direction(Animation::DIRECTION_REVERSE);
2638 EXPECT_TRUE( 2649 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2639 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2650 &max_scale));
2640 EXPECT_EQ(6.f, max_scale); 2651 EXPECT_EQ(6.f, max_scale);
2641 EXPECT_TRUE( 2652 EXPECT_TRUE(
2642 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2653 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2643 EXPECT_EQ(6.f, max_scale); 2654 EXPECT_EQ(6.f, max_scale);
2644 2655
2645 // ALTERNATE reverse direction with negative playback rate. 2656 // ALTERNATE reverse direction with negative playback rate.
2646 animation->set_direction(Animation::DIRECTION_REVERSE); 2657 animation->set_direction(Animation::DIRECTION_REVERSE);
2647 EXPECT_TRUE( 2658 EXPECT_TRUE(animations_impl->MaximumTargetScale(ElementListType::PENDING,
2648 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2659 &max_scale));
2649 EXPECT_EQ(6.f, max_scale); 2660 EXPECT_EQ(6.f, max_scale);
2650 EXPECT_TRUE( 2661 EXPECT_TRUE(
2651 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2662 animations_impl->MaximumTargetScale(ElementListType::ACTIVE, &max_scale));
2652 EXPECT_EQ(6.f, max_scale); 2663 EXPECT_EQ(6.f, max_scale);
2653 } 2664 }
2654 2665
2655 TEST_F(ElementAnimationsTest, NewlyPushedAnimationWaitsForActivation) { 2666 TEST_F(ElementAnimationsTest, NewlyPushedAnimationWaitsForActivation) {
2656 CreateTestLayer(true, true); 2667 CreateTestLayer(true, true);
2657 AttachTimelinePlayerLayer(); 2668 AttachTimelinePlayerLayer();
2658 CreateImplTimelineAndPlayer(); 2669 CreateImplTimelineAndPlayer();
2659 2670
2660 scoped_refptr<ElementAnimations> animations = element_animations(); 2671 scoped_refptr<ElementAnimations> animations = element_animations();
2661 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 2672 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
(...skipping 21 matching lines...) Expand all
2683 EXPECT_FALSE(animations_impl->needs_to_start_animations_for_testing()); 2694 EXPECT_FALSE(animations_impl->needs_to_start_animations_for_testing());
2684 animations_impl->UpdateState(true, events.get()); 2695 animations_impl->UpdateState(true, events.get());
2685 2696
2686 // Since the animation hasn't been activated, it should still be STARTING 2697 // Since the animation hasn't been activated, it should still be STARTING
2687 // rather than RUNNING. 2698 // rather than RUNNING.
2688 EXPECT_EQ(Animation::STARTING, 2699 EXPECT_EQ(Animation::STARTING,
2689 animations_impl->GetAnimationById(animation_id)->run_state()); 2700 animations_impl->GetAnimationById(animation_id)->run_state());
2690 2701
2691 // Since the animation hasn't been activated, only the pending observer 2702 // Since the animation hasn't been activated, only the pending observer
2692 // should have been ticked. 2703 // should have been ticked.
2693 EXPECT_EQ(0.5f, client_impl_.GetOpacity(element_id_, LayerTreeType::PENDING)); 2704 EXPECT_EQ(0.5f,
2694 EXPECT_EQ(0.f, client_impl_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 2705 client_impl_.GetOpacity(element_id_, ElementListType::PENDING));
2706 EXPECT_EQ(0.f, client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE));
2695 2707
2696 animations_impl->ActivateAnimations(); 2708 animations_impl->ActivateAnimations();
2697 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2709 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2698 ->affects_pending_elements()); 2710 ->affects_pending_elements());
2699 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2711 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2700 ->affects_active_elements()); 2712 ->affects_active_elements());
2701 2713
2702 animations_impl->Animate(kInitialTickTime + 2714 animations_impl->Animate(kInitialTickTime +
2703 TimeDelta::FromMilliseconds(1000)); 2715 TimeDelta::FromMilliseconds(1000));
2704 animations_impl->UpdateState(true, events.get()); 2716 animations_impl->UpdateState(true, events.get());
2705 2717
2706 // Since the animation has been activated, it should have reached the 2718 // Since the animation has been activated, it should have reached the
2707 // RUNNING state and the active observer should start to get ticked. 2719 // RUNNING state and the active observer should start to get ticked.
2708 EXPECT_EQ(Animation::RUNNING, 2720 EXPECT_EQ(Animation::RUNNING,
2709 animations_impl->GetAnimationById(animation_id)->run_state()); 2721 animations_impl->GetAnimationById(animation_id)->run_state());
2710 EXPECT_EQ(0.5f, client_impl_.GetOpacity(element_id_, LayerTreeType::PENDING)); 2722 EXPECT_EQ(0.5f,
2711 EXPECT_EQ(0.5f, client_impl_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 2723 client_impl_.GetOpacity(element_id_, ElementListType::PENDING));
2724 EXPECT_EQ(0.5f,
2725 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE));
2712 } 2726 }
2713 2727
2714 TEST_F(ElementAnimationsTest, ActivationBetweenAnimateAndUpdateState) { 2728 TEST_F(ElementAnimationsTest, ActivationBetweenAnimateAndUpdateState) {
2715 CreateTestLayer(true, true); 2729 CreateTestLayer(true, true);
2716 AttachTimelinePlayerLayer(); 2730 AttachTimelinePlayerLayer();
2717 CreateImplTimelineAndPlayer(); 2731 CreateImplTimelineAndPlayer();
2718 2732
2719 scoped_refptr<ElementAnimations> animations = element_animations(); 2733 scoped_refptr<ElementAnimations> animations = element_animations();
2720 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 2734 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
2721 2735
2722 auto events = host_impl_->CreateEvents(); 2736 auto events = host_impl_->CreateEvents();
2723 2737
2724 const int animation_id = AddOpacityTransitionToElementAnimations( 2738 const int animation_id = AddOpacityTransitionToElementAnimations(
2725 animations.get(), 1, 0.5f, 1.f, true); 2739 animations.get(), 1, 0.5f, 1.f, true);
2726 2740
2727 animations->PushPropertiesTo(animations_impl.get()); 2741 animations->PushPropertiesTo(animations_impl.get());
2728 2742
2729 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); 2743 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id));
2730 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, 2744 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY,
2731 animations_impl->GetAnimationById(animation_id)->run_state()); 2745 animations_impl->GetAnimationById(animation_id)->run_state());
2732 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2746 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2733 ->affects_pending_elements()); 2747 ->affects_pending_elements());
2734 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id) 2748 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)
2735 ->affects_active_elements()); 2749 ->affects_active_elements());
2736 2750
2737 animations_impl->Animate(kInitialTickTime); 2751 animations_impl->Animate(kInitialTickTime);
2738 2752
2739 // Since the animation hasn't been activated, only the pending observer 2753 // Since the animation hasn't been activated, only the pending observer
2740 // should have been ticked. 2754 // should have been ticked.
2741 EXPECT_EQ(0.5f, client_impl_.GetOpacity(element_id_, LayerTreeType::PENDING)); 2755 EXPECT_EQ(0.5f,
2742 EXPECT_EQ(0.f, client_impl_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 2756 client_impl_.GetOpacity(element_id_, ElementListType::PENDING));
2757 EXPECT_EQ(0.f, client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE));
2743 2758
2744 animations_impl->ActivateAnimations(); 2759 animations_impl->ActivateAnimations();
2745 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2760 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2746 ->affects_pending_elements()); 2761 ->affects_pending_elements());
2747 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2762 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2748 ->affects_active_elements()); 2763 ->affects_active_elements());
2749 2764
2750 animations_impl->UpdateState(true, events.get()); 2765 animations_impl->UpdateState(true, events.get());
2751 2766
2752 // Since the animation has been activated, it should have reached the 2767 // Since the animation has been activated, it should have reached the
2753 // RUNNING state. 2768 // RUNNING state.
2754 EXPECT_EQ(Animation::RUNNING, 2769 EXPECT_EQ(Animation::RUNNING,
2755 animations_impl->GetAnimationById(animation_id)->run_state()); 2770 animations_impl->GetAnimationById(animation_id)->run_state());
2756 2771
2757 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); 2772 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
2758 2773
2759 // Both elements should have been ticked. 2774 // Both elements should have been ticked.
2760 EXPECT_EQ(0.75f, 2775 EXPECT_EQ(0.75f,
2761 client_impl_.GetOpacity(element_id_, LayerTreeType::PENDING)); 2776 client_impl_.GetOpacity(element_id_, ElementListType::PENDING));
2762 EXPECT_EQ(0.75f, client_impl_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 2777 EXPECT_EQ(0.75f,
2778 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE));
2763 } 2779 }
2764 2780
2765 TEST_F(ElementAnimationsTest, 2781 TEST_F(ElementAnimationsTest,
2766 ObserverNotifiedWhenTransformIsPotentiallyAnimatingChanges) { 2782 ObserverNotifiedWhenTransformIsPotentiallyAnimatingChanges) {
2767 CreateTestLayer(true, true); 2783 CreateTestLayer(true, true);
2768 AttachTimelinePlayerLayer(); 2784 AttachTimelinePlayerLayer();
2769 CreateImplTimelineAndPlayer(); 2785 CreateImplTimelineAndPlayer();
2770 2786
2771 scoped_refptr<ElementAnimations> animations = element_animations(); 2787 scoped_refptr<ElementAnimations> animations = element_animations();
2772 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 2788 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
2773 2789
2774 auto events = host_impl_->CreateEvents(); 2790 auto events = host_impl_->CreateEvents();
2775 2791
2776 EXPECT_FALSE( 2792 EXPECT_FALSE(
2777 client_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2793 client_.GetTransformIsAnimating(element_id_, ElementListType::ACTIVE));
2778 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_, 2794 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_,
2779 LayerTreeType::PENDING)); 2795 ElementListType::PENDING));
2780 EXPECT_FALSE( 2796 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_,
2781 client_impl_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2797 ElementListType::ACTIVE));
2782 2798
2783 // Case 1: An animation that's allowed to run until its finish point. 2799 // Case 1: An animation that's allowed to run until its finish point.
2784 AddAnimatedTransformToElementAnimations(animations.get(), 1.0, 1, 1); 2800 AddAnimatedTransformToElementAnimations(animations.get(), 1.0, 1, 1);
2785 EXPECT_TRUE( 2801 EXPECT_TRUE(
2786 client_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2802 client_.GetTransformIsAnimating(element_id_, ElementListType::ACTIVE));
2787 2803
2788 animations->PushPropertiesTo(animations_impl.get()); 2804 animations->PushPropertiesTo(animations_impl.get());
2789 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_, 2805 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_,
2790 LayerTreeType::PENDING)); 2806 ElementListType::PENDING));
2791 EXPECT_FALSE( 2807 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_,
2792 client_impl_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2808 ElementListType::ACTIVE));
2793 2809
2794 animations_impl->ActivateAnimations(); 2810 animations_impl->ActivateAnimations();
2795 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_, 2811 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_,
2796 LayerTreeType::PENDING)); 2812 ElementListType::PENDING));
2797 EXPECT_TRUE( 2813 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_,
2798 client_impl_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2814 ElementListType::ACTIVE));
2799 2815
2800 animations_impl->Animate(kInitialTickTime); 2816 animations_impl->Animate(kInitialTickTime);
2801 animations_impl->UpdateState(true, events.get()); 2817 animations_impl->UpdateState(true, events.get());
2802 2818
2803 animations->NotifyAnimationStarted(events->events_[0]); 2819 animations->NotifyAnimationStarted(events->events_[0]);
2804 events->events_.clear(); 2820 events->events_.clear();
2805 2821
2806 // Finish the animation. 2822 // Finish the animation.
2807 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 2823 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
2808 animations->UpdateState(true, nullptr); 2824 animations->UpdateState(true, nullptr);
2809 EXPECT_FALSE( 2825 EXPECT_FALSE(
2810 client_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2826 client_.GetTransformIsAnimating(element_id_, ElementListType::ACTIVE));
2811 2827
2812 animations->PushPropertiesTo(animations_impl.get()); 2828 animations->PushPropertiesTo(animations_impl.get());
2813 2829
2814 // animations_impl hasn't yet ticked at/past the end of the animation. 2830 // animations_impl hasn't yet ticked at/past the end of the animation.
2815 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_, 2831 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_,
2816 LayerTreeType::PENDING)); 2832 ElementListType::PENDING));
2817 EXPECT_TRUE( 2833 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_,
2818 client_impl_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2834 ElementListType::ACTIVE));
2819 2835
2820 animations_impl->Animate(kInitialTickTime + 2836 animations_impl->Animate(kInitialTickTime +
2821 TimeDelta::FromMilliseconds(1000)); 2837 TimeDelta::FromMilliseconds(1000));
2822 animations_impl->UpdateState(true, events.get()); 2838 animations_impl->UpdateState(true, events.get());
2823 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_, 2839 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_,
2824 LayerTreeType::PENDING)); 2840 ElementListType::PENDING));
2825 EXPECT_FALSE( 2841 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_,
2826 client_impl_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2842 ElementListType::ACTIVE));
2827 2843
2828 animations->NotifyAnimationFinished(events->events_[0]); 2844 animations->NotifyAnimationFinished(events->events_[0]);
2829 events->events_.clear(); 2845 events->events_.clear();
2830 2846
2831 // Case 2: An animation that's removed before it finishes. 2847 // Case 2: An animation that's removed before it finishes.
2832 int animation_id = 2848 int animation_id =
2833 AddAnimatedTransformToElementAnimations(animations.get(), 10.0, 2, 2); 2849 AddAnimatedTransformToElementAnimations(animations.get(), 10.0, 2, 2);
2834 EXPECT_TRUE( 2850 EXPECT_TRUE(
2835 client_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2851 client_.GetTransformIsAnimating(element_id_, ElementListType::ACTIVE));
2836 2852
2837 animations->PushPropertiesTo(animations_impl.get()); 2853 animations->PushPropertiesTo(animations_impl.get());
2838 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_, 2854 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_,
2839 LayerTreeType::PENDING)); 2855 ElementListType::PENDING));
2840 EXPECT_FALSE( 2856 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_,
2841 client_impl_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2857 ElementListType::ACTIVE));
2842 2858
2843 animations_impl->ActivateAnimations(); 2859 animations_impl->ActivateAnimations();
2844 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_, 2860 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_,
2845 LayerTreeType::PENDING)); 2861 ElementListType::PENDING));
2846 EXPECT_TRUE( 2862 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_,
2847 client_impl_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2863 ElementListType::ACTIVE));
2848 2864
2849 animations_impl->Animate(kInitialTickTime + 2865 animations_impl->Animate(kInitialTickTime +
2850 TimeDelta::FromMilliseconds(2000)); 2866 TimeDelta::FromMilliseconds(2000));
2851 animations_impl->UpdateState(true, events.get()); 2867 animations_impl->UpdateState(true, events.get());
2852 2868
2853 animations->NotifyAnimationStarted(events->events_[0]); 2869 animations->NotifyAnimationStarted(events->events_[0]);
2854 events->events_.clear(); 2870 events->events_.clear();
2855 2871
2856 animations->RemoveAnimation(animation_id); 2872 animations->RemoveAnimation(animation_id);
2857 EXPECT_FALSE( 2873 EXPECT_FALSE(
2858 client_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2874 client_.GetTransformIsAnimating(element_id_, ElementListType::ACTIVE));
2859 2875
2860 animations->PushPropertiesTo(animations_impl.get()); 2876 animations->PushPropertiesTo(animations_impl.get());
2861 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_, 2877 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_,
2862 LayerTreeType::PENDING)); 2878 ElementListType::PENDING));
2863 EXPECT_TRUE( 2879 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_,
2864 client_impl_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2880 ElementListType::ACTIVE));
2865 2881
2866 animations_impl->ActivateAnimations(); 2882 animations_impl->ActivateAnimations();
2867 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_, 2883 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_,
2868 LayerTreeType::PENDING)); 2884 ElementListType::PENDING));
2869 EXPECT_FALSE( 2885 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_,
2870 client_impl_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2886 ElementListType::ACTIVE));
2871 2887
2872 // Case 3: An animation that's aborted before it finishes. 2888 // Case 3: An animation that's aborted before it finishes.
2873 animation_id = 2889 animation_id =
2874 AddAnimatedTransformToElementAnimations(animations.get(), 10.0, 3, 3); 2890 AddAnimatedTransformToElementAnimations(animations.get(), 10.0, 3, 3);
2875 EXPECT_TRUE( 2891 EXPECT_TRUE(
2876 client_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2892 client_.GetTransformIsAnimating(element_id_, ElementListType::ACTIVE));
2877 2893
2878 animations->PushPropertiesTo(animations_impl.get()); 2894 animations->PushPropertiesTo(animations_impl.get());
2879 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_, 2895 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_,
2880 LayerTreeType::PENDING)); 2896 ElementListType::PENDING));
2881 EXPECT_FALSE( 2897 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_,
2882 client_impl_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2898 ElementListType::ACTIVE));
2883 2899
2884 animations_impl->ActivateAnimations(); 2900 animations_impl->ActivateAnimations();
2885 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_, 2901 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_,
2886 LayerTreeType::PENDING)); 2902 ElementListType::PENDING));
2887 EXPECT_TRUE( 2903 EXPECT_TRUE(client_impl_.GetTransformIsAnimating(element_id_,
2888 client_impl_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2904 ElementListType::ACTIVE));
2889 2905
2890 animations_impl->Animate(kInitialTickTime + 2906 animations_impl->Animate(kInitialTickTime +
2891 TimeDelta::FromMilliseconds(3000)); 2907 TimeDelta::FromMilliseconds(3000));
2892 animations_impl->UpdateState(true, events.get()); 2908 animations_impl->UpdateState(true, events.get());
2893 2909
2894 animations->NotifyAnimationStarted(events->events_[0]); 2910 animations->NotifyAnimationStarted(events->events_[0]);
2895 events->events_.clear(); 2911 events->events_.clear();
2896 2912
2897 animations_impl->AbortAnimations(TargetProperty::TRANSFORM); 2913 animations_impl->AbortAnimations(TargetProperty::TRANSFORM);
2898 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_, 2914 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_,
2899 LayerTreeType::PENDING)); 2915 ElementListType::PENDING));
2900 EXPECT_FALSE( 2916 EXPECT_FALSE(client_impl_.GetTransformIsAnimating(element_id_,
2901 client_impl_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2917 ElementListType::ACTIVE));
2902 2918
2903 animations_impl->Animate(kInitialTickTime + 2919 animations_impl->Animate(kInitialTickTime +
2904 TimeDelta::FromMilliseconds(4000)); 2920 TimeDelta::FromMilliseconds(4000));
2905 animations_impl->UpdateState(true, events.get()); 2921 animations_impl->UpdateState(true, events.get());
2906 2922
2907 animations->NotifyAnimationAborted(events->events_[0]); 2923 animations->NotifyAnimationAborted(events->events_[0]);
2908 EXPECT_FALSE( 2924 EXPECT_FALSE(
2909 client_.GetTransformIsAnimating(element_id_, LayerTreeType::ACTIVE)); 2925 client_.GetTransformIsAnimating(element_id_, ElementListType::ACTIVE));
2910 } 2926 }
2911 2927
2912 TEST_F(ElementAnimationsTest, ClippedOpacityValues) { 2928 TEST_F(ElementAnimationsTest, ClippedOpacityValues) {
2913 CreateTestLayer(false, false); 2929 CreateTestLayer(false, false);
2914 AttachTimelinePlayerLayer(); 2930 AttachTimelinePlayerLayer();
2915 2931
2916 scoped_refptr<ElementAnimations> animations = element_animations(); 2932 scoped_refptr<ElementAnimations> animations = element_animations();
2917 2933
2918 AddOpacityTransitionToElementAnimations(animations.get(), 1, 1.f, 2.f, true); 2934 AddOpacityTransitionToElementAnimations(animations.get(), 1, 1.f, 2.f, true);
2919 2935
2920 animations->Animate(kInitialTickTime); 2936 animations->Animate(kInitialTickTime);
2921 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 2937 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
2922 2938
2923 // Opacity values are clipped [0,1] 2939 // Opacity values are clipped [0,1]
2924 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 2940 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
2925 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 2941 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
2926 } 2942 }
2927 2943
2928 TEST_F(ElementAnimationsTest, ClippedNegativeOpacityValues) { 2944 TEST_F(ElementAnimationsTest, ClippedNegativeOpacityValues) {
2929 CreateTestLayer(false, false); 2945 CreateTestLayer(false, false);
2930 AttachTimelinePlayerLayer(); 2946 AttachTimelinePlayerLayer();
2931 2947
2932 scoped_refptr<ElementAnimations> animations = element_animations(); 2948 scoped_refptr<ElementAnimations> animations = element_animations();
2933 2949
2934 AddOpacityTransitionToElementAnimations(animations.get(), 1, 0.f, -2.f, true); 2950 AddOpacityTransitionToElementAnimations(animations.get(), 1, 0.f, -2.f, true);
2935 2951
2936 animations->Animate(kInitialTickTime); 2952 animations->Animate(kInitialTickTime);
2937 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 2953 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
2938 2954
2939 // Opacity values are clipped [0,1] 2955 // Opacity values are clipped [0,1]
2940 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 2956 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
2941 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 2957 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
2942 } 2958 }
2943 2959
2944 TEST_F(ElementAnimationsTest, PushedDeletedAnimationWaitsForActivation) { 2960 TEST_F(ElementAnimationsTest, PushedDeletedAnimationWaitsForActivation) {
2945 CreateTestLayer(true, true); 2961 CreateTestLayer(true, true);
2946 AttachTimelinePlayerLayer(); 2962 AttachTimelinePlayerLayer();
2947 CreateImplTimelineAndPlayer(); 2963 CreateImplTimelineAndPlayer();
2948 2964
2949 scoped_refptr<ElementAnimations> animations = element_animations(); 2965 scoped_refptr<ElementAnimations> animations = element_animations();
2950 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 2966 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
2951 2967
2952 auto events = host_impl_->CreateEvents(); 2968 auto events = host_impl_->CreateEvents();
2953 2969
2954 const int animation_id = AddOpacityTransitionToElementAnimations( 2970 const int animation_id = AddOpacityTransitionToElementAnimations(
2955 animations.get(), 1, 0.5f, 1.f, true); 2971 animations.get(), 1, 0.5f, 1.f, true);
2956 2972
2957 animations->PushPropertiesTo(animations_impl.get()); 2973 animations->PushPropertiesTo(animations_impl.get());
2958 animations_impl->ActivateAnimations(); 2974 animations_impl->ActivateAnimations();
2959 animations_impl->Animate(kInitialTickTime); 2975 animations_impl->Animate(kInitialTickTime);
2960 animations_impl->UpdateState(true, events.get()); 2976 animations_impl->UpdateState(true, events.get());
2961 EXPECT_EQ(Animation::RUNNING, 2977 EXPECT_EQ(Animation::RUNNING,
2962 animations_impl->GetAnimationById(animation_id)->run_state()); 2978 animations_impl->GetAnimationById(animation_id)->run_state());
2963 EXPECT_EQ(0.5f, client_impl_.GetOpacity(element_id_, LayerTreeType::PENDING)); 2979 EXPECT_EQ(0.5f,
2964 EXPECT_EQ(0.5f, client_impl_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 2980 client_impl_.GetOpacity(element_id_, ElementListType::PENDING));
2981 EXPECT_EQ(0.5f,
2982 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE));
2965 2983
2966 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2984 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2967 ->affects_pending_elements()); 2985 ->affects_pending_elements());
2968 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2986 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2969 ->affects_active_elements()); 2987 ->affects_active_elements());
2970 2988
2971 // Delete the animation on the main-thread animations. 2989 // Delete the animation on the main-thread animations.
2972 animations->RemoveAnimation( 2990 animations->RemoveAnimation(
2973 animations->GetAnimation(TargetProperty::OPACITY)->id()); 2991 animations->GetAnimation(TargetProperty::OPACITY)->id());
2974 animations->PushPropertiesTo(animations_impl.get()); 2992 animations->PushPropertiesTo(animations_impl.get());
2975 2993
2976 // The animation should no longer affect pending elements. 2994 // The animation should no longer affect pending elements.
2977 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id) 2995 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)
2978 ->affects_pending_elements()); 2996 ->affects_pending_elements());
2979 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2997 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2980 ->affects_active_elements()); 2998 ->affects_active_elements());
2981 2999
2982 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); 3000 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
2983 animations_impl->UpdateState(true, events.get()); 3001 animations_impl->UpdateState(true, events.get());
2984 3002
2985 // Only the active observer should have been ticked. 3003 // Only the active observer should have been ticked.
2986 EXPECT_EQ(0.5f, client_impl_.GetOpacity(element_id_, LayerTreeType::PENDING)); 3004 EXPECT_EQ(0.5f,
2987 EXPECT_EQ(0.75f, client_impl_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 3005 client_impl_.GetOpacity(element_id_, ElementListType::PENDING));
3006 EXPECT_EQ(0.75f,
3007 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE));
2988 3008
2989 animations_impl->ActivateAnimations(); 3009 animations_impl->ActivateAnimations();
2990 3010
2991 // Activation should cause the animation to be deleted. 3011 // Activation should cause the animation to be deleted.
2992 EXPECT_FALSE(animations_impl->has_any_animation()); 3012 EXPECT_FALSE(animations_impl->has_any_animation());
2993 } 3013 }
2994 3014
2995 // Tests that an animation that affects only active elements won't block 3015 // Tests that an animation that affects only active elements won't block
2996 // an animation that affects only pending elements from starting. 3016 // an animation that affects only pending elements from starting.
2997 TEST_F(ElementAnimationsTest, StartAnimationsAffectingDifferentObservers) { 3017 TEST_F(ElementAnimationsTest, StartAnimationsAffectingDifferentObservers) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3037 // The original animation should still be running, and the new animation 3057 // The original animation should still be running, and the new animation
3038 // should be starting. 3058 // should be starting.
3039 EXPECT_EQ(Animation::RUNNING, 3059 EXPECT_EQ(Animation::RUNNING,
3040 animations_impl->GetAnimationById(first_animation_id)->run_state()); 3060 animations_impl->GetAnimationById(first_animation_id)->run_state());
3041 EXPECT_EQ( 3061 EXPECT_EQ(
3042 Animation::STARTING, 3062 Animation::STARTING,
3043 animations_impl->GetAnimationById(second_animation_id)->run_state()); 3063 animations_impl->GetAnimationById(second_animation_id)->run_state());
3044 3064
3045 // The active observer should have been ticked by the original animation, 3065 // The active observer should have been ticked by the original animation,
3046 // and the pending observer should have been ticked by the new animation. 3066 // and the pending observer should have been ticked by the new animation.
3047 EXPECT_EQ(1.f, client_impl_.GetOpacity(element_id_, LayerTreeType::PENDING)); 3067 EXPECT_EQ(1.f,
3048 EXPECT_EQ(0.5f, client_impl_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 3068 client_impl_.GetOpacity(element_id_, ElementListType::PENDING));
3069 EXPECT_EQ(0.5f,
3070 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE));
3049 3071
3050 animations_impl->ActivateAnimations(); 3072 animations_impl->ActivateAnimations();
3051 3073
3052 // The original animation should have been deleted, and the new animation 3074 // The original animation should have been deleted, and the new animation
3053 // should now affect both elements. 3075 // should now affect both elements.
3054 EXPECT_FALSE(animations_impl->GetAnimationById(first_animation_id)); 3076 EXPECT_FALSE(animations_impl->GetAnimationById(first_animation_id));
3055 EXPECT_TRUE(animations_impl->GetAnimationById(second_animation_id) 3077 EXPECT_TRUE(animations_impl->GetAnimationById(second_animation_id)
3056 ->affects_pending_elements()); 3078 ->affects_pending_elements());
3057 EXPECT_TRUE(animations_impl->GetAnimationById(second_animation_id) 3079 EXPECT_TRUE(animations_impl->GetAnimationById(second_animation_id)
3058 ->affects_active_elements()); 3080 ->affects_active_elements());
3059 3081
3060 animations_impl->Animate(kInitialTickTime + 3082 animations_impl->Animate(kInitialTickTime +
3061 TimeDelta::FromMilliseconds(1000)); 3083 TimeDelta::FromMilliseconds(1000));
3062 animations_impl->UpdateState(true, events.get()); 3084 animations_impl->UpdateState(true, events.get());
3063 3085
3064 // The new animation should be running, and the active observer should have 3086 // The new animation should be running, and the active observer should have
3065 // been ticked at the new animation's starting point. 3087 // been ticked at the new animation's starting point.
3066 EXPECT_EQ( 3088 EXPECT_EQ(
3067 Animation::RUNNING, 3089 Animation::RUNNING,
3068 animations_impl->GetAnimationById(second_animation_id)->run_state()); 3090 animations_impl->GetAnimationById(second_animation_id)->run_state());
3069 EXPECT_EQ(1.f, client_impl_.GetOpacity(element_id_, LayerTreeType::PENDING)); 3091 EXPECT_EQ(1.f,
3070 EXPECT_EQ(1.f, client_impl_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 3092 client_impl_.GetOpacity(element_id_, ElementListType::PENDING));
3093 EXPECT_EQ(1.f, client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE));
3071 } 3094 }
3072 3095
3073 TEST_F(ElementAnimationsTest, TestIsCurrentlyAnimatingProperty) { 3096 TEST_F(ElementAnimationsTest, TestIsCurrentlyAnimatingProperty) {
3074 CreateTestLayer(false, false); 3097 CreateTestLayer(false, false);
3075 AttachTimelinePlayerLayer(); 3098 AttachTimelinePlayerLayer();
3076 3099
3077 scoped_refptr<ElementAnimations> animations = element_animations(); 3100 scoped_refptr<ElementAnimations> animations = element_animations();
3078 3101
3079 // Create an animation that initially affects only pending elements. 3102 // Create an animation that initially affects only pending elements.
3080 std::unique_ptr<Animation> animation(CreateAnimation( 3103 std::unique_ptr<Animation> animation(CreateAnimation(
3081 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 3104 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
3082 1, TargetProperty::OPACITY)); 3105 1, TargetProperty::OPACITY));
3083 animation->set_affects_active_elements(false); 3106 animation->set_affects_active_elements(false);
3084 3107
3085 animations->AddAnimation(std::move(animation)); 3108 animations->AddAnimation(std::move(animation));
3086 animations->Animate(kInitialTickTime); 3109 animations->Animate(kInitialTickTime);
3087 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3110 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(
3088 LayerTreeType::PENDING)); 3111 TargetProperty::OPACITY, ElementListType::PENDING));
3089 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3112 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3090 LayerTreeType::ACTIVE)); 3113 TargetProperty::OPACITY, ElementListType::ACTIVE));
3091 animations->UpdateState(true, nullptr); 3114 animations->UpdateState(true, nullptr);
3092 EXPECT_TRUE(animations->HasActiveAnimation()); 3115 EXPECT_TRUE(animations->HasActiveAnimation());
3093 3116
3094 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3117 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(
3095 LayerTreeType::PENDING)); 3118 TargetProperty::OPACITY, ElementListType::PENDING));
3096 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY,
3097 LayerTreeType::ACTIVE));
3098 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3119 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3099 TargetProperty::FILTER, LayerTreeType::PENDING)); 3120 TargetProperty::OPACITY, ElementListType::ACTIVE));
3100 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, 3121 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3101 LayerTreeType::ACTIVE)); 3122 TargetProperty::FILTER, ElementListType::PENDING));
3123 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3124 TargetProperty::FILTER, ElementListType::ACTIVE));
3102 3125
3103 animations->ActivateAnimations(); 3126 animations->ActivateAnimations();
3104 3127
3105 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3128 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(
3106 LayerTreeType::PENDING)); 3129 TargetProperty::OPACITY, ElementListType::PENDING));
3107 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3130 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(
3108 LayerTreeType::ACTIVE)); 3131 TargetProperty::OPACITY, ElementListType::ACTIVE));
3109 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3132 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3110 TargetProperty::FILTER, LayerTreeType::PENDING)); 3133 TargetProperty::FILTER, ElementListType::PENDING));
3111 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, 3134 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3112 LayerTreeType::ACTIVE)); 3135 TargetProperty::FILTER, ElementListType::ACTIVE));
3113 3136
3114 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(10)); 3137 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(10));
3115 animations->UpdateState(true, nullptr); 3138 animations->UpdateState(true, nullptr);
3116 3139
3117 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3140 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(
3118 LayerTreeType::PENDING)); 3141 TargetProperty::OPACITY, ElementListType::PENDING));
3119 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3142 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(
3120 LayerTreeType::ACTIVE)); 3143 TargetProperty::OPACITY, ElementListType::ACTIVE));
3121 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3144 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3122 TargetProperty::FILTER, LayerTreeType::PENDING)); 3145 TargetProperty::FILTER, ElementListType::PENDING));
3123 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, 3146 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3124 LayerTreeType::ACTIVE)); 3147 TargetProperty::FILTER, ElementListType::ACTIVE));
3125 3148
3126 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 3149 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
3127 3150
3128 // Tick past the end of the animation. 3151 // Tick past the end of the animation.
3129 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1100)); 3152 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1100));
3130 animations->UpdateState(true, nullptr); 3153 animations->UpdateState(true, nullptr);
3131 3154
3132 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3155 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3133 TargetProperty::OPACITY, LayerTreeType::PENDING)); 3156 TargetProperty::OPACITY, ElementListType::PENDING));
3134 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY,
3135 LayerTreeType::ACTIVE));
3136 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3157 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3137 TargetProperty::FILTER, LayerTreeType::PENDING)); 3158 TargetProperty::OPACITY, ElementListType::ACTIVE));
3138 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, 3159 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3139 LayerTreeType::ACTIVE)); 3160 TargetProperty::FILTER, ElementListType::PENDING));
3161 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3162 TargetProperty::FILTER, ElementListType::ACTIVE));
3140 3163
3141 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, LayerTreeType::ACTIVE)); 3164 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
3142 } 3165 }
3143 3166
3144 TEST_F(ElementAnimationsTest, TestIsAnimatingPropertyTimeOffsetFillMode) { 3167 TEST_F(ElementAnimationsTest, TestIsAnimatingPropertyTimeOffsetFillMode) {
3145 CreateTestLayer(false, false); 3168 CreateTestLayer(false, false);
3146 AttachTimelinePlayerLayer(); 3169 AttachTimelinePlayerLayer();
3147 3170
3148 scoped_refptr<ElementAnimations> animations = element_animations(); 3171 scoped_refptr<ElementAnimations> animations = element_animations();
3149 3172
3150 // Create an animation that initially affects only pending elements, and has 3173 // Create an animation that initially affects only pending elements, and has
3151 // a start delay of 2 seconds. 3174 // a start delay of 2 seconds.
3152 std::unique_ptr<Animation> animation(CreateAnimation( 3175 std::unique_ptr<Animation> animation(CreateAnimation(
3153 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 3176 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
3154 1, TargetProperty::OPACITY)); 3177 1, TargetProperty::OPACITY));
3155 animation->set_fill_mode(Animation::FILL_MODE_NONE); 3178 animation->set_fill_mode(Animation::FILL_MODE_NONE);
3156 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000)); 3179 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000));
3157 animation->set_affects_active_elements(false); 3180 animation->set_affects_active_elements(false);
3158 3181
3159 animations->AddAnimation(std::move(animation)); 3182 animations->AddAnimation(std::move(animation));
3160 3183
3161 animations->Animate(kInitialTickTime); 3184 animations->Animate(kInitialTickTime);
3162 3185
3163 // Since the animation has a start delay, the elements it affects have a 3186 // Since the animation has a start delay, the elements it affects have a
3164 // potentially running transform animation but aren't currently animating 3187 // potentially running transform animation but aren't currently animating
3165 // transform. 3188 // transform.
3166 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( 3189 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty(
3167 TargetProperty::OPACITY, LayerTreeType::PENDING)); 3190 TargetProperty::OPACITY, ElementListType::PENDING));
3168 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( 3191 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty(
3169 TargetProperty::OPACITY, LayerTreeType::ACTIVE)); 3192 TargetProperty::OPACITY, ElementListType::ACTIVE));
3170 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3193 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3171 TargetProperty::OPACITY, LayerTreeType::PENDING)); 3194 TargetProperty::OPACITY, ElementListType::PENDING));
3172 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3195 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3173 LayerTreeType::ACTIVE)); 3196 TargetProperty::OPACITY, ElementListType::ACTIVE));
3174 EXPECT_TRUE(animations->HasActiveAnimation()); 3197 EXPECT_TRUE(animations->HasActiveAnimation());
3175 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( 3198 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty(
3176 TargetProperty::FILTER, LayerTreeType::PENDING)); 3199 TargetProperty::FILTER, ElementListType::PENDING));
3177 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( 3200 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty(
3178 TargetProperty::FILTER, LayerTreeType::ACTIVE)); 3201 TargetProperty::FILTER, ElementListType::ACTIVE));
3179 3202
3180 animations->ActivateAnimations(); 3203 animations->ActivateAnimations();
3181 3204
3182 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( 3205 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty(
3183 TargetProperty::OPACITY, LayerTreeType::PENDING)); 3206 TargetProperty::OPACITY, ElementListType::PENDING));
3184 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( 3207 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty(
3185 TargetProperty::OPACITY, LayerTreeType::ACTIVE)); 3208 TargetProperty::OPACITY, ElementListType::ACTIVE));
3186 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3209 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3187 TargetProperty::OPACITY, LayerTreeType::PENDING)); 3210 TargetProperty::OPACITY, ElementListType::PENDING));
3188 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3211 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3189 LayerTreeType::ACTIVE)); 3212 TargetProperty::OPACITY, ElementListType::ACTIVE));
3190 EXPECT_TRUE(animations->HasActiveAnimation()); 3213 EXPECT_TRUE(animations->HasActiveAnimation());
3191 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( 3214 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty(
3192 TargetProperty::FILTER, LayerTreeType::PENDING)); 3215 TargetProperty::FILTER, ElementListType::PENDING));
3193 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( 3216 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty(
3194 TargetProperty::FILTER, LayerTreeType::ACTIVE)); 3217 TargetProperty::FILTER, ElementListType::ACTIVE));
3195 3218
3196 animations->UpdateState(true, nullptr); 3219 animations->UpdateState(true, nullptr);
3197 3220
3198 // Tick past the start delay. 3221 // Tick past the start delay.
3199 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 3222 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
3200 animations->UpdateState(true, nullptr); 3223 animations->UpdateState(true, nullptr);
3201 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( 3224 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty(
3202 TargetProperty::OPACITY, LayerTreeType::PENDING)); 3225 TargetProperty::OPACITY, ElementListType::PENDING));
3203 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( 3226 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty(
3204 TargetProperty::OPACITY, LayerTreeType::ACTIVE)); 3227 TargetProperty::OPACITY, ElementListType::ACTIVE));
3205 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3228 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(
3206 LayerTreeType::PENDING)); 3229 TargetProperty::OPACITY, ElementListType::PENDING));
3207 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3230 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(
3208 LayerTreeType::ACTIVE)); 3231 TargetProperty::OPACITY, ElementListType::ACTIVE));
3209 3232
3210 // After the animaton finishes, the elements it affects have neither a 3233 // After the animaton finishes, the elements it affects have neither a
3211 // potentially running transform animation nor a currently running transform 3234 // potentially running transform animation nor a currently running transform
3212 // animation. 3235 // animation.
3213 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); 3236 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000));
3214 animations->UpdateState(true, nullptr); 3237 animations->UpdateState(true, nullptr);
3215 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( 3238 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty(
3216 TargetProperty::OPACITY, LayerTreeType::PENDING)); 3239 TargetProperty::OPACITY, ElementListType::PENDING));
3217 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( 3240 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty(
3218 TargetProperty::OPACITY, LayerTreeType::ACTIVE)); 3241 TargetProperty::OPACITY, ElementListType::ACTIVE));
3219 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3242 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3220 TargetProperty::OPACITY, LayerTreeType::PENDING)); 3243 TargetProperty::OPACITY, ElementListType::PENDING));
3221 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3244 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3222 LayerTreeType::ACTIVE)); 3245 TargetProperty::OPACITY, ElementListType::ACTIVE));
3223 } 3246 }
3224 3247
3225 } // namespace 3248 } // namespace
3226 } // namespace cc 3249 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/element_animations.cc ('k') | cc/test/animation_test_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698