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

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

Issue 1912023003: CC Animation: Remove Observers and Observations in namings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@observertype
Patch Set: Rename it in .cc comments as well 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/trees/layer_tree_host_unittest_animation.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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 host_->AddAnimationTimeline(timeline_); 52 host_->AddAnimationTimeline(timeline_);
53 53
54 timeline_->AttachPlayer(player_); 54 timeline_->AttachPlayer(player_);
55 player_->AttachLayer(layer_id_); 55 player_->AttachLayer(layer_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->needs_active_value_observations()); 61 EXPECT_TRUE(element_animations->has_element_in_active_list());
62 EXPECT_FALSE(element_animations->needs_pending_value_observations()); 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->needs_active_value_observations()); 72 EXPECT_FALSE(element_animations_impl->has_element_in_active_list());
73 EXPECT_TRUE(element_animations_impl->needs_pending_value_observations()); 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(layer_id_, LayerTreeType::ACTIVE); 76 client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE);
77 EXPECT_TRUE(element_animations_impl->needs_active_value_observations()); 77 EXPECT_TRUE(element_animations_impl->has_element_in_active_list());
78 EXPECT_TRUE(element_animations_impl->needs_pending_value_observations()); 78 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list());
79 79
80 EXPECT_TRUE(client_impl_.IsLayerInTree(layer_id_, LayerTreeType::ACTIVE)); 80 EXPECT_TRUE(client_impl_.IsLayerInTree(layer_id_, LayerTreeType::ACTIVE));
81 EXPECT_TRUE(client_impl_.IsLayerInTree(layer_id_, LayerTreeType::PENDING)); 81 EXPECT_TRUE(client_impl_.IsLayerInTree(layer_id_, LayerTreeType::PENDING));
82 82
83 // kill layer on main thread. 83 // kill layer on main thread.
84 client_.UnregisterLayer(layer_id_, LayerTreeType::ACTIVE); 84 client_.UnregisterLayer(layer_id_, LayerTreeType::ACTIVE);
85 EXPECT_EQ(element_animations, player_->element_animations()); 85 EXPECT_EQ(element_animations, player_->element_animations());
86 EXPECT_FALSE(element_animations->needs_active_value_observations()); 86 EXPECT_FALSE(element_animations->has_element_in_active_list());
87 EXPECT_FALSE(element_animations->needs_pending_value_observations()); 87 EXPECT_FALSE(element_animations->has_element_in_pending_list());
88 88
89 // Sync doesn't detach LayerImpl. 89 // Sync doesn't detach LayerImpl.
90 host_->PushPropertiesTo(host_impl_); 90 host_->PushPropertiesTo(host_impl_);
91 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); 91 EXPECT_EQ(element_animations_impl, player_impl_->element_animations());
92 EXPECT_TRUE(element_animations_impl->needs_active_value_observations()); 92 EXPECT_TRUE(element_animations_impl->has_element_in_active_list());
93 EXPECT_TRUE(element_animations_impl->needs_pending_value_observations()); 93 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list());
94 94
95 // Kill layer on impl thread in pending tree. 95 // Kill layer on impl thread in pending tree.
96 client_impl_.UnregisterLayer(layer_id_, LayerTreeType::PENDING); 96 client_impl_.UnregisterLayer(layer_id_, LayerTreeType::PENDING);
97 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); 97 EXPECT_EQ(element_animations_impl, player_impl_->element_animations());
98 EXPECT_TRUE(element_animations_impl->needs_active_value_observations()); 98 EXPECT_TRUE(element_animations_impl->has_element_in_active_list());
99 EXPECT_FALSE(element_animations_impl->needs_pending_value_observations()); 99 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list());
100 100
101 // Kill layer on impl thread in active tree. 101 // Kill layer on impl thread in active tree.
102 client_impl_.UnregisterLayer(layer_id_, LayerTreeType::ACTIVE); 102 client_impl_.UnregisterLayer(layer_id_, LayerTreeType::ACTIVE);
103 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); 103 EXPECT_EQ(element_animations_impl, player_impl_->element_animations());
104 EXPECT_FALSE(element_animations_impl->needs_active_value_observations()); 104 EXPECT_FALSE(element_animations_impl->has_element_in_active_list());
105 EXPECT_FALSE(element_animations_impl->needs_pending_value_observations()); 105 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list());
106 106
107 // Sync doesn't change anything. 107 // Sync doesn't change anything.
108 host_->PushPropertiesTo(host_impl_); 108 host_->PushPropertiesTo(host_impl_);
109 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); 109 EXPECT_EQ(element_animations_impl, player_impl_->element_animations());
110 EXPECT_FALSE(element_animations_impl->needs_active_value_observations()); 110 EXPECT_FALSE(element_animations_impl->has_element_in_active_list());
111 EXPECT_FALSE(element_animations_impl->needs_pending_value_observations()); 111 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list());
112 112
113 player_->DetachLayer(); 113 player_->DetachLayer();
114 EXPECT_FALSE(player_->element_animations()); 114 EXPECT_FALSE(player_->element_animations());
115 115
116 // Release ptrs now to test the order of destruction. 116 // Release ptrs now to test the order of destruction.
117 ReleaseRefPtrs(); 117 ReleaseRefPtrs();
118 } 118 }
119 119
120 TEST_F(ElementAnimationsTest, AttachToNotYetCreatedLayer) { 120 TEST_F(ElementAnimationsTest, AttachToNotYetCreatedLayer) {
121 host_->AddAnimationTimeline(timeline_); 121 host_->AddAnimationTimeline(timeline_);
122 timeline_->AttachPlayer(player_); 122 timeline_->AttachPlayer(player_);
123 123
124 host_->PushPropertiesTo(host_impl_); 124 host_->PushPropertiesTo(host_impl_);
125 125
126 GetImplTimelineAndPlayerByID(); 126 GetImplTimelineAndPlayerByID();
127 127
128 player_->AttachLayer(layer_id_); 128 player_->AttachLayer(layer_id_);
129 129
130 scoped_refptr<ElementAnimations> element_animations = 130 scoped_refptr<ElementAnimations> element_animations =
131 player_->element_animations(); 131 player_->element_animations();
132 EXPECT_TRUE(element_animations); 132 EXPECT_TRUE(element_animations);
133 133
134 EXPECT_FALSE(element_animations->needs_active_value_observations()); 134 EXPECT_FALSE(element_animations->has_element_in_active_list());
135 EXPECT_FALSE(element_animations->needs_pending_value_observations()); 135 EXPECT_FALSE(element_animations->has_element_in_pending_list());
136 136
137 host_->PushPropertiesTo(host_impl_); 137 host_->PushPropertiesTo(host_impl_);
138 138
139 scoped_refptr<ElementAnimations> element_animations_impl = 139 scoped_refptr<ElementAnimations> element_animations_impl =
140 player_impl_->element_animations(); 140 player_impl_->element_animations();
141 EXPECT_TRUE(element_animations_impl); 141 EXPECT_TRUE(element_animations_impl);
142 142
143 EXPECT_FALSE(element_animations_impl->needs_active_value_observations()); 143 EXPECT_FALSE(element_animations_impl->has_element_in_active_list());
144 EXPECT_FALSE(element_animations_impl->needs_pending_value_observations()); 144 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list());
145 145
146 // Create layer. 146 // Create layer.
147 client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); 147 client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE);
148 EXPECT_TRUE(element_animations->needs_active_value_observations()); 148 EXPECT_TRUE(element_animations->has_element_in_active_list());
149 EXPECT_FALSE(element_animations->needs_pending_value_observations()); 149 EXPECT_FALSE(element_animations->has_element_in_pending_list());
150 150
151 client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); 151 client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING);
152 EXPECT_FALSE(element_animations_impl->needs_active_value_observations()); 152 EXPECT_FALSE(element_animations_impl->has_element_in_active_list());
153 EXPECT_TRUE(element_animations_impl->needs_pending_value_observations()); 153 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list());
154 154
155 client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); 155 client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE);
156 EXPECT_TRUE(element_animations_impl->needs_active_value_observations()); 156 EXPECT_TRUE(element_animations_impl->has_element_in_active_list());
157 EXPECT_TRUE(element_animations_impl->needs_pending_value_observations()); 157 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list());
158 } 158 }
159 159
160 TEST_F(ElementAnimationsTest, AddRemovePlayers) { 160 TEST_F(ElementAnimationsTest, AddRemovePlayers) {
161 host_->AddAnimationTimeline(timeline_); 161 host_->AddAnimationTimeline(timeline_);
162 timeline_->AttachPlayer(player_); 162 timeline_->AttachPlayer(player_);
163 player_->AttachLayer(layer_id_); 163 player_->AttachLayer(layer_id_);
164 164
165 scoped_refptr<ElementAnimations> element_animations = 165 scoped_refptr<ElementAnimations> element_animations =
166 player_->element_animations(); 166 player_->element_animations();
167 EXPECT_TRUE(element_animations); 167 EXPECT_TRUE(element_animations);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 node = node->next()) { 214 node = node->next()) {
215 const AnimationPlayer* player_impl = node->value(); 215 const AnimationPlayer* player_impl = node->value();
216 EXPECT_TRUE(timeline_->GetPlayerById(player_impl->id())); 216 EXPECT_TRUE(timeline_->GetPlayerById(player_impl->id()));
217 ++list_size_after; 217 ++list_size_after;
218 } 218 }
219 EXPECT_EQ(2, list_size_after); 219 EXPECT_EQ(2, list_size_after);
220 } 220 }
221 221
222 TEST_F(ElementAnimationsTest, SyncNewAnimation) { 222 TEST_F(ElementAnimationsTest, SyncNewAnimation) {
223 auto animations_impl = ElementAnimations::Create(); 223 auto animations_impl = ElementAnimations::Create();
224 animations_impl->set_needs_active_value_observations(true); 224 animations_impl->set_has_element_in_active_list(true);
225 225
226 auto animations = ElementAnimations::Create(); 226 auto animations = ElementAnimations::Create();
227 animations->set_needs_active_value_observations(true); 227 animations->set_has_element_in_active_list(true);
228 228
229 EXPECT_FALSE(animations_impl->GetAnimation(TargetProperty::OPACITY)); 229 EXPECT_FALSE(animations_impl->GetAnimation(TargetProperty::OPACITY));
230 230
231 EXPECT_FALSE(animations->needs_to_start_animations_for_testing()); 231 EXPECT_FALSE(animations->needs_to_start_animations_for_testing());
232 EXPECT_FALSE(animations_impl->needs_to_start_animations_for_testing()); 232 EXPECT_FALSE(animations_impl->needs_to_start_animations_for_testing());
233 233
234 int animation_id = 234 int animation_id =
235 AddOpacityTransitionToElementAnimations(animations.get(), 1, 0, 1, false); 235 AddOpacityTransitionToElementAnimations(animations.get(), 1, 0, 1, false);
236 EXPECT_TRUE(animations->needs_to_start_animations_for_testing()); 236 EXPECT_TRUE(animations->needs_to_start_animations_for_testing());
237 237
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 // scroll offset. 1026 // scroll offset.
1027 TEST_F(ElementAnimationsTest, ScrollOffsetTransitionNoImplProvider) { 1027 TEST_F(ElementAnimationsTest, ScrollOffsetTransitionNoImplProvider) {
1028 CreateTestLayer(false, false); 1028 CreateTestLayer(false, false);
1029 CreateTestImplLayer(LayerTreeType::PENDING); 1029 CreateTestImplLayer(LayerTreeType::PENDING);
1030 AttachTimelinePlayerLayer(); 1030 AttachTimelinePlayerLayer();
1031 CreateImplTimelineAndPlayer(); 1031 CreateImplTimelineAndPlayer();
1032 1032
1033 scoped_refptr<ElementAnimations> animations = element_animations(); 1033 scoped_refptr<ElementAnimations> animations = element_animations();
1034 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 1034 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
1035 1035
1036 EXPECT_TRUE(animations_impl->needs_pending_value_observations()); 1036 EXPECT_TRUE(animations_impl->has_element_in_pending_list());
1037 EXPECT_FALSE(animations_impl->needs_active_value_observations()); 1037 EXPECT_FALSE(animations_impl->has_element_in_active_list());
1038 1038
1039 auto events = host_impl_->CreateEvents(); 1039 auto events = host_impl_->CreateEvents();
1040 1040
1041 gfx::ScrollOffset initial_value(500.f, 100.f); 1041 gfx::ScrollOffset initial_value(500.f, 100.f);
1042 gfx::ScrollOffset target_value(300.f, 200.f); 1042 gfx::ScrollOffset target_value(300.f, 200.f);
1043 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 1043 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
1044 ScrollOffsetAnimationCurve::Create(target_value, 1044 ScrollOffsetAnimationCurve::Create(target_value,
1045 EaseInOutTimingFunction::Create())); 1045 EaseInOutTimingFunction::Create()));
1046 1046
1047 std::unique_ptr<Animation> animation( 1047 std::unique_ptr<Animation> animation(
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1764 id, TargetProperty::OPACITY)); 1764 id, TargetProperty::OPACITY));
1765 1765
1766 // Without an observer, the animation shouldn't progress to the STARTING 1766 // Without an observer, the animation shouldn't progress to the STARTING
1767 // state. 1767 // state.
1768 animations->Animate(kInitialTickTime); 1768 animations->Animate(kInitialTickTime);
1769 animations->UpdateState(true, events.get()); 1769 animations->UpdateState(true, events.get());
1770 EXPECT_EQ(0u, events->events_.size()); 1770 EXPECT_EQ(0u, events->events_.size());
1771 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, 1771 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY,
1772 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); 1772 animations->GetAnimation(TargetProperty::OPACITY)->run_state());
1773 1773
1774 // animations->set_needs_pending_value_observations(true);
1775 CreateTestImplLayer(LayerTreeType::PENDING); 1774 CreateTestImplLayer(LayerTreeType::PENDING);
1776 1775
1777 // With only a pending observer, the animation should progress to the 1776 // With only a pending observer, the animation should progress to the
1778 // STARTING state and get ticked at its starting point, but should not 1777 // STARTING state and get ticked at its starting point, but should not
1779 // progress to RUNNING. 1778 // progress to RUNNING.
1780 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 1779 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1781 animations->UpdateState(true, events.get()); 1780 animations->UpdateState(true, events.get());
1782 EXPECT_EQ(0u, events->events_.size()); 1781 EXPECT_EQ(0u, events->events_.size());
1783 EXPECT_EQ(Animation::STARTING, 1782 EXPECT_EQ(Animation::STARTING,
1784 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); 1783 animations->GetAnimation(TargetProperty::OPACITY)->run_state());
1785 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING)); 1784 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING));
1786 1785
1787 // Even when already in the STARTING state, the animation should stay 1786 // Even when already in the STARTING state, the animation should stay
1788 // there, and shouldn't be ticked past its starting point. 1787 // there, and shouldn't be ticked past its starting point.
1789 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 1788 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1790 animations->UpdateState(true, events.get()); 1789 animations->UpdateState(true, events.get());
1791 EXPECT_EQ(0u, events->events_.size()); 1790 EXPECT_EQ(0u, events->events_.size());
1792 EXPECT_EQ(Animation::STARTING, 1791 EXPECT_EQ(Animation::STARTING,
1793 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); 1792 animations->GetAnimation(TargetProperty::OPACITY)->run_state());
1794 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING)); 1793 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING));
1795 1794
1796 // animations->set_needs_active_value_observations(true);
1797 CreateTestImplLayer(LayerTreeType::ACTIVE); 1795 CreateTestImplLayer(LayerTreeType::ACTIVE);
1798 1796
1799 // Now that an active observer has been added, the animation should still 1797 // Now that an active observer has been added, the animation should still
1800 // initially tick at its starting point, but should now progress to RUNNING. 1798 // initially tick at its starting point, but should now progress to RUNNING.
1801 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); 1799 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
1802 animations->UpdateState(true, events.get()); 1800 animations->UpdateState(true, events.get());
1803 EXPECT_EQ(1u, events->events_.size()); 1801 EXPECT_EQ(1u, events->events_.size());
1804 EXPECT_EQ(Animation::RUNNING, 1802 EXPECT_EQ(Animation::RUNNING,
1805 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); 1803 animations->GetAnimation(TargetProperty::OPACITY)->run_state());
1806 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING)); 1804 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING));
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
2294 2292
2295 TransformOperations operations2; 2293 TransformOperations operations2;
2296 curve2->AddKeyframe( 2294 curve2->AddKeyframe(
2297 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); 2295 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr));
2298 operations2.AppendScale(2.0, 3.0, 4.0); 2296 operations2.AppendScale(2.0, 3.0, 4.0);
2299 curve2->AddKeyframe(TransformKeyframe::Create( 2297 curve2->AddKeyframe(TransformKeyframe::Create(
2300 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); 2298 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr));
2301 2299
2302 animation = 2300 animation =
2303 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM); 2301 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM);
2304 animation->set_affects_active_observers(false); 2302 animation->set_affects_active_elements(false);
2305 animations_impl->AddAnimation(std::move(animation)); 2303 animations_impl->AddAnimation(std::move(animation));
2306 2304
2307 // A scale animation is not a translation. 2305 // A scale animation is not a translation.
2308 EXPECT_FALSE( 2306 EXPECT_FALSE(
2309 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); 2307 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING));
2310 EXPECT_TRUE( 2308 EXPECT_TRUE(
2311 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); 2309 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE));
2312 2310
2313 animations_impl->ActivateAnimations(); 2311 animations_impl->ActivateAnimations();
2314 EXPECT_FALSE( 2312 EXPECT_FALSE(
2315 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); 2313 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING));
2316 EXPECT_FALSE( 2314 EXPECT_FALSE(
2317 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); 2315 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE));
2318 2316
2319 animations_impl->GetAnimationById(3)->set_affects_pending_observers(false); 2317 animations_impl->GetAnimationById(3)->set_affects_pending_elements(false);
2320 EXPECT_TRUE( 2318 EXPECT_TRUE(
2321 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); 2319 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING));
2322 EXPECT_FALSE( 2320 EXPECT_FALSE(
2323 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); 2321 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE));
2324 2322
2325 animations_impl->GetAnimationById(3)->SetRunState(Animation::FINISHED, 2323 animations_impl->GetAnimationById(3)->SetRunState(Animation::FINISHED,
2326 TicksFromSecondsF(0.0)); 2324 TicksFromSecondsF(0.0));
2327 2325
2328 // Only unfinished animations should be considered by 2326 // Only unfinished animations should be considered by
2329 // HasOnlyTranslationTransforms. 2327 // HasOnlyTranslationTransforms.
(...skipping 15 matching lines...) Expand all
2345 2343
2346 TransformOperations operations1; 2344 TransformOperations operations1;
2347 operations1.AppendScale(2.0, 3.0, 4.0); 2345 operations1.AppendScale(2.0, 3.0, 4.0);
2348 curve1->AddKeyframe( 2346 curve1->AddKeyframe(
2349 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); 2347 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr));
2350 TransformOperations operations2; 2348 TransformOperations operations2;
2351 curve1->AddKeyframe(TransformKeyframe::Create( 2349 curve1->AddKeyframe(TransformKeyframe::Create(
2352 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); 2350 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr));
2353 std::unique_ptr<Animation> animation( 2351 std::unique_ptr<Animation> animation(
2354 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); 2352 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM));
2355 animation->set_affects_active_observers(false); 2353 animation->set_affects_active_elements(false);
2356 animations_impl->AddAnimation(std::move(animation)); 2354 animations_impl->AddAnimation(std::move(animation));
2357 2355
2358 float start_scale = 0.f; 2356 float start_scale = 0.f;
2359 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::PENDING, 2357 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::PENDING,
2360 &start_scale)); 2358 &start_scale));
2361 EXPECT_EQ(4.f, start_scale); 2359 EXPECT_EQ(4.f, start_scale);
2362 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::ACTIVE, 2360 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::ACTIVE,
2363 &start_scale)); 2361 &start_scale));
2364 EXPECT_EQ(0.f, start_scale); 2362 EXPECT_EQ(0.f, start_scale);
2365 2363
(...skipping 14 matching lines...) Expand all
2380 operations3.AppendScale(6.0, 5.0, 4.0); 2378 operations3.AppendScale(6.0, 5.0, 4.0);
2381 curve2->AddKeyframe(TransformKeyframe::Create( 2379 curve2->AddKeyframe(TransformKeyframe::Create(
2382 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); 2380 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr));
2383 2381
2384 animations_impl->RemoveAnimation(1); 2382 animations_impl->RemoveAnimation(1);
2385 animation = 2383 animation =
2386 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); 2384 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM);
2387 2385
2388 // Reverse Direction 2386 // Reverse Direction
2389 animation->set_direction(Animation::DIRECTION_REVERSE); 2387 animation->set_direction(Animation::DIRECTION_REVERSE);
2390 animation->set_affects_active_observers(false); 2388 animation->set_affects_active_elements(false);
2391 animations_impl->AddAnimation(std::move(animation)); 2389 animations_impl->AddAnimation(std::move(animation));
2392 2390
2393 std::unique_ptr<KeyframedTransformAnimationCurve> curve3( 2391 std::unique_ptr<KeyframedTransformAnimationCurve> curve3(
2394 KeyframedTransformAnimationCurve::Create()); 2392 KeyframedTransformAnimationCurve::Create());
2395 2393
2396 TransformOperations operations4; 2394 TransformOperations operations4;
2397 operations4.AppendScale(5.0, 3.0, 1.0); 2395 operations4.AppendScale(5.0, 3.0, 1.0);
2398 curve3->AddKeyframe( 2396 curve3->AddKeyframe(
2399 TransformKeyframe::Create(base::TimeDelta(), operations4, nullptr)); 2397 TransformKeyframe::Create(base::TimeDelta(), operations4, nullptr));
2400 TransformOperations operations5; 2398 TransformOperations operations5;
2401 curve3->AddKeyframe(TransformKeyframe::Create( 2399 curve3->AddKeyframe(TransformKeyframe::Create(
2402 base::TimeDelta::FromSecondsD(1.0), operations5, nullptr)); 2400 base::TimeDelta::FromSecondsD(1.0), operations5, nullptr));
2403 2401
2404 animation = 2402 animation =
2405 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); 2403 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM);
2406 animation->set_affects_active_observers(false); 2404 animation->set_affects_active_elements(false);
2407 animations_impl->AddAnimation(std::move(animation)); 2405 animations_impl->AddAnimation(std::move(animation));
2408 2406
2409 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::PENDING, 2407 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::PENDING,
2410 &start_scale)); 2408 &start_scale));
2411 EXPECT_EQ(6.f, start_scale); 2409 EXPECT_EQ(6.f, start_scale);
2412 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::ACTIVE, 2410 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::ACTIVE,
2413 &start_scale)); 2411 &start_scale));
2414 EXPECT_EQ(0.f, start_scale); 2412 EXPECT_EQ(0.f, start_scale);
2415 2413
2416 animations_impl->ActivateAnimations(); 2414 animations_impl->ActivateAnimations();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2454 2452
2455 TransformOperations operations1; 2453 TransformOperations operations1;
2456 curve1->AddKeyframe( 2454 curve1->AddKeyframe(
2457 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); 2455 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr));
2458 operations1.AppendScale(2.0, 3.0, 4.0); 2456 operations1.AppendScale(2.0, 3.0, 4.0);
2459 curve1->AddKeyframe(TransformKeyframe::Create( 2457 curve1->AddKeyframe(TransformKeyframe::Create(
2460 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); 2458 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr));
2461 2459
2462 std::unique_ptr<Animation> animation( 2460 std::unique_ptr<Animation> animation(
2463 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); 2461 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM));
2464 animation->set_affects_active_observers(false); 2462 animation->set_affects_active_elements(false);
2465 animations_impl->AddAnimation(std::move(animation)); 2463 animations_impl->AddAnimation(std::move(animation));
2466 2464
2467 EXPECT_TRUE( 2465 EXPECT_TRUE(
2468 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2466 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale));
2469 EXPECT_EQ(4.f, max_scale); 2467 EXPECT_EQ(4.f, max_scale);
2470 EXPECT_TRUE( 2468 EXPECT_TRUE(
2471 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2469 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale));
2472 EXPECT_EQ(0.f, max_scale); 2470 EXPECT_EQ(0.f, max_scale);
2473 2471
2474 animations_impl->ActivateAnimations(); 2472 animations_impl->ActivateAnimations();
2475 EXPECT_TRUE( 2473 EXPECT_TRUE(
2476 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2474 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale));
2477 EXPECT_EQ(4.f, max_scale); 2475 EXPECT_EQ(4.f, max_scale);
2478 EXPECT_TRUE( 2476 EXPECT_TRUE(
2479 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2477 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale));
2480 EXPECT_EQ(4.f, max_scale); 2478 EXPECT_EQ(4.f, max_scale);
2481 2479
2482 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( 2480 std::unique_ptr<KeyframedTransformAnimationCurve> curve2(
2483 KeyframedTransformAnimationCurve::Create()); 2481 KeyframedTransformAnimationCurve::Create());
2484 2482
2485 TransformOperations operations2; 2483 TransformOperations operations2;
2486 curve2->AddKeyframe( 2484 curve2->AddKeyframe(
2487 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); 2485 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr));
2488 operations2.AppendScale(6.0, 5.0, 4.0); 2486 operations2.AppendScale(6.0, 5.0, 4.0);
2489 curve2->AddKeyframe(TransformKeyframe::Create( 2487 curve2->AddKeyframe(TransformKeyframe::Create(
2490 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); 2488 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr));
2491 2489
2492 animation = 2490 animation =
2493 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); 2491 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM);
2494 animation->set_affects_active_observers(false); 2492 animation->set_affects_active_elements(false);
2495 animations_impl->AddAnimation(std::move(animation)); 2493 animations_impl->AddAnimation(std::move(animation));
2496 2494
2497 EXPECT_TRUE( 2495 EXPECT_TRUE(
2498 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2496 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale));
2499 EXPECT_EQ(6.f, max_scale); 2497 EXPECT_EQ(6.f, max_scale);
2500 EXPECT_TRUE( 2498 EXPECT_TRUE(
2501 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2499 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale));
2502 EXPECT_EQ(4.f, max_scale); 2500 EXPECT_EQ(4.f, max_scale);
2503 2501
2504 animations_impl->ActivateAnimations(); 2502 animations_impl->ActivateAnimations();
2505 EXPECT_TRUE( 2503 EXPECT_TRUE(
2506 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2504 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale));
2507 EXPECT_EQ(6.f, max_scale); 2505 EXPECT_EQ(6.f, max_scale);
2508 EXPECT_TRUE( 2506 EXPECT_TRUE(
2509 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2507 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale));
2510 EXPECT_EQ(6.f, max_scale); 2508 EXPECT_EQ(6.f, max_scale);
2511 2509
2512 std::unique_ptr<KeyframedTransformAnimationCurve> curve3( 2510 std::unique_ptr<KeyframedTransformAnimationCurve> curve3(
2513 KeyframedTransformAnimationCurve::Create()); 2511 KeyframedTransformAnimationCurve::Create());
2514 2512
2515 TransformOperations operations3; 2513 TransformOperations operations3;
2516 curve3->AddKeyframe( 2514 curve3->AddKeyframe(
2517 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); 2515 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr));
2518 operations3.AppendPerspective(6.0); 2516 operations3.AppendPerspective(6.0);
2519 curve3->AddKeyframe(TransformKeyframe::Create( 2517 curve3->AddKeyframe(TransformKeyframe::Create(
2520 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); 2518 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr));
2521 2519
2522 animation = 2520 animation =
2523 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); 2521 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM);
2524 animation->set_affects_active_observers(false); 2522 animation->set_affects_active_elements(false);
2525 animations_impl->AddAnimation(std::move(animation)); 2523 animations_impl->AddAnimation(std::move(animation));
2526 2524
2527 EXPECT_FALSE( 2525 EXPECT_FALSE(
2528 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); 2526 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale));
2529 EXPECT_TRUE( 2527 EXPECT_TRUE(
2530 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); 2528 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale));
2531 EXPECT_EQ(6.f, max_scale); 2529 EXPECT_EQ(6.f, max_scale);
2532 2530
2533 animations_impl->ActivateAnimations(); 2531 animations_impl->ActivateAnimations();
2534 EXPECT_FALSE( 2532 EXPECT_FALSE(
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2669 EXPECT_TRUE(animations->needs_to_start_animations_for_testing()); 2667 EXPECT_TRUE(animations->needs_to_start_animations_for_testing());
2670 2668
2671 EXPECT_FALSE(animations_impl->needs_to_start_animations_for_testing()); 2669 EXPECT_FALSE(animations_impl->needs_to_start_animations_for_testing());
2672 animations->PushPropertiesTo(animations_impl.get()); 2670 animations->PushPropertiesTo(animations_impl.get());
2673 EXPECT_TRUE(animations_impl->needs_to_start_animations_for_testing()); 2671 EXPECT_TRUE(animations_impl->needs_to_start_animations_for_testing());
2674 2672
2675 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); 2673 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id));
2676 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, 2674 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY,
2677 animations_impl->GetAnimationById(animation_id)->run_state()); 2675 animations_impl->GetAnimationById(animation_id)->run_state());
2678 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2676 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2679 ->affects_pending_observers()); 2677 ->affects_pending_elements());
2680 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id) 2678 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)
2681 ->affects_active_observers()); 2679 ->affects_active_elements());
2682 2680
2683 animations_impl->Animate(kInitialTickTime); 2681 animations_impl->Animate(kInitialTickTime);
2684 EXPECT_FALSE(animations_impl->needs_to_start_animations_for_testing()); 2682 EXPECT_FALSE(animations_impl->needs_to_start_animations_for_testing());
2685 animations_impl->UpdateState(true, events.get()); 2683 animations_impl->UpdateState(true, events.get());
2686 2684
2687 // Since the animation hasn't been activated, it should still be STARTING 2685 // Since the animation hasn't been activated, it should still be STARTING
2688 // rather than RUNNING. 2686 // rather than RUNNING.
2689 EXPECT_EQ(Animation::STARTING, 2687 EXPECT_EQ(Animation::STARTING,
2690 animations_impl->GetAnimationById(animation_id)->run_state()); 2688 animations_impl->GetAnimationById(animation_id)->run_state());
2691 2689
2692 // Since the animation hasn't been activated, only the pending observer 2690 // Since the animation hasn't been activated, only the pending observer
2693 // should have been ticked. 2691 // should have been ticked.
2694 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING)); 2692 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING));
2695 EXPECT_EQ(0.f, client_impl_.GetOpacity(layer_id_, LayerTreeType::ACTIVE)); 2693 EXPECT_EQ(0.f, client_impl_.GetOpacity(layer_id_, LayerTreeType::ACTIVE));
2696 2694
2697 animations_impl->ActivateAnimations(); 2695 animations_impl->ActivateAnimations();
2698 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2696 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2699 ->affects_pending_observers()); 2697 ->affects_pending_elements());
2700 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2698 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2701 ->affects_active_observers()); 2699 ->affects_active_elements());
2702 2700
2703 animations_impl->Animate(kInitialTickTime + 2701 animations_impl->Animate(kInitialTickTime +
2704 TimeDelta::FromMilliseconds(1000)); 2702 TimeDelta::FromMilliseconds(1000));
2705 animations_impl->UpdateState(true, events.get()); 2703 animations_impl->UpdateState(true, events.get());
2706 2704
2707 // Since the animation has been activated, it should have reached the 2705 // Since the animation has been activated, it should have reached the
2708 // RUNNING state and the active observer should start to get ticked. 2706 // RUNNING state and the active observer should start to get ticked.
2709 EXPECT_EQ(Animation::RUNNING, 2707 EXPECT_EQ(Animation::RUNNING,
2710 animations_impl->GetAnimationById(animation_id)->run_state()); 2708 animations_impl->GetAnimationById(animation_id)->run_state());
2711 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING)); 2709 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING));
(...skipping 12 matching lines...) Expand all
2724 2722
2725 const int animation_id = AddOpacityTransitionToElementAnimations( 2723 const int animation_id = AddOpacityTransitionToElementAnimations(
2726 animations.get(), 1, 0.5f, 1.f, true); 2724 animations.get(), 1, 0.5f, 1.f, true);
2727 2725
2728 animations->PushPropertiesTo(animations_impl.get()); 2726 animations->PushPropertiesTo(animations_impl.get());
2729 2727
2730 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); 2728 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id));
2731 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, 2729 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY,
2732 animations_impl->GetAnimationById(animation_id)->run_state()); 2730 animations_impl->GetAnimationById(animation_id)->run_state());
2733 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2731 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2734 ->affects_pending_observers()); 2732 ->affects_pending_elements());
2735 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id) 2733 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)
2736 ->affects_active_observers()); 2734 ->affects_active_elements());
2737 2735
2738 animations_impl->Animate(kInitialTickTime); 2736 animations_impl->Animate(kInitialTickTime);
2739 2737
2740 // Since the animation hasn't been activated, only the pending observer 2738 // Since the animation hasn't been activated, only the pending observer
2741 // should have been ticked. 2739 // should have been ticked.
2742 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING)); 2740 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING));
2743 EXPECT_EQ(0.f, client_impl_.GetOpacity(layer_id_, LayerTreeType::ACTIVE)); 2741 EXPECT_EQ(0.f, client_impl_.GetOpacity(layer_id_, LayerTreeType::ACTIVE));
2744 2742
2745 animations_impl->ActivateAnimations(); 2743 animations_impl->ActivateAnimations();
2746 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2744 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2747 ->affects_pending_observers()); 2745 ->affects_pending_elements());
2748 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2746 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2749 ->affects_active_observers()); 2747 ->affects_active_elements());
2750 2748
2751 animations_impl->UpdateState(true, events.get()); 2749 animations_impl->UpdateState(true, events.get());
2752 2750
2753 // Since the animation has been activated, it should have reached the 2751 // Since the animation has been activated, it should have reached the
2754 // RUNNING state. 2752 // RUNNING state.
2755 EXPECT_EQ(Animation::RUNNING, 2753 EXPECT_EQ(Animation::RUNNING,
2756 animations_impl->GetAnimationById(animation_id)->run_state()); 2754 animations_impl->GetAnimationById(animation_id)->run_state());
2757 2755
2758 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); 2756 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
2759 2757
2760 // Both observers should have been ticked. 2758 // Both elements should have been ticked.
2761 EXPECT_EQ(0.75f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING)); 2759 EXPECT_EQ(0.75f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING));
2762 EXPECT_EQ(0.75f, client_impl_.GetOpacity(layer_id_, LayerTreeType::ACTIVE)); 2760 EXPECT_EQ(0.75f, client_impl_.GetOpacity(layer_id_, LayerTreeType::ACTIVE));
2763 } 2761 }
2764 2762
2765 TEST_F(ElementAnimationsTest, 2763 TEST_F(ElementAnimationsTest,
2766 ObserverNotifiedWhenTransformIsPotentiallyAnimatingChanges) { 2764 ObserverNotifiedWhenTransformIsPotentiallyAnimatingChanges) {
2767 CreateTestLayer(true, true); 2765 CreateTestLayer(true, true);
2768 AttachTimelinePlayerLayer(); 2766 AttachTimelinePlayerLayer();
2769 CreateImplTimelineAndPlayer(); 2767 CreateImplTimelineAndPlayer();
2770 2768
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2957 animations->PushPropertiesTo(animations_impl.get()); 2955 animations->PushPropertiesTo(animations_impl.get());
2958 animations_impl->ActivateAnimations(); 2956 animations_impl->ActivateAnimations();
2959 animations_impl->Animate(kInitialTickTime); 2957 animations_impl->Animate(kInitialTickTime);
2960 animations_impl->UpdateState(true, events.get()); 2958 animations_impl->UpdateState(true, events.get());
2961 EXPECT_EQ(Animation::RUNNING, 2959 EXPECT_EQ(Animation::RUNNING,
2962 animations_impl->GetAnimationById(animation_id)->run_state()); 2960 animations_impl->GetAnimationById(animation_id)->run_state());
2963 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING)); 2961 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING));
2964 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::ACTIVE)); 2962 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::ACTIVE));
2965 2963
2966 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2964 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2967 ->affects_pending_observers()); 2965 ->affects_pending_elements());
2968 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2966 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2969 ->affects_active_observers()); 2967 ->affects_active_elements());
2970 2968
2971 // Delete the animation on the main-thread animations. 2969 // Delete the animation on the main-thread animations.
2972 animations->RemoveAnimation( 2970 animations->RemoveAnimation(
2973 animations->GetAnimation(TargetProperty::OPACITY)->id()); 2971 animations->GetAnimation(TargetProperty::OPACITY)->id());
2974 animations->PushPropertiesTo(animations_impl.get()); 2972 animations->PushPropertiesTo(animations_impl.get());
2975 2973
2976 // The animation should no longer affect pending observers. 2974 // The animation should no longer affect pending elements.
2977 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id) 2975 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)
2978 ->affects_pending_observers()); 2976 ->affects_pending_elements());
2979 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) 2977 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)
2980 ->affects_active_observers()); 2978 ->affects_active_elements());
2981 2979
2982 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); 2980 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
2983 animations_impl->UpdateState(true, events.get()); 2981 animations_impl->UpdateState(true, events.get());
2984 2982
2985 // Only the active observer should have been ticked. 2983 // Only the active observer should have been ticked.
2986 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING)); 2984 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING));
2987 EXPECT_EQ(0.75f, client_impl_.GetOpacity(layer_id_, LayerTreeType::ACTIVE)); 2985 EXPECT_EQ(0.75f, client_impl_.GetOpacity(layer_id_, LayerTreeType::ACTIVE));
2988 2986
2989 animations_impl->ActivateAnimations(); 2987 animations_impl->ActivateAnimations();
2990 2988
2991 // Activation should cause the animation to be deleted. 2989 // Activation should cause the animation to be deleted.
2992 EXPECT_FALSE(animations_impl->has_any_animation()); 2990 EXPECT_FALSE(animations_impl->has_any_animation());
2993 } 2991 }
2994 2992
2995 // Tests that an animation that affects only active observers won't block 2993 // Tests that an animation that affects only active elements won't block
2996 // an animation that affects only pending observers from starting. 2994 // an animation that affects only pending elements from starting.
2997 TEST_F(ElementAnimationsTest, StartAnimationsAffectingDifferentObservers) { 2995 TEST_F(ElementAnimationsTest, StartAnimationsAffectingDifferentObservers) {
2998 CreateTestLayer(true, true); 2996 CreateTestLayer(true, true);
2999 AttachTimelinePlayerLayer(); 2997 AttachTimelinePlayerLayer();
3000 CreateImplTimelineAndPlayer(); 2998 CreateImplTimelineAndPlayer();
3001 2999
3002 scoped_refptr<ElementAnimations> animations = element_animations(); 3000 scoped_refptr<ElementAnimations> animations = element_animations();
3003 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 3001 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
3004 3002
3005 auto events = host_impl_->CreateEvents(); 3003 auto events = host_impl_->CreateEvents();
3006 3004
3007 const int first_animation_id = AddOpacityTransitionToElementAnimations( 3005 const int first_animation_id = AddOpacityTransitionToElementAnimations(
3008 animations.get(), 1, 0.f, 1.f, true); 3006 animations.get(), 1, 0.f, 1.f, true);
3009 3007
3010 animations->PushPropertiesTo(animations_impl.get()); 3008 animations->PushPropertiesTo(animations_impl.get());
3011 animations_impl->ActivateAnimations(); 3009 animations_impl->ActivateAnimations();
3012 animations_impl->Animate(kInitialTickTime); 3010 animations_impl->Animate(kInitialTickTime);
3013 animations_impl->UpdateState(true, events.get()); 3011 animations_impl->UpdateState(true, events.get());
3014 3012
3015 // Remove the first animation from the main-thread animations, and add a 3013 // Remove the first animation from the main-thread animations, and add a
3016 // new animation affecting the same property. 3014 // new animation affecting the same property.
3017 animations->RemoveAnimation( 3015 animations->RemoveAnimation(
3018 animations->GetAnimation(TargetProperty::OPACITY)->id()); 3016 animations->GetAnimation(TargetProperty::OPACITY)->id());
3019 const int second_animation_id = AddOpacityTransitionToElementAnimations( 3017 const int second_animation_id = AddOpacityTransitionToElementAnimations(
3020 animations.get(), 1, 1.f, 0.5f, true); 3018 animations.get(), 1, 1.f, 0.5f, true);
3021 animations->PushPropertiesTo(animations_impl.get()); 3019 animations->PushPropertiesTo(animations_impl.get());
3022 3020
3023 // The original animation should only affect active observers, and the new 3021 // The original animation should only affect active elements, and the new
3024 // animation should only affect pending observers. 3022 // animation should only affect pending elements.
3025 EXPECT_FALSE(animations_impl->GetAnimationById(first_animation_id) 3023 EXPECT_FALSE(animations_impl->GetAnimationById(first_animation_id)
3026 ->affects_pending_observers()); 3024 ->affects_pending_elements());
3027 EXPECT_TRUE(animations_impl->GetAnimationById(first_animation_id) 3025 EXPECT_TRUE(animations_impl->GetAnimationById(first_animation_id)
3028 ->affects_active_observers()); 3026 ->affects_active_elements());
3029 EXPECT_TRUE(animations_impl->GetAnimationById(second_animation_id) 3027 EXPECT_TRUE(animations_impl->GetAnimationById(second_animation_id)
3030 ->affects_pending_observers()); 3028 ->affects_pending_elements());
3031 EXPECT_FALSE(animations_impl->GetAnimationById(second_animation_id) 3029 EXPECT_FALSE(animations_impl->GetAnimationById(second_animation_id)
3032 ->affects_active_observers()); 3030 ->affects_active_elements());
3033 3031
3034 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); 3032 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
3035 animations_impl->UpdateState(true, events.get()); 3033 animations_impl->UpdateState(true, events.get());
3036 3034
3037 // The original animation should still be running, and the new animation 3035 // The original animation should still be running, and the new animation
3038 // should be starting. 3036 // should be starting.
3039 EXPECT_EQ(Animation::RUNNING, 3037 EXPECT_EQ(Animation::RUNNING,
3040 animations_impl->GetAnimationById(first_animation_id)->run_state()); 3038 animations_impl->GetAnimationById(first_animation_id)->run_state());
3041 EXPECT_EQ( 3039 EXPECT_EQ(
3042 Animation::STARTING, 3040 Animation::STARTING,
3043 animations_impl->GetAnimationById(second_animation_id)->run_state()); 3041 animations_impl->GetAnimationById(second_animation_id)->run_state());
3044 3042
3045 // The active observer should have been ticked by the original animation, 3043 // The active observer should have been ticked by the original animation,
3046 // and the pending observer should have been ticked by the new animation. 3044 // and the pending observer should have been ticked by the new animation.
3047 EXPECT_EQ(1.f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING)); 3045 EXPECT_EQ(1.f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING));
3048 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::ACTIVE)); 3046 EXPECT_EQ(0.5f, client_impl_.GetOpacity(layer_id_, LayerTreeType::ACTIVE));
3049 3047
3050 animations_impl->ActivateAnimations(); 3048 animations_impl->ActivateAnimations();
3051 3049
3052 // The original animation should have been deleted, and the new animation 3050 // The original animation should have been deleted, and the new animation
3053 // should now affect both observers. 3051 // should now affect both elements.
3054 EXPECT_FALSE(animations_impl->GetAnimationById(first_animation_id)); 3052 EXPECT_FALSE(animations_impl->GetAnimationById(first_animation_id));
3055 EXPECT_TRUE(animations_impl->GetAnimationById(second_animation_id) 3053 EXPECT_TRUE(animations_impl->GetAnimationById(second_animation_id)
3056 ->affects_pending_observers()); 3054 ->affects_pending_elements());
3057 EXPECT_TRUE(animations_impl->GetAnimationById(second_animation_id) 3055 EXPECT_TRUE(animations_impl->GetAnimationById(second_animation_id)
3058 ->affects_active_observers()); 3056 ->affects_active_elements());
3059 3057
3060 animations_impl->Animate(kInitialTickTime + 3058 animations_impl->Animate(kInitialTickTime +
3061 TimeDelta::FromMilliseconds(1000)); 3059 TimeDelta::FromMilliseconds(1000));
3062 animations_impl->UpdateState(true, events.get()); 3060 animations_impl->UpdateState(true, events.get());
3063 3061
3064 // The new animation should be running, and the active observer should have 3062 // The new animation should be running, and the active observer should have
3065 // been ticked at the new animation's starting point. 3063 // been ticked at the new animation's starting point.
3066 EXPECT_EQ( 3064 EXPECT_EQ(
3067 Animation::RUNNING, 3065 Animation::RUNNING,
3068 animations_impl->GetAnimationById(second_animation_id)->run_state()); 3066 animations_impl->GetAnimationById(second_animation_id)->run_state());
3069 EXPECT_EQ(1.f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING)); 3067 EXPECT_EQ(1.f, client_impl_.GetOpacity(layer_id_, LayerTreeType::PENDING));
3070 EXPECT_EQ(1.f, client_impl_.GetOpacity(layer_id_, LayerTreeType::ACTIVE)); 3068 EXPECT_EQ(1.f, client_impl_.GetOpacity(layer_id_, LayerTreeType::ACTIVE));
3071 } 3069 }
3072 3070
3073 TEST_F(ElementAnimationsTest, TestIsCurrentlyAnimatingProperty) { 3071 TEST_F(ElementAnimationsTest, TestIsCurrentlyAnimatingProperty) {
3074 CreateTestLayer(false, false); 3072 CreateTestLayer(false, false);
3075 AttachTimelinePlayerLayer(); 3073 AttachTimelinePlayerLayer();
3076 3074
3077 scoped_refptr<ElementAnimations> animations = element_animations(); 3075 scoped_refptr<ElementAnimations> animations = element_animations();
3078 3076
3079 // Create an animation that initially affects only pending observers. 3077 // Create an animation that initially affects only pending elements.
3080 std::unique_ptr<Animation> animation(CreateAnimation( 3078 std::unique_ptr<Animation> animation(CreateAnimation(
3081 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 3079 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
3082 1, TargetProperty::OPACITY)); 3080 1, TargetProperty::OPACITY));
3083 animation->set_affects_active_observers(false); 3081 animation->set_affects_active_elements(false);
3084 3082
3085 animations->AddAnimation(std::move(animation)); 3083 animations->AddAnimation(std::move(animation));
3086 animations->Animate(kInitialTickTime); 3084 animations->Animate(kInitialTickTime);
3087 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3085 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY,
3088 LayerTreeType::PENDING)); 3086 LayerTreeType::PENDING));
3089 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3087 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY,
3090 LayerTreeType::ACTIVE)); 3088 LayerTreeType::ACTIVE));
3091 animations->UpdateState(true, nullptr); 3089 animations->UpdateState(true, nullptr);
3092 EXPECT_TRUE(animations->HasActiveAnimation()); 3090 EXPECT_TRUE(animations->HasActiveAnimation());
3093 3091
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3140 3138
3141 EXPECT_EQ(1.f, client_.GetOpacity(layer_id_, LayerTreeType::ACTIVE)); 3139 EXPECT_EQ(1.f, client_.GetOpacity(layer_id_, LayerTreeType::ACTIVE));
3142 } 3140 }
3143 3141
3144 TEST_F(ElementAnimationsTest, TestIsAnimatingPropertyTimeOffsetFillMode) { 3142 TEST_F(ElementAnimationsTest, TestIsAnimatingPropertyTimeOffsetFillMode) {
3145 CreateTestLayer(false, false); 3143 CreateTestLayer(false, false);
3146 AttachTimelinePlayerLayer(); 3144 AttachTimelinePlayerLayer();
3147 3145
3148 scoped_refptr<ElementAnimations> animations = element_animations(); 3146 scoped_refptr<ElementAnimations> animations = element_animations();
3149 3147
3150 // Create an animation that initially affects only pending observers, and has 3148 // Create an animation that initially affects only pending elements, and has
3151 // a start delay of 2 seconds. 3149 // a start delay of 2 seconds.
3152 std::unique_ptr<Animation> animation(CreateAnimation( 3150 std::unique_ptr<Animation> animation(CreateAnimation(
3153 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 3151 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)),
3154 1, TargetProperty::OPACITY)); 3152 1, TargetProperty::OPACITY));
3155 animation->set_fill_mode(Animation::FILL_MODE_NONE); 3153 animation->set_fill_mode(Animation::FILL_MODE_NONE);
3156 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000)); 3154 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000));
3157 animation->set_affects_active_observers(false); 3155 animation->set_affects_active_elements(false);
3158 3156
3159 animations->AddAnimation(std::move(animation)); 3157 animations->AddAnimation(std::move(animation));
3160 3158
3161 animations->Animate(kInitialTickTime); 3159 animations->Animate(kInitialTickTime);
3162 3160
3163 // Since the animation has a start delay, the observers it affects have a 3161 // Since the animation has a start delay, the elements it affects have a
3164 // potentially running transform animation but aren't currently animating 3162 // potentially running transform animation but aren't currently animating
3165 // transform. 3163 // transform.
3166 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( 3164 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty(
3167 TargetProperty::OPACITY, LayerTreeType::PENDING)); 3165 TargetProperty::OPACITY, LayerTreeType::PENDING));
3168 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( 3166 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty(
3169 TargetProperty::OPACITY, LayerTreeType::ACTIVE)); 3167 TargetProperty::OPACITY, LayerTreeType::ACTIVE));
3170 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3168 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3171 TargetProperty::OPACITY, LayerTreeType::PENDING)); 3169 TargetProperty::OPACITY, LayerTreeType::PENDING));
3172 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3170 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY,
3173 LayerTreeType::ACTIVE)); 3171 LayerTreeType::ACTIVE));
(...skipping 26 matching lines...) Expand all
3200 animations->UpdateState(true, nullptr); 3198 animations->UpdateState(true, nullptr);
3201 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( 3199 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty(
3202 TargetProperty::OPACITY, LayerTreeType::PENDING)); 3200 TargetProperty::OPACITY, LayerTreeType::PENDING));
3203 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( 3201 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty(
3204 TargetProperty::OPACITY, LayerTreeType::ACTIVE)); 3202 TargetProperty::OPACITY, LayerTreeType::ACTIVE));
3205 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3203 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY,
3206 LayerTreeType::PENDING)); 3204 LayerTreeType::PENDING));
3207 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3205 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY,
3208 LayerTreeType::ACTIVE)); 3206 LayerTreeType::ACTIVE));
3209 3207
3210 // After the animaton finishes, the observers it affects have neither a 3208 // After the animaton finishes, the elements it affects have neither a
3211 // potentially running transform animation nor a currently running transform 3209 // potentially running transform animation nor a currently running transform
3212 // animation. 3210 // animation.
3213 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); 3211 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000));
3214 animations->UpdateState(true, nullptr); 3212 animations->UpdateState(true, nullptr);
3215 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( 3213 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty(
3216 TargetProperty::OPACITY, LayerTreeType::PENDING)); 3214 TargetProperty::OPACITY, LayerTreeType::PENDING));
3217 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( 3215 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty(
3218 TargetProperty::OPACITY, LayerTreeType::ACTIVE)); 3216 TargetProperty::OPACITY, LayerTreeType::ACTIVE));
3219 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3217 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3220 TargetProperty::OPACITY, LayerTreeType::PENDING)); 3218 TargetProperty::OPACITY, LayerTreeType::PENDING));
3221 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, 3219 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY,
3222 LayerTreeType::ACTIVE)); 3220 LayerTreeType::ACTIVE));
3223 } 3221 }
3224 3222
3225 } // namespace 3223 } // namespace
3226 } // namespace cc 3224 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/element_animations.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698