| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/animation/element_animations.h" | 5 #include "cc/animation/element_animations.h" |
| 6 | 6 |
| 7 #include "cc/animation/animation_delegate.h" | 7 #include "cc/animation/animation_delegate.h" |
| 8 #include "cc/animation/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
| 9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
| 10 #include "cc/animation/animation_player.h" | 10 #include "cc/animation/animation_player.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 timeline_->AttachPlayer(player_); | 54 timeline_->AttachPlayer(player_); |
| 55 player_->AttachElement(element_id_); | 55 player_->AttachElement(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 PushProperties(); |
| 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_.RegisterElement(element_id_, ElementListType::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( | 80 EXPECT_TRUE( |
| 81 client_impl_.IsElementInList(element_id_, ElementListType::ACTIVE)); | 81 client_impl_.IsElementInList(element_id_, ElementListType::ACTIVE)); |
| 82 EXPECT_TRUE( | 82 EXPECT_TRUE( |
| 83 client_impl_.IsElementInList(element_id_, ElementListType::PENDING)); | 83 client_impl_.IsElementInList(element_id_, ElementListType::PENDING)); |
| 84 | 84 |
| 85 // kill layer on main thread. | 85 // kill layer on main thread. |
| 86 client_.UnregisterElement(element_id_, ElementListType::ACTIVE); | 86 client_.UnregisterElement(element_id_, ElementListType::ACTIVE); |
| 87 EXPECT_EQ(element_animations, player_->element_animations()); | 87 EXPECT_EQ(element_animations, player_->element_animations()); |
| 88 EXPECT_FALSE(element_animations->has_element_in_active_list()); | 88 EXPECT_FALSE(element_animations->has_element_in_active_list()); |
| 89 EXPECT_FALSE(element_animations->has_element_in_pending_list()); | 89 EXPECT_FALSE(element_animations->has_element_in_pending_list()); |
| 90 | 90 |
| 91 // Sync doesn't detach LayerImpl. | 91 // Sync doesn't detach LayerImpl. |
| 92 host_->PushPropertiesTo(host_impl_); | 92 PushProperties(); |
| 93 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); | 93 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); |
| 94 EXPECT_TRUE(element_animations_impl->has_element_in_active_list()); | 94 EXPECT_TRUE(element_animations_impl->has_element_in_active_list()); |
| 95 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list()); | 95 EXPECT_TRUE(element_animations_impl->has_element_in_pending_list()); |
| 96 | 96 |
| 97 // Kill layer on impl thread in pending tree. | 97 // Kill layer on impl thread in pending tree. |
| 98 client_impl_.UnregisterElement(element_id_, ElementListType::PENDING); | 98 client_impl_.UnregisterElement(element_id_, ElementListType::PENDING); |
| 99 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); | 99 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); |
| 100 EXPECT_TRUE(element_animations_impl->has_element_in_active_list()); | 100 EXPECT_TRUE(element_animations_impl->has_element_in_active_list()); |
| 101 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); | 101 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); |
| 102 | 102 |
| 103 // Kill layer on impl thread in active tree. | 103 // Kill layer on impl thread in active tree. |
| 104 client_impl_.UnregisterElement(element_id_, ElementListType::ACTIVE); | 104 client_impl_.UnregisterElement(element_id_, ElementListType::ACTIVE); |
| 105 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); | 105 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); |
| 106 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); | 106 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); |
| 107 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); | 107 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); |
| 108 | 108 |
| 109 // Sync doesn't change anything. | 109 // Sync doesn't change anything. |
| 110 host_->PushPropertiesTo(host_impl_); | 110 PushProperties(); |
| 111 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); | 111 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); |
| 112 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); | 112 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); |
| 113 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); | 113 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); |
| 114 | 114 |
| 115 player_->DetachElement(); | 115 player_->DetachElement(); |
| 116 EXPECT_FALSE(player_->element_animations()); | 116 EXPECT_FALSE(player_->element_animations()); |
| 117 | 117 |
| 118 // Release ptrs now to test the order of destruction. | 118 // Release ptrs now to test the order of destruction. |
| 119 ReleaseRefPtrs(); | 119 ReleaseRefPtrs(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 TEST_F(ElementAnimationsTest, AttachToNotYetCreatedLayer) { | 122 TEST_F(ElementAnimationsTest, AttachToNotYetCreatedLayer) { |
| 123 host_->AddAnimationTimeline(timeline_); | 123 host_->AddAnimationTimeline(timeline_); |
| 124 timeline_->AttachPlayer(player_); | 124 timeline_->AttachPlayer(player_); |
| 125 | 125 |
| 126 host_->PushPropertiesTo(host_impl_); | 126 PushProperties(); |
| 127 | |
| 128 GetImplTimelineAndPlayerByID(); | 127 GetImplTimelineAndPlayerByID(); |
| 129 | 128 |
| 130 player_->AttachElement(element_id_); | 129 player_->AttachElement(element_id_); |
| 131 | 130 |
| 132 scoped_refptr<ElementAnimations> element_animations = | 131 scoped_refptr<ElementAnimations> element_animations = |
| 133 player_->element_animations(); | 132 player_->element_animations(); |
| 134 EXPECT_TRUE(element_animations); | 133 EXPECT_TRUE(element_animations); |
| 135 | 134 |
| 136 EXPECT_FALSE(element_animations->has_element_in_active_list()); | 135 EXPECT_FALSE(element_animations->has_element_in_active_list()); |
| 137 EXPECT_FALSE(element_animations->has_element_in_pending_list()); | 136 EXPECT_FALSE(element_animations->has_element_in_pending_list()); |
| 138 | 137 |
| 139 host_->PushPropertiesTo(host_impl_); | 138 PushProperties(); |
| 140 | 139 |
| 141 scoped_refptr<ElementAnimations> element_animations_impl = | 140 scoped_refptr<ElementAnimations> element_animations_impl = |
| 142 player_impl_->element_animations(); | 141 player_impl_->element_animations(); |
| 143 EXPECT_TRUE(element_animations_impl); | 142 EXPECT_TRUE(element_animations_impl); |
| 144 | 143 |
| 145 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); | 144 EXPECT_FALSE(element_animations_impl->has_element_in_active_list()); |
| 146 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); | 145 EXPECT_FALSE(element_animations_impl->has_element_in_pending_list()); |
| 147 | 146 |
| 148 // Create layer. | 147 // Create layer. |
| 149 client_.RegisterElement(element_id_, ElementListType::ACTIVE); | 148 client_.RegisterElement(element_id_, ElementListType::ACTIVE); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 176 timeline_->AttachPlayer(player1); | 175 timeline_->AttachPlayer(player1); |
| 177 timeline_->AttachPlayer(player2); | 176 timeline_->AttachPlayer(player2); |
| 178 | 177 |
| 179 // Attach players to the same layer. | 178 // Attach players to the same layer. |
| 180 player1->AttachElement(element_id_); | 179 player1->AttachElement(element_id_); |
| 181 player2->AttachElement(element_id_); | 180 player2->AttachElement(element_id_); |
| 182 | 181 |
| 183 EXPECT_EQ(element_animations, player1->element_animations()); | 182 EXPECT_EQ(element_animations, player1->element_animations()); |
| 184 EXPECT_EQ(element_animations, player2->element_animations()); | 183 EXPECT_EQ(element_animations, player2->element_animations()); |
| 185 | 184 |
| 186 host_->PushPropertiesTo(host_impl_); | 185 PushProperties(); |
| 187 GetImplTimelineAndPlayerByID(); | 186 GetImplTimelineAndPlayerByID(); |
| 188 | 187 |
| 189 scoped_refptr<ElementAnimations> element_animations_impl = | 188 scoped_refptr<ElementAnimations> element_animations_impl = |
| 190 player_impl_->element_animations(); | 189 player_impl_->element_animations(); |
| 191 EXPECT_TRUE(element_animations_impl); | 190 EXPECT_TRUE(element_animations_impl); |
| 192 | 191 |
| 193 int list_size_before = 0; | 192 int list_size_before = 0; |
| 194 ElementAnimations::PlayersList::Iterator it( | 193 ElementAnimations::PlayersList::Iterator it( |
| 195 &element_animations_impl->players_list()); | 194 &element_animations_impl->players_list()); |
| 196 AnimationPlayer* player; | 195 AnimationPlayer* player; |
| 197 while ((player = it.GetNext()) != nullptr) { | 196 while ((player = it.GetNext()) != nullptr) { |
| 198 EXPECT_TRUE(timeline_->GetPlayerById(player->id())); | 197 EXPECT_TRUE(timeline_->GetPlayerById(player->id())); |
| 199 ++list_size_before; | 198 ++list_size_before; |
| 200 } | 199 } |
| 201 EXPECT_EQ(3, list_size_before); | 200 EXPECT_EQ(3, list_size_before); |
| 202 | 201 |
| 203 player2->DetachElement(); | 202 player2->DetachElement(); |
| 204 EXPECT_FALSE(player2->element_animations()); | 203 EXPECT_FALSE(player2->element_animations()); |
| 205 EXPECT_EQ(element_animations, player_->element_animations()); | 204 EXPECT_EQ(element_animations, player_->element_animations()); |
| 206 EXPECT_EQ(element_animations, player1->element_animations()); | 205 EXPECT_EQ(element_animations, player1->element_animations()); |
| 207 | 206 |
| 208 host_->PushPropertiesTo(host_impl_); | 207 PushProperties(); |
| 209 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); | 208 EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); |
| 210 | 209 |
| 211 int list_size_after = 0; | 210 int list_size_after = 0; |
| 212 it = ElementAnimations::PlayersList::Iterator( | 211 it = ElementAnimations::PlayersList::Iterator( |
| 213 &element_animations_impl->players_list()); | 212 &element_animations_impl->players_list()); |
| 214 while ((player = it.GetNext()) != nullptr) { | 213 while ((player = it.GetNext()) != nullptr) { |
| 215 EXPECT_TRUE(timeline_->GetPlayerById(player->id())); | 214 EXPECT_TRUE(timeline_->GetPlayerById(player->id())); |
| 216 ++list_size_after; | 215 ++list_size_after; |
| 217 } | 216 } |
| 218 EXPECT_EQ(2, list_size_after); | 217 EXPECT_EQ(2, list_size_after); |
| 219 } | 218 } |
| 220 | 219 |
| 221 TEST_F(ElementAnimationsTest, SyncNewAnimation) { | 220 TEST_F(ElementAnimationsTest, SyncNewAnimation) { |
| 222 auto animations_impl = ElementAnimations::Create(); | 221 CreateTestLayer(true, false); |
| 223 animations_impl->set_has_element_in_active_list(true); | 222 AttachTimelinePlayerLayer(); |
| 223 CreateImplTimelineAndPlayer(); |
| 224 | 224 |
| 225 auto animations = ElementAnimations::Create(); | 225 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 226 animations->set_has_element_in_active_list(true); | 226 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 227 | 227 |
| 228 EXPECT_FALSE(animations_impl->GetAnimation(TargetProperty::OPACITY)); | 228 EXPECT_FALSE(animations_impl->GetAnimation(TargetProperty::OPACITY)); |
| 229 | 229 |
| 230 EXPECT_FALSE(animations->needs_to_start_animations_for_testing()); | 230 EXPECT_FALSE(animations->needs_to_start_animations_for_testing()); |
| 231 EXPECT_FALSE(animations_impl->needs_to_start_animations_for_testing()); | 231 EXPECT_FALSE(animations_impl->needs_to_start_animations_for_testing()); |
| 232 | 232 |
| 233 int animation_id = | 233 int animation_id = |
| 234 AddOpacityTransitionToElementAnimations(animations.get(), 1, 0, 1, false); | 234 AddOpacityTransitionToPlayer(player_.get(), 1, 0, 1, false); |
| 235 EXPECT_TRUE(animations->needs_to_start_animations_for_testing()); | 235 EXPECT_TRUE(animations->needs_to_start_animations_for_testing()); |
| 236 | 236 |
| 237 animations->PushPropertiesTo(animations_impl.get()); | 237 PushProperties(); |
| 238 EXPECT_TRUE(animations_impl->needs_to_start_animations_for_testing()); | 238 EXPECT_TRUE(animations_impl->needs_to_start_animations_for_testing()); |
| 239 animations_impl->ActivateAnimations(); | 239 animations_impl->ActivateAnimations(); |
| 240 | 240 |
| 241 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 241 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
| 242 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 242 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 243 animations_impl->GetAnimationById(animation_id)->run_state()); | 243 animations_impl->GetAnimationById(animation_id)->run_state()); |
| 244 } | 244 } |
| 245 | 245 |
| 246 TEST_F(ElementAnimationsTest, | 246 TEST_F(ElementAnimationsTest, |
| 247 SyncScrollOffsetAnimationRespectsHasSetInitialValue) { | 247 SyncScrollOffsetAnimationRespectsHasSetInitialValue) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 266 // Animation with initial value set. | 266 // Animation with initial value set. |
| 267 std::unique_ptr<ScrollOffsetAnimationCurve> curve_fixed( | 267 std::unique_ptr<ScrollOffsetAnimationCurve> curve_fixed( |
| 268 ScrollOffsetAnimationCurve::Create( | 268 ScrollOffsetAnimationCurve::Create( |
| 269 target_value, CubicBezierTimingFunction::CreatePreset( | 269 target_value, CubicBezierTimingFunction::CreatePreset( |
| 270 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 270 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 271 curve_fixed->SetInitialValue(initial_value); | 271 curve_fixed->SetInitialValue(initial_value); |
| 272 const int animation1_id = 1; | 272 const int animation1_id = 1; |
| 273 std::unique_ptr<Animation> animation_fixed(Animation::Create( | 273 std::unique_ptr<Animation> animation_fixed(Animation::Create( |
| 274 std::move(curve_fixed), animation1_id, 0, TargetProperty::SCROLL_OFFSET)); | 274 std::move(curve_fixed), animation1_id, 0, TargetProperty::SCROLL_OFFSET)); |
| 275 animations->AddAnimation(std::move(animation_fixed)); | 275 animations->AddAnimation(std::move(animation_fixed)); |
| 276 animations->PushPropertiesTo(animations_impl.get()); | 276 PushProperties(); |
| 277 EXPECT_VECTOR2DF_EQ(initial_value, | 277 EXPECT_VECTOR2DF_EQ(initial_value, |
| 278 animations_impl->GetAnimationById(animation1_id) | 278 animations_impl->GetAnimationById(animation1_id) |
| 279 ->curve() | 279 ->curve() |
| 280 ->ToScrollOffsetAnimationCurve() | 280 ->ToScrollOffsetAnimationCurve() |
| 281 ->GetValue(base::TimeDelta())); | 281 ->GetValue(base::TimeDelta())); |
| 282 | 282 |
| 283 // Animation without initial value set. | 283 // Animation without initial value set. |
| 284 std::unique_ptr<ScrollOffsetAnimationCurve> curve( | 284 std::unique_ptr<ScrollOffsetAnimationCurve> curve( |
| 285 ScrollOffsetAnimationCurve::Create( | 285 ScrollOffsetAnimationCurve::Create( |
| 286 target_value, CubicBezierTimingFunction::CreatePreset( | 286 target_value, CubicBezierTimingFunction::CreatePreset( |
| 287 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 287 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 288 const int animation2_id = 2; | 288 const int animation2_id = 2; |
| 289 std::unique_ptr<Animation> animation(Animation::Create( | 289 std::unique_ptr<Animation> animation(Animation::Create( |
| 290 std::move(curve), animation2_id, 0, TargetProperty::SCROLL_OFFSET)); | 290 std::move(curve), animation2_id, 0, TargetProperty::SCROLL_OFFSET)); |
| 291 animations->AddAnimation(std::move(animation)); | 291 animations->AddAnimation(std::move(animation)); |
| 292 animations->PushPropertiesTo(animations_impl.get()); | 292 PushProperties(); |
| 293 EXPECT_VECTOR2DF_EQ(provider_initial_value, | 293 EXPECT_VECTOR2DF_EQ(provider_initial_value, |
| 294 animations_impl->GetAnimationById(animation2_id) | 294 animations_impl->GetAnimationById(animation2_id) |
| 295 ->curve() | 295 ->curve() |
| 296 ->ToScrollOffsetAnimationCurve() | 296 ->ToScrollOffsetAnimationCurve() |
| 297 ->GetValue(base::TimeDelta())); | 297 ->GetValue(base::TimeDelta())); |
| 298 } | 298 } |
| 299 | 299 |
| 300 class TestAnimationDelegateThatDestroysPlayer : public TestAnimationDelegate { | 300 class TestAnimationDelegateThatDestroysPlayer : public TestAnimationDelegate { |
| 301 public: | 301 public: |
| 302 TestAnimationDelegateThatDestroysPlayer() {} | 302 TestAnimationDelegateThatDestroysPlayer() {} |
| (...skipping 24 matching lines...) Expand all Loading... |
| 327 // passes if it doesn't crash. | 327 // passes if it doesn't crash. |
| 328 TEST_F(ElementAnimationsTest, AddedPlayerIsDestroyed) { | 328 TEST_F(ElementAnimationsTest, AddedPlayerIsDestroyed) { |
| 329 CreateTestLayer(true, false); | 329 CreateTestLayer(true, false); |
| 330 AttachTimelinePlayerLayer(); | 330 AttachTimelinePlayerLayer(); |
| 331 CreateImplTimelineAndPlayer(); | 331 CreateImplTimelineAndPlayer(); |
| 332 | 332 |
| 333 scoped_refptr<ElementAnimations> animations = element_animations(); | 333 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 334 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 334 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 335 | 335 |
| 336 TestAnimationDelegateThatDestroysPlayer delegate; | 336 TestAnimationDelegateThatDestroysPlayer delegate; |
| 337 { | |
| 338 scoped_refptr<AnimationPlayer> player = | |
| 339 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | |
| 340 delegate.setTimelineAndPlayer(timeline_, player); | |
| 341 | 337 |
| 342 timeline_->AttachPlayer(player); | 338 scoped_refptr<AnimationPlayer> player2 = |
| 343 player->AttachElement(element_id_); | 339 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 344 player->set_animation_delegate(&delegate); | 340 delegate.setTimelineAndPlayer(timeline_, player2); |
| 345 } | |
| 346 | 341 |
| 347 int animation_id = AddOpacityTransitionToElementAnimations( | 342 timeline_->AttachPlayer(player2); |
| 348 animations.get(), 1.0, 0.f, 1.f, false); | 343 player2->AttachElement(element_id_); |
| 344 player2->set_animation_delegate(&delegate); |
| 349 | 345 |
| 350 animations->PushPropertiesTo(animations_impl.get()); | 346 int animation_id = |
| 347 AddOpacityTransitionToPlayer(player2.get(), 1.0, 0.f, 1.f, false); |
| 348 |
| 349 PushProperties(); |
| 350 |
| 351 animations_impl->ActivateAnimations(); | 351 animations_impl->ActivateAnimations(); |
| 352 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 352 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
| 353 | 353 |
| 354 animations_impl->Animate(kInitialTickTime); | 354 animations_impl->Animate(kInitialTickTime); |
| 355 | 355 |
| 356 auto events = host_impl_->CreateEvents(); | 356 auto events = host_impl_->CreateEvents(); |
| 357 animations_impl->UpdateState(true, events.get()); | 357 animations_impl->UpdateState(true, events.get()); |
| 358 EXPECT_EQ(1u, events->events_.size()); | 358 EXPECT_EQ(1u, events->events_.size()); |
| 359 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); | 359 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); |
| 360 | 360 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 371 CreateImplTimelineAndPlayer(); | 371 CreateImplTimelineAndPlayer(); |
| 372 | 372 |
| 373 scoped_refptr<ElementAnimations> animations = element_animations(); | 373 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 374 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 374 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 375 | 375 |
| 376 EXPECT_FALSE(animations_impl->GetAnimation(TargetProperty::OPACITY)); | 376 EXPECT_FALSE(animations_impl->GetAnimation(TargetProperty::OPACITY)); |
| 377 | 377 |
| 378 int animation_id = | 378 int animation_id = |
| 379 AddOpacityTransitionToElementAnimations(animations.get(), 1, 0, 1, false); | 379 AddOpacityTransitionToElementAnimations(animations.get(), 1, 0, 1, false); |
| 380 | 380 |
| 381 animations->PushPropertiesTo(animations_impl.get()); | 381 PushProperties(); |
| 382 animations_impl->ActivateAnimations(); | 382 animations_impl->ActivateAnimations(); |
| 383 | 383 |
| 384 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 384 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
| 385 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 385 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 386 animations_impl->GetAnimationById(animation_id)->run_state()); | 386 animations_impl->GetAnimationById(animation_id)->run_state()); |
| 387 | 387 |
| 388 auto events = host_impl_->CreateEvents(); | 388 auto events = host_impl_->CreateEvents(); |
| 389 animations_impl->Animate(kInitialTickTime); | 389 animations_impl->Animate(kInitialTickTime); |
| 390 animations_impl->UpdateState(true, events.get()); | 390 animations_impl->UpdateState(true, events.get()); |
| 391 | 391 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 409 | 409 |
| 410 scoped_refptr<ElementAnimations> animations = element_animations(); | 410 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 411 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 411 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 412 | 412 |
| 413 int animation_id = | 413 int animation_id = |
| 414 AddOpacityTransitionToElementAnimations(animations.get(), 1, 0, 1, false); | 414 AddOpacityTransitionToElementAnimations(animations.get(), 1, 0, 1, false); |
| 415 | 415 |
| 416 const TimeTicks start_time = TicksFromSecondsF(123); | 416 const TimeTicks start_time = TicksFromSecondsF(123); |
| 417 animations->GetAnimation(TargetProperty::OPACITY)->set_start_time(start_time); | 417 animations->GetAnimation(TargetProperty::OPACITY)->set_start_time(start_time); |
| 418 | 418 |
| 419 animations->PushPropertiesTo(animations_impl.get()); | 419 PushProperties(); |
| 420 animations_impl->ActivateAnimations(); | 420 animations_impl->ActivateAnimations(); |
| 421 | 421 |
| 422 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 422 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
| 423 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 423 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 424 animations_impl->GetAnimationById(animation_id)->run_state()); | 424 animations_impl->GetAnimationById(animation_id)->run_state()); |
| 425 | 425 |
| 426 auto events = host_impl_->CreateEvents(); | 426 auto events = host_impl_->CreateEvents(); |
| 427 animations_impl->Animate(kInitialTickTime); | 427 animations_impl->Animate(kInitialTickTime); |
| 428 animations_impl->UpdateState(true, events.get()); | 428 animations_impl->UpdateState(true, events.get()); |
| 429 | 429 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 EXPECT_EQ(1u, host_impl->all_element_animations_for_testing().size()); | 463 EXPECT_EQ(1u, host_impl->all_element_animations_for_testing().size()); |
| 464 | 464 |
| 465 // Initially, both animationss should be inactive. | 465 // Initially, both animationss should be inactive. |
| 466 EXPECT_EQ(0u, host->active_element_animations_for_testing().size()); | 466 EXPECT_EQ(0u, host->active_element_animations_for_testing().size()); |
| 467 EXPECT_EQ(0u, host_impl->active_element_animations_for_testing().size()); | 467 EXPECT_EQ(0u, host_impl->active_element_animations_for_testing().size()); |
| 468 | 468 |
| 469 AddOpacityTransitionToElementAnimations(animations.get(), 1, 0, 1, false); | 469 AddOpacityTransitionToElementAnimations(animations.get(), 1, 0, 1, false); |
| 470 // The main thread animations should now be active. | 470 // The main thread animations should now be active. |
| 471 EXPECT_EQ(1u, host->active_element_animations_for_testing().size()); | 471 EXPECT_EQ(1u, host->active_element_animations_for_testing().size()); |
| 472 | 472 |
| 473 animations->PushPropertiesTo(animations_impl.get()); | 473 PushProperties(); |
| 474 animations_impl->ActivateAnimations(); | 474 animations_impl->ActivateAnimations(); |
| 475 // Both animationss should now be active. | 475 // Both animationss should now be active. |
| 476 EXPECT_EQ(1u, host->active_element_animations_for_testing().size()); | 476 EXPECT_EQ(1u, host->active_element_animations_for_testing().size()); |
| 477 EXPECT_EQ(1u, host_impl->active_element_animations_for_testing().size()); | 477 EXPECT_EQ(1u, host_impl->active_element_animations_for_testing().size()); |
| 478 | 478 |
| 479 animations_impl->Animate(kInitialTickTime); | 479 animations_impl->Animate(kInitialTickTime); |
| 480 animations_impl->UpdateState(true, events.get()); | 480 animations_impl->UpdateState(true, events.get()); |
| 481 EXPECT_EQ(1u, events->events_.size()); | 481 EXPECT_EQ(1u, events->events_.size()); |
| 482 animations->NotifyAnimationStarted(events->events_[0]); | 482 animations->NotifyAnimationStarted(events->events_[0]); |
| 483 | 483 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 509 EXPECT_EQ(1u, events->events_.size()); | 509 EXPECT_EQ(1u, events->events_.size()); |
| 510 animations->NotifyAnimationFinished(events->events_[0]); | 510 animations->NotifyAnimationFinished(events->events_[0]); |
| 511 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); | 511 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); |
| 512 animations->UpdateState(true, nullptr); | 512 animations->UpdateState(true, nullptr); |
| 513 | 513 |
| 514 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 514 EXPECT_EQ(Animation::WAITING_FOR_DELETION, |
| 515 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); | 515 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 516 // The main thread animations should have de-activated. | 516 // The main thread animations should have de-activated. |
| 517 EXPECT_EQ(0u, host->active_element_animations_for_testing().size()); | 517 EXPECT_EQ(0u, host->active_element_animations_for_testing().size()); |
| 518 | 518 |
| 519 animations->PushPropertiesTo(animations_impl.get()); | 519 PushProperties(); |
| 520 animations_impl->ActivateAnimations(); | 520 animations_impl->ActivateAnimations(); |
| 521 EXPECT_FALSE(animations->HasAnyAnimation()); | 521 EXPECT_FALSE(animations->HasAnyAnimation()); |
| 522 EXPECT_FALSE(animations_impl->HasAnyAnimation()); | 522 EXPECT_FALSE(animations_impl->HasAnyAnimation()); |
| 523 EXPECT_EQ(0u, host->active_element_animations_for_testing().size()); | 523 EXPECT_EQ(0u, host->active_element_animations_for_testing().size()); |
| 524 EXPECT_EQ(0u, host_impl->active_element_animations_for_testing().size()); | 524 EXPECT_EQ(0u, host_impl->active_element_animations_for_testing().size()); |
| 525 } | 525 } |
| 526 | 526 |
| 527 TEST_F(ElementAnimationsTest, SyncPause) { | 527 TEST_F(ElementAnimationsTest, SyncPause) { |
| 528 CreateTestLayer(true, false); | 528 CreateTestLayer(true, false); |
| 529 AttachTimelinePlayerLayer(); | 529 AttachTimelinePlayerLayer(); |
| 530 CreateImplTimelineAndPlayer(); | 530 CreateImplTimelineAndPlayer(); |
| 531 | 531 |
| 532 scoped_refptr<ElementAnimations> animations = element_animations(); | 532 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 533 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 533 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 534 | 534 |
| 535 EXPECT_FALSE(animations_impl->GetAnimation(TargetProperty::OPACITY)); | 535 EXPECT_FALSE(animations_impl->GetAnimation(TargetProperty::OPACITY)); |
| 536 | 536 |
| 537 // Two steps, three ranges: [0-1) -> 0.2, [1-2) -> 0.3, [2-3] -> 0.4. | 537 // Two steps, three ranges: [0-1) -> 0.2, [1-2) -> 0.3, [2-3] -> 0.4. |
| 538 const double duration = 3.0; | 538 const double duration = 3.0; |
| 539 const int animation_id = AddOpacityStepsToElementAnimations( | 539 const int animation_id = AddOpacityStepsToElementAnimations( |
| 540 animations.get(), duration, 0.2f, 0.4f, 2); | 540 animations.get(), duration, 0.2f, 0.4f, 2); |
| 541 | 541 |
| 542 // Set start offset to be at the beginning of the second range. | 542 // Set start offset to be at the beginning of the second range. |
| 543 animations->GetAnimationById(animation_id) | 543 animations->GetAnimationById(animation_id) |
| 544 ->set_time_offset(TimeDelta::FromSecondsD(1.01)); | 544 ->set_time_offset(TimeDelta::FromSecondsD(1.01)); |
| 545 | 545 |
| 546 animations->PushPropertiesTo(animations_impl.get()); | 546 PushProperties(); |
| 547 animations_impl->ActivateAnimations(); | 547 animations_impl->ActivateAnimations(); |
| 548 | 548 |
| 549 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 549 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
| 550 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 550 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 551 animations_impl->GetAnimationById(animation_id)->run_state()); | 551 animations_impl->GetAnimationById(animation_id)->run_state()); |
| 552 | 552 |
| 553 TimeTicks time = kInitialTickTime; | 553 TimeTicks time = kInitialTickTime; |
| 554 | 554 |
| 555 // Start the animations on each animations. | 555 // Start the animations on each animations. |
| 556 auto events = host_impl_->CreateEvents(); | 556 auto events = host_impl_->CreateEvents(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 576 EXPECT_EQ(kInitialTickTime, | 576 EXPECT_EQ(kInitialTickTime, |
| 577 animations_impl->GetAnimationById(animation_id)->start_time()); | 577 animations_impl->GetAnimationById(animation_id)->start_time()); |
| 578 | 578 |
| 579 // Pause the animation at the middle of the second range so the offset | 579 // Pause the animation at the middle of the second range so the offset |
| 580 // delays animation until the middle of the third range. | 580 // delays animation until the middle of the third range. |
| 581 animations->PauseAnimation(animation_id, TimeDelta::FromSecondsD(1.5)); | 581 animations->PauseAnimation(animation_id, TimeDelta::FromSecondsD(1.5)); |
| 582 EXPECT_EQ(Animation::PAUSED, | 582 EXPECT_EQ(Animation::PAUSED, |
| 583 animations->GetAnimationById(animation_id)->run_state()); | 583 animations->GetAnimationById(animation_id)->run_state()); |
| 584 | 584 |
| 585 // The pause run state change should make it to the impl thread animations. | 585 // The pause run state change should make it to the impl thread animations. |
| 586 animations->PushPropertiesTo(animations_impl.get()); | 586 PushProperties(); |
| 587 animations_impl->ActivateAnimations(); | 587 animations_impl->ActivateAnimations(); |
| 588 | 588 |
| 589 // Advance time so it stays within the first range. | 589 // Advance time so it stays within the first range. |
| 590 time += TimeDelta::FromMilliseconds(10); | 590 time += TimeDelta::FromMilliseconds(10); |
| 591 animations->Animate(time); | 591 animations->Animate(time); |
| 592 animations_impl->Animate(time); | 592 animations_impl->Animate(time); |
| 593 | 593 |
| 594 EXPECT_EQ(Animation::PAUSED, | 594 EXPECT_EQ(Animation::PAUSED, |
| 595 animations_impl->GetAnimationById(animation_id)->run_state()); | 595 animations_impl->GetAnimationById(animation_id)->run_state()); |
| 596 | 596 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 608 scoped_refptr<ElementAnimations> animations = element_animations(); | 608 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 609 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 609 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 610 | 610 |
| 611 auto events = host_impl_->CreateEvents(); | 611 auto events = host_impl_->CreateEvents(); |
| 612 | 612 |
| 613 EXPECT_FALSE(animations_impl->GetAnimation(TargetProperty::OPACITY)); | 613 EXPECT_FALSE(animations_impl->GetAnimation(TargetProperty::OPACITY)); |
| 614 | 614 |
| 615 int animation_id = | 615 int animation_id = |
| 616 AddOpacityTransitionToElementAnimations(animations.get(), 1, 0, 1, false); | 616 AddOpacityTransitionToElementAnimations(animations.get(), 1, 0, 1, false); |
| 617 | 617 |
| 618 animations->PushPropertiesTo(animations_impl.get()); | 618 PushProperties(); |
| 619 animations_impl->ActivateAnimations(); | 619 animations_impl->ActivateAnimations(); |
| 620 | 620 |
| 621 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 621 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
| 622 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 622 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 623 animations_impl->GetAnimationById(animation_id)->run_state()); | 623 animations_impl->GetAnimationById(animation_id)->run_state()); |
| 624 | 624 |
| 625 events = host_impl_->CreateEvents(); | 625 events = host_impl_->CreateEvents(); |
| 626 animations_impl->Animate(kInitialTickTime); | 626 animations_impl->Animate(kInitialTickTime); |
| 627 animations_impl->UpdateState(true, events.get()); | 627 animations_impl->UpdateState(true, events.get()); |
| 628 EXPECT_EQ(1u, events->events_.size()); | 628 EXPECT_EQ(1u, events->events_.size()); |
| 629 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); | 629 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); |
| 630 | 630 |
| 631 // Notify main thread animations that the animation has started. | 631 // Notify main thread animations that the animation has started. |
| 632 animations->NotifyAnimationStarted(events->events_[0]); | 632 animations->NotifyAnimationStarted(events->events_[0]); |
| 633 | 633 |
| 634 // Complete animation on impl thread. | 634 // Complete animation on impl thread. |
| 635 events = host_impl_->CreateEvents(); | 635 events = host_impl_->CreateEvents(); |
| 636 animations_impl->Animate(kInitialTickTime + TimeDelta::FromSeconds(1)); | 636 animations_impl->Animate(kInitialTickTime + TimeDelta::FromSeconds(1)); |
| 637 animations_impl->UpdateState(true, events.get()); | 637 animations_impl->UpdateState(true, events.get()); |
| 638 EXPECT_EQ(1u, events->events_.size()); | 638 EXPECT_EQ(1u, events->events_.size()); |
| 639 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); | 639 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); |
| 640 | 640 |
| 641 animations->NotifyAnimationFinished(events->events_[0]); | 641 animations->NotifyAnimationFinished(events->events_[0]); |
| 642 | 642 |
| 643 animations->Animate(kInitialTickTime + TimeDelta::FromSeconds(2)); | 643 animations->Animate(kInitialTickTime + TimeDelta::FromSeconds(2)); |
| 644 animations->UpdateState(true, nullptr); | 644 animations->UpdateState(true, nullptr); |
| 645 | 645 |
| 646 animations->PushPropertiesTo(animations_impl.get()); | 646 PushProperties(); |
| 647 animations_impl->ActivateAnimations(); | 647 animations_impl->ActivateAnimations(); |
| 648 EXPECT_FALSE(animations->GetAnimationById(animation_id)); | 648 EXPECT_FALSE(animations->GetAnimationById(animation_id)); |
| 649 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); | 649 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); |
| 650 } | 650 } |
| 651 | 651 |
| 652 // Ensure that a finished animation is eventually deleted by both the | 652 // Ensure that a finished animation is eventually deleted by both the |
| 653 // main-thread and the impl-thread animationss. | 653 // main-thread and the impl-thread animationss. |
| 654 TEST_F(ElementAnimationsTest, AnimationsAreDeleted) { | 654 TEST_F(ElementAnimationsTest, AnimationsAreDeleted) { |
| 655 CreateTestLayer(true, false); | 655 CreateTestLayer(true, false); |
| 656 AttachTimelinePlayerLayer(); | 656 AttachTimelinePlayerLayer(); |
| 657 CreateImplTimelineAndPlayer(); | 657 CreateImplTimelineAndPlayer(); |
| 658 | 658 |
| 659 scoped_refptr<ElementAnimations> animations = element_animations(); | 659 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 660 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 660 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 661 | 661 |
| 662 auto events = host_impl_->CreateEvents(); | 662 auto events = host_impl_->CreateEvents(); |
| 663 | 663 |
| 664 AddOpacityTransitionToElementAnimations(animations.get(), 1.0, 0.0f, 1.0f, | 664 AddOpacityTransitionToElementAnimations(animations.get(), 1.0, 0.0f, 1.0f, |
| 665 false); | 665 false); |
| 666 animations->Animate(kInitialTickTime); | 666 animations->Animate(kInitialTickTime); |
| 667 animations->UpdateState(true, nullptr); | 667 animations->UpdateState(true, nullptr); |
| 668 EXPECT_TRUE(animations->needs_push_properties()); | 668 EXPECT_TRUE(animations->needs_push_properties()); |
| 669 animations->PushPropertiesTo(animations_impl.get()); | 669 |
| 670 PushProperties(); |
| 671 EXPECT_FALSE(animations->needs_push_properties()); |
| 672 |
| 673 EXPECT_FALSE(host_->needs_push_properties()); |
| 674 EXPECT_FALSE(host_impl_->needs_push_properties()); |
| 675 |
| 670 animations_impl->ActivateAnimations(); | 676 animations_impl->ActivateAnimations(); |
| 671 | 677 |
| 672 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 678 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 673 animations_impl->UpdateState(true, events.get()); | 679 animations_impl->UpdateState(true, events.get()); |
| 674 | 680 |
| 675 // There should be a STARTED event for the animation. | 681 // There should be a STARTED event for the animation. |
| 676 EXPECT_EQ(1u, events->events_.size()); | 682 EXPECT_EQ(1u, events->events_.size()); |
| 677 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); | 683 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); |
| 678 animations->NotifyAnimationStarted(events->events_[0]); | 684 animations->NotifyAnimationStarted(events->events_[0]); |
| 679 | 685 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 697 // Neither animations should have deleted the animation yet. | 703 // Neither animations should have deleted the animation yet. |
| 698 EXPECT_TRUE(animations->GetAnimation(TargetProperty::OPACITY)); | 704 EXPECT_TRUE(animations->GetAnimation(TargetProperty::OPACITY)); |
| 699 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::OPACITY)); | 705 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::OPACITY)); |
| 700 | 706 |
| 701 animations->NotifyAnimationFinished(events->events_[0]); | 707 animations->NotifyAnimationFinished(events->events_[0]); |
| 702 | 708 |
| 703 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); | 709 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
| 704 animations->UpdateState(true, nullptr); | 710 animations->UpdateState(true, nullptr); |
| 705 EXPECT_TRUE(host_->needs_push_properties()); | 711 EXPECT_TRUE(host_->needs_push_properties()); |
| 706 | 712 |
| 707 animations->PushPropertiesTo(animations_impl.get()); | 713 PushProperties(); |
| 708 | 714 |
| 709 // Both animationss should now have deleted the animation. The impl animations | 715 // Both animationss should now have deleted the animation. The impl animations |
| 710 // should have deleted the animation even though activation has not occurred, | 716 // should have deleted the animation even though activation has not occurred, |
| 711 // since the animation was already waiting for deletion when | 717 // since the animation was already waiting for deletion when |
| 712 // PushPropertiesTo was called. | 718 // PushPropertiesTo was called. |
| 713 EXPECT_FALSE(animations->HasAnyAnimation()); | 719 EXPECT_FALSE(animations->HasAnyAnimation()); |
| 714 EXPECT_FALSE(animations_impl->HasAnyAnimation()); | 720 EXPECT_FALSE(animations_impl->HasAnyAnimation()); |
| 715 } | 721 } |
| 716 | 722 |
| 717 // Tests that transitioning opacity from 0 to 1 works as expected. | 723 // Tests that transitioning opacity from 0 to 1 works as expected. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 ScrollOffsetAnimationCurve::Create( | 837 ScrollOffsetAnimationCurve::Create( |
| 832 target_value, CubicBezierTimingFunction::CreatePreset( | 838 target_value, CubicBezierTimingFunction::CreatePreset( |
| 833 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 839 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 834 | 840 |
| 835 std::unique_ptr<Animation> animation( | 841 std::unique_ptr<Animation> animation( |
| 836 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); | 842 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); |
| 837 animation->set_needs_synchronized_start_time(true); | 843 animation->set_needs_synchronized_start_time(true); |
| 838 animations->AddAnimation(std::move(animation)); | 844 animations->AddAnimation(std::move(animation)); |
| 839 | 845 |
| 840 client_impl_.SetScrollOffsetForAnimation(initial_value); | 846 client_impl_.SetScrollOffsetForAnimation(initial_value); |
| 841 animations->PushPropertiesTo(animations_impl.get()); | 847 PushProperties(); |
| 842 animations_impl->ActivateAnimations(); | 848 animations_impl->ActivateAnimations(); |
| 843 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)); | 849 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)); |
| 844 TimeDelta duration = | 850 TimeDelta duration = |
| 845 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) | 851 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| 846 ->curve() | 852 ->curve() |
| 847 ->Duration(); | 853 ->Duration(); |
| 848 EXPECT_EQ(duration, animations->GetAnimation(TargetProperty::SCROLL_OFFSET) | 854 EXPECT_EQ(duration, animations->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| 849 ->curve() | 855 ->curve() |
| 850 ->Duration()); | 856 ->Duration()); |
| 851 | 857 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 ScrollOffsetAnimationCurve::Create( | 1033 ScrollOffsetAnimationCurve::Create( |
| 1028 target_value, CubicBezierTimingFunction::CreatePreset( | 1034 target_value, CubicBezierTimingFunction::CreatePreset( |
| 1029 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 1035 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 1030 | 1036 |
| 1031 std::unique_ptr<Animation> animation( | 1037 std::unique_ptr<Animation> animation( |
| 1032 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); | 1038 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); |
| 1033 animation->set_needs_synchronized_start_time(true); | 1039 animation->set_needs_synchronized_start_time(true); |
| 1034 animations->AddAnimation(std::move(animation)); | 1040 animations->AddAnimation(std::move(animation)); |
| 1035 | 1041 |
| 1036 client_.SetScrollOffsetForAnimation(initial_value); | 1042 client_.SetScrollOffsetForAnimation(initial_value); |
| 1037 animations->PushPropertiesTo(animations_impl.get()); | 1043 PushProperties(); |
| 1038 animations_impl->ActivateAnimations(); | 1044 animations_impl->ActivateAnimations(); |
| 1039 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)); | 1045 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)); |
| 1040 TimeDelta duration = | 1046 TimeDelta duration = |
| 1041 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) | 1047 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| 1042 ->curve() | 1048 ->curve() |
| 1043 ->Duration(); | 1049 ->Duration(); |
| 1044 EXPECT_EQ(duration, animations->GetAnimation(TargetProperty::SCROLL_OFFSET) | 1050 EXPECT_EQ(duration, animations->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| 1045 ->curve() | 1051 ->curve() |
| 1046 ->Duration()); | 1052 ->Duration()); |
| 1047 | 1053 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 std::unique_ptr<ScrollOffsetAnimationCurve> curve( | 1121 std::unique_ptr<ScrollOffsetAnimationCurve> curve( |
| 1116 ScrollOffsetAnimationCurve::Create( | 1122 ScrollOffsetAnimationCurve::Create( |
| 1117 target_value, CubicBezierTimingFunction::CreatePreset( | 1123 target_value, CubicBezierTimingFunction::CreatePreset( |
| 1118 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 1124 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 1119 | 1125 |
| 1120 int animation_id = 1; | 1126 int animation_id = 1; |
| 1121 std::unique_ptr<Animation> animation(Animation::Create( | 1127 std::unique_ptr<Animation> animation(Animation::Create( |
| 1122 std::move(curve), animation_id, 0, TargetProperty::SCROLL_OFFSET)); | 1128 std::move(curve), animation_id, 0, TargetProperty::SCROLL_OFFSET)); |
| 1123 animation->set_needs_synchronized_start_time(true); | 1129 animation->set_needs_synchronized_start_time(true); |
| 1124 animations->AddAnimation(std::move(animation)); | 1130 animations->AddAnimation(std::move(animation)); |
| 1125 animations->PushPropertiesTo(animations_impl.get()); | 1131 PushProperties(); |
| 1126 animations_impl->ActivateAnimations(); | 1132 animations_impl->ActivateAnimations(); |
| 1127 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1133 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1128 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1134 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1129 | 1135 |
| 1130 animations->RemoveAnimation(animation_id); | 1136 animations->RemoveAnimation(animation_id); |
| 1131 EXPECT_TRUE(animations->scroll_offset_animation_was_interrupted()); | 1137 EXPECT_TRUE(animations->scroll_offset_animation_was_interrupted()); |
| 1132 | 1138 |
| 1133 animations->PushPropertiesTo(animations_impl.get()); | 1139 PushProperties(); |
| 1134 EXPECT_TRUE(animations_impl->scroll_offset_animation_was_interrupted()); | 1140 EXPECT_TRUE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1135 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1141 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1136 | 1142 |
| 1137 animations_impl->ActivateAnimations(); | 1143 animations_impl->ActivateAnimations(); |
| 1138 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1144 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1139 | 1145 |
| 1140 // Now, test the 2-argument version of RemoveAnimation. | 1146 // Now, test the 2-argument version of RemoveAnimation. |
| 1141 curve = ScrollOffsetAnimationCurve::Create( | 1147 curve = ScrollOffsetAnimationCurve::Create( |
| 1142 target_value, CubicBezierTimingFunction::CreatePreset( | 1148 target_value, CubicBezierTimingFunction::CreatePreset( |
| 1143 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)); | 1149 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)); |
| 1144 animation = Animation::Create(std::move(curve), animation_id, 0, | 1150 animation = Animation::Create(std::move(curve), animation_id, 0, |
| 1145 TargetProperty::SCROLL_OFFSET); | 1151 TargetProperty::SCROLL_OFFSET); |
| 1146 animation->set_needs_synchronized_start_time(true); | 1152 animation->set_needs_synchronized_start_time(true); |
| 1147 animations->AddAnimation(std::move(animation)); | 1153 animations->AddAnimation(std::move(animation)); |
| 1148 animations->PushPropertiesTo(animations_impl.get()); | 1154 PushProperties(); |
| 1149 animations_impl->ActivateAnimations(); | 1155 animations_impl->ActivateAnimations(); |
| 1150 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1156 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1151 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1157 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1152 | 1158 |
| 1153 animations->RemoveAnimation(animation_id); | 1159 animations->RemoveAnimation(animation_id); |
| 1154 EXPECT_TRUE(animations->scroll_offset_animation_was_interrupted()); | 1160 EXPECT_TRUE(animations->scroll_offset_animation_was_interrupted()); |
| 1155 | 1161 |
| 1156 animations->PushPropertiesTo(animations_impl.get()); | 1162 PushProperties(); |
| 1157 EXPECT_TRUE(animations_impl->scroll_offset_animation_was_interrupted()); | 1163 EXPECT_TRUE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1158 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1164 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1159 | 1165 |
| 1160 animations_impl->ActivateAnimations(); | 1166 animations_impl->ActivateAnimations(); |
| 1161 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1167 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1162 | 1168 |
| 1163 // Check that removing non-scroll-offset animations does not cause | 1169 // Check that removing non-scroll-offset animations does not cause |
| 1164 // scroll_offset_animation_was_interrupted() to get set. | 1170 // scroll_offset_animation_was_interrupted() to get set. |
| 1165 animation_id = | 1171 animation_id = |
| 1166 AddAnimatedTransformToElementAnimations(animations.get(), 1.0, 1, 2); | 1172 AddAnimatedTransformToElementAnimations(animations.get(), 1.0, 1, 2); |
| 1167 animations->PushPropertiesTo(animations_impl.get()); | 1173 PushProperties(); |
| 1168 animations_impl->ActivateAnimations(); | 1174 animations_impl->ActivateAnimations(); |
| 1169 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1175 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1170 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1176 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1171 | 1177 |
| 1172 animations->RemoveAnimation(animation_id); | 1178 animations->RemoveAnimation(animation_id); |
| 1173 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1179 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1174 | 1180 |
| 1175 animations->PushPropertiesTo(animations_impl.get()); | 1181 PushProperties(); |
| 1176 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1182 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1177 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1183 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1178 | 1184 |
| 1179 animations_impl->ActivateAnimations(); | 1185 animations_impl->ActivateAnimations(); |
| 1180 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1186 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1181 | 1187 |
| 1182 animation_id = | 1188 animation_id = |
| 1183 AddAnimatedFilterToElementAnimations(animations.get(), 1.0, 0.1f, 0.2f); | 1189 AddAnimatedFilterToElementAnimations(animations.get(), 1.0, 0.1f, 0.2f); |
| 1184 animations->PushPropertiesTo(animations_impl.get()); | 1190 PushProperties(); |
| 1185 animations_impl->ActivateAnimations(); | 1191 animations_impl->ActivateAnimations(); |
| 1186 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1192 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1187 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1193 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1188 | 1194 |
| 1189 animations->RemoveAnimation(animation_id); | 1195 animations->RemoveAnimation(animation_id); |
| 1190 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1196 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1191 | 1197 |
| 1192 animations->PushPropertiesTo(animations_impl.get()); | 1198 PushProperties(); |
| 1193 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1199 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1194 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); | 1200 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); |
| 1195 | 1201 |
| 1196 animations_impl->ActivateAnimations(); | 1202 animations_impl->ActivateAnimations(); |
| 1197 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); | 1203 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); |
| 1198 } | 1204 } |
| 1199 | 1205 |
| 1200 // Tests that impl-only animations lead to start and finished notifications | 1206 // Tests that impl-only animations lead to start and finished notifications |
| 1201 // on the impl thread animations's animation delegate. | 1207 // on the impl thread animations's animation delegate. |
| 1202 TEST_F(ElementAnimationsTest, | 1208 TEST_F(ElementAnimationsTest, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 | 1264 |
| 1259 TestAnimationDelegate delegate; | 1265 TestAnimationDelegate delegate; |
| 1260 player_->set_animation_delegate(&delegate); | 1266 player_->set_animation_delegate(&delegate); |
| 1261 | 1267 |
| 1262 int animation_id = | 1268 int animation_id = |
| 1263 AddOpacityTransitionToElementAnimations(animations.get(), 1, 0, 1, false); | 1269 AddOpacityTransitionToElementAnimations(animations.get(), 1, 0, 1, false); |
| 1264 | 1270 |
| 1265 const TimeTicks start_time = TicksFromSecondsF(123); | 1271 const TimeTicks start_time = TicksFromSecondsF(123); |
| 1266 animations->GetAnimation(TargetProperty::OPACITY)->set_start_time(start_time); | 1272 animations->GetAnimation(TargetProperty::OPACITY)->set_start_time(start_time); |
| 1267 | 1273 |
| 1268 animations->PushPropertiesTo(animations_impl.get()); | 1274 PushProperties(); |
| 1269 animations_impl->ActivateAnimations(); | 1275 animations_impl->ActivateAnimations(); |
| 1270 | 1276 |
| 1271 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 1277 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
| 1272 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1278 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 1273 animations_impl->GetAnimationById(animation_id)->run_state()); | 1279 animations_impl->GetAnimationById(animation_id)->run_state()); |
| 1274 | 1280 |
| 1275 auto events = host_impl_->CreateEvents(); | 1281 auto events = host_impl_->CreateEvents(); |
| 1276 animations_impl->Animate(kInitialTickTime); | 1282 animations_impl->Animate(kInitialTickTime); |
| 1277 animations_impl->UpdateState(true, events.get()); | 1283 animations_impl->UpdateState(true, events.get()); |
| 1278 | 1284 |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 | 1688 |
| 1683 animations->Animate(kInitialTickTime); | 1689 animations->Animate(kInitialTickTime); |
| 1684 animations->UpdateState(true, events.get()); | 1690 animations->UpdateState(true, events.get()); |
| 1685 EXPECT_TRUE(animations->HasActiveAnimation()); | 1691 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 1686 Animation* active_animation = | 1692 Animation* active_animation = |
| 1687 animations->GetAnimation(TargetProperty::OPACITY); | 1693 animations->GetAnimation(TargetProperty::OPACITY); |
| 1688 EXPECT_TRUE(active_animation); | 1694 EXPECT_TRUE(active_animation); |
| 1689 EXPECT_TRUE(active_animation->needs_synchronized_start_time()); | 1695 EXPECT_TRUE(active_animation->needs_synchronized_start_time()); |
| 1690 | 1696 |
| 1691 EXPECT_TRUE(animations->needs_push_properties()); | 1697 EXPECT_TRUE(animations->needs_push_properties()); |
| 1692 animations->PushPropertiesTo(animations_impl.get()); | 1698 PushProperties(); |
| 1693 animations_impl->ActivateAnimations(); | 1699 animations_impl->ActivateAnimations(); |
| 1694 | 1700 |
| 1695 active_animation = animations_impl->GetAnimation(TargetProperty::OPACITY); | 1701 active_animation = animations_impl->GetAnimation(TargetProperty::OPACITY); |
| 1696 EXPECT_TRUE(active_animation); | 1702 EXPECT_TRUE(active_animation); |
| 1697 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1703 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 1698 active_animation->run_state()); | 1704 active_animation->run_state()); |
| 1699 } | 1705 } |
| 1700 | 1706 |
| 1701 // Tests that skipping a call to UpdateState works as expected. | 1707 // Tests that skipping a call to UpdateState works as expected. |
| 1702 TEST_F(ElementAnimationsTest, SkipUpdateState) { | 1708 TEST_F(ElementAnimationsTest, SkipUpdateState) { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1935 | 1941 |
| 1936 // An animation aborted on the main thread should get deleted on both threads. | 1942 // An animation aborted on the main thread should get deleted on both threads. |
| 1937 TEST_F(ElementAnimationsTest, MainThreadAbortedAnimationGetsDeleted) { | 1943 TEST_F(ElementAnimationsTest, MainThreadAbortedAnimationGetsDeleted) { |
| 1938 CreateTestLayer(true, false); | 1944 CreateTestLayer(true, false); |
| 1939 AttachTimelinePlayerLayer(); | 1945 AttachTimelinePlayerLayer(); |
| 1940 CreateImplTimelineAndPlayer(); | 1946 CreateImplTimelineAndPlayer(); |
| 1941 | 1947 |
| 1942 scoped_refptr<ElementAnimations> animations = element_animations(); | 1948 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 1943 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 1949 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 1944 | 1950 |
| 1945 int animation_id = AddOpacityTransitionToElementAnimations( | 1951 int animation_id = |
| 1946 animations.get(), 1.0, 0.f, 1.f, false); | 1952 AddOpacityTransitionToPlayer(player_.get(), 1.0, 0.f, 1.f, false); |
| 1953 EXPECT_TRUE(host_->needs_push_properties()); |
| 1947 | 1954 |
| 1948 animations->PushPropertiesTo(animations_impl.get()); | 1955 PushProperties(); |
| 1956 |
| 1949 animations_impl->ActivateAnimations(); | 1957 animations_impl->ActivateAnimations(); |
| 1958 |
| 1950 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 1959 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
| 1960 EXPECT_FALSE(host_->needs_push_properties()); |
| 1951 | 1961 |
| 1952 animations->AbortAnimations(TargetProperty::OPACITY); | 1962 animations->AbortAnimations(TargetProperty::OPACITY); |
| 1953 EXPECT_EQ(Animation::ABORTED, | 1963 EXPECT_EQ(Animation::ABORTED, |
| 1954 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1964 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1955 EXPECT_FALSE(host_->needs_push_properties()); | 1965 EXPECT_TRUE(host_->needs_push_properties()); |
| 1956 EXPECT_FALSE(host_impl_->needs_push_properties()); | |
| 1957 | 1966 |
| 1958 animations->Animate(kInitialTickTime); | 1967 animations->Animate(kInitialTickTime); |
| 1959 animations->UpdateState(true, nullptr); | 1968 animations->UpdateState(true, nullptr); |
| 1960 EXPECT_FALSE(host_->needs_push_properties()); | |
| 1961 EXPECT_EQ(Animation::ABORTED, | 1969 EXPECT_EQ(Animation::ABORTED, |
| 1962 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1970 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1963 | 1971 |
| 1964 EXPECT_TRUE(animations->needs_push_properties()); | 1972 EXPECT_TRUE(animations->needs_push_properties()); |
| 1965 animations->PushPropertiesTo(animations_impl.get()); | 1973 EXPECT_TRUE(player_->needs_push_properties()); |
| 1974 EXPECT_TRUE(host_->needs_push_properties()); |
| 1975 |
| 1976 PushProperties(); |
| 1977 EXPECT_FALSE(host_->needs_push_properties()); |
| 1978 EXPECT_FALSE(player_->needs_push_properties()); |
| 1979 |
| 1966 EXPECT_FALSE(animations->GetAnimationById(animation_id)); | 1980 EXPECT_FALSE(animations->GetAnimationById(animation_id)); |
| 1967 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); | 1981 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); |
| 1968 } | 1982 } |
| 1969 | 1983 |
| 1970 // An animation aborted on the impl thread should get deleted on both threads. | 1984 // An animation aborted on the impl thread should get deleted on both threads. |
| 1971 TEST_F(ElementAnimationsTest, ImplThreadAbortedAnimationGetsDeleted) { | 1985 TEST_F(ElementAnimationsTest, ImplThreadAbortedAnimationGetsDeleted) { |
| 1972 CreateTestLayer(true, false); | 1986 CreateTestLayer(true, false); |
| 1973 AttachTimelinePlayerLayer(); | 1987 AttachTimelinePlayerLayer(); |
| 1974 CreateImplTimelineAndPlayer(); | 1988 CreateImplTimelineAndPlayer(); |
| 1975 | 1989 |
| 1976 scoped_refptr<ElementAnimations> animations = element_animations(); | 1990 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 1977 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 1991 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 1978 | 1992 |
| 1979 TestAnimationDelegate delegate; | 1993 TestAnimationDelegate delegate; |
| 1980 player_->set_animation_delegate(&delegate); | 1994 player_->set_animation_delegate(&delegate); |
| 1981 | 1995 |
| 1982 int animation_id = AddOpacityTransitionToElementAnimations( | 1996 int animation_id = AddOpacityTransitionToElementAnimations( |
| 1983 animations.get(), 1.0, 0.f, 1.f, false); | 1997 animations.get(), 1.0, 0.f, 1.f, false); |
| 1984 | 1998 |
| 1985 animations->PushPropertiesTo(animations_impl.get()); | 1999 PushProperties(); |
| 2000 EXPECT_FALSE(host_->needs_push_properties()); |
| 2001 |
| 1986 animations_impl->ActivateAnimations(); | 2002 animations_impl->ActivateAnimations(); |
| 1987 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 2003 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
| 1988 | 2004 |
| 1989 animations_impl->AbortAnimations(TargetProperty::OPACITY); | 2005 animations_impl->AbortAnimations(TargetProperty::OPACITY); |
| 1990 EXPECT_EQ( | 2006 EXPECT_EQ( |
| 1991 Animation::ABORTED, | 2007 Animation::ABORTED, |
| 1992 animations_impl->GetAnimation(TargetProperty::OPACITY)->run_state()); | 2008 animations_impl->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1993 EXPECT_FALSE(host_->needs_push_properties()); | 2009 EXPECT_TRUE(host_impl_->needs_push_properties()); |
| 1994 EXPECT_FALSE(host_impl_->needs_push_properties()); | 2010 EXPECT_TRUE(player_impl_->needs_push_properties()); |
| 1995 | 2011 |
| 1996 auto events = host_impl_->CreateEvents(); | 2012 auto events = host_impl_->CreateEvents(); |
| 1997 animations_impl->Animate(kInitialTickTime); | 2013 animations_impl->Animate(kInitialTickTime); |
| 1998 animations_impl->UpdateState(true, events.get()); | 2014 animations_impl->UpdateState(true, events.get()); |
| 1999 EXPECT_TRUE(host_impl_->needs_push_properties()); | 2015 EXPECT_TRUE(host_impl_->needs_push_properties()); |
| 2000 EXPECT_EQ(1u, events->events_.size()); | 2016 EXPECT_EQ(1u, events->events_.size()); |
| 2001 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[0].type); | 2017 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[0].type); |
| 2002 EXPECT_EQ( | 2018 EXPECT_EQ( |
| 2003 Animation::WAITING_FOR_DELETION, | 2019 Animation::WAITING_FOR_DELETION, |
| 2004 animations_impl->GetAnimation(TargetProperty::OPACITY)->run_state()); | 2020 animations_impl->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 2005 | 2021 |
| 2006 animations->NotifyAnimationAborted(events->events_[0]); | 2022 animations->NotifyAnimationAborted(events->events_[0]); |
| 2007 EXPECT_EQ(Animation::ABORTED, | 2023 EXPECT_EQ(Animation::ABORTED, |
| 2008 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); | 2024 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 2009 EXPECT_TRUE(delegate.aborted()); | 2025 EXPECT_TRUE(delegate.aborted()); |
| 2010 | 2026 |
| 2011 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 2027 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 2012 animations->UpdateState(true, nullptr); | 2028 animations->UpdateState(true, nullptr); |
| 2013 EXPECT_TRUE(host_->needs_push_properties()); | 2029 EXPECT_TRUE(host_->needs_push_properties()); |
| 2014 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 2030 EXPECT_EQ(Animation::WAITING_FOR_DELETION, |
| 2015 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); | 2031 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 2016 | 2032 |
| 2017 animations->PushPropertiesTo(animations_impl.get()); | 2033 PushProperties(); |
| 2034 |
| 2018 animations_impl->ActivateAnimations(); | 2035 animations_impl->ActivateAnimations(); |
| 2019 EXPECT_FALSE(animations->GetAnimationById(animation_id)); | 2036 EXPECT_FALSE(animations->GetAnimationById(animation_id)); |
| 2020 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); | 2037 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); |
| 2021 } | 2038 } |
| 2022 | 2039 |
| 2023 // Test that an impl-only scroll offset animation that needs to be completed on | 2040 // Test that an impl-only scroll offset animation that needs to be completed on |
| 2024 // the main thread gets deleted. | 2041 // the main thread gets deleted. |
| 2025 TEST_F(ElementAnimationsTest, ImplThreadTakeoverAnimationGetsDeleted) { | 2042 TEST_F(ElementAnimationsTest, ImplThreadTakeoverAnimationGetsDeleted) { |
| 2026 CreateTestLayer(true, false); | 2043 CreateTestLayer(true, false); |
| 2027 AttachTimelinePlayerLayer(); | 2044 AttachTimelinePlayerLayer(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2043 ScrollOffsetAnimationCurve::Create( | 2060 ScrollOffsetAnimationCurve::Create( |
| 2044 target_value, CubicBezierTimingFunction::CreatePreset( | 2061 target_value, CubicBezierTimingFunction::CreatePreset( |
| 2045 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 2062 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 2046 curve->SetInitialValue(initial_value); | 2063 curve->SetInitialValue(initial_value); |
| 2047 std::unique_ptr<Animation> animation(Animation::Create( | 2064 std::unique_ptr<Animation> animation(Animation::Create( |
| 2048 std::move(curve), animation_id, 0, TargetProperty::SCROLL_OFFSET)); | 2065 std::move(curve), animation_id, 0, TargetProperty::SCROLL_OFFSET)); |
| 2049 animation->set_start_time(TicksFromSecondsF(123)); | 2066 animation->set_start_time(TicksFromSecondsF(123)); |
| 2050 animation->set_is_impl_only(true); | 2067 animation->set_is_impl_only(true); |
| 2051 animations_impl->AddAnimation(std::move(animation)); | 2068 animations_impl->AddAnimation(std::move(animation)); |
| 2052 | 2069 |
| 2053 animations->PushPropertiesTo(animations_impl.get()); | 2070 PushProperties(); |
| 2071 EXPECT_FALSE(host_->needs_push_properties()); |
| 2072 |
| 2054 animations_impl->ActivateAnimations(); | 2073 animations_impl->ActivateAnimations(); |
| 2055 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 2074 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
| 2056 | 2075 |
| 2057 const bool needs_completion = true; | 2076 const bool needs_completion = true; |
| 2058 animations_impl->AbortAnimations(TargetProperty::SCROLL_OFFSET, | 2077 animations_impl->AbortAnimations(TargetProperty::SCROLL_OFFSET, |
| 2059 needs_completion); | 2078 needs_completion); |
| 2079 EXPECT_TRUE(host_impl_->needs_push_properties()); |
| 2060 EXPECT_EQ(Animation::ABORTED_BUT_NEEDS_COMPLETION, | 2080 EXPECT_EQ(Animation::ABORTED_BUT_NEEDS_COMPLETION, |
| 2061 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) | 2081 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| 2062 ->run_state()); | 2082 ->run_state()); |
| 2063 EXPECT_FALSE(host_->needs_push_properties()); | |
| 2064 EXPECT_FALSE(host_impl_->needs_push_properties()); | |
| 2065 | 2083 |
| 2066 auto events = host_impl_->CreateEvents(); | 2084 auto events = host_impl_->CreateEvents(); |
| 2067 animations_impl->Animate(kInitialTickTime); | 2085 animations_impl->Animate(kInitialTickTime); |
| 2068 animations_impl->UpdateState(true, events.get()); | 2086 animations_impl->UpdateState(true, events.get()); |
| 2069 EXPECT_TRUE(delegate_impl.finished()); | 2087 EXPECT_TRUE(delegate_impl.finished()); |
| 2070 EXPECT_TRUE(host_impl_->needs_push_properties()); | 2088 EXPECT_TRUE(host_impl_->needs_push_properties()); |
| 2071 EXPECT_EQ(1u, events->events_.size()); | 2089 EXPECT_EQ(1u, events->events_.size()); |
| 2072 EXPECT_EQ(AnimationEvent::TAKEOVER, events->events_[0].type); | 2090 EXPECT_EQ(AnimationEvent::TAKEOVER, events->events_[0].type); |
| 2073 EXPECT_EQ(123, events->events_[0].animation_start_time); | 2091 EXPECT_EQ(123, events->events_[0].animation_start_time); |
| 2074 EXPECT_EQ( | 2092 EXPECT_EQ( |
| 2075 target_value, | 2093 target_value, |
| 2076 events->events_[0].curve->ToScrollOffsetAnimationCurve()->target_value()); | 2094 events->events_[0].curve->ToScrollOffsetAnimationCurve()->target_value()); |
| 2077 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 2095 EXPECT_EQ(Animation::WAITING_FOR_DELETION, |
| 2078 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) | 2096 animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| 2079 ->run_state()); | 2097 ->run_state()); |
| 2080 | 2098 |
| 2081 // MT receives the event to take over. | 2099 // MT receives the event to take over. |
| 2082 animations->NotifyAnimationTakeover(events->events_[0]); | 2100 animations->NotifyAnimationTakeover(events->events_[0]); |
| 2083 EXPECT_TRUE(delegate.takeover()); | 2101 EXPECT_TRUE(delegate.takeover()); |
| 2084 | 2102 |
| 2085 // AnimationPlayer::NotifyAnimationTakeover requests SetNeedsPushProperties | 2103 // AnimationPlayer::NotifyAnimationTakeover requests SetNeedsPushProperties |
| 2086 // to purge CT animations marked for deletion. | 2104 // to purge CT animations marked for deletion. |
| 2087 EXPECT_TRUE(animations->needs_push_properties()); | 2105 EXPECT_TRUE(animations->needs_push_properties()); |
| 2088 | 2106 |
| 2089 // ElementAnimations::PurgeAnimationsMarkedForDeletion call happens only in | 2107 // ElementAnimations::PurgeAnimationsMarkedForDeletion call happens only in |
| 2090 // ElementAnimations::PushPropertiesTo. | 2108 // ElementAnimations::PushPropertiesTo. |
| 2091 animations->PushPropertiesTo(animations_impl.get()); | 2109 PushProperties(); |
| 2110 |
| 2092 animations_impl->ActivateAnimations(); | 2111 animations_impl->ActivateAnimations(); |
| 2093 EXPECT_FALSE(animations->GetAnimationById(animation_id)); | 2112 EXPECT_FALSE(animations->GetAnimationById(animation_id)); |
| 2094 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); | 2113 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id)); |
| 2095 } | 2114 } |
| 2096 | 2115 |
| 2097 // Ensure that we only generate FINISHED events for animations in a group | 2116 // Ensure that we only generate FINISHED events for animations in a group |
| 2098 // once all animations in that group are finished. | 2117 // once all animations in that group are finished. |
| 2099 TEST_F(ElementAnimationsTest, FinishedEventsForGroup) { | 2118 TEST_F(ElementAnimationsTest, FinishedEventsForGroup) { |
| 2100 CreateTestLayer(true, false); | 2119 CreateTestLayer(true, false); |
| 2101 AttachTimelinePlayerLayer(); | 2120 AttachTimelinePlayerLayer(); |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2672 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 2691 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 2673 | 2692 |
| 2674 auto events = host_impl_->CreateEvents(); | 2693 auto events = host_impl_->CreateEvents(); |
| 2675 | 2694 |
| 2676 EXPECT_FALSE(animations->needs_to_start_animations_for_testing()); | 2695 EXPECT_FALSE(animations->needs_to_start_animations_for_testing()); |
| 2677 int animation_id = AddOpacityTransitionToElementAnimations( | 2696 int animation_id = AddOpacityTransitionToElementAnimations( |
| 2678 animations.get(), 1, 0.5f, 1.f, false); | 2697 animations.get(), 1, 0.5f, 1.f, false); |
| 2679 EXPECT_TRUE(animations->needs_to_start_animations_for_testing()); | 2698 EXPECT_TRUE(animations->needs_to_start_animations_for_testing()); |
| 2680 | 2699 |
| 2681 EXPECT_FALSE(animations_impl->needs_to_start_animations_for_testing()); | 2700 EXPECT_FALSE(animations_impl->needs_to_start_animations_for_testing()); |
| 2682 animations->PushPropertiesTo(animations_impl.get()); | 2701 PushProperties(); |
| 2683 EXPECT_TRUE(animations_impl->needs_to_start_animations_for_testing()); | 2702 EXPECT_TRUE(animations_impl->needs_to_start_animations_for_testing()); |
| 2684 | 2703 |
| 2685 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 2704 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
| 2686 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 2705 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 2687 animations_impl->GetAnimationById(animation_id)->run_state()); | 2706 animations_impl->GetAnimationById(animation_id)->run_state()); |
| 2688 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) | 2707 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) |
| 2689 ->affects_pending_elements()); | 2708 ->affects_pending_elements()); |
| 2690 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id) | 2709 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id) |
| 2691 ->affects_active_elements()); | 2710 ->affects_active_elements()); |
| 2692 | 2711 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2731 CreateImplTimelineAndPlayer(); | 2750 CreateImplTimelineAndPlayer(); |
| 2732 | 2751 |
| 2733 scoped_refptr<ElementAnimations> animations = element_animations(); | 2752 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 2734 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 2753 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 2735 | 2754 |
| 2736 auto events = host_impl_->CreateEvents(); | 2755 auto events = host_impl_->CreateEvents(); |
| 2737 | 2756 |
| 2738 const int animation_id = AddOpacityTransitionToElementAnimations( | 2757 const int animation_id = AddOpacityTransitionToElementAnimations( |
| 2739 animations.get(), 1, 0.5f, 1.f, true); | 2758 animations.get(), 1, 0.5f, 1.f, true); |
| 2740 | 2759 |
| 2741 animations->PushPropertiesTo(animations_impl.get()); | 2760 PushProperties(); |
| 2742 | 2761 |
| 2743 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); | 2762 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); |
| 2744 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 2763 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 2745 animations_impl->GetAnimationById(animation_id)->run_state()); | 2764 animations_impl->GetAnimationById(animation_id)->run_state()); |
| 2746 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) | 2765 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) |
| 2747 ->affects_pending_elements()); | 2766 ->affects_pending_elements()); |
| 2748 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id) | 2767 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id) |
| 2749 ->affects_active_elements()); | 2768 ->affects_active_elements()); |
| 2750 | 2769 |
| 2751 animations_impl->Animate(kInitialTickTime); | 2770 animations_impl->Animate(kInitialTickTime); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2801 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( | 2820 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2802 element_id_, ElementListType::ACTIVE)); | 2821 element_id_, ElementListType::ACTIVE)); |
| 2803 | 2822 |
| 2804 // Case 1: An animation that's allowed to run until its finish point. | 2823 // Case 1: An animation that's allowed to run until its finish point. |
| 2805 AddAnimatedTransformToElementAnimations(animations.get(), 1.0, 1, 1); | 2824 AddAnimatedTransformToElementAnimations(animations.get(), 1.0, 1, 1); |
| 2806 EXPECT_TRUE(client_.GetHasPotentialTransformAnimation( | 2825 EXPECT_TRUE(client_.GetHasPotentialTransformAnimation( |
| 2807 element_id_, ElementListType::ACTIVE)); | 2826 element_id_, ElementListType::ACTIVE)); |
| 2808 EXPECT_TRUE(client_.GetTransformIsCurrentlyAnimating( | 2827 EXPECT_TRUE(client_.GetTransformIsCurrentlyAnimating( |
| 2809 element_id_, ElementListType::ACTIVE)); | 2828 element_id_, ElementListType::ACTIVE)); |
| 2810 | 2829 |
| 2811 animations->PushPropertiesTo(animations_impl.get()); | 2830 PushProperties(); |
| 2812 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( | 2831 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( |
| 2813 element_id_, ElementListType::PENDING)); | 2832 element_id_, ElementListType::PENDING)); |
| 2814 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( | 2833 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2815 element_id_, ElementListType::PENDING)); | 2834 element_id_, ElementListType::PENDING)); |
| 2816 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( | 2835 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( |
| 2817 element_id_, ElementListType::ACTIVE)); | 2836 element_id_, ElementListType::ACTIVE)); |
| 2818 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( | 2837 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2819 element_id_, ElementListType::ACTIVE)); | 2838 element_id_, ElementListType::ACTIVE)); |
| 2820 | 2839 |
| 2821 animations_impl->ActivateAnimations(); | 2840 animations_impl->ActivateAnimations(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2835 events->events_.clear(); | 2854 events->events_.clear(); |
| 2836 | 2855 |
| 2837 // Finish the animation. | 2856 // Finish the animation. |
| 2838 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 2857 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 2839 animations->UpdateState(true, nullptr); | 2858 animations->UpdateState(true, nullptr); |
| 2840 EXPECT_FALSE(client_.GetHasPotentialTransformAnimation( | 2859 EXPECT_FALSE(client_.GetHasPotentialTransformAnimation( |
| 2841 element_id_, ElementListType::ACTIVE)); | 2860 element_id_, ElementListType::ACTIVE)); |
| 2842 EXPECT_FALSE(client_.GetTransformIsCurrentlyAnimating( | 2861 EXPECT_FALSE(client_.GetTransformIsCurrentlyAnimating( |
| 2843 element_id_, ElementListType::ACTIVE)); | 2862 element_id_, ElementListType::ACTIVE)); |
| 2844 | 2863 |
| 2845 animations->PushPropertiesTo(animations_impl.get()); | 2864 PushProperties(); |
| 2846 | 2865 |
| 2847 // animations_impl hasn't yet ticked at/past the end of the animation. | 2866 // animations_impl hasn't yet ticked at/past the end of the animation. |
| 2848 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( | 2867 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( |
| 2849 element_id_, ElementListType::PENDING)); | 2868 element_id_, ElementListType::PENDING)); |
| 2850 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( | 2869 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2851 element_id_, ElementListType::PENDING)); | 2870 element_id_, ElementListType::PENDING)); |
| 2852 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( | 2871 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( |
| 2853 element_id_, ElementListType::ACTIVE)); | 2872 element_id_, ElementListType::ACTIVE)); |
| 2854 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( | 2873 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2855 element_id_, ElementListType::ACTIVE)); | 2874 element_id_, ElementListType::ACTIVE)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2867 element_id_, ElementListType::ACTIVE)); | 2886 element_id_, ElementListType::ACTIVE)); |
| 2868 | 2887 |
| 2869 // Case 2: An animation that's removed before it finishes. | 2888 // Case 2: An animation that's removed before it finishes. |
| 2870 int animation_id = | 2889 int animation_id = |
| 2871 AddAnimatedTransformToElementAnimations(animations.get(), 10.0, 2, 2); | 2890 AddAnimatedTransformToElementAnimations(animations.get(), 10.0, 2, 2); |
| 2872 EXPECT_TRUE(client_.GetHasPotentialTransformAnimation( | 2891 EXPECT_TRUE(client_.GetHasPotentialTransformAnimation( |
| 2873 element_id_, ElementListType::ACTIVE)); | 2892 element_id_, ElementListType::ACTIVE)); |
| 2874 EXPECT_TRUE(client_.GetTransformIsCurrentlyAnimating( | 2893 EXPECT_TRUE(client_.GetTransformIsCurrentlyAnimating( |
| 2875 element_id_, ElementListType::ACTIVE)); | 2894 element_id_, ElementListType::ACTIVE)); |
| 2876 | 2895 |
| 2877 animations->PushPropertiesTo(animations_impl.get()); | 2896 PushProperties(); |
| 2878 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( | 2897 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( |
| 2879 element_id_, ElementListType::PENDING)); | 2898 element_id_, ElementListType::PENDING)); |
| 2880 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( | 2899 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2881 element_id_, ElementListType::PENDING)); | 2900 element_id_, ElementListType::PENDING)); |
| 2882 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( | 2901 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( |
| 2883 element_id_, ElementListType::ACTIVE)); | 2902 element_id_, ElementListType::ACTIVE)); |
| 2884 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( | 2903 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2885 element_id_, ElementListType::ACTIVE)); | 2904 element_id_, ElementListType::ACTIVE)); |
| 2886 | 2905 |
| 2887 animations_impl->ActivateAnimations(); | 2906 animations_impl->ActivateAnimations(); |
| 2888 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( | 2907 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( |
| 2889 element_id_, ElementListType::ACTIVE)); | 2908 element_id_, ElementListType::ACTIVE)); |
| 2890 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( | 2909 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2891 element_id_, ElementListType::ACTIVE)); | 2910 element_id_, ElementListType::ACTIVE)); |
| 2892 | 2911 |
| 2893 animations_impl->Animate(kInitialTickTime + | 2912 animations_impl->Animate(kInitialTickTime + |
| 2894 TimeDelta::FromMilliseconds(2000)); | 2913 TimeDelta::FromMilliseconds(2000)); |
| 2895 animations_impl->UpdateState(true, events.get()); | 2914 animations_impl->UpdateState(true, events.get()); |
| 2896 | 2915 |
| 2897 animations->NotifyAnimationStarted(events->events_[0]); | 2916 animations->NotifyAnimationStarted(events->events_[0]); |
| 2898 events->events_.clear(); | 2917 events->events_.clear(); |
| 2899 | 2918 |
| 2900 animations->RemoveAnimation(animation_id); | 2919 animations->RemoveAnimation(animation_id); |
| 2901 EXPECT_FALSE(client_.GetHasPotentialTransformAnimation( | 2920 EXPECT_FALSE(client_.GetHasPotentialTransformAnimation( |
| 2902 element_id_, ElementListType::ACTIVE)); | 2921 element_id_, ElementListType::ACTIVE)); |
| 2903 EXPECT_FALSE(client_.GetTransformIsCurrentlyAnimating( | 2922 EXPECT_FALSE(client_.GetTransformIsCurrentlyAnimating( |
| 2904 element_id_, ElementListType::ACTIVE)); | 2923 element_id_, ElementListType::ACTIVE)); |
| 2905 | 2924 |
| 2906 animations->PushPropertiesTo(animations_impl.get()); | 2925 PushProperties(); |
| 2907 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( | 2926 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( |
| 2908 element_id_, ElementListType::PENDING)); | 2927 element_id_, ElementListType::PENDING)); |
| 2909 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( | 2928 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2910 element_id_, ElementListType::PENDING)); | 2929 element_id_, ElementListType::PENDING)); |
| 2911 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( | 2930 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( |
| 2912 element_id_, ElementListType::ACTIVE)); | 2931 element_id_, ElementListType::ACTIVE)); |
| 2913 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( | 2932 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2914 element_id_, ElementListType::ACTIVE)); | 2933 element_id_, ElementListType::ACTIVE)); |
| 2915 | 2934 |
| 2916 animations_impl->ActivateAnimations(); | 2935 animations_impl->ActivateAnimations(); |
| 2917 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( | 2936 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( |
| 2918 element_id_, ElementListType::ACTIVE)); | 2937 element_id_, ElementListType::ACTIVE)); |
| 2919 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( | 2938 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2920 element_id_, ElementListType::ACTIVE)); | 2939 element_id_, ElementListType::ACTIVE)); |
| 2921 | 2940 |
| 2922 // Case 3: An animation that's aborted before it finishes. | 2941 // Case 3: An animation that's aborted before it finishes. |
| 2923 animation_id = | 2942 animation_id = |
| 2924 AddAnimatedTransformToElementAnimations(animations.get(), 10.0, 3, 3); | 2943 AddAnimatedTransformToElementAnimations(animations.get(), 10.0, 3, 3); |
| 2925 EXPECT_TRUE(client_.GetHasPotentialTransformAnimation( | 2944 EXPECT_TRUE(client_.GetHasPotentialTransformAnimation( |
| 2926 element_id_, ElementListType::ACTIVE)); | 2945 element_id_, ElementListType::ACTIVE)); |
| 2927 EXPECT_TRUE(client_.GetTransformIsCurrentlyAnimating( | 2946 EXPECT_TRUE(client_.GetTransformIsCurrentlyAnimating( |
| 2928 element_id_, ElementListType::ACTIVE)); | 2947 element_id_, ElementListType::ACTIVE)); |
| 2929 | 2948 |
| 2930 animations->PushPropertiesTo(animations_impl.get()); | 2949 PushProperties(); |
| 2931 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( | 2950 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( |
| 2932 element_id_, ElementListType::PENDING)); | 2951 element_id_, ElementListType::PENDING)); |
| 2933 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( | 2952 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2934 element_id_, ElementListType::PENDING)); | 2953 element_id_, ElementListType::PENDING)); |
| 2935 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( | 2954 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( |
| 2936 element_id_, ElementListType::ACTIVE)); | 2955 element_id_, ElementListType::ACTIVE)); |
| 2937 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( | 2956 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2938 element_id_, ElementListType::ACTIVE)); | 2957 element_id_, ElementListType::ACTIVE)); |
| 2939 | 2958 |
| 2940 animations_impl->ActivateAnimations(); | 2959 animations_impl->ActivateAnimations(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2971 element_id_, ElementListType::ACTIVE)); | 2990 element_id_, ElementListType::ACTIVE)); |
| 2972 | 2991 |
| 2973 // Case 4 : An animation that's not in effect. | 2992 // Case 4 : An animation that's not in effect. |
| 2974 animation_id = | 2993 animation_id = |
| 2975 AddAnimatedTransformToElementAnimations(animations.get(), 1.0, 1, 6); | 2994 AddAnimatedTransformToElementAnimations(animations.get(), 1.0, 1, 6); |
| 2976 animations->GetAnimationById(animation_id) | 2995 animations->GetAnimationById(animation_id) |
| 2977 ->set_time_offset(base::TimeDelta::FromMilliseconds(-10000)); | 2996 ->set_time_offset(base::TimeDelta::FromMilliseconds(-10000)); |
| 2978 animations->GetAnimationById(animation_id) | 2997 animations->GetAnimationById(animation_id) |
| 2979 ->set_fill_mode(Animation::FillMode::NONE); | 2998 ->set_fill_mode(Animation::FillMode::NONE); |
| 2980 | 2999 |
| 2981 animations->PushPropertiesTo(animations_impl.get()); | 3000 PushProperties(); |
| 2982 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( | 3001 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( |
| 2983 element_id_, ElementListType::PENDING)); | 3002 element_id_, ElementListType::PENDING)); |
| 2984 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( | 3003 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2985 element_id_, ElementListType::PENDING)); | 3004 element_id_, ElementListType::PENDING)); |
| 2986 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( | 3005 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( |
| 2987 element_id_, ElementListType::ACTIVE)); | 3006 element_id_, ElementListType::ACTIVE)); |
| 2988 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( | 3007 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2989 element_id_, ElementListType::ACTIVE)); | 3008 element_id_, ElementListType::ACTIVE)); |
| 2990 | 3009 |
| 2991 animations_impl->ActivateAnimations(); | 3010 animations_impl->ActivateAnimations(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3019 element_id_, ElementListType::ACTIVE)); | 3038 element_id_, ElementListType::ACTIVE)); |
| 3020 | 3039 |
| 3021 // Case 1: An animation that's allowed to run until its finish point. | 3040 // Case 1: An animation that's allowed to run until its finish point. |
| 3022 AddOpacityTransitionToElementAnimations(animations.get(), 1.0, 0.f, 1.f, | 3041 AddOpacityTransitionToElementAnimations(animations.get(), 1.0, 0.f, 1.f, |
| 3023 false /*use_timing_function*/); | 3042 false /*use_timing_function*/); |
| 3024 EXPECT_TRUE(client_.GetHasPotentialOpacityAnimation(element_id_, | 3043 EXPECT_TRUE(client_.GetHasPotentialOpacityAnimation(element_id_, |
| 3025 ElementListType::ACTIVE)); | 3044 ElementListType::ACTIVE)); |
| 3026 EXPECT_TRUE(client_.GetOpacityIsCurrentlyAnimating(element_id_, | 3045 EXPECT_TRUE(client_.GetOpacityIsCurrentlyAnimating(element_id_, |
| 3027 ElementListType::ACTIVE)); | 3046 ElementListType::ACTIVE)); |
| 3028 | 3047 |
| 3029 animations->PushPropertiesTo(animations_impl.get()); | 3048 PushProperties(); |
| 3030 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( | 3049 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( |
| 3031 element_id_, ElementListType::PENDING)); | 3050 element_id_, ElementListType::PENDING)); |
| 3032 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3051 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3033 element_id_, ElementListType::PENDING)); | 3052 element_id_, ElementListType::PENDING)); |
| 3034 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( | 3053 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( |
| 3035 element_id_, ElementListType::ACTIVE)); | 3054 element_id_, ElementListType::ACTIVE)); |
| 3036 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3055 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3037 element_id_, ElementListType::ACTIVE)); | 3056 element_id_, ElementListType::ACTIVE)); |
| 3038 | 3057 |
| 3039 animations_impl->ActivateAnimations(); | 3058 animations_impl->ActivateAnimations(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3053 events->events_.clear(); | 3072 events->events_.clear(); |
| 3054 | 3073 |
| 3055 // Finish the animation. | 3074 // Finish the animation. |
| 3056 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 3075 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 3057 animations->UpdateState(true, nullptr); | 3076 animations->UpdateState(true, nullptr); |
| 3058 EXPECT_FALSE(client_.GetHasPotentialOpacityAnimation( | 3077 EXPECT_FALSE(client_.GetHasPotentialOpacityAnimation( |
| 3059 element_id_, ElementListType::ACTIVE)); | 3078 element_id_, ElementListType::ACTIVE)); |
| 3060 EXPECT_FALSE(client_.GetOpacityIsCurrentlyAnimating(element_id_, | 3079 EXPECT_FALSE(client_.GetOpacityIsCurrentlyAnimating(element_id_, |
| 3061 ElementListType::ACTIVE)); | 3080 ElementListType::ACTIVE)); |
| 3062 | 3081 |
| 3063 animations->PushPropertiesTo(animations_impl.get()); | 3082 PushProperties(); |
| 3064 | 3083 |
| 3065 // animations_impl hasn't yet ticked at/past the end of the animation. | 3084 // animations_impl hasn't yet ticked at/past the end of the animation. |
| 3066 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( | 3085 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( |
| 3067 element_id_, ElementListType::PENDING)); | 3086 element_id_, ElementListType::PENDING)); |
| 3068 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3087 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3069 element_id_, ElementListType::PENDING)); | 3088 element_id_, ElementListType::PENDING)); |
| 3070 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( | 3089 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( |
| 3071 element_id_, ElementListType::ACTIVE)); | 3090 element_id_, ElementListType::ACTIVE)); |
| 3072 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3091 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3073 element_id_, ElementListType::ACTIVE)); | 3092 element_id_, ElementListType::ACTIVE)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3085 element_id_, ElementListType::ACTIVE)); | 3104 element_id_, ElementListType::ACTIVE)); |
| 3086 | 3105 |
| 3087 // Case 2: An animation that's removed before it finishes. | 3106 // Case 2: An animation that's removed before it finishes. |
| 3088 int animation_id = AddOpacityTransitionToElementAnimations( | 3107 int animation_id = AddOpacityTransitionToElementAnimations( |
| 3089 animations.get(), 10.0, 0.f, 1.f, false /*use_timing_function*/); | 3108 animations.get(), 10.0, 0.f, 1.f, false /*use_timing_function*/); |
| 3090 EXPECT_TRUE(client_.GetHasPotentialOpacityAnimation(element_id_, | 3109 EXPECT_TRUE(client_.GetHasPotentialOpacityAnimation(element_id_, |
| 3091 ElementListType::ACTIVE)); | 3110 ElementListType::ACTIVE)); |
| 3092 EXPECT_TRUE(client_.GetOpacityIsCurrentlyAnimating(element_id_, | 3111 EXPECT_TRUE(client_.GetOpacityIsCurrentlyAnimating(element_id_, |
| 3093 ElementListType::ACTIVE)); | 3112 ElementListType::ACTIVE)); |
| 3094 | 3113 |
| 3095 animations->PushPropertiesTo(animations_impl.get()); | 3114 PushProperties(); |
| 3096 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( | 3115 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( |
| 3097 element_id_, ElementListType::PENDING)); | 3116 element_id_, ElementListType::PENDING)); |
| 3098 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3117 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3099 element_id_, ElementListType::PENDING)); | 3118 element_id_, ElementListType::PENDING)); |
| 3100 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( | 3119 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( |
| 3101 element_id_, ElementListType::ACTIVE)); | 3120 element_id_, ElementListType::ACTIVE)); |
| 3102 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3121 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3103 element_id_, ElementListType::ACTIVE)); | 3122 element_id_, ElementListType::ACTIVE)); |
| 3104 | 3123 |
| 3105 animations_impl->ActivateAnimations(); | 3124 animations_impl->ActivateAnimations(); |
| 3106 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( | 3125 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( |
| 3107 element_id_, ElementListType::ACTIVE)); | 3126 element_id_, ElementListType::ACTIVE)); |
| 3108 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3127 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3109 element_id_, ElementListType::ACTIVE)); | 3128 element_id_, ElementListType::ACTIVE)); |
| 3110 | 3129 |
| 3111 animations_impl->Animate(kInitialTickTime + | 3130 animations_impl->Animate(kInitialTickTime + |
| 3112 TimeDelta::FromMilliseconds(2000)); | 3131 TimeDelta::FromMilliseconds(2000)); |
| 3113 animations_impl->UpdateState(true, events.get()); | 3132 animations_impl->UpdateState(true, events.get()); |
| 3114 | 3133 |
| 3115 animations->NotifyAnimationStarted(events->events_[0]); | 3134 animations->NotifyAnimationStarted(events->events_[0]); |
| 3116 events->events_.clear(); | 3135 events->events_.clear(); |
| 3117 | 3136 |
| 3118 animations->RemoveAnimation(animation_id); | 3137 animations->RemoveAnimation(animation_id); |
| 3119 EXPECT_FALSE(client_.GetHasPotentialOpacityAnimation( | 3138 EXPECT_FALSE(client_.GetHasPotentialOpacityAnimation( |
| 3120 element_id_, ElementListType::ACTIVE)); | 3139 element_id_, ElementListType::ACTIVE)); |
| 3121 EXPECT_FALSE(client_.GetOpacityIsCurrentlyAnimating(element_id_, | 3140 EXPECT_FALSE(client_.GetOpacityIsCurrentlyAnimating(element_id_, |
| 3122 ElementListType::ACTIVE)); | 3141 ElementListType::ACTIVE)); |
| 3123 | 3142 |
| 3124 animations->PushPropertiesTo(animations_impl.get()); | 3143 PushProperties(); |
| 3125 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( | 3144 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( |
| 3126 element_id_, ElementListType::PENDING)); | 3145 element_id_, ElementListType::PENDING)); |
| 3127 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3146 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3128 element_id_, ElementListType::PENDING)); | 3147 element_id_, ElementListType::PENDING)); |
| 3129 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( | 3148 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( |
| 3130 element_id_, ElementListType::ACTIVE)); | 3149 element_id_, ElementListType::ACTIVE)); |
| 3131 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3150 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3132 element_id_, ElementListType::ACTIVE)); | 3151 element_id_, ElementListType::ACTIVE)); |
| 3133 | 3152 |
| 3134 animations_impl->ActivateAnimations(); | 3153 animations_impl->ActivateAnimations(); |
| 3135 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( | 3154 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( |
| 3136 element_id_, ElementListType::ACTIVE)); | 3155 element_id_, ElementListType::ACTIVE)); |
| 3137 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3156 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3138 element_id_, ElementListType::ACTIVE)); | 3157 element_id_, ElementListType::ACTIVE)); |
| 3139 | 3158 |
| 3140 // Case 3: An animation that's aborted before it finishes. | 3159 // Case 3: An animation that's aborted before it finishes. |
| 3141 animation_id = AddOpacityTransitionToElementAnimations( | 3160 animation_id = AddOpacityTransitionToElementAnimations( |
| 3142 animations.get(), 10.0, 0.f, 0.5f, false /*use_timing_function*/); | 3161 animations.get(), 10.0, 0.f, 0.5f, false /*use_timing_function*/); |
| 3143 EXPECT_TRUE(client_.GetHasPotentialOpacityAnimation(element_id_, | 3162 EXPECT_TRUE(client_.GetHasPotentialOpacityAnimation(element_id_, |
| 3144 ElementListType::ACTIVE)); | 3163 ElementListType::ACTIVE)); |
| 3145 EXPECT_TRUE(client_.GetOpacityIsCurrentlyAnimating(element_id_, | 3164 EXPECT_TRUE(client_.GetOpacityIsCurrentlyAnimating(element_id_, |
| 3146 ElementListType::ACTIVE)); | 3165 ElementListType::ACTIVE)); |
| 3147 | 3166 |
| 3148 animations->PushPropertiesTo(animations_impl.get()); | 3167 PushProperties(); |
| 3149 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( | 3168 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( |
| 3150 element_id_, ElementListType::PENDING)); | 3169 element_id_, ElementListType::PENDING)); |
| 3151 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3170 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3152 element_id_, ElementListType::PENDING)); | 3171 element_id_, ElementListType::PENDING)); |
| 3153 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( | 3172 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( |
| 3154 element_id_, ElementListType::ACTIVE)); | 3173 element_id_, ElementListType::ACTIVE)); |
| 3155 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3174 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3156 element_id_, ElementListType::ACTIVE)); | 3175 element_id_, ElementListType::ACTIVE)); |
| 3157 | 3176 |
| 3158 animations_impl->ActivateAnimations(); | 3177 animations_impl->ActivateAnimations(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3189 ElementListType::ACTIVE)); | 3208 ElementListType::ACTIVE)); |
| 3190 | 3209 |
| 3191 // Case 4 : An animation that's not in effect. | 3210 // Case 4 : An animation that's not in effect. |
| 3192 animation_id = AddOpacityTransitionToElementAnimations( | 3211 animation_id = AddOpacityTransitionToElementAnimations( |
| 3193 animations.get(), 1.0, 0.f, 0.5f, false /*use_timing_function*/); | 3212 animations.get(), 1.0, 0.f, 0.5f, false /*use_timing_function*/); |
| 3194 animations->GetAnimationById(animation_id) | 3213 animations->GetAnimationById(animation_id) |
| 3195 ->set_time_offset(base::TimeDelta::FromMilliseconds(-10000)); | 3214 ->set_time_offset(base::TimeDelta::FromMilliseconds(-10000)); |
| 3196 animations->GetAnimationById(animation_id) | 3215 animations->GetAnimationById(animation_id) |
| 3197 ->set_fill_mode(Animation::FillMode::NONE); | 3216 ->set_fill_mode(Animation::FillMode::NONE); |
| 3198 | 3217 |
| 3199 animations->PushPropertiesTo(animations_impl.get()); | 3218 PushProperties(); |
| 3200 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( | 3219 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( |
| 3201 element_id_, ElementListType::PENDING)); | 3220 element_id_, ElementListType::PENDING)); |
| 3202 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3221 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3203 element_id_, ElementListType::PENDING)); | 3222 element_id_, ElementListType::PENDING)); |
| 3204 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( | 3223 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( |
| 3205 element_id_, ElementListType::ACTIVE)); | 3224 element_id_, ElementListType::ACTIVE)); |
| 3206 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( | 3225 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 3207 element_id_, ElementListType::ACTIVE)); | 3226 element_id_, ElementListType::ACTIVE)); |
| 3208 | 3227 |
| 3209 animations_impl->ActivateAnimations(); | 3228 animations_impl->ActivateAnimations(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3236 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3255 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3237 element_id_, ElementListType::ACTIVE)); | 3256 element_id_, ElementListType::ACTIVE)); |
| 3238 | 3257 |
| 3239 // Case 1: An animation that's allowed to run until its finish point. | 3258 // Case 1: An animation that's allowed to run until its finish point. |
| 3240 AddAnimatedFilterToElementAnimations(animations.get(), 1.0, 0.f, 1.f); | 3259 AddAnimatedFilterToElementAnimations(animations.get(), 1.0, 0.f, 1.f); |
| 3241 EXPECT_TRUE(client_.GetHasPotentialFilterAnimation(element_id_, | 3260 EXPECT_TRUE(client_.GetHasPotentialFilterAnimation(element_id_, |
| 3242 ElementListType::ACTIVE)); | 3261 ElementListType::ACTIVE)); |
| 3243 EXPECT_TRUE(client_.GetFilterIsCurrentlyAnimating(element_id_, | 3262 EXPECT_TRUE(client_.GetFilterIsCurrentlyAnimating(element_id_, |
| 3244 ElementListType::ACTIVE)); | 3263 ElementListType::ACTIVE)); |
| 3245 | 3264 |
| 3246 animations->PushPropertiesTo(animations_impl.get()); | 3265 PushProperties(); |
| 3247 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( | 3266 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( |
| 3248 element_id_, ElementListType::PENDING)); | 3267 element_id_, ElementListType::PENDING)); |
| 3249 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( | 3268 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3250 element_id_, ElementListType::PENDING)); | 3269 element_id_, ElementListType::PENDING)); |
| 3251 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( | 3270 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( |
| 3252 element_id_, ElementListType::ACTIVE)); | 3271 element_id_, ElementListType::ACTIVE)); |
| 3253 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3272 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3254 element_id_, ElementListType::ACTIVE)); | 3273 element_id_, ElementListType::ACTIVE)); |
| 3255 | 3274 |
| 3256 animations_impl->ActivateAnimations(); | 3275 animations_impl->ActivateAnimations(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3270 events->events_.clear(); | 3289 events->events_.clear(); |
| 3271 | 3290 |
| 3272 // Finish the animation. | 3291 // Finish the animation. |
| 3273 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 3292 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 3274 animations->UpdateState(true, nullptr); | 3293 animations->UpdateState(true, nullptr); |
| 3275 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_, | 3294 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_, |
| 3276 ElementListType::ACTIVE)); | 3295 ElementListType::ACTIVE)); |
| 3277 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_, | 3296 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_, |
| 3278 ElementListType::ACTIVE)); | 3297 ElementListType::ACTIVE)); |
| 3279 | 3298 |
| 3280 animations->PushPropertiesTo(animations_impl.get()); | 3299 PushProperties(); |
| 3281 | 3300 |
| 3282 // animations_impl hasn't yet ticked at/past the end of the animation. | 3301 // animations_impl hasn't yet ticked at/past the end of the animation. |
| 3283 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( | 3302 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( |
| 3284 element_id_, ElementListType::PENDING)); | 3303 element_id_, ElementListType::PENDING)); |
| 3285 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( | 3304 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3286 element_id_, ElementListType::PENDING)); | 3305 element_id_, ElementListType::PENDING)); |
| 3287 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( | 3306 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( |
| 3288 element_id_, ElementListType::ACTIVE)); | 3307 element_id_, ElementListType::ACTIVE)); |
| 3289 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( | 3308 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3290 element_id_, ElementListType::ACTIVE)); | 3309 element_id_, ElementListType::ACTIVE)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3302 element_id_, ElementListType::ACTIVE)); | 3321 element_id_, ElementListType::ACTIVE)); |
| 3303 | 3322 |
| 3304 // Case 2: An animation that's removed before it finishes. | 3323 // Case 2: An animation that's removed before it finishes. |
| 3305 int animation_id = | 3324 int animation_id = |
| 3306 AddAnimatedFilterToElementAnimations(animations.get(), 10.0, 0.f, 1.f); | 3325 AddAnimatedFilterToElementAnimations(animations.get(), 10.0, 0.f, 1.f); |
| 3307 EXPECT_TRUE(client_.GetHasPotentialFilterAnimation(element_id_, | 3326 EXPECT_TRUE(client_.GetHasPotentialFilterAnimation(element_id_, |
| 3308 ElementListType::ACTIVE)); | 3327 ElementListType::ACTIVE)); |
| 3309 EXPECT_TRUE(client_.GetFilterIsCurrentlyAnimating(element_id_, | 3328 EXPECT_TRUE(client_.GetFilterIsCurrentlyAnimating(element_id_, |
| 3310 ElementListType::ACTIVE)); | 3329 ElementListType::ACTIVE)); |
| 3311 | 3330 |
| 3312 animations->PushPropertiesTo(animations_impl.get()); | 3331 PushProperties(); |
| 3313 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( | 3332 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( |
| 3314 element_id_, ElementListType::PENDING)); | 3333 element_id_, ElementListType::PENDING)); |
| 3315 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( | 3334 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3316 element_id_, ElementListType::PENDING)); | 3335 element_id_, ElementListType::PENDING)); |
| 3317 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( | 3336 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( |
| 3318 element_id_, ElementListType::ACTIVE)); | 3337 element_id_, ElementListType::ACTIVE)); |
| 3319 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3338 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3320 element_id_, ElementListType::ACTIVE)); | 3339 element_id_, ElementListType::ACTIVE)); |
| 3321 | 3340 |
| 3322 animations_impl->ActivateAnimations(); | 3341 animations_impl->ActivateAnimations(); |
| 3323 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( | 3342 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( |
| 3324 element_id_, ElementListType::ACTIVE)); | 3343 element_id_, ElementListType::ACTIVE)); |
| 3325 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( | 3344 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3326 element_id_, ElementListType::ACTIVE)); | 3345 element_id_, ElementListType::ACTIVE)); |
| 3327 | 3346 |
| 3328 animations_impl->Animate(kInitialTickTime + | 3347 animations_impl->Animate(kInitialTickTime + |
| 3329 TimeDelta::FromMilliseconds(2000)); | 3348 TimeDelta::FromMilliseconds(2000)); |
| 3330 animations_impl->UpdateState(true, events.get()); | 3349 animations_impl->UpdateState(true, events.get()); |
| 3331 | 3350 |
| 3332 animations->NotifyAnimationStarted(events->events_[0]); | 3351 animations->NotifyAnimationStarted(events->events_[0]); |
| 3333 events->events_.clear(); | 3352 events->events_.clear(); |
| 3334 | 3353 |
| 3335 animations->RemoveAnimation(animation_id); | 3354 animations->RemoveAnimation(animation_id); |
| 3336 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_, | 3355 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_, |
| 3337 ElementListType::ACTIVE)); | 3356 ElementListType::ACTIVE)); |
| 3338 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_, | 3357 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_, |
| 3339 ElementListType::ACTIVE)); | 3358 ElementListType::ACTIVE)); |
| 3340 | 3359 |
| 3341 animations->PushPropertiesTo(animations_impl.get()); | 3360 PushProperties(); |
| 3342 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( | 3361 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( |
| 3343 element_id_, ElementListType::PENDING)); | 3362 element_id_, ElementListType::PENDING)); |
| 3344 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3363 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3345 element_id_, ElementListType::PENDING)); | 3364 element_id_, ElementListType::PENDING)); |
| 3346 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( | 3365 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( |
| 3347 element_id_, ElementListType::ACTIVE)); | 3366 element_id_, ElementListType::ACTIVE)); |
| 3348 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( | 3367 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3349 element_id_, ElementListType::ACTIVE)); | 3368 element_id_, ElementListType::ACTIVE)); |
| 3350 | 3369 |
| 3351 animations_impl->ActivateAnimations(); | 3370 animations_impl->ActivateAnimations(); |
| 3352 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( | 3371 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( |
| 3353 element_id_, ElementListType::ACTIVE)); | 3372 element_id_, ElementListType::ACTIVE)); |
| 3354 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3373 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3355 element_id_, ElementListType::ACTIVE)); | 3374 element_id_, ElementListType::ACTIVE)); |
| 3356 | 3375 |
| 3357 // Case 3: An animation that's aborted before it finishes. | 3376 // Case 3: An animation that's aborted before it finishes. |
| 3358 animation_id = | 3377 animation_id = |
| 3359 AddAnimatedFilterToElementAnimations(animations.get(), 10.0, 0.f, 0.5f); | 3378 AddAnimatedFilterToElementAnimations(animations.get(), 10.0, 0.f, 0.5f); |
| 3360 EXPECT_TRUE(client_.GetHasPotentialFilterAnimation(element_id_, | 3379 EXPECT_TRUE(client_.GetHasPotentialFilterAnimation(element_id_, |
| 3361 ElementListType::ACTIVE)); | 3380 ElementListType::ACTIVE)); |
| 3362 EXPECT_TRUE(client_.GetFilterIsCurrentlyAnimating(element_id_, | 3381 EXPECT_TRUE(client_.GetFilterIsCurrentlyAnimating(element_id_, |
| 3363 ElementListType::ACTIVE)); | 3382 ElementListType::ACTIVE)); |
| 3364 | 3383 |
| 3365 animations->PushPropertiesTo(animations_impl.get()); | 3384 PushProperties(); |
| 3366 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( | 3385 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( |
| 3367 element_id_, ElementListType::PENDING)); | 3386 element_id_, ElementListType::PENDING)); |
| 3368 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( | 3387 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3369 element_id_, ElementListType::PENDING)); | 3388 element_id_, ElementListType::PENDING)); |
| 3370 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( | 3389 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( |
| 3371 element_id_, ElementListType::ACTIVE)); | 3390 element_id_, ElementListType::ACTIVE)); |
| 3372 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3391 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3373 element_id_, ElementListType::ACTIVE)); | 3392 element_id_, ElementListType::ACTIVE)); |
| 3374 | 3393 |
| 3375 animations_impl->ActivateAnimations(); | 3394 animations_impl->ActivateAnimations(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3406 ElementListType::ACTIVE)); | 3425 ElementListType::ACTIVE)); |
| 3407 | 3426 |
| 3408 // Case 4 : An animation that's not in effect. | 3427 // Case 4 : An animation that's not in effect. |
| 3409 animation_id = | 3428 animation_id = |
| 3410 AddAnimatedFilterToElementAnimations(animations.get(), 1.0, 0.f, 0.5f); | 3429 AddAnimatedFilterToElementAnimations(animations.get(), 1.0, 0.f, 0.5f); |
| 3411 animations->GetAnimationById(animation_id) | 3430 animations->GetAnimationById(animation_id) |
| 3412 ->set_time_offset(base::TimeDelta::FromMilliseconds(-10000)); | 3431 ->set_time_offset(base::TimeDelta::FromMilliseconds(-10000)); |
| 3413 animations->GetAnimationById(animation_id) | 3432 animations->GetAnimationById(animation_id) |
| 3414 ->set_fill_mode(Animation::FillMode::NONE); | 3433 ->set_fill_mode(Animation::FillMode::NONE); |
| 3415 | 3434 |
| 3416 animations->PushPropertiesTo(animations_impl.get()); | 3435 PushProperties(); |
| 3417 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( | 3436 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( |
| 3418 element_id_, ElementListType::PENDING)); | 3437 element_id_, ElementListType::PENDING)); |
| 3419 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3438 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3420 element_id_, ElementListType::PENDING)); | 3439 element_id_, ElementListType::PENDING)); |
| 3421 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( | 3440 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( |
| 3422 element_id_, ElementListType::ACTIVE)); | 3441 element_id_, ElementListType::ACTIVE)); |
| 3423 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3442 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3424 element_id_, ElementListType::ACTIVE)); | 3443 element_id_, ElementListType::ACTIVE)); |
| 3425 | 3444 |
| 3426 animations_impl->ActivateAnimations(); | 3445 animations_impl->ActivateAnimations(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3468 CreateImplTimelineAndPlayer(); | 3487 CreateImplTimelineAndPlayer(); |
| 3469 | 3488 |
| 3470 scoped_refptr<ElementAnimations> animations = element_animations(); | 3489 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 3471 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 3490 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 3472 | 3491 |
| 3473 auto events = host_impl_->CreateEvents(); | 3492 auto events = host_impl_->CreateEvents(); |
| 3474 | 3493 |
| 3475 const int animation_id = AddOpacityTransitionToElementAnimations( | 3494 const int animation_id = AddOpacityTransitionToElementAnimations( |
| 3476 animations.get(), 1, 0.5f, 1.f, true); | 3495 animations.get(), 1, 0.5f, 1.f, true); |
| 3477 | 3496 |
| 3478 animations->PushPropertiesTo(animations_impl.get()); | 3497 PushProperties(); |
| 3479 animations_impl->ActivateAnimations(); | 3498 animations_impl->ActivateAnimations(); |
| 3480 animations_impl->Animate(kInitialTickTime); | 3499 animations_impl->Animate(kInitialTickTime); |
| 3481 animations_impl->UpdateState(true, events.get()); | 3500 animations_impl->UpdateState(true, events.get()); |
| 3482 EXPECT_EQ(Animation::RUNNING, | 3501 EXPECT_EQ(Animation::RUNNING, |
| 3483 animations_impl->GetAnimationById(animation_id)->run_state()); | 3502 animations_impl->GetAnimationById(animation_id)->run_state()); |
| 3484 EXPECT_EQ(0.5f, | 3503 EXPECT_EQ(0.5f, |
| 3485 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); | 3504 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); |
| 3486 EXPECT_EQ(0.5f, | 3505 EXPECT_EQ(0.5f, |
| 3487 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 3506 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 3488 | 3507 |
| 3489 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) | 3508 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) |
| 3490 ->affects_pending_elements()); | 3509 ->affects_pending_elements()); |
| 3491 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) | 3510 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) |
| 3492 ->affects_active_elements()); | 3511 ->affects_active_elements()); |
| 3493 | 3512 |
| 3494 // Delete the animation on the main-thread animations. | 3513 // Delete the animation on the main-thread animations. |
| 3495 animations->RemoveAnimation( | 3514 animations->RemoveAnimation( |
| 3496 animations->GetAnimation(TargetProperty::OPACITY)->id()); | 3515 animations->GetAnimation(TargetProperty::OPACITY)->id()); |
| 3497 animations->PushPropertiesTo(animations_impl.get()); | 3516 PushProperties(); |
| 3498 | 3517 |
| 3499 // The animation should no longer affect pending elements. | 3518 // The animation should no longer affect pending elements. |
| 3500 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id) | 3519 EXPECT_FALSE(animations_impl->GetAnimationById(animation_id) |
| 3501 ->affects_pending_elements()); | 3520 ->affects_pending_elements()); |
| 3502 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) | 3521 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id) |
| 3503 ->affects_active_elements()); | 3522 ->affects_active_elements()); |
| 3504 | 3523 |
| 3505 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 3524 animations_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 3506 animations_impl->UpdateState(true, events.get()); | 3525 animations_impl->UpdateState(true, events.get()); |
| 3507 | 3526 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3525 CreateImplTimelineAndPlayer(); | 3544 CreateImplTimelineAndPlayer(); |
| 3526 | 3545 |
| 3527 scoped_refptr<ElementAnimations> animations = element_animations(); | 3546 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 3528 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 3547 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 3529 | 3548 |
| 3530 auto events = host_impl_->CreateEvents(); | 3549 auto events = host_impl_->CreateEvents(); |
| 3531 | 3550 |
| 3532 const int first_animation_id = AddOpacityTransitionToElementAnimations( | 3551 const int first_animation_id = AddOpacityTransitionToElementAnimations( |
| 3533 animations.get(), 1, 0.f, 1.f, true); | 3552 animations.get(), 1, 0.f, 1.f, true); |
| 3534 | 3553 |
| 3535 animations->PushPropertiesTo(animations_impl.get()); | 3554 PushProperties(); |
| 3536 animations_impl->ActivateAnimations(); | 3555 animations_impl->ActivateAnimations(); |
| 3537 animations_impl->Animate(kInitialTickTime); | 3556 animations_impl->Animate(kInitialTickTime); |
| 3538 animations_impl->UpdateState(true, events.get()); | 3557 animations_impl->UpdateState(true, events.get()); |
| 3539 | 3558 |
| 3540 // Remove the first animation from the main-thread animations, and add a | 3559 // Remove the first animation from the main-thread animations, and add a |
| 3541 // new animation affecting the same property. | 3560 // new animation affecting the same property. |
| 3542 animations->RemoveAnimation( | 3561 animations->RemoveAnimation( |
| 3543 animations->GetAnimation(TargetProperty::OPACITY)->id()); | 3562 animations->GetAnimation(TargetProperty::OPACITY)->id()); |
| 3544 const int second_animation_id = AddOpacityTransitionToElementAnimations( | 3563 const int second_animation_id = AddOpacityTransitionToElementAnimations( |
| 3545 animations.get(), 1, 1.f, 0.5f, true); | 3564 animations.get(), 1, 1.f, 0.5f, true); |
| 3546 animations->PushPropertiesTo(animations_impl.get()); | 3565 PushProperties(); |
| 3547 | 3566 |
| 3548 // The original animation should only affect active elements, and the new | 3567 // The original animation should only affect active elements, and the new |
| 3549 // animation should only affect pending elements. | 3568 // animation should only affect pending elements. |
| 3550 EXPECT_FALSE(animations_impl->GetAnimationById(first_animation_id) | 3569 EXPECT_FALSE(animations_impl->GetAnimationById(first_animation_id) |
| 3551 ->affects_pending_elements()); | 3570 ->affects_pending_elements()); |
| 3552 EXPECT_TRUE(animations_impl->GetAnimationById(first_animation_id) | 3571 EXPECT_TRUE(animations_impl->GetAnimationById(first_animation_id) |
| 3553 ->affects_active_elements()); | 3572 ->affects_active_elements()); |
| 3554 EXPECT_TRUE(animations_impl->GetAnimationById(second_animation_id) | 3573 EXPECT_TRUE(animations_impl->GetAnimationById(second_animation_id) |
| 3555 ->affects_pending_elements()); | 3574 ->affects_pending_elements()); |
| 3556 EXPECT_FALSE(animations_impl->GetAnimationById(second_animation_id) | 3575 EXPECT_FALSE(animations_impl->GetAnimationById(second_animation_id) |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3745 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( | 3764 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( |
| 3746 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3765 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
| 3747 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3766 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
| 3748 TargetProperty::OPACITY, ElementListType::PENDING)); | 3767 TargetProperty::OPACITY, ElementListType::PENDING)); |
| 3749 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3768 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
| 3750 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3769 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
| 3751 } | 3770 } |
| 3752 | 3771 |
| 3753 } // namespace | 3772 } // namespace |
| 3754 } // namespace cc | 3773 } // namespace cc |
| OLD | NEW |