| 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_events.h" | 8 #include "cc/animation/animation_events.h" |
| 9 #include "cc/animation/animation_host.h" | 9 #include "cc/animation/animation_host.h" |
| 10 #include "cc/animation/animation_id_provider.h" | 10 #include "cc/animation/animation_id_provider.h" |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 325 |
| 326 PushProperties(); | 326 PushProperties(); |
| 327 | 327 |
| 328 scoped_refptr<AnimationPlayer> player2_impl = | 328 scoped_refptr<AnimationPlayer> player2_impl = |
| 329 timeline_impl_->GetPlayerById(player2_id); | 329 timeline_impl_->GetPlayerById(player2_id); |
| 330 DCHECK(player2_impl); | 330 DCHECK(player2_impl); |
| 331 | 331 |
| 332 player2_impl->ActivateAnimations(); | 332 player2_impl->ActivateAnimations(); |
| 333 EXPECT_TRUE(player2_impl->GetAnimationById(animation_id)); | 333 EXPECT_TRUE(player2_impl->GetAnimationById(animation_id)); |
| 334 | 334 |
| 335 player2_impl->Animate(kInitialTickTime); | 335 player2_impl->Tick(kInitialTickTime); |
| 336 | 336 |
| 337 auto events = CreateEventsForTesting(); | 337 auto events = CreateEventsForTesting(); |
| 338 player2_impl->UpdateState(true, events.get()); | 338 player2_impl->UpdateState(true, events.get()); |
| 339 EXPECT_EQ(1u, events->events_.size()); | 339 EXPECT_EQ(1u, events->events_.size()); |
| 340 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); | 340 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); |
| 341 | 341 |
| 342 // The actual detachment happens here, inside the callback | 342 // The actual detachment happens here, inside the callback |
| 343 player2->NotifyAnimationStarted(events->events_[0]); | 343 player2->NotifyAnimationStarted(events->events_[0]); |
| 344 EXPECT_TRUE(delegate.started()); | 344 EXPECT_TRUE(delegate.started()); |
| 345 } | 345 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 357 AddOpacityTransitionToPlayer(player_.get(), 1, 0, 1, false); | 357 AddOpacityTransitionToPlayer(player_.get(), 1, 0, 1, false); |
| 358 | 358 |
| 359 PushProperties(); | 359 PushProperties(); |
| 360 player_impl_->ActivateAnimations(); | 360 player_impl_->ActivateAnimations(); |
| 361 | 361 |
| 362 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); | 362 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); |
| 363 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 363 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 364 player_impl_->GetAnimationById(animation_id)->run_state()); | 364 player_impl_->GetAnimationById(animation_id)->run_state()); |
| 365 | 365 |
| 366 auto events = CreateEventsForTesting(); | 366 auto events = CreateEventsForTesting(); |
| 367 player_impl_->Animate(kInitialTickTime); | 367 player_impl_->Tick(kInitialTickTime); |
| 368 player_impl_->UpdateState(true, events.get()); | 368 player_impl_->UpdateState(true, events.get()); |
| 369 | 369 |
| 370 // Synchronize the start times. | 370 // Synchronize the start times. |
| 371 EXPECT_EQ(1u, events->events_.size()); | 371 EXPECT_EQ(1u, events->events_.size()); |
| 372 player_->NotifyAnimationStarted(events->events_[0]); | 372 player_->NotifyAnimationStarted(events->events_[0]); |
| 373 EXPECT_EQ(player_->GetAnimationById(animation_id)->start_time(), | 373 EXPECT_EQ(player_->GetAnimationById(animation_id)->start_time(), |
| 374 player_impl_->GetAnimationById(animation_id)->start_time()); | 374 player_impl_->GetAnimationById(animation_id)->start_time()); |
| 375 | 375 |
| 376 // Start the animation on the main thread. Should not affect the start time. | 376 // Start the animation on the main thread. Should not affect the start time. |
| 377 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 377 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 378 player_impl_->UpdateState(true, nullptr); | 378 player_impl_->UpdateState(true, nullptr); |
| 379 EXPECT_EQ(player_->GetAnimationById(animation_id)->start_time(), | 379 EXPECT_EQ(player_->GetAnimationById(animation_id)->start_time(), |
| 380 player_impl_->GetAnimationById(animation_id)->start_time()); | 380 player_impl_->GetAnimationById(animation_id)->start_time()); |
| 381 } | 381 } |
| 382 | 382 |
| 383 TEST_F(ElementAnimationsTest, UseSpecifiedStartTimes) { | 383 TEST_F(ElementAnimationsTest, UseSpecifiedStartTimes) { |
| 384 CreateTestLayer(true, false); | 384 CreateTestLayer(true, false); |
| 385 AttachTimelinePlayerLayer(); | 385 AttachTimelinePlayerLayer(); |
| 386 CreateImplTimelineAndPlayer(); | 386 CreateImplTimelineAndPlayer(); |
| 387 | 387 |
| 388 int animation_id = | 388 int animation_id = |
| 389 AddOpacityTransitionToPlayer(player_.get(), 1, 0, 1, false); | 389 AddOpacityTransitionToPlayer(player_.get(), 1, 0, 1, false); |
| 390 | 390 |
| 391 const TimeTicks start_time = TicksFromSecondsF(123); | 391 const TimeTicks start_time = TicksFromSecondsF(123); |
| 392 player_->GetAnimation(TargetProperty::OPACITY)->set_start_time(start_time); | 392 player_->GetAnimation(TargetProperty::OPACITY)->set_start_time(start_time); |
| 393 | 393 |
| 394 PushProperties(); | 394 PushProperties(); |
| 395 player_impl_->ActivateAnimations(); | 395 player_impl_->ActivateAnimations(); |
| 396 | 396 |
| 397 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); | 397 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); |
| 398 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 398 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 399 player_impl_->GetAnimationById(animation_id)->run_state()); | 399 player_impl_->GetAnimationById(animation_id)->run_state()); |
| 400 | 400 |
| 401 auto events = CreateEventsForTesting(); | 401 auto events = CreateEventsForTesting(); |
| 402 player_impl_->Animate(kInitialTickTime); | 402 player_impl_->Tick(kInitialTickTime); |
| 403 player_impl_->UpdateState(true, events.get()); | 403 player_impl_->UpdateState(true, events.get()); |
| 404 | 404 |
| 405 // Synchronize the start times. | 405 // Synchronize the start times. |
| 406 EXPECT_EQ(1u, events->events_.size()); | 406 EXPECT_EQ(1u, events->events_.size()); |
| 407 player_->NotifyAnimationStarted(events->events_[0]); | 407 player_->NotifyAnimationStarted(events->events_[0]); |
| 408 | 408 |
| 409 EXPECT_EQ(start_time, player_->GetAnimationById(animation_id)->start_time()); | 409 EXPECT_EQ(start_time, player_->GetAnimationById(animation_id)->start_time()); |
| 410 EXPECT_EQ(player_->GetAnimationById(animation_id)->start_time(), | 410 EXPECT_EQ(player_->GetAnimationById(animation_id)->start_time(), |
| 411 player_impl_->GetAnimationById(animation_id)->start_time()); | 411 player_impl_->GetAnimationById(animation_id)->start_time()); |
| 412 | 412 |
| 413 // Start the animation on the main thread. Should not affect the start time. | 413 // Start the animation on the main thread. Should not affect the start time. |
| 414 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 414 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 415 player_->UpdateState(true, nullptr); | 415 player_->UpdateState(true, nullptr); |
| 416 EXPECT_EQ(start_time, player_->GetAnimationById(animation_id)->start_time()); | 416 EXPECT_EQ(start_time, player_->GetAnimationById(animation_id)->start_time()); |
| 417 EXPECT_EQ(player_->GetAnimationById(animation_id)->start_time(), | 417 EXPECT_EQ(player_->GetAnimationById(animation_id)->start_time(), |
| 418 player_impl_->GetAnimationById(animation_id)->start_time()); | 418 player_impl_->GetAnimationById(animation_id)->start_time()); |
| 419 } | 419 } |
| 420 | 420 |
| 421 // Tests that animationss activate and deactivate as expected. | 421 // Tests that animationss activate and deactivate as expected. |
| 422 TEST_F(ElementAnimationsTest, Activation) { | 422 TEST_F(ElementAnimationsTest, Activation) { |
| 423 CreateTestLayer(true, false); | 423 CreateTestLayer(true, false); |
| 424 AttachTimelinePlayerLayer(); | 424 AttachTimelinePlayerLayer(); |
| 425 CreateImplTimelineAndPlayer(); | 425 CreateImplTimelineAndPlayer(); |
| 426 | 426 |
| 427 AnimationHost* host = client_.host(); | 427 AnimationHost* host = client_.host(); |
| 428 AnimationHost* host_impl = client_impl_.host(); | 428 AnimationHost* host_impl = client_impl_.host(); |
| 429 | 429 |
| 430 auto events = CreateEventsForTesting(); | 430 auto events = CreateEventsForTesting(); |
| 431 | 431 |
| 432 EXPECT_EQ(1u, host->all_element_animations_for_testing().size()); | 432 EXPECT_EQ(1u, host->element_animations_for_testing().size()); |
| 433 EXPECT_EQ(1u, host_impl->all_element_animations_for_testing().size()); | 433 EXPECT_EQ(1u, host_impl->element_animations_for_testing().size()); |
| 434 | 434 |
| 435 // Initially, both animationss should be inactive. | 435 // Initially, both animationss should be inactive. |
| 436 EXPECT_EQ(0u, host->active_players_for_testing().size()); | 436 EXPECT_EQ(0u, host->ticking_players_for_testing().size()); |
| 437 EXPECT_EQ(0u, host_impl->active_players_for_testing().size()); | 437 EXPECT_EQ(0u, host_impl->ticking_players_for_testing().size()); |
| 438 | 438 |
| 439 AddOpacityTransitionToPlayer(player_.get(), 1, 0, 1, false); | 439 AddOpacityTransitionToPlayer(player_.get(), 1, 0, 1, false); |
| 440 // The main thread animations should now be active. | 440 // The main thread animations should now be active. |
| 441 EXPECT_EQ(1u, host->active_players_for_testing().size()); | 441 EXPECT_EQ(1u, host->ticking_players_for_testing().size()); |
| 442 | 442 |
| 443 PushProperties(); | 443 PushProperties(); |
| 444 player_impl_->ActivateAnimations(); | 444 player_impl_->ActivateAnimations(); |
| 445 // Both animationss should now be active. | 445 // Both animationss should now be active. |
| 446 EXPECT_EQ(1u, host->active_players_for_testing().size()); | 446 EXPECT_EQ(1u, host->ticking_players_for_testing().size()); |
| 447 EXPECT_EQ(1u, host_impl->active_players_for_testing().size()); | 447 EXPECT_EQ(1u, host_impl->ticking_players_for_testing().size()); |
| 448 | 448 |
| 449 player_impl_->Animate(kInitialTickTime); | 449 player_impl_->Tick(kInitialTickTime); |
| 450 player_impl_->UpdateState(true, events.get()); | 450 player_impl_->UpdateState(true, events.get()); |
| 451 EXPECT_EQ(1u, events->events_.size()); | 451 EXPECT_EQ(1u, events->events_.size()); |
| 452 player_->NotifyAnimationStarted(events->events_[0]); | 452 player_->NotifyAnimationStarted(events->events_[0]); |
| 453 | 453 |
| 454 EXPECT_EQ(1u, host->active_players_for_testing().size()); | 454 EXPECT_EQ(1u, host->ticking_players_for_testing().size()); |
| 455 EXPECT_EQ(1u, host_impl->active_players_for_testing().size()); | 455 EXPECT_EQ(1u, host_impl->ticking_players_for_testing().size()); |
| 456 | 456 |
| 457 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 457 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 458 player_->UpdateState(true, nullptr); | 458 player_->UpdateState(true, nullptr); |
| 459 EXPECT_EQ(1u, host->active_players_for_testing().size()); | 459 EXPECT_EQ(1u, host->ticking_players_for_testing().size()); |
| 460 | 460 |
| 461 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 461 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 462 player_->UpdateState(true, nullptr); | 462 player_->UpdateState(true, nullptr); |
| 463 EXPECT_EQ(Animation::FINISHED, | 463 EXPECT_EQ(Animation::FINISHED, |
| 464 player_->GetAnimation(TargetProperty::OPACITY)->run_state()); | 464 player_->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 465 EXPECT_EQ(1u, host->active_players_for_testing().size()); | 465 EXPECT_EQ(1u, host->ticking_players_for_testing().size()); |
| 466 | 466 |
| 467 events = CreateEventsForTesting(); | 467 events = CreateEventsForTesting(); |
| 468 | 468 |
| 469 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); | 469 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); |
| 470 player_impl_->UpdateState(true, events.get()); | 470 player_impl_->UpdateState(true, events.get()); |
| 471 | 471 |
| 472 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 472 EXPECT_EQ(Animation::WAITING_FOR_DELETION, |
| 473 player_impl_->GetAnimation(TargetProperty::OPACITY)->run_state()); | 473 player_impl_->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 474 // The impl thread animations should have de-activated. | 474 // The impl thread animations should have de-activated. |
| 475 EXPECT_EQ(0u, host_impl->active_players_for_testing().size()); | 475 EXPECT_EQ(0u, host_impl->ticking_players_for_testing().size()); |
| 476 | 476 |
| 477 EXPECT_EQ(1u, events->events_.size()); | 477 EXPECT_EQ(1u, events->events_.size()); |
| 478 player_->NotifyAnimationFinished(events->events_[0]); | 478 player_->NotifyAnimationFinished(events->events_[0]); |
| 479 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); | 479 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); |
| 480 player_->UpdateState(true, nullptr); | 480 player_->UpdateState(true, nullptr); |
| 481 | 481 |
| 482 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 482 EXPECT_EQ(Animation::WAITING_FOR_DELETION, |
| 483 player_->GetAnimation(TargetProperty::OPACITY)->run_state()); | 483 player_->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 484 // The main thread animations should have de-activated. | 484 // The main thread animations should have de-activated. |
| 485 EXPECT_EQ(0u, host->active_players_for_testing().size()); | 485 EXPECT_EQ(0u, host->ticking_players_for_testing().size()); |
| 486 | 486 |
| 487 PushProperties(); | 487 PushProperties(); |
| 488 player_impl_->ActivateAnimations(); | 488 player_impl_->ActivateAnimations(); |
| 489 EXPECT_FALSE(player_->has_any_animation()); | 489 EXPECT_FALSE(player_->has_any_animation()); |
| 490 EXPECT_FALSE(player_impl_->has_any_animation()); | 490 EXPECT_FALSE(player_impl_->has_any_animation()); |
| 491 EXPECT_EQ(0u, host->active_players_for_testing().size()); | 491 EXPECT_EQ(0u, host->ticking_players_for_testing().size()); |
| 492 EXPECT_EQ(0u, host_impl->active_players_for_testing().size()); | 492 EXPECT_EQ(0u, host_impl->ticking_players_for_testing().size()); |
| 493 } | 493 } |
| 494 | 494 |
| 495 TEST_F(ElementAnimationsTest, SyncPause) { | 495 TEST_F(ElementAnimationsTest, SyncPause) { |
| 496 CreateTestLayer(true, false); | 496 CreateTestLayer(true, false); |
| 497 AttachTimelinePlayerLayer(); | 497 AttachTimelinePlayerLayer(); |
| 498 CreateImplTimelineAndPlayer(); | 498 CreateImplTimelineAndPlayer(); |
| 499 | 499 |
| 500 EXPECT_FALSE(player_impl_->GetAnimation(TargetProperty::OPACITY)); | 500 EXPECT_FALSE(player_impl_->GetAnimation(TargetProperty::OPACITY)); |
| 501 | 501 |
| 502 // Two steps, three ranges: [0-1) -> 0.2, [1-2) -> 0.3, [2-3] -> 0.4. | 502 // Two steps, three ranges: [0-1) -> 0.2, [1-2) -> 0.3, [2-3] -> 0.4. |
| 503 const double duration = 3.0; | 503 const double duration = 3.0; |
| 504 const int animation_id = | 504 const int animation_id = |
| 505 AddOpacityStepsToPlayer(player_.get(), duration, 0.2f, 0.4f, 2); | 505 AddOpacityStepsToPlayer(player_.get(), duration, 0.2f, 0.4f, 2); |
| 506 | 506 |
| 507 // Set start offset to be at the beginning of the second range. | 507 // Set start offset to be at the beginning of the second range. |
| 508 player_->GetAnimationById(animation_id) | 508 player_->GetAnimationById(animation_id) |
| 509 ->set_time_offset(TimeDelta::FromSecondsD(1.01)); | 509 ->set_time_offset(TimeDelta::FromSecondsD(1.01)); |
| 510 | 510 |
| 511 PushProperties(); | 511 PushProperties(); |
| 512 player_impl_->ActivateAnimations(); | 512 player_impl_->ActivateAnimations(); |
| 513 | 513 |
| 514 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); | 514 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); |
| 515 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 515 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 516 player_impl_->GetAnimationById(animation_id)->run_state()); | 516 player_impl_->GetAnimationById(animation_id)->run_state()); |
| 517 | 517 |
| 518 TimeTicks time = kInitialTickTime; | 518 TimeTicks time = kInitialTickTime; |
| 519 | 519 |
| 520 // Start the animations on each animations. | 520 // Start the animations on each animations. |
| 521 auto events = CreateEventsForTesting(); | 521 auto events = CreateEventsForTesting(); |
| 522 player_impl_->Animate(time); | 522 player_impl_->Tick(time); |
| 523 player_impl_->UpdateState(true, events.get()); | 523 player_impl_->UpdateState(true, events.get()); |
| 524 EXPECT_EQ(1u, events->events_.size()); | 524 EXPECT_EQ(1u, events->events_.size()); |
| 525 | 525 |
| 526 player_->Animate(time); | 526 player_->Tick(time); |
| 527 player_->UpdateState(true, nullptr); | 527 player_->UpdateState(true, nullptr); |
| 528 player_->NotifyAnimationStarted(events->events_[0]); | 528 player_->NotifyAnimationStarted(events->events_[0]); |
| 529 | 529 |
| 530 EXPECT_EQ(Animation::RUNNING, | 530 EXPECT_EQ(Animation::RUNNING, |
| 531 player_impl_->GetAnimationById(animation_id)->run_state()); | 531 player_impl_->GetAnimationById(animation_id)->run_state()); |
| 532 EXPECT_EQ(Animation::RUNNING, | 532 EXPECT_EQ(Animation::RUNNING, |
| 533 player_->GetAnimationById(animation_id)->run_state()); | 533 player_->GetAnimationById(animation_id)->run_state()); |
| 534 | 534 |
| 535 EXPECT_EQ(0.3f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 535 EXPECT_EQ(0.3f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 536 EXPECT_EQ(0.3f, | 536 EXPECT_EQ(0.3f, |
| 537 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 537 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 538 | 538 |
| 539 EXPECT_EQ(kInitialTickTime, | 539 EXPECT_EQ(kInitialTickTime, |
| 540 player_->GetAnimationById(animation_id)->start_time()); | 540 player_->GetAnimationById(animation_id)->start_time()); |
| 541 EXPECT_EQ(kInitialTickTime, | 541 EXPECT_EQ(kInitialTickTime, |
| 542 player_impl_->GetAnimationById(animation_id)->start_time()); | 542 player_impl_->GetAnimationById(animation_id)->start_time()); |
| 543 | 543 |
| 544 // Pause the animation at the middle of the second range so the offset | 544 // Pause the animation at the middle of the second range so the offset |
| 545 // delays animation until the middle of the third range. | 545 // delays animation until the middle of the third range. |
| 546 player_->PauseAnimation(animation_id, 1.5); | 546 player_->PauseAnimation(animation_id, 1.5); |
| 547 EXPECT_EQ(Animation::PAUSED, | 547 EXPECT_EQ(Animation::PAUSED, |
| 548 player_->GetAnimationById(animation_id)->run_state()); | 548 player_->GetAnimationById(animation_id)->run_state()); |
| 549 | 549 |
| 550 // The pause run state change should make it to the impl thread animations. | 550 // The pause run state change should make it to the impl thread animations. |
| 551 PushProperties(); | 551 PushProperties(); |
| 552 player_impl_->ActivateAnimations(); | 552 player_impl_->ActivateAnimations(); |
| 553 | 553 |
| 554 // Advance time so it stays within the first range. | 554 // Advance time so it stays within the first range. |
| 555 time += TimeDelta::FromMilliseconds(10); | 555 time += TimeDelta::FromMilliseconds(10); |
| 556 player_->Animate(time); | 556 player_->Tick(time); |
| 557 player_impl_->Animate(time); | 557 player_impl_->Tick(time); |
| 558 | 558 |
| 559 EXPECT_EQ(Animation::PAUSED, | 559 EXPECT_EQ(Animation::PAUSED, |
| 560 player_impl_->GetAnimationById(animation_id)->run_state()); | 560 player_impl_->GetAnimationById(animation_id)->run_state()); |
| 561 | 561 |
| 562 // Opacity value doesn't depend on time if paused at specified time offset. | 562 // Opacity value doesn't depend on time if paused at specified time offset. |
| 563 EXPECT_EQ(0.4f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 563 EXPECT_EQ(0.4f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 564 EXPECT_EQ(0.4f, | 564 EXPECT_EQ(0.4f, |
| 565 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 565 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 566 } | 566 } |
| 567 | 567 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 578 AddOpacityTransitionToPlayer(player_.get(), 1, 0, 1, false); | 578 AddOpacityTransitionToPlayer(player_.get(), 1, 0, 1, false); |
| 579 | 579 |
| 580 PushProperties(); | 580 PushProperties(); |
| 581 player_impl_->ActivateAnimations(); | 581 player_impl_->ActivateAnimations(); |
| 582 | 582 |
| 583 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); | 583 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); |
| 584 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 584 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 585 player_impl_->GetAnimationById(animation_id)->run_state()); | 585 player_impl_->GetAnimationById(animation_id)->run_state()); |
| 586 | 586 |
| 587 events = CreateEventsForTesting(); | 587 events = CreateEventsForTesting(); |
| 588 player_impl_->Animate(kInitialTickTime); | 588 player_impl_->Tick(kInitialTickTime); |
| 589 player_impl_->UpdateState(true, events.get()); | 589 player_impl_->UpdateState(true, events.get()); |
| 590 EXPECT_EQ(1u, events->events_.size()); | 590 EXPECT_EQ(1u, events->events_.size()); |
| 591 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); | 591 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); |
| 592 | 592 |
| 593 // Notify main thread animations that the animation has started. | 593 // Notify main thread animations that the animation has started. |
| 594 player_->NotifyAnimationStarted(events->events_[0]); | 594 player_->NotifyAnimationStarted(events->events_[0]); |
| 595 | 595 |
| 596 // Complete animation on impl thread. | 596 // Complete animation on impl thread. |
| 597 events = CreateEventsForTesting(); | 597 events = CreateEventsForTesting(); |
| 598 player_impl_->Animate(kInitialTickTime + TimeDelta::FromSeconds(1)); | 598 player_impl_->Tick(kInitialTickTime + TimeDelta::FromSeconds(1)); |
| 599 player_impl_->UpdateState(true, events.get()); | 599 player_impl_->UpdateState(true, events.get()); |
| 600 EXPECT_EQ(1u, events->events_.size()); | 600 EXPECT_EQ(1u, events->events_.size()); |
| 601 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); | 601 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); |
| 602 | 602 |
| 603 player_->NotifyAnimationFinished(events->events_[0]); | 603 player_->NotifyAnimationFinished(events->events_[0]); |
| 604 | 604 |
| 605 player_->Animate(kInitialTickTime + TimeDelta::FromSeconds(2)); | 605 player_->Tick(kInitialTickTime + TimeDelta::FromSeconds(2)); |
| 606 player_->UpdateState(true, nullptr); | 606 player_->UpdateState(true, nullptr); |
| 607 | 607 |
| 608 PushProperties(); | 608 PushProperties(); |
| 609 player_impl_->ActivateAnimations(); | 609 player_impl_->ActivateAnimations(); |
| 610 EXPECT_FALSE(player_->GetAnimationById(animation_id)); | 610 EXPECT_FALSE(player_->GetAnimationById(animation_id)); |
| 611 EXPECT_FALSE(player_impl_->GetAnimationById(animation_id)); | 611 EXPECT_FALSE(player_impl_->GetAnimationById(animation_id)); |
| 612 } | 612 } |
| 613 | 613 |
| 614 // Ensure that a finished animation is eventually deleted by both the | 614 // Ensure that a finished animation is eventually deleted by both the |
| 615 // main-thread and the impl-thread animationss. | 615 // main-thread and the impl-thread animationss. |
| 616 TEST_F(ElementAnimationsTest, AnimationsAreDeleted) { | 616 TEST_F(ElementAnimationsTest, AnimationsAreDeleted) { |
| 617 CreateTestLayer(true, false); | 617 CreateTestLayer(true, false); |
| 618 AttachTimelinePlayerLayer(); | 618 AttachTimelinePlayerLayer(); |
| 619 CreateImplTimelineAndPlayer(); | 619 CreateImplTimelineAndPlayer(); |
| 620 | 620 |
| 621 auto events = CreateEventsForTesting(); | 621 auto events = CreateEventsForTesting(); |
| 622 | 622 |
| 623 AddOpacityTransitionToPlayer(player_.get(), 1.0, 0.0f, 1.0f, false); | 623 AddOpacityTransitionToPlayer(player_.get(), 1.0, 0.0f, 1.0f, false); |
| 624 player_->Animate(kInitialTickTime); | 624 player_->Tick(kInitialTickTime); |
| 625 player_->UpdateState(true, nullptr); | 625 player_->UpdateState(true, nullptr); |
| 626 EXPECT_TRUE(player_->needs_push_properties()); | 626 EXPECT_TRUE(player_->needs_push_properties()); |
| 627 | 627 |
| 628 PushProperties(); | 628 PushProperties(); |
| 629 EXPECT_FALSE(player_->needs_push_properties()); | 629 EXPECT_FALSE(player_->needs_push_properties()); |
| 630 | 630 |
| 631 EXPECT_FALSE(host_->needs_push_properties()); | 631 EXPECT_FALSE(host_->needs_push_properties()); |
| 632 EXPECT_FALSE(host_impl_->needs_push_properties()); | 632 EXPECT_FALSE(host_impl_->needs_push_properties()); |
| 633 | 633 |
| 634 player_impl_->ActivateAnimations(); | 634 player_impl_->ActivateAnimations(); |
| 635 | 635 |
| 636 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 636 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 637 player_impl_->UpdateState(true, events.get()); | 637 player_impl_->UpdateState(true, events.get()); |
| 638 | 638 |
| 639 // There should be a STARTED event for the animation. | 639 // There should be a STARTED event for the animation. |
| 640 EXPECT_EQ(1u, events->events_.size()); | 640 EXPECT_EQ(1u, events->events_.size()); |
| 641 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); | 641 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); |
| 642 player_->NotifyAnimationStarted(events->events_[0]); | 642 player_->NotifyAnimationStarted(events->events_[0]); |
| 643 | 643 |
| 644 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 644 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 645 player_->UpdateState(true, nullptr); | 645 player_->UpdateState(true, nullptr); |
| 646 | 646 |
| 647 EXPECT_FALSE(host_->needs_push_properties()); | 647 EXPECT_FALSE(host_->needs_push_properties()); |
| 648 EXPECT_FALSE(host_impl_->needs_push_properties()); | 648 EXPECT_FALSE(host_impl_->needs_push_properties()); |
| 649 | 649 |
| 650 events = CreateEventsForTesting(); | 650 events = CreateEventsForTesting(); |
| 651 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 651 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 652 player_impl_->UpdateState(true, events.get()); | 652 player_impl_->UpdateState(true, events.get()); |
| 653 | 653 |
| 654 EXPECT_TRUE(host_impl_->needs_push_properties()); | 654 EXPECT_TRUE(host_impl_->needs_push_properties()); |
| 655 | 655 |
| 656 // There should be a FINISHED event for the animation. | 656 // There should be a FINISHED event for the animation. |
| 657 EXPECT_EQ(1u, events->events_.size()); | 657 EXPECT_EQ(1u, events->events_.size()); |
| 658 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); | 658 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); |
| 659 | 659 |
| 660 // Neither animations should have deleted the animation yet. | 660 // Neither animations should have deleted the animation yet. |
| 661 EXPECT_TRUE(player_->GetAnimation(TargetProperty::OPACITY)); | 661 EXPECT_TRUE(player_->GetAnimation(TargetProperty::OPACITY)); |
| 662 EXPECT_TRUE(player_impl_->GetAnimation(TargetProperty::OPACITY)); | 662 EXPECT_TRUE(player_impl_->GetAnimation(TargetProperty::OPACITY)); |
| 663 | 663 |
| 664 player_->NotifyAnimationFinished(events->events_[0]); | 664 player_->NotifyAnimationFinished(events->events_[0]); |
| 665 | 665 |
| 666 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); | 666 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
| 667 player_->UpdateState(true, nullptr); | 667 player_->UpdateState(true, nullptr); |
| 668 EXPECT_TRUE(host_->needs_push_properties()); | 668 EXPECT_TRUE(host_->needs_push_properties()); |
| 669 | 669 |
| 670 PushProperties(); | 670 PushProperties(); |
| 671 | 671 |
| 672 // Both animationss should now have deleted the animation. The impl animations | 672 // Both animationss should now have deleted the animation. The impl animations |
| 673 // should have deleted the animation even though activation has not occurred, | 673 // should have deleted the animation even though activation has not occurred, |
| 674 // since the animation was already waiting for deletion when | 674 // since the animation was already waiting for deletion when |
| 675 // PushPropertiesTo was called. | 675 // PushPropertiesTo was called. |
| 676 EXPECT_FALSE(player_->has_any_animation()); | 676 EXPECT_FALSE(player_->has_any_animation()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 702 | 702 |
| 703 auto events = CreateEventsForTesting(); | 703 auto events = CreateEventsForTesting(); |
| 704 | 704 |
| 705 std::unique_ptr<Animation> to_add(CreateAnimation( | 705 std::unique_ptr<Animation> to_add(CreateAnimation( |
| 706 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 706 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 707 1, TargetProperty::OPACITY)); | 707 1, TargetProperty::OPACITY)); |
| 708 | 708 |
| 709 EXPECT_FALSE(player_->needs_to_start_animations()); | 709 EXPECT_FALSE(player_->needs_to_start_animations()); |
| 710 player_->AddAnimation(std::move(to_add)); | 710 player_->AddAnimation(std::move(to_add)); |
| 711 EXPECT_TRUE(player_->needs_to_start_animations()); | 711 EXPECT_TRUE(player_->needs_to_start_animations()); |
| 712 player_->Animate(kInitialTickTime); | 712 player_->Tick(kInitialTickTime); |
| 713 EXPECT_FALSE(player_->needs_to_start_animations()); | 713 EXPECT_FALSE(player_->needs_to_start_animations()); |
| 714 player_->UpdateState(true, events.get()); | 714 player_->UpdateState(true, events.get()); |
| 715 EXPECT_TRUE(player_->HasActiveAnimation()); | 715 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 716 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 716 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 717 // A non-impl-only animation should not generate property updates. | 717 // A non-impl-only animation should not generate property updates. |
| 718 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 718 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 719 EXPECT_FALSE(event); | 719 EXPECT_FALSE(event); |
| 720 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 720 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 721 player_->UpdateState(true, events.get()); | 721 player_->UpdateState(true, events.get()); |
| 722 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 722 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 723 EXPECT_FALSE(player_->HasActiveAnimation()); | 723 EXPECT_FALSE(player_->HasTickingAnimation()); |
| 724 event = GetMostRecentPropertyUpdateEvent(events.get()); | 724 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 725 EXPECT_FALSE(event); | 725 EXPECT_FALSE(event); |
| 726 } | 726 } |
| 727 | 727 |
| 728 TEST_F(ElementAnimationsTest, FilterTransition) { | 728 TEST_F(ElementAnimationsTest, FilterTransition) { |
| 729 CreateTestLayer(true, false); | 729 CreateTestLayer(true, false); |
| 730 AttachTimelinePlayerLayer(); | 730 AttachTimelinePlayerLayer(); |
| 731 | 731 |
| 732 auto events = CreateEventsForTesting(); | 732 auto events = CreateEventsForTesting(); |
| 733 | 733 |
| 734 std::unique_ptr<KeyframedFilterAnimationCurve> curve( | 734 std::unique_ptr<KeyframedFilterAnimationCurve> curve( |
| 735 KeyframedFilterAnimationCurve::Create()); | 735 KeyframedFilterAnimationCurve::Create()); |
| 736 | 736 |
| 737 FilterOperations start_filters; | 737 FilterOperations start_filters; |
| 738 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); | 738 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); |
| 739 curve->AddKeyframe( | 739 curve->AddKeyframe( |
| 740 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); | 740 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); |
| 741 FilterOperations end_filters; | 741 FilterOperations end_filters; |
| 742 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); | 742 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); |
| 743 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), | 743 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), |
| 744 end_filters, nullptr)); | 744 end_filters, nullptr)); |
| 745 | 745 |
| 746 std::unique_ptr<Animation> animation( | 746 std::unique_ptr<Animation> animation( |
| 747 Animation::Create(std::move(curve), 1, 0, TargetProperty::FILTER)); | 747 Animation::Create(std::move(curve), 1, 0, TargetProperty::FILTER)); |
| 748 player_->AddAnimation(std::move(animation)); | 748 player_->AddAnimation(std::move(animation)); |
| 749 | 749 |
| 750 player_->Animate(kInitialTickTime); | 750 player_->Tick(kInitialTickTime); |
| 751 player_->UpdateState(true, events.get()); | 751 player_->UpdateState(true, events.get()); |
| 752 EXPECT_TRUE(player_->HasActiveAnimation()); | 752 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 753 EXPECT_EQ(start_filters, | 753 EXPECT_EQ(start_filters, |
| 754 client_.GetFilters(element_id_, ElementListType::ACTIVE)); | 754 client_.GetFilters(element_id_, ElementListType::ACTIVE)); |
| 755 // A non-impl-only animation should not generate property updates. | 755 // A non-impl-only animation should not generate property updates. |
| 756 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 756 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 757 EXPECT_FALSE(event); | 757 EXPECT_FALSE(event); |
| 758 | 758 |
| 759 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 759 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 760 player_->UpdateState(true, events.get()); | 760 player_->UpdateState(true, events.get()); |
| 761 EXPECT_EQ(1u, | 761 EXPECT_EQ(1u, |
| 762 client_.GetFilters(element_id_, ElementListType::ACTIVE).size()); | 762 client_.GetFilters(element_id_, ElementListType::ACTIVE).size()); |
| 763 EXPECT_EQ(FilterOperation::CreateBrightnessFilter(1.5f), | 763 EXPECT_EQ(FilterOperation::CreateBrightnessFilter(1.5f), |
| 764 client_.GetFilters(element_id_, ElementListType::ACTIVE).at(0)); | 764 client_.GetFilters(element_id_, ElementListType::ACTIVE).at(0)); |
| 765 event = GetMostRecentPropertyUpdateEvent(events.get()); | 765 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 766 EXPECT_FALSE(event); | 766 EXPECT_FALSE(event); |
| 767 | 767 |
| 768 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 768 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 769 player_->UpdateState(true, events.get()); | 769 player_->UpdateState(true, events.get()); |
| 770 EXPECT_EQ(end_filters, | 770 EXPECT_EQ(end_filters, |
| 771 client_.GetFilters(element_id_, ElementListType::ACTIVE)); | 771 client_.GetFilters(element_id_, ElementListType::ACTIVE)); |
| 772 EXPECT_FALSE(player_->HasActiveAnimation()); | 772 EXPECT_FALSE(player_->HasTickingAnimation()); |
| 773 event = GetMostRecentPropertyUpdateEvent(events.get()); | 773 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 774 EXPECT_FALSE(event); | 774 EXPECT_FALSE(event); |
| 775 } | 775 } |
| 776 | 776 |
| 777 TEST_F(ElementAnimationsTest, ScrollOffsetTransition) { | 777 TEST_F(ElementAnimationsTest, ScrollOffsetTransition) { |
| 778 CreateTestLayer(true, false); | 778 CreateTestLayer(true, false); |
| 779 AttachTimelinePlayerLayer(); | 779 AttachTimelinePlayerLayer(); |
| 780 CreateImplTimelineAndPlayer(); | 780 CreateImplTimelineAndPlayer(); |
| 781 | 781 |
| 782 auto events = CreateEventsForTesting(); | 782 auto events = CreateEventsForTesting(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 797 PushProperties(); | 797 PushProperties(); |
| 798 player_impl_->ActivateAnimations(); | 798 player_impl_->ActivateAnimations(); |
| 799 EXPECT_TRUE(player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET)); | 799 EXPECT_TRUE(player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET)); |
| 800 TimeDelta duration = player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET) | 800 TimeDelta duration = player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| 801 ->curve() | 801 ->curve() |
| 802 ->Duration(); | 802 ->Duration(); |
| 803 EXPECT_EQ(duration, player_->GetAnimation(TargetProperty::SCROLL_OFFSET) | 803 EXPECT_EQ(duration, player_->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| 804 ->curve() | 804 ->curve() |
| 805 ->Duration()); | 805 ->Duration()); |
| 806 | 806 |
| 807 player_->Animate(kInitialTickTime); | 807 player_->Tick(kInitialTickTime); |
| 808 player_->UpdateState(true, nullptr); | 808 player_->UpdateState(true, nullptr); |
| 809 EXPECT_TRUE(player_->HasActiveAnimation()); | 809 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 810 EXPECT_EQ(initial_value, | 810 EXPECT_EQ(initial_value, |
| 811 client_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); | 811 client_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); |
| 812 | 812 |
| 813 player_impl_->Animate(kInitialTickTime); | 813 player_impl_->Tick(kInitialTickTime); |
| 814 player_impl_->UpdateState(true, events.get()); | 814 player_impl_->UpdateState(true, events.get()); |
| 815 EXPECT_TRUE(player_impl_->HasActiveAnimation()); | 815 EXPECT_TRUE(player_impl_->HasTickingAnimation()); |
| 816 EXPECT_EQ(initial_value, | 816 EXPECT_EQ(initial_value, |
| 817 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); | 817 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); |
| 818 // Scroll offset animations should not generate property updates. | 818 // Scroll offset animations should not generate property updates. |
| 819 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 819 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 820 EXPECT_FALSE(event); | 820 EXPECT_FALSE(event); |
| 821 | 821 |
| 822 player_->NotifyAnimationStarted(events->events_[0]); | 822 player_->NotifyAnimationStarted(events->events_[0]); |
| 823 player_->Animate(kInitialTickTime + duration / 2); | 823 player_->Tick(kInitialTickTime + duration / 2); |
| 824 player_->UpdateState(true, nullptr); | 824 player_->UpdateState(true, nullptr); |
| 825 EXPECT_TRUE(player_->HasActiveAnimation()); | 825 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 826 EXPECT_VECTOR2DF_EQ( | 826 EXPECT_VECTOR2DF_EQ( |
| 827 gfx::Vector2dF(200.f, 250.f), | 827 gfx::Vector2dF(200.f, 250.f), |
| 828 client_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); | 828 client_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); |
| 829 | 829 |
| 830 player_impl_->Animate(kInitialTickTime + duration / 2); | 830 player_impl_->Tick(kInitialTickTime + duration / 2); |
| 831 player_impl_->UpdateState(true, events.get()); | 831 player_impl_->UpdateState(true, events.get()); |
| 832 EXPECT_VECTOR2DF_EQ( | 832 EXPECT_VECTOR2DF_EQ( |
| 833 gfx::Vector2dF(200.f, 250.f), | 833 gfx::Vector2dF(200.f, 250.f), |
| 834 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); | 834 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); |
| 835 event = GetMostRecentPropertyUpdateEvent(events.get()); | 835 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 836 EXPECT_FALSE(event); | 836 EXPECT_FALSE(event); |
| 837 | 837 |
| 838 player_impl_->Animate(kInitialTickTime + duration); | 838 player_impl_->Tick(kInitialTickTime + duration); |
| 839 player_impl_->UpdateState(true, events.get()); | 839 player_impl_->UpdateState(true, events.get()); |
| 840 EXPECT_VECTOR2DF_EQ(target_value, client_impl_.GetScrollOffset( | 840 EXPECT_VECTOR2DF_EQ(target_value, client_impl_.GetScrollOffset( |
| 841 element_id_, ElementListType::ACTIVE)); | 841 element_id_, ElementListType::ACTIVE)); |
| 842 EXPECT_FALSE(player_impl_->HasActiveAnimation()); | 842 EXPECT_FALSE(player_impl_->HasTickingAnimation()); |
| 843 event = GetMostRecentPropertyUpdateEvent(events.get()); | 843 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 844 EXPECT_FALSE(event); | 844 EXPECT_FALSE(event); |
| 845 | 845 |
| 846 player_->Animate(kInitialTickTime + duration); | 846 player_->Tick(kInitialTickTime + duration); |
| 847 player_->UpdateState(true, nullptr); | 847 player_->UpdateState(true, nullptr); |
| 848 EXPECT_VECTOR2DF_EQ(target_value, client_.GetScrollOffset( | 848 EXPECT_VECTOR2DF_EQ(target_value, client_.GetScrollOffset( |
| 849 element_id_, ElementListType::ACTIVE)); | 849 element_id_, ElementListType::ACTIVE)); |
| 850 EXPECT_FALSE(player_->HasActiveAnimation()); | 850 EXPECT_FALSE(player_->HasTickingAnimation()); |
| 851 } | 851 } |
| 852 | 852 |
| 853 TEST_F(ElementAnimationsTest, ScrollOffsetTransitionOnImplOnly) { | 853 TEST_F(ElementAnimationsTest, ScrollOffsetTransitionOnImplOnly) { |
| 854 CreateTestLayer(true, false); | 854 CreateTestLayer(true, false); |
| 855 AttachTimelinePlayerLayer(); | 855 AttachTimelinePlayerLayer(); |
| 856 CreateImplTimelineAndPlayer(); | 856 CreateImplTimelineAndPlayer(); |
| 857 | 857 |
| 858 auto events = CreateEventsForTesting(); | 858 auto events = CreateEventsForTesting(); |
| 859 | 859 |
| 860 gfx::ScrollOffset initial_value(100.f, 300.f); | 860 gfx::ScrollOffset initial_value(100.f, 300.f); |
| 861 gfx::ScrollOffset target_value(300.f, 200.f); | 861 gfx::ScrollOffset target_value(300.f, 200.f); |
| 862 std::unique_ptr<ScrollOffsetAnimationCurve> curve( | 862 std::unique_ptr<ScrollOffsetAnimationCurve> curve( |
| 863 ScrollOffsetAnimationCurve::Create( | 863 ScrollOffsetAnimationCurve::Create( |
| 864 target_value, CubicBezierTimingFunction::CreatePreset( | 864 target_value, CubicBezierTimingFunction::CreatePreset( |
| 865 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); | 865 CubicBezierTimingFunction::EaseType::EASE_IN_OUT))); |
| 866 curve->SetInitialValue(initial_value); | 866 curve->SetInitialValue(initial_value); |
| 867 double duration_in_seconds = curve->Duration().InSecondsF(); | 867 double duration_in_seconds = curve->Duration().InSecondsF(); |
| 868 | 868 |
| 869 std::unique_ptr<Animation> animation( | 869 std::unique_ptr<Animation> animation( |
| 870 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); | 870 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); |
| 871 animation->set_is_impl_only(true); | 871 animation->set_is_impl_only(true); |
| 872 player_impl_->AddAnimation(std::move(animation)); | 872 player_impl_->AddAnimation(std::move(animation)); |
| 873 | 873 |
| 874 player_impl_->Animate(kInitialTickTime); | 874 player_impl_->Tick(kInitialTickTime); |
| 875 player_impl_->UpdateState(true, events.get()); | 875 player_impl_->UpdateState(true, events.get()); |
| 876 EXPECT_TRUE(player_impl_->HasActiveAnimation()); | 876 EXPECT_TRUE(player_impl_->HasTickingAnimation()); |
| 877 EXPECT_EQ(initial_value, | 877 EXPECT_EQ(initial_value, |
| 878 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); | 878 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); |
| 879 // Scroll offset animations should not generate property updates. | 879 // Scroll offset animations should not generate property updates. |
| 880 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 880 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 881 EXPECT_FALSE(event); | 881 EXPECT_FALSE(event); |
| 882 | 882 |
| 883 TimeDelta duration = TimeDelta::FromMicroseconds( | 883 TimeDelta duration = TimeDelta::FromMicroseconds( |
| 884 duration_in_seconds * base::Time::kMicrosecondsPerSecond); | 884 duration_in_seconds * base::Time::kMicrosecondsPerSecond); |
| 885 | 885 |
| 886 player_impl_->Animate(kInitialTickTime + duration / 2); | 886 player_impl_->Tick(kInitialTickTime + duration / 2); |
| 887 player_impl_->UpdateState(true, events.get()); | 887 player_impl_->UpdateState(true, events.get()); |
| 888 EXPECT_VECTOR2DF_EQ( | 888 EXPECT_VECTOR2DF_EQ( |
| 889 gfx::Vector2dF(200.f, 250.f), | 889 gfx::Vector2dF(200.f, 250.f), |
| 890 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); | 890 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); |
| 891 event = GetMostRecentPropertyUpdateEvent(events.get()); | 891 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 892 EXPECT_FALSE(event); | 892 EXPECT_FALSE(event); |
| 893 | 893 |
| 894 player_impl_->Animate(kInitialTickTime + duration); | 894 player_impl_->Tick(kInitialTickTime + duration); |
| 895 player_impl_->UpdateState(true, events.get()); | 895 player_impl_->UpdateState(true, events.get()); |
| 896 EXPECT_VECTOR2DF_EQ(target_value, client_impl_.GetScrollOffset( | 896 EXPECT_VECTOR2DF_EQ(target_value, client_impl_.GetScrollOffset( |
| 897 element_id_, ElementListType::ACTIVE)); | 897 element_id_, ElementListType::ACTIVE)); |
| 898 EXPECT_FALSE(player_impl_->HasActiveAnimation()); | 898 EXPECT_FALSE(player_impl_->HasTickingAnimation()); |
| 899 event = GetMostRecentPropertyUpdateEvent(events.get()); | 899 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 900 EXPECT_FALSE(event); | 900 EXPECT_FALSE(event); |
| 901 } | 901 } |
| 902 | 902 |
| 903 // This test verifies that if an animation is added after a layer is animated, | 903 // This test verifies that if an animation is added after a layer is animated, |
| 904 // it doesn't get promoted to be in the RUNNING state. This prevents cases where | 904 // it doesn't get promoted to be in the RUNNING state. This prevents cases where |
| 905 // a start time gets set on an animation using the stale value of | 905 // a start time gets set on an animation using the stale value of |
| 906 // last_tick_time_. | 906 // last_tick_time_. |
| 907 TEST_F(ElementAnimationsTest, UpdateStateWithoutAnimate) { | 907 TEST_F(ElementAnimationsTest, UpdateStateWithoutAnimate) { |
| 908 CreateTestLayer(true, false); | 908 CreateTestLayer(true, false); |
| 909 AttachTimelinePlayerLayer(); | 909 AttachTimelinePlayerLayer(); |
| 910 CreateImplTimelineAndPlayer(); | 910 CreateImplTimelineAndPlayer(); |
| 911 | 911 |
| 912 auto events = CreateEventsForTesting(); | 912 auto events = CreateEventsForTesting(); |
| 913 | 913 |
| 914 // Add first scroll offset animation. | 914 // Add first scroll offset animation. |
| 915 AddScrollOffsetAnimationToPlayer(player_impl_.get(), | 915 AddScrollOffsetAnimationToPlayer(player_impl_.get(), |
| 916 gfx::ScrollOffset(100.f, 300.f), | 916 gfx::ScrollOffset(100.f, 300.f), |
| 917 gfx::ScrollOffset(100.f, 200.f), true); | 917 gfx::ScrollOffset(100.f, 200.f), true); |
| 918 | 918 |
| 919 // Calling UpdateState after Animate should promote the animation to running | 919 // Calling UpdateState after Animate should promote the animation to running |
| 920 // state. | 920 // state. |
| 921 player_impl_->Animate(kInitialTickTime); | 921 player_impl_->Tick(kInitialTickTime); |
| 922 player_impl_->UpdateState(true, events.get()); | 922 player_impl_->UpdateState(true, events.get()); |
| 923 EXPECT_EQ( | 923 EXPECT_EQ( |
| 924 Animation::RUNNING, | 924 Animation::RUNNING, |
| 925 player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET)->run_state()); | 925 player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET)->run_state()); |
| 926 | 926 |
| 927 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); | 927 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); |
| 928 player_impl_->UpdateState(true, events.get()); | 928 player_impl_->UpdateState(true, events.get()); |
| 929 EXPECT_EQ( | 929 EXPECT_EQ( |
| 930 Animation::WAITING_FOR_DELETION, | 930 Animation::WAITING_FOR_DELETION, |
| 931 player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET)->run_state()); | 931 player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET)->run_state()); |
| 932 | 932 |
| 933 // Add second scroll offset animation. | 933 // Add second scroll offset animation. |
| 934 AddScrollOffsetAnimationToPlayer(player_impl_.get(), | 934 AddScrollOffsetAnimationToPlayer(player_impl_.get(), |
| 935 gfx::ScrollOffset(100.f, 200.f), | 935 gfx::ScrollOffset(100.f, 200.f), |
| 936 gfx::ScrollOffset(100.f, 100.f), true); | 936 gfx::ScrollOffset(100.f, 100.f), true); |
| 937 | 937 |
| 938 // Calling UpdateState without Animate should NOT promote the animation to | 938 // Calling UpdateState without Animate should NOT promote the animation to |
| 939 // running state. | 939 // running state. |
| 940 player_impl_->UpdateState(true, events.get()); | 940 player_impl_->UpdateState(true, events.get()); |
| 941 EXPECT_EQ( | 941 EXPECT_EQ( |
| 942 Animation::WAITING_FOR_TARGET_AVAILABILITY, | 942 Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 943 player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET)->run_state()); | 943 player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET)->run_state()); |
| 944 | 944 |
| 945 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 945 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 946 player_impl_->UpdateState(true, events.get()); | 946 player_impl_->UpdateState(true, events.get()); |
| 947 | 947 |
| 948 EXPECT_EQ( | 948 EXPECT_EQ( |
| 949 Animation::RUNNING, | 949 Animation::RUNNING, |
| 950 player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET)->run_state()); | 950 player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET)->run_state()); |
| 951 EXPECT_VECTOR2DF_EQ( | 951 EXPECT_VECTOR2DF_EQ( |
| 952 gfx::ScrollOffset(100.f, 200.f), | 952 gfx::ScrollOffset(100.f, 200.f), |
| 953 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); | 953 client_impl_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); |
| 954 } | 954 } |
| 955 | 955 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 983 PushProperties(); | 983 PushProperties(); |
| 984 player_impl_->ActivateAnimations(); | 984 player_impl_->ActivateAnimations(); |
| 985 EXPECT_TRUE(player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET)); | 985 EXPECT_TRUE(player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET)); |
| 986 TimeDelta duration = player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET) | 986 TimeDelta duration = player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| 987 ->curve() | 987 ->curve() |
| 988 ->Duration(); | 988 ->Duration(); |
| 989 EXPECT_EQ(duration, player_->GetAnimation(TargetProperty::SCROLL_OFFSET) | 989 EXPECT_EQ(duration, player_->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| 990 ->curve() | 990 ->curve() |
| 991 ->Duration()); | 991 ->Duration()); |
| 992 | 992 |
| 993 player_->Animate(kInitialTickTime); | 993 player_->Tick(kInitialTickTime); |
| 994 player_->UpdateState(true, nullptr); | 994 player_->UpdateState(true, nullptr); |
| 995 | 995 |
| 996 EXPECT_TRUE(player_->HasActiveAnimation()); | 996 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 997 EXPECT_EQ(initial_value, | 997 EXPECT_EQ(initial_value, |
| 998 client_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); | 998 client_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); |
| 999 EXPECT_EQ(gfx::ScrollOffset(), client_impl_.GetScrollOffset( | 999 EXPECT_EQ(gfx::ScrollOffset(), client_impl_.GetScrollOffset( |
| 1000 element_id_, ElementListType::PENDING)); | 1000 element_id_, ElementListType::PENDING)); |
| 1001 | 1001 |
| 1002 player_impl_->Animate(kInitialTickTime); | 1002 player_impl_->Tick(kInitialTickTime); |
| 1003 | 1003 |
| 1004 EXPECT_TRUE(player_impl_->HasActiveAnimation()); | 1004 EXPECT_TRUE(player_impl_->HasTickingAnimation()); |
| 1005 EXPECT_EQ(initial_value, client_impl_.GetScrollOffset( | 1005 EXPECT_EQ(initial_value, client_impl_.GetScrollOffset( |
| 1006 element_id_, ElementListType::PENDING)); | 1006 element_id_, ElementListType::PENDING)); |
| 1007 | 1007 |
| 1008 CreateTestImplLayer(ElementListType::ACTIVE); | 1008 CreateTestImplLayer(ElementListType::ACTIVE); |
| 1009 | 1009 |
| 1010 player_impl_->UpdateState(true, events.get()); | 1010 player_impl_->UpdateState(true, events.get()); |
| 1011 DCHECK_EQ(1UL, events->events_.size()); | 1011 DCHECK_EQ(1UL, events->events_.size()); |
| 1012 | 1012 |
| 1013 // Scroll offset animations should not generate property updates. | 1013 // Scroll offset animations should not generate property updates. |
| 1014 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 1014 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 1015 EXPECT_FALSE(event); | 1015 EXPECT_FALSE(event); |
| 1016 | 1016 |
| 1017 player_->NotifyAnimationStarted(events->events_[0]); | 1017 player_->NotifyAnimationStarted(events->events_[0]); |
| 1018 player_->Animate(kInitialTickTime + duration / 2); | 1018 player_->Tick(kInitialTickTime + duration / 2); |
| 1019 player_->UpdateState(true, nullptr); | 1019 player_->UpdateState(true, nullptr); |
| 1020 EXPECT_TRUE(player_->HasActiveAnimation()); | 1020 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1021 EXPECT_VECTOR2DF_EQ( | 1021 EXPECT_VECTOR2DF_EQ( |
| 1022 gfx::Vector2dF(400.f, 150.f), | 1022 gfx::Vector2dF(400.f, 150.f), |
| 1023 client_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); | 1023 client_.GetScrollOffset(element_id_, ElementListType::ACTIVE)); |
| 1024 | 1024 |
| 1025 player_impl_->Animate(kInitialTickTime + duration / 2); | 1025 player_impl_->Tick(kInitialTickTime + duration / 2); |
| 1026 player_impl_->UpdateState(true, events.get()); | 1026 player_impl_->UpdateState(true, events.get()); |
| 1027 EXPECT_VECTOR2DF_EQ( | 1027 EXPECT_VECTOR2DF_EQ( |
| 1028 gfx::Vector2dF(400.f, 150.f), | 1028 gfx::Vector2dF(400.f, 150.f), |
| 1029 client_impl_.GetScrollOffset(element_id_, ElementListType::PENDING)); | 1029 client_impl_.GetScrollOffset(element_id_, ElementListType::PENDING)); |
| 1030 event = GetMostRecentPropertyUpdateEvent(events.get()); | 1030 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 1031 EXPECT_FALSE(event); | 1031 EXPECT_FALSE(event); |
| 1032 | 1032 |
| 1033 player_impl_->Animate(kInitialTickTime + duration); | 1033 player_impl_->Tick(kInitialTickTime + duration); |
| 1034 player_impl_->UpdateState(true, events.get()); | 1034 player_impl_->UpdateState(true, events.get()); |
| 1035 EXPECT_VECTOR2DF_EQ(target_value, client_impl_.GetScrollOffset( | 1035 EXPECT_VECTOR2DF_EQ(target_value, client_impl_.GetScrollOffset( |
| 1036 element_id_, ElementListType::PENDING)); | 1036 element_id_, ElementListType::PENDING)); |
| 1037 EXPECT_FALSE(player_impl_->HasActiveAnimation()); | 1037 EXPECT_FALSE(player_impl_->HasTickingAnimation()); |
| 1038 event = GetMostRecentPropertyUpdateEvent(events.get()); | 1038 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 1039 EXPECT_FALSE(event); | 1039 EXPECT_FALSE(event); |
| 1040 | 1040 |
| 1041 player_->Animate(kInitialTickTime + duration); | 1041 player_->Tick(kInitialTickTime + duration); |
| 1042 player_->UpdateState(true, nullptr); | 1042 player_->UpdateState(true, nullptr); |
| 1043 EXPECT_VECTOR2DF_EQ(target_value, client_.GetScrollOffset( | 1043 EXPECT_VECTOR2DF_EQ(target_value, client_.GetScrollOffset( |
| 1044 element_id_, ElementListType::ACTIVE)); | 1044 element_id_, ElementListType::ACTIVE)); |
| 1045 EXPECT_FALSE(player_->HasActiveAnimation()); | 1045 EXPECT_FALSE(player_->HasTickingAnimation()); |
| 1046 } | 1046 } |
| 1047 | 1047 |
| 1048 TEST_F(ElementAnimationsTest, ScrollOffsetRemovalClearsScrollDelta) { | 1048 TEST_F(ElementAnimationsTest, ScrollOffsetRemovalClearsScrollDelta) { |
| 1049 CreateTestLayer(true, false); | 1049 CreateTestLayer(true, false); |
| 1050 AttachTimelinePlayerLayer(); | 1050 AttachTimelinePlayerLayer(); |
| 1051 CreateImplTimelineAndPlayer(); | 1051 CreateImplTimelineAndPlayer(); |
| 1052 | 1052 |
| 1053 auto events = CreateEventsForTesting(); | 1053 auto events = CreateEventsForTesting(); |
| 1054 | 1054 |
| 1055 // First test the 1-argument version of RemoveAnimation. | 1055 // First test the 1-argument version of RemoveAnimation. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 curve->SetInitialValue(initial_value); | 1159 curve->SetInitialValue(initial_value); |
| 1160 TimeDelta duration = curve->Duration(); | 1160 TimeDelta duration = curve->Duration(); |
| 1161 std::unique_ptr<Animation> to_add( | 1161 std::unique_ptr<Animation> to_add( |
| 1162 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); | 1162 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); |
| 1163 to_add->set_is_impl_only(true); | 1163 to_add->set_is_impl_only(true); |
| 1164 player_impl_->AddAnimation(std::move(to_add)); | 1164 player_impl_->AddAnimation(std::move(to_add)); |
| 1165 | 1165 |
| 1166 EXPECT_FALSE(delegate.started()); | 1166 EXPECT_FALSE(delegate.started()); |
| 1167 EXPECT_FALSE(delegate.finished()); | 1167 EXPECT_FALSE(delegate.finished()); |
| 1168 | 1168 |
| 1169 player_impl_->Animate(kInitialTickTime); | 1169 player_impl_->Tick(kInitialTickTime); |
| 1170 player_impl_->UpdateState(true, events.get()); | 1170 player_impl_->UpdateState(true, events.get()); |
| 1171 | 1171 |
| 1172 EXPECT_TRUE(delegate.started()); | 1172 EXPECT_TRUE(delegate.started()); |
| 1173 EXPECT_FALSE(delegate.finished()); | 1173 EXPECT_FALSE(delegate.finished()); |
| 1174 | 1174 |
| 1175 events = CreateEventsForTesting(); | 1175 events = CreateEventsForTesting(); |
| 1176 player_impl_->Animate(kInitialTickTime + duration); | 1176 player_impl_->Tick(kInitialTickTime + duration); |
| 1177 EXPECT_EQ(duration, player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET) | 1177 EXPECT_EQ(duration, player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET) |
| 1178 ->curve() | 1178 ->curve() |
| 1179 ->Duration()); | 1179 ->Duration()); |
| 1180 player_impl_->UpdateState(true, events.get()); | 1180 player_impl_->UpdateState(true, events.get()); |
| 1181 | 1181 |
| 1182 EXPECT_TRUE(delegate.started()); | 1182 EXPECT_TRUE(delegate.started()); |
| 1183 EXPECT_TRUE(delegate.finished()); | 1183 EXPECT_TRUE(delegate.finished()); |
| 1184 } | 1184 } |
| 1185 | 1185 |
| 1186 // Tests that specified start times are sent to the main thread delegate | 1186 // Tests that specified start times are sent to the main thread delegate |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1199 player_->GetAnimation(TargetProperty::OPACITY)->set_start_time(start_time); | 1199 player_->GetAnimation(TargetProperty::OPACITY)->set_start_time(start_time); |
| 1200 | 1200 |
| 1201 PushProperties(); | 1201 PushProperties(); |
| 1202 player_impl_->ActivateAnimations(); | 1202 player_impl_->ActivateAnimations(); |
| 1203 | 1203 |
| 1204 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); | 1204 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); |
| 1205 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1205 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 1206 player_impl_->GetAnimationById(animation_id)->run_state()); | 1206 player_impl_->GetAnimationById(animation_id)->run_state()); |
| 1207 | 1207 |
| 1208 auto events = CreateEventsForTesting(); | 1208 auto events = CreateEventsForTesting(); |
| 1209 player_impl_->Animate(kInitialTickTime); | 1209 player_impl_->Tick(kInitialTickTime); |
| 1210 player_impl_->UpdateState(true, events.get()); | 1210 player_impl_->UpdateState(true, events.get()); |
| 1211 | 1211 |
| 1212 // Synchronize the start times. | 1212 // Synchronize the start times. |
| 1213 EXPECT_EQ(1u, events->events_.size()); | 1213 EXPECT_EQ(1u, events->events_.size()); |
| 1214 player_->NotifyAnimationStarted(events->events_[0]); | 1214 player_->NotifyAnimationStarted(events->events_[0]); |
| 1215 | 1215 |
| 1216 // Validate start time on the main thread delegate. | 1216 // Validate start time on the main thread delegate. |
| 1217 EXPECT_EQ(start_time, delegate.start_time()); | 1217 EXPECT_EQ(start_time, delegate.start_time()); |
| 1218 } | 1218 } |
| 1219 | 1219 |
| 1220 // Tests animations that are waiting for a synchronized start time do not | 1220 // Tests animations that are waiting for a synchronized start time do not |
| 1221 // finish. | 1221 // finish. |
| 1222 TEST_F(ElementAnimationsTest, | 1222 TEST_F(ElementAnimationsTest, |
| 1223 AnimationsWaitingForStartTimeDoNotFinishIfTheyOutwaitTheirFinish) { | 1223 AnimationsWaitingForStartTimeDoNotFinishIfTheyOutwaitTheirFinish) { |
| 1224 CreateTestLayer(false, false); | 1224 CreateTestLayer(false, false); |
| 1225 AttachTimelinePlayerLayer(); | 1225 AttachTimelinePlayerLayer(); |
| 1226 | 1226 |
| 1227 auto events = CreateEventsForTesting(); | 1227 auto events = CreateEventsForTesting(); |
| 1228 | 1228 |
| 1229 std::unique_ptr<Animation> to_add(CreateAnimation( | 1229 std::unique_ptr<Animation> to_add(CreateAnimation( |
| 1230 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 1230 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 1231 1, TargetProperty::OPACITY)); | 1231 1, TargetProperty::OPACITY)); |
| 1232 to_add->set_needs_synchronized_start_time(true); | 1232 to_add->set_needs_synchronized_start_time(true); |
| 1233 | 1233 |
| 1234 // We should pause at the first keyframe indefinitely waiting for that | 1234 // We should pause at the first keyframe indefinitely waiting for that |
| 1235 // animation to start. | 1235 // animation to start. |
| 1236 player_->AddAnimation(std::move(to_add)); | 1236 player_->AddAnimation(std::move(to_add)); |
| 1237 player_->Animate(kInitialTickTime); | 1237 player_->Tick(kInitialTickTime); |
| 1238 player_->UpdateState(true, events.get()); | 1238 player_->UpdateState(true, events.get()); |
| 1239 EXPECT_TRUE(player_->HasActiveAnimation()); | 1239 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1240 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1240 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1241 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1241 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1242 player_->UpdateState(true, events.get()); | 1242 player_->UpdateState(true, events.get()); |
| 1243 EXPECT_TRUE(player_->HasActiveAnimation()); | 1243 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1244 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1244 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1245 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1245 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 1246 player_->UpdateState(true, events.get()); | 1246 player_->UpdateState(true, events.get()); |
| 1247 EXPECT_TRUE(player_->HasActiveAnimation()); | 1247 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1248 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1248 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1249 | 1249 |
| 1250 // Send the synchronized start time. | 1250 // Send the synchronized start time. |
| 1251 player_->NotifyAnimationStarted(AnimationEvent( | 1251 player_->NotifyAnimationStarted(AnimationEvent( |
| 1252 AnimationEvent::STARTED, ElementId(), 1, TargetProperty::OPACITY, | 1252 AnimationEvent::STARTED, ElementId(), 1, TargetProperty::OPACITY, |
| 1253 kInitialTickTime + TimeDelta::FromMilliseconds(2000))); | 1253 kInitialTickTime + TimeDelta::FromMilliseconds(2000))); |
| 1254 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(5000)); | 1254 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(5000)); |
| 1255 player_->UpdateState(true, events.get()); | 1255 player_->UpdateState(true, events.get()); |
| 1256 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1256 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1257 EXPECT_FALSE(player_->HasActiveAnimation()); | 1257 EXPECT_FALSE(player_->HasTickingAnimation()); |
| 1258 } | 1258 } |
| 1259 | 1259 |
| 1260 // Tests that two queued animations affecting the same property run in sequence. | 1260 // Tests that two queued animations affecting the same property run in sequence. |
| 1261 TEST_F(ElementAnimationsTest, TrivialQueuing) { | 1261 TEST_F(ElementAnimationsTest, TrivialQueuing) { |
| 1262 CreateTestLayer(false, false); | 1262 CreateTestLayer(false, false); |
| 1263 AttachTimelinePlayerLayer(); | 1263 AttachTimelinePlayerLayer(); |
| 1264 | 1264 |
| 1265 auto events = CreateEventsForTesting(); | 1265 auto events = CreateEventsForTesting(); |
| 1266 | 1266 |
| 1267 EXPECT_FALSE(player_->needs_to_start_animations()); | 1267 EXPECT_FALSE(player_->needs_to_start_animations()); |
| 1268 | 1268 |
| 1269 player_->AddAnimation(CreateAnimation( | 1269 player_->AddAnimation(CreateAnimation( |
| 1270 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 1270 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 1271 1, TargetProperty::OPACITY)); | 1271 1, TargetProperty::OPACITY)); |
| 1272 player_->AddAnimation(CreateAnimation( | 1272 player_->AddAnimation(CreateAnimation( |
| 1273 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), | 1273 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), |
| 1274 2, TargetProperty::OPACITY)); | 1274 2, TargetProperty::OPACITY)); |
| 1275 | 1275 |
| 1276 EXPECT_TRUE(player_->needs_to_start_animations()); | 1276 EXPECT_TRUE(player_->needs_to_start_animations()); |
| 1277 | 1277 |
| 1278 player_->Animate(kInitialTickTime); | 1278 player_->Tick(kInitialTickTime); |
| 1279 | 1279 |
| 1280 // The second animation still needs to be started. | 1280 // The second animation still needs to be started. |
| 1281 EXPECT_TRUE(player_->needs_to_start_animations()); | 1281 EXPECT_TRUE(player_->needs_to_start_animations()); |
| 1282 | 1282 |
| 1283 player_->UpdateState(true, events.get()); | 1283 player_->UpdateState(true, events.get()); |
| 1284 EXPECT_TRUE(player_->HasActiveAnimation()); | 1284 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1285 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1285 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1286 | 1286 |
| 1287 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1287 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1288 EXPECT_TRUE(player_->needs_to_start_animations()); | 1288 EXPECT_TRUE(player_->needs_to_start_animations()); |
| 1289 player_->UpdateState(true, events.get()); | 1289 player_->UpdateState(true, events.get()); |
| 1290 EXPECT_FALSE(player_->needs_to_start_animations()); | 1290 EXPECT_FALSE(player_->needs_to_start_animations()); |
| 1291 | 1291 |
| 1292 EXPECT_TRUE(player_->HasActiveAnimation()); | 1292 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1293 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1293 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1294 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1294 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 1295 player_->UpdateState(true, events.get()); | 1295 player_->UpdateState(true, events.get()); |
| 1296 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1296 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1297 EXPECT_FALSE(player_->HasActiveAnimation()); | 1297 EXPECT_FALSE(player_->HasTickingAnimation()); |
| 1298 } | 1298 } |
| 1299 | 1299 |
| 1300 // Tests interrupting a transition with another transition. | 1300 // Tests interrupting a transition with another transition. |
| 1301 TEST_F(ElementAnimationsTest, Interrupt) { | 1301 TEST_F(ElementAnimationsTest, Interrupt) { |
| 1302 CreateTestLayer(false, false); | 1302 CreateTestLayer(false, false); |
| 1303 AttachTimelinePlayerLayer(); | 1303 AttachTimelinePlayerLayer(); |
| 1304 | 1304 |
| 1305 auto events = CreateEventsForTesting(); | 1305 auto events = CreateEventsForTesting(); |
| 1306 | 1306 |
| 1307 player_->AddAnimation(CreateAnimation( | 1307 player_->AddAnimation(CreateAnimation( |
| 1308 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 1308 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 1309 1, TargetProperty::OPACITY)); | 1309 1, TargetProperty::OPACITY)); |
| 1310 player_->Animate(kInitialTickTime); | 1310 player_->Tick(kInitialTickTime); |
| 1311 player_->UpdateState(true, events.get()); | 1311 player_->UpdateState(true, events.get()); |
| 1312 EXPECT_TRUE(player_->HasActiveAnimation()); | 1312 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1313 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1313 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1314 | 1314 |
| 1315 std::unique_ptr<Animation> to_add(CreateAnimation( | 1315 std::unique_ptr<Animation> to_add(CreateAnimation( |
| 1316 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), | 1316 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), |
| 1317 2, TargetProperty::OPACITY)); | 1317 2, TargetProperty::OPACITY)); |
| 1318 player_->AbortAnimations(TargetProperty::OPACITY, false); | 1318 player_->AbortAnimations(TargetProperty::OPACITY, false); |
| 1319 player_->AddAnimation(std::move(to_add)); | 1319 player_->AddAnimation(std::move(to_add)); |
| 1320 | 1320 |
| 1321 // Since the previous animation was aborted, the new animation should start | 1321 // Since the previous animation was aborted, the new animation should start |
| 1322 // right in this call to animate. | 1322 // right in this call to animate. |
| 1323 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1323 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 1324 player_->UpdateState(true, events.get()); | 1324 player_->UpdateState(true, events.get()); |
| 1325 EXPECT_TRUE(player_->HasActiveAnimation()); | 1325 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1326 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1326 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1327 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); | 1327 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); |
| 1328 player_->UpdateState(true, events.get()); | 1328 player_->UpdateState(true, events.get()); |
| 1329 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1329 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1330 EXPECT_FALSE(player_->HasActiveAnimation()); | 1330 EXPECT_FALSE(player_->HasTickingAnimation()); |
| 1331 } | 1331 } |
| 1332 | 1332 |
| 1333 // Tests scheduling two animations to run together when only one property is | 1333 // Tests scheduling two animations to run together when only one property is |
| 1334 // free. | 1334 // free. |
| 1335 TEST_F(ElementAnimationsTest, ScheduleTogetherWhenAPropertyIsBlocked) { | 1335 TEST_F(ElementAnimationsTest, ScheduleTogetherWhenAPropertyIsBlocked) { |
| 1336 CreateTestLayer(false, false); | 1336 CreateTestLayer(false, false); |
| 1337 AttachTimelinePlayerLayer(); | 1337 AttachTimelinePlayerLayer(); |
| 1338 | 1338 |
| 1339 auto events = CreateEventsForTesting(); | 1339 auto events = CreateEventsForTesting(); |
| 1340 | 1340 |
| 1341 player_->AddAnimation(CreateAnimation( | 1341 player_->AddAnimation(CreateAnimation( |
| 1342 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, | 1342 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, |
| 1343 TargetProperty::TRANSFORM)); | 1343 TargetProperty::TRANSFORM)); |
| 1344 player_->AddAnimation(CreateAnimation( | 1344 player_->AddAnimation(CreateAnimation( |
| 1345 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 2, | 1345 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 2, |
| 1346 TargetProperty::TRANSFORM)); | 1346 TargetProperty::TRANSFORM)); |
| 1347 player_->AddAnimation(CreateAnimation( | 1347 player_->AddAnimation(CreateAnimation( |
| 1348 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 1348 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 1349 2, TargetProperty::OPACITY)); | 1349 2, TargetProperty::OPACITY)); |
| 1350 | 1350 |
| 1351 player_->Animate(kInitialTickTime); | 1351 player_->Tick(kInitialTickTime); |
| 1352 player_->UpdateState(true, events.get()); | 1352 player_->UpdateState(true, events.get()); |
| 1353 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1353 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1354 EXPECT_TRUE(player_->HasActiveAnimation()); | 1354 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1355 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1355 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1356 player_->UpdateState(true, events.get()); | 1356 player_->UpdateState(true, events.get()); |
| 1357 // Should not have started the float transition yet. | 1357 // Should not have started the float transition yet. |
| 1358 EXPECT_TRUE(player_->HasActiveAnimation()); | 1358 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1359 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1359 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1360 // The float animation should have started at time 1 and should be done. | 1360 // The float animation should have started at time 1 and should be done. |
| 1361 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1361 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 1362 player_->UpdateState(true, events.get()); | 1362 player_->UpdateState(true, events.get()); |
| 1363 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1363 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1364 EXPECT_FALSE(player_->HasActiveAnimation()); | 1364 EXPECT_FALSE(player_->HasTickingAnimation()); |
| 1365 } | 1365 } |
| 1366 | 1366 |
| 1367 // Tests scheduling two animations to run together with different lengths and | 1367 // Tests scheduling two animations to run together with different lengths and |
| 1368 // another animation queued to start when the shorter animation finishes (should | 1368 // another animation queued to start when the shorter animation finishes (should |
| 1369 // wait for both to finish). | 1369 // wait for both to finish). |
| 1370 TEST_F(ElementAnimationsTest, ScheduleTogetherWithAnAnimWaiting) { | 1370 TEST_F(ElementAnimationsTest, ScheduleTogetherWithAnAnimWaiting) { |
| 1371 CreateTestLayer(false, false); | 1371 CreateTestLayer(false, false); |
| 1372 AttachTimelinePlayerLayer(); | 1372 AttachTimelinePlayerLayer(); |
| 1373 | 1373 |
| 1374 auto events = CreateEventsForTesting(); | 1374 auto events = CreateEventsForTesting(); |
| 1375 | 1375 |
| 1376 player_->AddAnimation(CreateAnimation( | 1376 player_->AddAnimation(CreateAnimation( |
| 1377 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(2)), 1, | 1377 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(2)), 1, |
| 1378 TargetProperty::TRANSFORM)); | 1378 TargetProperty::TRANSFORM)); |
| 1379 player_->AddAnimation(CreateAnimation( | 1379 player_->AddAnimation(CreateAnimation( |
| 1380 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 1380 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 1381 1, TargetProperty::OPACITY)); | 1381 1, TargetProperty::OPACITY)); |
| 1382 player_->AddAnimation(CreateAnimation( | 1382 player_->AddAnimation(CreateAnimation( |
| 1383 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), | 1383 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), |
| 1384 2, TargetProperty::OPACITY)); | 1384 2, TargetProperty::OPACITY)); |
| 1385 | 1385 |
| 1386 // Animations with id 1 should both start now. | 1386 // Animations with id 1 should both start now. |
| 1387 player_->Animate(kInitialTickTime); | 1387 player_->Tick(kInitialTickTime); |
| 1388 player_->UpdateState(true, events.get()); | 1388 player_->UpdateState(true, events.get()); |
| 1389 EXPECT_TRUE(player_->HasActiveAnimation()); | 1389 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1390 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1390 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1391 // The opacity animation should have finished at time 1, but the group | 1391 // The opacity animation should have finished at time 1, but the group |
| 1392 // of animations with id 1 don't finish until time 2 because of the length | 1392 // of animations with id 1 don't finish until time 2 because of the length |
| 1393 // of the transform animation. | 1393 // of the transform animation. |
| 1394 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1394 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 1395 player_->UpdateState(true, events.get()); | 1395 player_->UpdateState(true, events.get()); |
| 1396 // Should not have started the float transition yet. | 1396 // Should not have started the float transition yet. |
| 1397 EXPECT_TRUE(player_->HasActiveAnimation()); | 1397 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1398 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1398 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1399 | 1399 |
| 1400 // The second opacity animation should start at time 2 and should be done by | 1400 // The second opacity animation should start at time 2 and should be done by |
| 1401 // time 3. | 1401 // time 3. |
| 1402 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); | 1402 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
| 1403 player_->UpdateState(true, events.get()); | 1403 player_->UpdateState(true, events.get()); |
| 1404 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1404 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1405 EXPECT_FALSE(player_->HasActiveAnimation()); | 1405 EXPECT_FALSE(player_->HasTickingAnimation()); |
| 1406 } | 1406 } |
| 1407 | 1407 |
| 1408 // Test that a looping animation loops and for the correct number of iterations. | 1408 // Test that a looping animation loops and for the correct number of iterations. |
| 1409 TEST_F(ElementAnimationsTest, TrivialLooping) { | 1409 TEST_F(ElementAnimationsTest, TrivialLooping) { |
| 1410 CreateTestLayer(false, false); | 1410 CreateTestLayer(false, false); |
| 1411 AttachTimelinePlayerLayer(); | 1411 AttachTimelinePlayerLayer(); |
| 1412 | 1412 |
| 1413 auto events = CreateEventsForTesting(); | 1413 auto events = CreateEventsForTesting(); |
| 1414 | 1414 |
| 1415 std::unique_ptr<Animation> to_add(CreateAnimation( | 1415 std::unique_ptr<Animation> to_add(CreateAnimation( |
| 1416 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 1416 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 1417 1, TargetProperty::OPACITY)); | 1417 1, TargetProperty::OPACITY)); |
| 1418 to_add->set_iterations(3); | 1418 to_add->set_iterations(3); |
| 1419 player_->AddAnimation(std::move(to_add)); | 1419 player_->AddAnimation(std::move(to_add)); |
| 1420 | 1420 |
| 1421 player_->Animate(kInitialTickTime); | 1421 player_->Tick(kInitialTickTime); |
| 1422 player_->UpdateState(true, events.get()); | 1422 player_->UpdateState(true, events.get()); |
| 1423 EXPECT_TRUE(player_->HasActiveAnimation()); | 1423 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1424 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1424 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1425 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); | 1425 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); |
| 1426 player_->UpdateState(true, events.get()); | 1426 player_->UpdateState(true, events.get()); |
| 1427 EXPECT_TRUE(player_->HasActiveAnimation()); | 1427 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1428 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1428 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1429 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); | 1429 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); |
| 1430 player_->UpdateState(true, events.get()); | 1430 player_->UpdateState(true, events.get()); |
| 1431 EXPECT_TRUE(player_->HasActiveAnimation()); | 1431 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1432 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1432 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1433 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2250)); | 1433 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2250)); |
| 1434 player_->UpdateState(true, events.get()); | 1434 player_->UpdateState(true, events.get()); |
| 1435 EXPECT_TRUE(player_->HasActiveAnimation()); | 1435 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1436 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1436 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1437 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2750)); | 1437 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2750)); |
| 1438 player_->UpdateState(true, events.get()); | 1438 player_->UpdateState(true, events.get()); |
| 1439 EXPECT_TRUE(player_->HasActiveAnimation()); | 1439 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1440 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1440 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1441 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); | 1441 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
| 1442 player_->UpdateState(true, events.get()); | 1442 player_->UpdateState(true, events.get()); |
| 1443 EXPECT_FALSE(player_->HasActiveAnimation()); | 1443 EXPECT_FALSE(player_->HasTickingAnimation()); |
| 1444 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1444 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1445 | 1445 |
| 1446 // Just be extra sure. | 1446 // Just be extra sure. |
| 1447 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); | 1447 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); |
| 1448 player_->UpdateState(true, events.get()); | 1448 player_->UpdateState(true, events.get()); |
| 1449 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1449 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1450 } | 1450 } |
| 1451 | 1451 |
| 1452 // Test that an infinitely looping animation does indeed go until aborted. | 1452 // Test that an infinitely looping animation does indeed go until aborted. |
| 1453 TEST_F(ElementAnimationsTest, InfiniteLooping) { | 1453 TEST_F(ElementAnimationsTest, InfiniteLooping) { |
| 1454 CreateTestLayer(false, false); | 1454 CreateTestLayer(false, false); |
| 1455 AttachTimelinePlayerLayer(); | 1455 AttachTimelinePlayerLayer(); |
| 1456 | 1456 |
| 1457 auto events = CreateEventsForTesting(); | 1457 auto events = CreateEventsForTesting(); |
| 1458 | 1458 |
| 1459 std::unique_ptr<Animation> to_add(CreateAnimation( | 1459 std::unique_ptr<Animation> to_add(CreateAnimation( |
| 1460 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 1460 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 1461 1, TargetProperty::OPACITY)); | 1461 1, TargetProperty::OPACITY)); |
| 1462 to_add->set_iterations(-1); | 1462 to_add->set_iterations(-1); |
| 1463 player_->AddAnimation(std::move(to_add)); | 1463 player_->AddAnimation(std::move(to_add)); |
| 1464 | 1464 |
| 1465 player_->Animate(kInitialTickTime); | 1465 player_->Tick(kInitialTickTime); |
| 1466 player_->UpdateState(true, events.get()); | 1466 player_->UpdateState(true, events.get()); |
| 1467 EXPECT_TRUE(player_->HasActiveAnimation()); | 1467 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1468 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1468 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1469 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); | 1469 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); |
| 1470 player_->UpdateState(true, events.get()); | 1470 player_->UpdateState(true, events.get()); |
| 1471 EXPECT_TRUE(player_->HasActiveAnimation()); | 1471 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1472 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1472 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1473 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); | 1473 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); |
| 1474 player_->UpdateState(true, events.get()); | 1474 player_->UpdateState(true, events.get()); |
| 1475 EXPECT_TRUE(player_->HasActiveAnimation()); | 1475 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1476 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1476 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1477 | 1477 |
| 1478 player_->Animate(kInitialTickTime + | 1478 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1073741824250)); |
| 1479 TimeDelta::FromMilliseconds(1073741824250)); | |
| 1480 player_->UpdateState(true, events.get()); | 1479 player_->UpdateState(true, events.get()); |
| 1481 EXPECT_TRUE(player_->HasActiveAnimation()); | 1480 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1482 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1481 EXPECT_EQ(0.25f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1483 player_->Animate(kInitialTickTime + | 1482 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1073741824750)); |
| 1484 TimeDelta::FromMilliseconds(1073741824750)); | |
| 1485 player_->UpdateState(true, events.get()); | 1483 player_->UpdateState(true, events.get()); |
| 1486 EXPECT_TRUE(player_->HasActiveAnimation()); | 1484 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1487 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1485 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1488 | 1486 |
| 1489 EXPECT_TRUE(player_->GetAnimation(TargetProperty::OPACITY)); | 1487 EXPECT_TRUE(player_->GetAnimation(TargetProperty::OPACITY)); |
| 1490 player_->GetAnimation(TargetProperty::OPACITY) | 1488 player_->GetAnimation(TargetProperty::OPACITY) |
| 1491 ->SetRunState(Animation::ABORTED, | 1489 ->SetRunState(Animation::ABORTED, |
| 1492 kInitialTickTime + TimeDelta::FromMilliseconds(750)); | 1490 kInitialTickTime + TimeDelta::FromMilliseconds(750)); |
| 1493 EXPECT_FALSE(player_->HasActiveAnimation()); | 1491 EXPECT_FALSE(player_->HasTickingAnimation()); |
| 1494 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1492 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1495 } | 1493 } |
| 1496 | 1494 |
| 1497 // Test that pausing and resuming work as expected. | 1495 // Test that pausing and resuming work as expected. |
| 1498 TEST_F(ElementAnimationsTest, PauseResume) { | 1496 TEST_F(ElementAnimationsTest, PauseResume) { |
| 1499 CreateTestLayer(false, false); | 1497 CreateTestLayer(false, false); |
| 1500 AttachTimelinePlayerLayer(); | 1498 AttachTimelinePlayerLayer(); |
| 1501 | 1499 |
| 1502 auto events = CreateEventsForTesting(); | 1500 auto events = CreateEventsForTesting(); |
| 1503 | 1501 |
| 1504 player_->AddAnimation(CreateAnimation( | 1502 player_->AddAnimation(CreateAnimation( |
| 1505 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 1503 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 1506 1, TargetProperty::OPACITY)); | 1504 1, TargetProperty::OPACITY)); |
| 1507 | 1505 |
| 1508 player_->Animate(kInitialTickTime); | 1506 player_->Tick(kInitialTickTime); |
| 1509 player_->UpdateState(true, events.get()); | 1507 player_->UpdateState(true, events.get()); |
| 1510 EXPECT_TRUE(player_->HasActiveAnimation()); | 1508 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1511 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1509 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1512 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1510 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 1513 player_->UpdateState(true, events.get()); | 1511 player_->UpdateState(true, events.get()); |
| 1514 EXPECT_TRUE(player_->HasActiveAnimation()); | 1512 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1515 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1513 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1516 | 1514 |
| 1517 EXPECT_TRUE(player_->GetAnimation(TargetProperty::OPACITY)); | 1515 EXPECT_TRUE(player_->GetAnimation(TargetProperty::OPACITY)); |
| 1518 player_->GetAnimation(TargetProperty::OPACITY) | 1516 player_->GetAnimation(TargetProperty::OPACITY) |
| 1519 ->SetRunState(Animation::PAUSED, | 1517 ->SetRunState(Animation::PAUSED, |
| 1520 kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1518 kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 1521 | 1519 |
| 1522 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); | 1520 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); |
| 1523 player_->UpdateState(true, events.get()); | 1521 player_->UpdateState(true, events.get()); |
| 1524 EXPECT_TRUE(player_->HasActiveAnimation()); | 1522 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1525 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1523 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1526 | 1524 |
| 1527 EXPECT_TRUE(player_->GetAnimation(TargetProperty::OPACITY)); | 1525 EXPECT_TRUE(player_->GetAnimation(TargetProperty::OPACITY)); |
| 1528 player_->GetAnimation(TargetProperty::OPACITY) | 1526 player_->GetAnimation(TargetProperty::OPACITY) |
| 1529 ->SetRunState(Animation::RUNNING, | 1527 ->SetRunState(Animation::RUNNING, |
| 1530 kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); | 1528 kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); |
| 1531 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024250)); | 1529 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1024250)); |
| 1532 player_->UpdateState(true, events.get()); | 1530 player_->UpdateState(true, events.get()); |
| 1533 EXPECT_TRUE(player_->HasActiveAnimation()); | 1531 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1534 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1532 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1535 | 1533 |
| 1536 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024500)); | 1534 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1024500)); |
| 1537 player_->UpdateState(true, events.get()); | 1535 player_->UpdateState(true, events.get()); |
| 1538 EXPECT_FALSE(player_->HasActiveAnimation()); | 1536 EXPECT_FALSE(player_->HasTickingAnimation()); |
| 1539 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1537 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1540 } | 1538 } |
| 1541 | 1539 |
| 1542 TEST_F(ElementAnimationsTest, AbortAGroupedAnimation) { | 1540 TEST_F(ElementAnimationsTest, AbortAGroupedAnimation) { |
| 1543 CreateTestLayer(false, false); | 1541 CreateTestLayer(false, false); |
| 1544 AttachTimelinePlayerLayer(); | 1542 AttachTimelinePlayerLayer(); |
| 1545 | 1543 |
| 1546 auto events = CreateEventsForTesting(); | 1544 auto events = CreateEventsForTesting(); |
| 1547 | 1545 |
| 1548 const int animation_id = 2; | 1546 const int animation_id = 2; |
| 1549 player_->AddAnimation(Animation::Create( | 1547 player_->AddAnimation(Animation::Create( |
| 1550 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, 1, | 1548 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, 1, |
| 1551 TargetProperty::TRANSFORM)); | 1549 TargetProperty::TRANSFORM)); |
| 1552 player_->AddAnimation(Animation::Create( | 1550 player_->AddAnimation(Animation::Create( |
| 1553 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)), | 1551 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)), |
| 1554 animation_id, 1, TargetProperty::OPACITY)); | 1552 animation_id, 1, TargetProperty::OPACITY)); |
| 1555 player_->AddAnimation(Animation::Create( | 1553 player_->AddAnimation(Animation::Create( |
| 1556 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.75f)), | 1554 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.75f)), |
| 1557 3, 2, TargetProperty::OPACITY)); | 1555 3, 2, TargetProperty::OPACITY)); |
| 1558 | 1556 |
| 1559 player_->Animate(kInitialTickTime); | 1557 player_->Tick(kInitialTickTime); |
| 1560 player_->UpdateState(true, events.get()); | 1558 player_->UpdateState(true, events.get()); |
| 1561 EXPECT_TRUE(player_->HasActiveAnimation()); | 1559 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1562 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1560 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1563 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1561 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1564 player_->UpdateState(true, events.get()); | 1562 player_->UpdateState(true, events.get()); |
| 1565 EXPECT_TRUE(player_->HasActiveAnimation()); | 1563 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1566 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1564 EXPECT_EQ(0.5f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1567 | 1565 |
| 1568 EXPECT_TRUE(player_->GetAnimationById(animation_id)); | 1566 EXPECT_TRUE(player_->GetAnimationById(animation_id)); |
| 1569 player_->GetAnimationById(animation_id) | 1567 player_->GetAnimationById(animation_id) |
| 1570 ->SetRunState(Animation::ABORTED, | 1568 ->SetRunState(Animation::ABORTED, |
| 1571 kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1569 kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1572 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1570 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1573 player_->UpdateState(true, events.get()); | 1571 player_->UpdateState(true, events.get()); |
| 1574 EXPECT_TRUE(player_->HasActiveAnimation()); | 1572 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1575 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1573 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1576 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1574 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 1577 player_->UpdateState(true, events.get()); | 1575 player_->UpdateState(true, events.get()); |
| 1578 EXPECT_TRUE(!player_->HasActiveAnimation()); | 1576 EXPECT_TRUE(!player_->HasTickingAnimation()); |
| 1579 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1577 EXPECT_EQ(0.75f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1580 } | 1578 } |
| 1581 | 1579 |
| 1582 TEST_F(ElementAnimationsTest, PushUpdatesWhenSynchronizedStartTimeNeeded) { | 1580 TEST_F(ElementAnimationsTest, PushUpdatesWhenSynchronizedStartTimeNeeded) { |
| 1583 CreateTestLayer(true, false); | 1581 CreateTestLayer(true, false); |
| 1584 AttachTimelinePlayerLayer(); | 1582 AttachTimelinePlayerLayer(); |
| 1585 CreateImplTimelineAndPlayer(); | 1583 CreateImplTimelineAndPlayer(); |
| 1586 | 1584 |
| 1587 auto events = CreateEventsForTesting(); | 1585 auto events = CreateEventsForTesting(); |
| 1588 | 1586 |
| 1589 std::unique_ptr<Animation> to_add(CreateAnimation( | 1587 std::unique_ptr<Animation> to_add(CreateAnimation( |
| 1590 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)), | 1588 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)), |
| 1591 0, TargetProperty::OPACITY)); | 1589 0, TargetProperty::OPACITY)); |
| 1592 to_add->set_needs_synchronized_start_time(true); | 1590 to_add->set_needs_synchronized_start_time(true); |
| 1593 player_->AddAnimation(std::move(to_add)); | 1591 player_->AddAnimation(std::move(to_add)); |
| 1594 | 1592 |
| 1595 player_->Animate(kInitialTickTime); | 1593 player_->Tick(kInitialTickTime); |
| 1596 player_->UpdateState(true, events.get()); | 1594 player_->UpdateState(true, events.get()); |
| 1597 EXPECT_TRUE(player_->HasActiveAnimation()); | 1595 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1598 Animation* active_animation = player_->GetAnimation(TargetProperty::OPACITY); | 1596 Animation* active_animation = player_->GetAnimation(TargetProperty::OPACITY); |
| 1599 EXPECT_TRUE(active_animation); | 1597 EXPECT_TRUE(active_animation); |
| 1600 EXPECT_TRUE(active_animation->needs_synchronized_start_time()); | 1598 EXPECT_TRUE(active_animation->needs_synchronized_start_time()); |
| 1601 | 1599 |
| 1602 EXPECT_TRUE(player_->needs_push_properties()); | 1600 EXPECT_TRUE(player_->needs_push_properties()); |
| 1603 PushProperties(); | 1601 PushProperties(); |
| 1604 player_impl_->ActivateAnimations(); | 1602 player_impl_->ActivateAnimations(); |
| 1605 | 1603 |
| 1606 active_animation = player_impl_->GetAnimation(TargetProperty::OPACITY); | 1604 active_animation = player_impl_->GetAnimation(TargetProperty::OPACITY); |
| 1607 EXPECT_TRUE(active_animation); | 1605 EXPECT_TRUE(active_animation); |
| 1608 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1606 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 1609 active_animation->run_state()); | 1607 active_animation->run_state()); |
| 1610 } | 1608 } |
| 1611 | 1609 |
| 1612 // Tests that skipping a call to UpdateState works as expected. | 1610 // Tests that skipping a call to UpdateState works as expected. |
| 1613 TEST_F(ElementAnimationsTest, SkipUpdateState) { | 1611 TEST_F(ElementAnimationsTest, SkipUpdateState) { |
| 1614 CreateTestLayer(true, false); | 1612 CreateTestLayer(true, false); |
| 1615 AttachTimelinePlayerLayer(); | 1613 AttachTimelinePlayerLayer(); |
| 1616 | 1614 |
| 1617 auto events = CreateEventsForTesting(); | 1615 auto events = CreateEventsForTesting(); |
| 1618 | 1616 |
| 1619 std::unique_ptr<Animation> first_animation(CreateAnimation( | 1617 std::unique_ptr<Animation> first_animation(CreateAnimation( |
| 1620 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, | 1618 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, |
| 1621 TargetProperty::TRANSFORM)); | 1619 TargetProperty::TRANSFORM)); |
| 1622 first_animation->set_is_controlling_instance_for_test(true); | 1620 first_animation->set_is_controlling_instance_for_test(true); |
| 1623 player_->AddAnimation(std::move(first_animation)); | 1621 player_->AddAnimation(std::move(first_animation)); |
| 1624 | 1622 |
| 1625 player_->Animate(kInitialTickTime); | 1623 player_->Tick(kInitialTickTime); |
| 1626 player_->UpdateState(true, events.get()); | 1624 player_->UpdateState(true, events.get()); |
| 1627 | 1625 |
| 1628 std::unique_ptr<Animation> second_animation(CreateAnimation( | 1626 std::unique_ptr<Animation> second_animation(CreateAnimation( |
| 1629 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 1627 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 1630 2, TargetProperty::OPACITY)); | 1628 2, TargetProperty::OPACITY)); |
| 1631 second_animation->set_is_controlling_instance_for_test(true); | 1629 second_animation->set_is_controlling_instance_for_test(true); |
| 1632 player_->AddAnimation(std::move(second_animation)); | 1630 player_->AddAnimation(std::move(second_animation)); |
| 1633 | 1631 |
| 1634 // Animate but don't UpdateState. | 1632 // Animate but don't UpdateState. |
| 1635 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1633 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1636 | 1634 |
| 1637 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1635 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 1638 events = CreateEventsForTesting(); | 1636 events = CreateEventsForTesting(); |
| 1639 player_->UpdateState(true, events.get()); | 1637 player_->UpdateState(true, events.get()); |
| 1640 | 1638 |
| 1641 // Should have one STARTED event and one FINISHED event. | 1639 // Should have one STARTED event and one FINISHED event. |
| 1642 EXPECT_EQ(2u, events->events_.size()); | 1640 EXPECT_EQ(2u, events->events_.size()); |
| 1643 EXPECT_NE(events->events_[0].type, events->events_[1].type); | 1641 EXPECT_NE(events->events_[0].type, events->events_[1].type); |
| 1644 | 1642 |
| 1645 // The float transition should still be at its starting point. | 1643 // The float transition should still be at its starting point. |
| 1646 EXPECT_TRUE(player_->HasActiveAnimation()); | 1644 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 1647 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1645 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1648 | 1646 |
| 1649 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); | 1647 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
| 1650 player_->UpdateState(true, events.get()); | 1648 player_->UpdateState(true, events.get()); |
| 1651 | 1649 |
| 1652 // The float tranisition should now be done. | 1650 // The float tranisition should now be done. |
| 1653 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1651 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1654 EXPECT_FALSE(player_->HasActiveAnimation()); | 1652 EXPECT_FALSE(player_->HasTickingAnimation()); |
| 1655 } | 1653 } |
| 1656 | 1654 |
| 1657 // Tests that an animation animations with only a pending observer gets ticked | 1655 // Tests that an animation animations with only a pending observer gets ticked |
| 1658 // but doesn't progress animations past the STARTING state. | 1656 // but doesn't progress animations past the STARTING state. |
| 1659 TEST_F(ElementAnimationsTest, InactiveObserverGetsTicked) { | 1657 TEST_F(ElementAnimationsTest, InactiveObserverGetsTicked) { |
| 1660 AttachTimelinePlayerLayer(); | 1658 AttachTimelinePlayerLayer(); |
| 1661 CreateImplTimelineAndPlayer(); | 1659 CreateImplTimelineAndPlayer(); |
| 1662 | 1660 |
| 1663 auto events = CreateEventsForTesting(); | 1661 auto events = CreateEventsForTesting(); |
| 1664 | 1662 |
| 1665 const int id = 1; | 1663 const int id = 1; |
| 1666 player_impl_->AddAnimation(CreateAnimation( | 1664 player_impl_->AddAnimation(CreateAnimation( |
| 1667 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.5f, 1.f)), | 1665 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.5f, 1.f)), |
| 1668 id, TargetProperty::OPACITY)); | 1666 id, TargetProperty::OPACITY)); |
| 1669 | 1667 |
| 1670 // Without an observer, the animation shouldn't progress to the STARTING | 1668 // Without an observer, the animation shouldn't progress to the STARTING |
| 1671 // state. | 1669 // state. |
| 1672 player_impl_->Animate(kInitialTickTime); | 1670 player_impl_->Tick(kInitialTickTime); |
| 1673 player_impl_->UpdateState(true, events.get()); | 1671 player_impl_->UpdateState(true, events.get()); |
| 1674 EXPECT_EQ(0u, events->events_.size()); | 1672 EXPECT_EQ(0u, events->events_.size()); |
| 1675 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1673 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 1676 player_impl_->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1674 player_impl_->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1677 | 1675 |
| 1678 CreateTestImplLayer(ElementListType::PENDING); | 1676 CreateTestImplLayer(ElementListType::PENDING); |
| 1679 | 1677 |
| 1680 // With only a pending observer, the animation should progress to the | 1678 // With only a pending observer, the animation should progress to the |
| 1681 // STARTING state and get ticked at its starting point, but should not | 1679 // STARTING state and get ticked at its starting point, but should not |
| 1682 // progress to RUNNING. | 1680 // progress to RUNNING. |
| 1683 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1681 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1684 player_impl_->UpdateState(true, events.get()); | 1682 player_impl_->UpdateState(true, events.get()); |
| 1685 EXPECT_EQ(0u, events->events_.size()); | 1683 EXPECT_EQ(0u, events->events_.size()); |
| 1686 EXPECT_EQ(Animation::STARTING, | 1684 EXPECT_EQ(Animation::STARTING, |
| 1687 player_impl_->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1685 player_impl_->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1688 EXPECT_EQ(0.5f, | 1686 EXPECT_EQ(0.5f, |
| 1689 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); | 1687 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); |
| 1690 | 1688 |
| 1691 // Even when already in the STARTING state, the animation should stay | 1689 // Even when already in the STARTING state, the animation should stay |
| 1692 // there, and shouldn't be ticked past its starting point. | 1690 // there, and shouldn't be ticked past its starting point. |
| 1693 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1691 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 1694 player_impl_->UpdateState(true, events.get()); | 1692 player_impl_->UpdateState(true, events.get()); |
| 1695 EXPECT_EQ(0u, events->events_.size()); | 1693 EXPECT_EQ(0u, events->events_.size()); |
| 1696 EXPECT_EQ(Animation::STARTING, | 1694 EXPECT_EQ(Animation::STARTING, |
| 1697 player_impl_->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1695 player_impl_->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1698 EXPECT_EQ(0.5f, | 1696 EXPECT_EQ(0.5f, |
| 1699 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); | 1697 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); |
| 1700 | 1698 |
| 1701 CreateTestImplLayer(ElementListType::ACTIVE); | 1699 CreateTestImplLayer(ElementListType::ACTIVE); |
| 1702 | 1700 |
| 1703 // Now that an active observer has been added, the animation should still | 1701 // Now that an active observer has been added, the animation should still |
| 1704 // initially tick at its starting point, but should now progress to RUNNING. | 1702 // initially tick at its starting point, but should now progress to RUNNING. |
| 1705 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); | 1703 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
| 1706 player_impl_->UpdateState(true, events.get()); | 1704 player_impl_->UpdateState(true, events.get()); |
| 1707 EXPECT_EQ(1u, events->events_.size()); | 1705 EXPECT_EQ(1u, events->events_.size()); |
| 1708 EXPECT_EQ(Animation::RUNNING, | 1706 EXPECT_EQ(Animation::RUNNING, |
| 1709 player_impl_->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1707 player_impl_->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1710 EXPECT_EQ(0.5f, | 1708 EXPECT_EQ(0.5f, |
| 1711 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); | 1709 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); |
| 1712 EXPECT_EQ(0.5f, | 1710 EXPECT_EQ(0.5f, |
| 1713 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1711 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1714 | 1712 |
| 1715 // The animation should now tick past its starting point. | 1713 // The animation should now tick past its starting point. |
| 1716 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3500)); | 1714 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(3500)); |
| 1717 EXPECT_NE(0.5f, | 1715 EXPECT_NE(0.5f, |
| 1718 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); | 1716 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); |
| 1719 EXPECT_NE(0.5f, | 1717 EXPECT_NE(0.5f, |
| 1720 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 1718 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 1721 } | 1719 } |
| 1722 | 1720 |
| 1723 TEST_F(ElementAnimationsTest, TransformAnimationBounds) { | 1721 TEST_F(ElementAnimationsTest, TransformAnimationBounds) { |
| 1724 AttachTimelinePlayerLayer(); | 1722 AttachTimelinePlayerLayer(); |
| 1725 CreateImplTimelineAndPlayer(); | 1723 CreateImplTimelineAndPlayer(); |
| 1726 | 1724 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1807 player_->AddAnimation(Animation::Create( | 1805 player_->AddAnimation(Animation::Create( |
| 1808 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 3, 3, | 1806 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 3, 3, |
| 1809 TargetProperty::TRANSFORM)); | 1807 TargetProperty::TRANSFORM)); |
| 1810 player_->AddAnimation(Animation::Create( | 1808 player_->AddAnimation(Animation::Create( |
| 1811 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(2.0)), 4, 4, | 1809 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(2.0)), 4, 4, |
| 1812 TargetProperty::TRANSFORM)); | 1810 TargetProperty::TRANSFORM)); |
| 1813 player_->AddAnimation(Animation::Create( | 1811 player_->AddAnimation(Animation::Create( |
| 1814 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 1812 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 1815 5, 5, TargetProperty::OPACITY)); | 1813 5, 5, TargetProperty::OPACITY)); |
| 1816 | 1814 |
| 1817 player_->Animate(kInitialTickTime); | 1815 player_->Tick(kInitialTickTime); |
| 1818 player_->UpdateState(true, nullptr); | 1816 player_->UpdateState(true, nullptr); |
| 1819 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1817 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1820 player_->UpdateState(true, nullptr); | 1818 player_->UpdateState(true, nullptr); |
| 1821 | 1819 |
| 1822 EXPECT_EQ(Animation::FINISHED, player_->GetAnimationById(1)->run_state()); | 1820 EXPECT_EQ(Animation::FINISHED, player_->GetAnimationById(1)->run_state()); |
| 1823 EXPECT_EQ(Animation::FINISHED, player_->GetAnimationById(2)->run_state()); | 1821 EXPECT_EQ(Animation::FINISHED, player_->GetAnimationById(2)->run_state()); |
| 1824 EXPECT_EQ(Animation::RUNNING, player_->GetAnimationById(3)->run_state()); | 1822 EXPECT_EQ(Animation::RUNNING, player_->GetAnimationById(3)->run_state()); |
| 1825 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1823 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 1826 player_->GetAnimationById(4)->run_state()); | 1824 player_->GetAnimationById(4)->run_state()); |
| 1827 EXPECT_EQ(Animation::RUNNING, player_->GetAnimationById(5)->run_state()); | 1825 EXPECT_EQ(Animation::RUNNING, player_->GetAnimationById(5)->run_state()); |
| 1828 | 1826 |
| 1829 player_->AbortAnimations(TargetProperty::TRANSFORM, false); | 1827 player_->AbortAnimations(TargetProperty::TRANSFORM, false); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1851 player_impl_->ActivateAnimations(); | 1849 player_impl_->ActivateAnimations(); |
| 1852 | 1850 |
| 1853 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); | 1851 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); |
| 1854 EXPECT_FALSE(host_->needs_push_properties()); | 1852 EXPECT_FALSE(host_->needs_push_properties()); |
| 1855 | 1853 |
| 1856 player_->AbortAnimations(TargetProperty::OPACITY, false); | 1854 player_->AbortAnimations(TargetProperty::OPACITY, false); |
| 1857 EXPECT_EQ(Animation::ABORTED, | 1855 EXPECT_EQ(Animation::ABORTED, |
| 1858 player_->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1856 player_->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1859 EXPECT_TRUE(host_->needs_push_properties()); | 1857 EXPECT_TRUE(host_->needs_push_properties()); |
| 1860 | 1858 |
| 1861 player_->Animate(kInitialTickTime); | 1859 player_->Tick(kInitialTickTime); |
| 1862 player_->UpdateState(true, nullptr); | 1860 player_->UpdateState(true, nullptr); |
| 1863 EXPECT_EQ(Animation::ABORTED, | 1861 EXPECT_EQ(Animation::ABORTED, |
| 1864 player_->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1862 player_->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1865 | 1863 |
| 1866 EXPECT_TRUE(player_->needs_push_properties()); | 1864 EXPECT_TRUE(player_->needs_push_properties()); |
| 1867 EXPECT_TRUE(player_->needs_push_properties()); | 1865 EXPECT_TRUE(player_->needs_push_properties()); |
| 1868 EXPECT_TRUE(host_->needs_push_properties()); | 1866 EXPECT_TRUE(host_->needs_push_properties()); |
| 1869 | 1867 |
| 1870 PushProperties(); | 1868 PushProperties(); |
| 1871 EXPECT_FALSE(host_->needs_push_properties()); | 1869 EXPECT_FALSE(host_->needs_push_properties()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1893 player_impl_->ActivateAnimations(); | 1891 player_impl_->ActivateAnimations(); |
| 1894 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); | 1892 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); |
| 1895 | 1893 |
| 1896 player_impl_->AbortAnimations(TargetProperty::OPACITY, false); | 1894 player_impl_->AbortAnimations(TargetProperty::OPACITY, false); |
| 1897 EXPECT_EQ(Animation::ABORTED, | 1895 EXPECT_EQ(Animation::ABORTED, |
| 1898 player_impl_->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1896 player_impl_->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1899 EXPECT_TRUE(host_impl_->needs_push_properties()); | 1897 EXPECT_TRUE(host_impl_->needs_push_properties()); |
| 1900 EXPECT_TRUE(player_impl_->needs_push_properties()); | 1898 EXPECT_TRUE(player_impl_->needs_push_properties()); |
| 1901 | 1899 |
| 1902 auto events = CreateEventsForTesting(); | 1900 auto events = CreateEventsForTesting(); |
| 1903 player_impl_->Animate(kInitialTickTime); | 1901 player_impl_->Tick(kInitialTickTime); |
| 1904 player_impl_->UpdateState(true, events.get()); | 1902 player_impl_->UpdateState(true, events.get()); |
| 1905 EXPECT_TRUE(host_impl_->needs_push_properties()); | 1903 EXPECT_TRUE(host_impl_->needs_push_properties()); |
| 1906 EXPECT_EQ(1u, events->events_.size()); | 1904 EXPECT_EQ(1u, events->events_.size()); |
| 1907 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[0].type); | 1905 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[0].type); |
| 1908 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 1906 EXPECT_EQ(Animation::WAITING_FOR_DELETION, |
| 1909 player_impl_->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1907 player_impl_->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1910 | 1908 |
| 1911 player_->NotifyAnimationAborted(events->events_[0]); | 1909 player_->NotifyAnimationAborted(events->events_[0]); |
| 1912 EXPECT_EQ(Animation::ABORTED, | 1910 EXPECT_EQ(Animation::ABORTED, |
| 1913 player_->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1911 player_->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1914 EXPECT_TRUE(delegate.aborted()); | 1912 EXPECT_TRUE(delegate.aborted()); |
| 1915 | 1913 |
| 1916 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1914 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 1917 player_->UpdateState(true, nullptr); | 1915 player_->UpdateState(true, nullptr); |
| 1918 EXPECT_TRUE(host_->needs_push_properties()); | 1916 EXPECT_TRUE(host_->needs_push_properties()); |
| 1919 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 1917 EXPECT_EQ(Animation::WAITING_FOR_DELETION, |
| 1920 player_->GetAnimation(TargetProperty::OPACITY)->run_state()); | 1918 player_->GetAnimation(TargetProperty::OPACITY)->run_state()); |
| 1921 | 1919 |
| 1922 PushProperties(); | 1920 PushProperties(); |
| 1923 | 1921 |
| 1924 player_impl_->ActivateAnimations(); | 1922 player_impl_->ActivateAnimations(); |
| 1925 EXPECT_FALSE(player_->GetAnimationById(animation_id)); | 1923 EXPECT_FALSE(player_->GetAnimationById(animation_id)); |
| 1926 EXPECT_FALSE(player_impl_->GetAnimationById(animation_id)); | 1924 EXPECT_FALSE(player_impl_->GetAnimationById(animation_id)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1959 player_impl_->ActivateAnimations(); | 1957 player_impl_->ActivateAnimations(); |
| 1960 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); | 1958 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); |
| 1961 | 1959 |
| 1962 player_impl_->AbortAnimations(TargetProperty::SCROLL_OFFSET, true); | 1960 player_impl_->AbortAnimations(TargetProperty::SCROLL_OFFSET, true); |
| 1963 EXPECT_TRUE(host_impl_->needs_push_properties()); | 1961 EXPECT_TRUE(host_impl_->needs_push_properties()); |
| 1964 EXPECT_EQ( | 1962 EXPECT_EQ( |
| 1965 Animation::ABORTED_BUT_NEEDS_COMPLETION, | 1963 Animation::ABORTED_BUT_NEEDS_COMPLETION, |
| 1966 player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET)->run_state()); | 1964 player_impl_->GetAnimation(TargetProperty::SCROLL_OFFSET)->run_state()); |
| 1967 | 1965 |
| 1968 auto events = CreateEventsForTesting(); | 1966 auto events = CreateEventsForTesting(); |
| 1969 player_impl_->Animate(kInitialTickTime); | 1967 player_impl_->Tick(kInitialTickTime); |
| 1970 player_impl_->UpdateState(true, events.get()); | 1968 player_impl_->UpdateState(true, events.get()); |
| 1971 EXPECT_TRUE(delegate_impl.finished()); | 1969 EXPECT_TRUE(delegate_impl.finished()); |
| 1972 EXPECT_TRUE(host_impl_->needs_push_properties()); | 1970 EXPECT_TRUE(host_impl_->needs_push_properties()); |
| 1973 EXPECT_EQ(1u, events->events_.size()); | 1971 EXPECT_EQ(1u, events->events_.size()); |
| 1974 EXPECT_EQ(AnimationEvent::TAKEOVER, events->events_[0].type); | 1972 EXPECT_EQ(AnimationEvent::TAKEOVER, events->events_[0].type); |
| 1975 EXPECT_EQ(123, events->events_[0].animation_start_time); | 1973 EXPECT_EQ(123, events->events_[0].animation_start_time); |
| 1976 EXPECT_EQ( | 1974 EXPECT_EQ( |
| 1977 target_value, | 1975 target_value, |
| 1978 events->events_[0].curve->ToScrollOffsetAnimationCurve()->target_value()); | 1976 events->events_[0].curve->ToScrollOffsetAnimationCurve()->target_value()); |
| 1979 EXPECT_EQ( | 1977 EXPECT_EQ( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2014 group_id, TargetProperty::TRANSFORM)); | 2012 group_id, TargetProperty::TRANSFORM)); |
| 2015 first_animation->set_is_controlling_instance_for_test(true); | 2013 first_animation->set_is_controlling_instance_for_test(true); |
| 2016 player_impl_->AddAnimation(std::move(first_animation)); | 2014 player_impl_->AddAnimation(std::move(first_animation)); |
| 2017 | 2015 |
| 2018 std::unique_ptr<Animation> second_animation(Animation::Create( | 2016 std::unique_ptr<Animation> second_animation(Animation::Create( |
| 2019 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 2017 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 2020 2, group_id, TargetProperty::OPACITY)); | 2018 2, group_id, TargetProperty::OPACITY)); |
| 2021 second_animation->set_is_controlling_instance_for_test(true); | 2019 second_animation->set_is_controlling_instance_for_test(true); |
| 2022 player_impl_->AddAnimation(std::move(second_animation)); | 2020 player_impl_->AddAnimation(std::move(second_animation)); |
| 2023 | 2021 |
| 2024 player_impl_->Animate(kInitialTickTime); | 2022 player_impl_->Tick(kInitialTickTime); |
| 2025 player_impl_->UpdateState(true, events.get()); | 2023 player_impl_->UpdateState(true, events.get()); |
| 2026 | 2024 |
| 2027 // Both animations should have started. | 2025 // Both animations should have started. |
| 2028 EXPECT_EQ(2u, events->events_.size()); | 2026 EXPECT_EQ(2u, events->events_.size()); |
| 2029 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); | 2027 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); |
| 2030 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); | 2028 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); |
| 2031 | 2029 |
| 2032 events = CreateEventsForTesting(); | 2030 events = CreateEventsForTesting(); |
| 2033 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 2031 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 2034 player_impl_->UpdateState(true, events.get()); | 2032 player_impl_->UpdateState(true, events.get()); |
| 2035 | 2033 |
| 2036 // The opacity animation should be finished, but should not have generated | 2034 // The opacity animation should be finished, but should not have generated |
| 2037 // a FINISHED event yet. | 2035 // a FINISHED event yet. |
| 2038 EXPECT_EQ(0u, events->events_.size()); | 2036 EXPECT_EQ(0u, events->events_.size()); |
| 2039 EXPECT_EQ(Animation::FINISHED, | 2037 EXPECT_EQ(Animation::FINISHED, |
| 2040 player_impl_->GetAnimationById(2)->run_state()); | 2038 player_impl_->GetAnimationById(2)->run_state()); |
| 2041 EXPECT_EQ(Animation::RUNNING, player_impl_->GetAnimationById(1)->run_state()); | 2039 EXPECT_EQ(Animation::RUNNING, player_impl_->GetAnimationById(1)->run_state()); |
| 2042 | 2040 |
| 2043 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 2041 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 2044 player_impl_->UpdateState(true, events.get()); | 2042 player_impl_->UpdateState(true, events.get()); |
| 2045 | 2043 |
| 2046 // Both animations should have generated FINISHED events. | 2044 // Both animations should have generated FINISHED events. |
| 2047 EXPECT_EQ(2u, events->events_.size()); | 2045 EXPECT_EQ(2u, events->events_.size()); |
| 2048 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); | 2046 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); |
| 2049 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[1].type); | 2047 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[1].type); |
| 2050 } | 2048 } |
| 2051 | 2049 |
| 2052 // Ensure that when a group has a mix of aborted and finished animations, | 2050 // Ensure that when a group has a mix of aborted and finished animations, |
| 2053 // we generate a FINISHED event for the finished animation and an ABORTED | 2051 // we generate a FINISHED event for the finished animation and an ABORTED |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2065 TargetProperty::TRANSFORM)); | 2063 TargetProperty::TRANSFORM)); |
| 2066 first_animation->set_is_controlling_instance_for_test(true); | 2064 first_animation->set_is_controlling_instance_for_test(true); |
| 2067 player_impl_->AddAnimation(std::move(first_animation)); | 2065 player_impl_->AddAnimation(std::move(first_animation)); |
| 2068 | 2066 |
| 2069 std::unique_ptr<Animation> second_animation(CreateAnimation( | 2067 std::unique_ptr<Animation> second_animation(CreateAnimation( |
| 2070 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 2068 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 2071 1, TargetProperty::OPACITY)); | 2069 1, TargetProperty::OPACITY)); |
| 2072 second_animation->set_is_controlling_instance_for_test(true); | 2070 second_animation->set_is_controlling_instance_for_test(true); |
| 2073 player_impl_->AddAnimation(std::move(second_animation)); | 2071 player_impl_->AddAnimation(std::move(second_animation)); |
| 2074 | 2072 |
| 2075 player_impl_->Animate(kInitialTickTime); | 2073 player_impl_->Tick(kInitialTickTime); |
| 2076 player_impl_->UpdateState(true, events.get()); | 2074 player_impl_->UpdateState(true, events.get()); |
| 2077 | 2075 |
| 2078 // Both animations should have started. | 2076 // Both animations should have started. |
| 2079 EXPECT_EQ(2u, events->events_.size()); | 2077 EXPECT_EQ(2u, events->events_.size()); |
| 2080 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); | 2078 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); |
| 2081 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); | 2079 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); |
| 2082 | 2080 |
| 2083 player_impl_->AbortAnimations(TargetProperty::OPACITY, false); | 2081 player_impl_->AbortAnimations(TargetProperty::OPACITY, false); |
| 2084 | 2082 |
| 2085 events = CreateEventsForTesting(); | 2083 events = CreateEventsForTesting(); |
| 2086 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 2084 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 2087 player_impl_->UpdateState(true, events.get()); | 2085 player_impl_->UpdateState(true, events.get()); |
| 2088 | 2086 |
| 2089 // We should have exactly 2 events: a FINISHED event for the tranform | 2087 // We should have exactly 2 events: a FINISHED event for the tranform |
| 2090 // animation, and an ABORTED event for the opacity animation. | 2088 // animation, and an ABORTED event for the opacity animation. |
| 2091 EXPECT_EQ(2u, events->events_.size()); | 2089 EXPECT_EQ(2u, events->events_.size()); |
| 2092 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); | 2090 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); |
| 2093 EXPECT_EQ(TargetProperty::TRANSFORM, events->events_[0].target_property); | 2091 EXPECT_EQ(TargetProperty::TRANSFORM, events->events_[0].target_property); |
| 2094 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[1].type); | 2092 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[1].type); |
| 2095 EXPECT_EQ(TargetProperty::OPACITY, events->events_[1].target_property); | 2093 EXPECT_EQ(TargetProperty::OPACITY, events->events_[1].target_property); |
| 2096 } | 2094 } |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2510 EXPECT_TRUE(player_impl_->needs_to_start_animations()); | 2508 EXPECT_TRUE(player_impl_->needs_to_start_animations()); |
| 2511 | 2509 |
| 2512 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); | 2510 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); |
| 2513 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 2511 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 2514 player_impl_->GetAnimationById(animation_id)->run_state()); | 2512 player_impl_->GetAnimationById(animation_id)->run_state()); |
| 2515 EXPECT_TRUE( | 2513 EXPECT_TRUE( |
| 2516 player_impl_->GetAnimationById(animation_id)->affects_pending_elements()); | 2514 player_impl_->GetAnimationById(animation_id)->affects_pending_elements()); |
| 2517 EXPECT_FALSE( | 2515 EXPECT_FALSE( |
| 2518 player_impl_->GetAnimationById(animation_id)->affects_active_elements()); | 2516 player_impl_->GetAnimationById(animation_id)->affects_active_elements()); |
| 2519 | 2517 |
| 2520 player_impl_->Animate(kInitialTickTime); | 2518 player_impl_->Tick(kInitialTickTime); |
| 2521 EXPECT_FALSE(player_impl_->needs_to_start_animations()); | 2519 EXPECT_FALSE(player_impl_->needs_to_start_animations()); |
| 2522 player_impl_->UpdateState(true, events.get()); | 2520 player_impl_->UpdateState(true, events.get()); |
| 2523 | 2521 |
| 2524 // Since the animation hasn't been activated, it should still be STARTING | 2522 // Since the animation hasn't been activated, it should still be STARTING |
| 2525 // rather than RUNNING. | 2523 // rather than RUNNING. |
| 2526 EXPECT_EQ(Animation::STARTING, | 2524 EXPECT_EQ(Animation::STARTING, |
| 2527 player_impl_->GetAnimationById(animation_id)->run_state()); | 2525 player_impl_->GetAnimationById(animation_id)->run_state()); |
| 2528 | 2526 |
| 2529 // Since the animation hasn't been activated, only the pending observer | 2527 // Since the animation hasn't been activated, only the pending observer |
| 2530 // should have been ticked. | 2528 // should have been ticked. |
| 2531 EXPECT_EQ(0.5f, | 2529 EXPECT_EQ(0.5f, |
| 2532 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); | 2530 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); |
| 2533 EXPECT_EQ(0.f, client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 2531 EXPECT_EQ(0.f, client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 2534 | 2532 |
| 2535 player_impl_->ActivateAnimations(); | 2533 player_impl_->ActivateAnimations(); |
| 2536 EXPECT_TRUE( | 2534 EXPECT_TRUE( |
| 2537 player_impl_->GetAnimationById(animation_id)->affects_pending_elements()); | 2535 player_impl_->GetAnimationById(animation_id)->affects_pending_elements()); |
| 2538 EXPECT_TRUE( | 2536 EXPECT_TRUE( |
| 2539 player_impl_->GetAnimationById(animation_id)->affects_active_elements()); | 2537 player_impl_->GetAnimationById(animation_id)->affects_active_elements()); |
| 2540 | 2538 |
| 2541 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 2539 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 2542 player_impl_->UpdateState(true, events.get()); | 2540 player_impl_->UpdateState(true, events.get()); |
| 2543 | 2541 |
| 2544 // Since the animation has been activated, it should have reached the | 2542 // Since the animation has been activated, it should have reached the |
| 2545 // RUNNING state and the active observer should start to get ticked. | 2543 // RUNNING state and the active observer should start to get ticked. |
| 2546 EXPECT_EQ(Animation::RUNNING, | 2544 EXPECT_EQ(Animation::RUNNING, |
| 2547 player_impl_->GetAnimationById(animation_id)->run_state()); | 2545 player_impl_->GetAnimationById(animation_id)->run_state()); |
| 2548 EXPECT_EQ(0.5f, | 2546 EXPECT_EQ(0.5f, |
| 2549 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); | 2547 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); |
| 2550 EXPECT_EQ(0.5f, | 2548 EXPECT_EQ(0.5f, |
| 2551 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 2549 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2564 PushProperties(); | 2562 PushProperties(); |
| 2565 | 2563 |
| 2566 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); | 2564 EXPECT_TRUE(player_impl_->GetAnimationById(animation_id)); |
| 2567 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 2565 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 2568 player_impl_->GetAnimationById(animation_id)->run_state()); | 2566 player_impl_->GetAnimationById(animation_id)->run_state()); |
| 2569 EXPECT_TRUE( | 2567 EXPECT_TRUE( |
| 2570 player_impl_->GetAnimationById(animation_id)->affects_pending_elements()); | 2568 player_impl_->GetAnimationById(animation_id)->affects_pending_elements()); |
| 2571 EXPECT_FALSE( | 2569 EXPECT_FALSE( |
| 2572 player_impl_->GetAnimationById(animation_id)->affects_active_elements()); | 2570 player_impl_->GetAnimationById(animation_id)->affects_active_elements()); |
| 2573 | 2571 |
| 2574 player_impl_->Animate(kInitialTickTime); | 2572 player_impl_->Tick(kInitialTickTime); |
| 2575 | 2573 |
| 2576 // Since the animation hasn't been activated, only the pending observer | 2574 // Since the animation hasn't been activated, only the pending observer |
| 2577 // should have been ticked. | 2575 // should have been ticked. |
| 2578 EXPECT_EQ(0.5f, | 2576 EXPECT_EQ(0.5f, |
| 2579 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); | 2577 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); |
| 2580 EXPECT_EQ(0.f, client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 2578 EXPECT_EQ(0.f, client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 2581 | 2579 |
| 2582 player_impl_->ActivateAnimations(); | 2580 player_impl_->ActivateAnimations(); |
| 2583 EXPECT_TRUE( | 2581 EXPECT_TRUE( |
| 2584 player_impl_->GetAnimationById(animation_id)->affects_pending_elements()); | 2582 player_impl_->GetAnimationById(animation_id)->affects_pending_elements()); |
| 2585 EXPECT_TRUE( | 2583 EXPECT_TRUE( |
| 2586 player_impl_->GetAnimationById(animation_id)->affects_active_elements()); | 2584 player_impl_->GetAnimationById(animation_id)->affects_active_elements()); |
| 2587 | 2585 |
| 2588 player_impl_->UpdateState(true, events.get()); | 2586 player_impl_->UpdateState(true, events.get()); |
| 2589 | 2587 |
| 2590 // Since the animation has been activated, it should have reached the | 2588 // Since the animation has been activated, it should have reached the |
| 2591 // RUNNING state. | 2589 // RUNNING state. |
| 2592 EXPECT_EQ(Animation::RUNNING, | 2590 EXPECT_EQ(Animation::RUNNING, |
| 2593 player_impl_->GetAnimationById(animation_id)->run_state()); | 2591 player_impl_->GetAnimationById(animation_id)->run_state()); |
| 2594 | 2592 |
| 2595 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 2593 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 2596 | 2594 |
| 2597 // Both elements should have been ticked. | 2595 // Both elements should have been ticked. |
| 2598 EXPECT_EQ(0.75f, | 2596 EXPECT_EQ(0.75f, |
| 2599 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); | 2597 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); |
| 2600 EXPECT_EQ(0.75f, | 2598 EXPECT_EQ(0.75f, |
| 2601 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 2599 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 2602 } | 2600 } |
| 2603 | 2601 |
| 2604 TEST_F(ElementAnimationsTest, ObserverNotifiedWhenTransformAnimationChanges) { | 2602 TEST_F(ElementAnimationsTest, ObserverNotifiedWhenTransformAnimationChanges) { |
| 2605 CreateTestLayer(true, true); | 2603 CreateTestLayer(true, true); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2641 player_impl_->ActivateAnimations(); | 2639 player_impl_->ActivateAnimations(); |
| 2642 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( | 2640 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( |
| 2643 element_id_, ElementListType::PENDING)); | 2641 element_id_, ElementListType::PENDING)); |
| 2644 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( | 2642 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2645 element_id_, ElementListType::PENDING)); | 2643 element_id_, ElementListType::PENDING)); |
| 2646 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( | 2644 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( |
| 2647 element_id_, ElementListType::ACTIVE)); | 2645 element_id_, ElementListType::ACTIVE)); |
| 2648 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( | 2646 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2649 element_id_, ElementListType::ACTIVE)); | 2647 element_id_, ElementListType::ACTIVE)); |
| 2650 | 2648 |
| 2651 player_impl_->Animate(kInitialTickTime); | 2649 player_impl_->Tick(kInitialTickTime); |
| 2652 player_impl_->UpdateState(true, events.get()); | 2650 player_impl_->UpdateState(true, events.get()); |
| 2653 | 2651 |
| 2654 player_->NotifyAnimationStarted(events->events_[0]); | 2652 player_->NotifyAnimationStarted(events->events_[0]); |
| 2655 events->events_.clear(); | 2653 events->events_.clear(); |
| 2656 | 2654 |
| 2657 // Finish the animation. | 2655 // Finish the animation. |
| 2658 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 2656 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 2659 player_->UpdateState(true, nullptr); | 2657 player_->UpdateState(true, nullptr); |
| 2660 EXPECT_FALSE(client_.GetHasPotentialTransformAnimation( | 2658 EXPECT_FALSE(client_.GetHasPotentialTransformAnimation( |
| 2661 element_id_, ElementListType::ACTIVE)); | 2659 element_id_, ElementListType::ACTIVE)); |
| 2662 EXPECT_FALSE(client_.GetTransformIsCurrentlyAnimating( | 2660 EXPECT_FALSE(client_.GetTransformIsCurrentlyAnimating( |
| 2663 element_id_, ElementListType::ACTIVE)); | 2661 element_id_, ElementListType::ACTIVE)); |
| 2664 | 2662 |
| 2665 PushProperties(); | 2663 PushProperties(); |
| 2666 | 2664 |
| 2667 // animations_impl hasn't yet ticked at/past the end of the animation. | 2665 // animations_impl hasn't yet ticked at/past the end of the animation. |
| 2668 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( | 2666 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( |
| 2669 element_id_, ElementListType::PENDING)); | 2667 element_id_, ElementListType::PENDING)); |
| 2670 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( | 2668 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2671 element_id_, ElementListType::PENDING)); | 2669 element_id_, ElementListType::PENDING)); |
| 2672 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( | 2670 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( |
| 2673 element_id_, ElementListType::ACTIVE)); | 2671 element_id_, ElementListType::ACTIVE)); |
| 2674 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( | 2672 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2675 element_id_, ElementListType::ACTIVE)); | 2673 element_id_, ElementListType::ACTIVE)); |
| 2676 | 2674 |
| 2677 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 2675 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 2678 player_impl_->UpdateState(true, events.get()); | 2676 player_impl_->UpdateState(true, events.get()); |
| 2679 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( | 2677 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( |
| 2680 element_id_, ElementListType::PENDING)); | 2678 element_id_, ElementListType::PENDING)); |
| 2681 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( | 2679 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2682 element_id_, ElementListType::PENDING)); | 2680 element_id_, ElementListType::PENDING)); |
| 2683 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( | 2681 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( |
| 2684 element_id_, ElementListType::ACTIVE)); | 2682 element_id_, ElementListType::ACTIVE)); |
| 2685 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( | 2683 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2686 element_id_, ElementListType::ACTIVE)); | 2684 element_id_, ElementListType::ACTIVE)); |
| 2687 | 2685 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2709 | 2707 |
| 2710 player_impl_->ActivateAnimations(); | 2708 player_impl_->ActivateAnimations(); |
| 2711 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( | 2709 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( |
| 2712 element_id_, ElementListType::ACTIVE)); | 2710 element_id_, ElementListType::ACTIVE)); |
| 2713 // animation1 is in effect currently and animation2 isn't. As the element has | 2711 // animation1 is in effect currently and animation2 isn't. As the element has |
| 2714 // atleast one animation that's in effect currently, client should be notified | 2712 // atleast one animation that's in effect currently, client should be notified |
| 2715 // that the transform is currently animating. | 2713 // that the transform is currently animating. |
| 2716 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( | 2714 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2717 element_id_, ElementListType::ACTIVE)); | 2715 element_id_, ElementListType::ACTIVE)); |
| 2718 | 2716 |
| 2719 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 2717 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 2720 player_impl_->UpdateState(true, events.get()); | 2718 player_impl_->UpdateState(true, events.get()); |
| 2721 | 2719 |
| 2722 player_->NotifyAnimationStarted(events->events_[0]); | 2720 player_->NotifyAnimationStarted(events->events_[0]); |
| 2723 events->events_.clear(); | 2721 events->events_.clear(); |
| 2724 | 2722 |
| 2725 player_->RemoveAnimation(animation_id); | 2723 player_->RemoveAnimation(animation_id); |
| 2726 player_->RemoveAnimation(animation2_id); | 2724 player_->RemoveAnimation(animation2_id); |
| 2727 EXPECT_FALSE(client_.GetHasPotentialTransformAnimation( | 2725 EXPECT_FALSE(client_.GetHasPotentialTransformAnimation( |
| 2728 element_id_, ElementListType::ACTIVE)); | 2726 element_id_, ElementListType::ACTIVE)); |
| 2729 EXPECT_FALSE(client_.GetTransformIsCurrentlyAnimating( | 2727 EXPECT_FALSE(client_.GetTransformIsCurrentlyAnimating( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2761 element_id_, ElementListType::ACTIVE)); | 2759 element_id_, ElementListType::ACTIVE)); |
| 2762 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( | 2760 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2763 element_id_, ElementListType::ACTIVE)); | 2761 element_id_, ElementListType::ACTIVE)); |
| 2764 | 2762 |
| 2765 player_impl_->ActivateAnimations(); | 2763 player_impl_->ActivateAnimations(); |
| 2766 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( | 2764 EXPECT_TRUE(client_impl_.GetHasPotentialTransformAnimation( |
| 2767 element_id_, ElementListType::ACTIVE)); | 2765 element_id_, ElementListType::ACTIVE)); |
| 2768 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( | 2766 EXPECT_TRUE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2769 element_id_, ElementListType::ACTIVE)); | 2767 element_id_, ElementListType::ACTIVE)); |
| 2770 | 2768 |
| 2771 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 2769 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 2772 player_impl_->UpdateState(true, events.get()); | 2770 player_impl_->UpdateState(true, events.get()); |
| 2773 | 2771 |
| 2774 player_->NotifyAnimationStarted(events->events_[0]); | 2772 player_->NotifyAnimationStarted(events->events_[0]); |
| 2775 events->events_.clear(); | 2773 events->events_.clear(); |
| 2776 | 2774 |
| 2777 player_impl_->AbortAnimations(TargetProperty::TRANSFORM, false); | 2775 player_impl_->AbortAnimations(TargetProperty::TRANSFORM, false); |
| 2778 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( | 2776 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( |
| 2779 element_id_, ElementListType::PENDING)); | 2777 element_id_, ElementListType::PENDING)); |
| 2780 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( | 2778 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2781 element_id_, ElementListType::PENDING)); | 2779 element_id_, ElementListType::PENDING)); |
| 2782 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( | 2780 EXPECT_FALSE(client_impl_.GetHasPotentialTransformAnimation( |
| 2783 element_id_, ElementListType::ACTIVE)); | 2781 element_id_, ElementListType::ACTIVE)); |
| 2784 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( | 2782 EXPECT_FALSE(client_impl_.GetTransformIsCurrentlyAnimating( |
| 2785 element_id_, ElementListType::ACTIVE)); | 2783 element_id_, ElementListType::ACTIVE)); |
| 2786 | 2784 |
| 2787 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); | 2785 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); |
| 2788 player_impl_->UpdateState(true, events.get()); | 2786 player_impl_->UpdateState(true, events.get()); |
| 2789 | 2787 |
| 2790 element_animations_->NotifyAnimationAborted(events->events_[0]); | 2788 element_animations_->NotifyAnimationAborted(events->events_[0]); |
| 2791 EXPECT_FALSE(client_.GetHasPotentialTransformAnimation( | 2789 EXPECT_FALSE(client_.GetHasPotentialTransformAnimation( |
| 2792 element_id_, ElementListType::ACTIVE)); | 2790 element_id_, ElementListType::ACTIVE)); |
| 2793 EXPECT_FALSE(client_.GetTransformIsCurrentlyAnimating( | 2791 EXPECT_FALSE(client_.GetTransformIsCurrentlyAnimating( |
| 2794 element_id_, ElementListType::ACTIVE)); | 2792 element_id_, ElementListType::ACTIVE)); |
| 2795 | 2793 |
| 2796 // Case 4 : An animation that's not in effect. | 2794 // Case 4 : An animation that's not in effect. |
| 2797 animation_id = AddAnimatedTransformToPlayer(player_.get(), 1.0, 1, 6); | 2795 animation_id = AddAnimatedTransformToPlayer(player_.get(), 1.0, 1, 6); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2858 player_impl_->ActivateAnimations(); | 2856 player_impl_->ActivateAnimations(); |
| 2859 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( | 2857 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( |
| 2860 element_id_, ElementListType::PENDING)); | 2858 element_id_, ElementListType::PENDING)); |
| 2861 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( | 2859 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 2862 element_id_, ElementListType::PENDING)); | 2860 element_id_, ElementListType::PENDING)); |
| 2863 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( | 2861 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( |
| 2864 element_id_, ElementListType::ACTIVE)); | 2862 element_id_, ElementListType::ACTIVE)); |
| 2865 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( | 2863 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 2866 element_id_, ElementListType::ACTIVE)); | 2864 element_id_, ElementListType::ACTIVE)); |
| 2867 | 2865 |
| 2868 player_impl_->Animate(kInitialTickTime); | 2866 player_impl_->Tick(kInitialTickTime); |
| 2869 player_impl_->UpdateState(true, events.get()); | 2867 player_impl_->UpdateState(true, events.get()); |
| 2870 | 2868 |
| 2871 player_->NotifyAnimationStarted(events->events_[0]); | 2869 player_->NotifyAnimationStarted(events->events_[0]); |
| 2872 events->events_.clear(); | 2870 events->events_.clear(); |
| 2873 | 2871 |
| 2874 // Finish the animation. | 2872 // Finish the animation. |
| 2875 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 2873 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 2876 player_->UpdateState(true, nullptr); | 2874 player_->UpdateState(true, nullptr); |
| 2877 EXPECT_FALSE(client_.GetHasPotentialOpacityAnimation( | 2875 EXPECT_FALSE(client_.GetHasPotentialOpacityAnimation( |
| 2878 element_id_, ElementListType::ACTIVE)); | 2876 element_id_, ElementListType::ACTIVE)); |
| 2879 EXPECT_FALSE(client_.GetOpacityIsCurrentlyAnimating(element_id_, | 2877 EXPECT_FALSE(client_.GetOpacityIsCurrentlyAnimating(element_id_, |
| 2880 ElementListType::ACTIVE)); | 2878 ElementListType::ACTIVE)); |
| 2881 | 2879 |
| 2882 PushProperties(); | 2880 PushProperties(); |
| 2883 | 2881 |
| 2884 // animations_impl hasn't yet ticked at/past the end of the animation. | 2882 // animations_impl hasn't yet ticked at/past the end of the animation. |
| 2885 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( | 2883 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( |
| 2886 element_id_, ElementListType::PENDING)); | 2884 element_id_, ElementListType::PENDING)); |
| 2887 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( | 2885 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 2888 element_id_, ElementListType::PENDING)); | 2886 element_id_, ElementListType::PENDING)); |
| 2889 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( | 2887 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( |
| 2890 element_id_, ElementListType::ACTIVE)); | 2888 element_id_, ElementListType::ACTIVE)); |
| 2891 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( | 2889 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 2892 element_id_, ElementListType::ACTIVE)); | 2890 element_id_, ElementListType::ACTIVE)); |
| 2893 | 2891 |
| 2894 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 2892 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 2895 player_impl_->UpdateState(true, events.get()); | 2893 player_impl_->UpdateState(true, events.get()); |
| 2896 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( | 2894 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( |
| 2897 element_id_, ElementListType::PENDING)); | 2895 element_id_, ElementListType::PENDING)); |
| 2898 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( | 2896 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 2899 element_id_, ElementListType::PENDING)); | 2897 element_id_, ElementListType::PENDING)); |
| 2900 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( | 2898 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( |
| 2901 element_id_, ElementListType::ACTIVE)); | 2899 element_id_, ElementListType::ACTIVE)); |
| 2902 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( | 2900 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 2903 element_id_, ElementListType::ACTIVE)); | 2901 element_id_, ElementListType::ACTIVE)); |
| 2904 | 2902 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2919 element_id_, ElementListType::ACTIVE)); | 2917 element_id_, ElementListType::ACTIVE)); |
| 2920 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( | 2918 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 2921 element_id_, ElementListType::ACTIVE)); | 2919 element_id_, ElementListType::ACTIVE)); |
| 2922 | 2920 |
| 2923 player_impl_->ActivateAnimations(); | 2921 player_impl_->ActivateAnimations(); |
| 2924 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( | 2922 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( |
| 2925 element_id_, ElementListType::ACTIVE)); | 2923 element_id_, ElementListType::ACTIVE)); |
| 2926 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( | 2924 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 2927 element_id_, ElementListType::ACTIVE)); | 2925 element_id_, ElementListType::ACTIVE)); |
| 2928 | 2926 |
| 2929 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 2927 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 2930 player_impl_->UpdateState(true, events.get()); | 2928 player_impl_->UpdateState(true, events.get()); |
| 2931 | 2929 |
| 2932 player_->NotifyAnimationStarted(events->events_[0]); | 2930 player_->NotifyAnimationStarted(events->events_[0]); |
| 2933 events->events_.clear(); | 2931 events->events_.clear(); |
| 2934 | 2932 |
| 2935 player_->RemoveAnimation(animation_id); | 2933 player_->RemoveAnimation(animation_id); |
| 2936 EXPECT_FALSE(client_.GetHasPotentialOpacityAnimation( | 2934 EXPECT_FALSE(client_.GetHasPotentialOpacityAnimation( |
| 2937 element_id_, ElementListType::ACTIVE)); | 2935 element_id_, ElementListType::ACTIVE)); |
| 2938 EXPECT_FALSE(client_.GetOpacityIsCurrentlyAnimating(element_id_, | 2936 EXPECT_FALSE(client_.GetOpacityIsCurrentlyAnimating(element_id_, |
| 2939 ElementListType::ACTIVE)); | 2937 ElementListType::ACTIVE)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2971 element_id_, ElementListType::ACTIVE)); | 2969 element_id_, ElementListType::ACTIVE)); |
| 2972 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( | 2970 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 2973 element_id_, ElementListType::ACTIVE)); | 2971 element_id_, ElementListType::ACTIVE)); |
| 2974 | 2972 |
| 2975 player_impl_->ActivateAnimations(); | 2973 player_impl_->ActivateAnimations(); |
| 2976 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( | 2974 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( |
| 2977 element_id_, ElementListType::ACTIVE)); | 2975 element_id_, ElementListType::ACTIVE)); |
| 2978 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( | 2976 EXPECT_TRUE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 2979 element_id_, ElementListType::ACTIVE)); | 2977 element_id_, ElementListType::ACTIVE)); |
| 2980 | 2978 |
| 2981 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 2979 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 2982 player_impl_->UpdateState(true, events.get()); | 2980 player_impl_->UpdateState(true, events.get()); |
| 2983 | 2981 |
| 2984 player_->NotifyAnimationStarted(events->events_[0]); | 2982 player_->NotifyAnimationStarted(events->events_[0]); |
| 2985 events->events_.clear(); | 2983 events->events_.clear(); |
| 2986 | 2984 |
| 2987 player_impl_->AbortAnimations(TargetProperty::OPACITY, false); | 2985 player_impl_->AbortAnimations(TargetProperty::OPACITY, false); |
| 2988 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( | 2986 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( |
| 2989 element_id_, ElementListType::PENDING)); | 2987 element_id_, ElementListType::PENDING)); |
| 2990 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( | 2988 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 2991 element_id_, ElementListType::PENDING)); | 2989 element_id_, ElementListType::PENDING)); |
| 2992 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( | 2990 EXPECT_FALSE(client_impl_.GetHasPotentialOpacityAnimation( |
| 2993 element_id_, ElementListType::ACTIVE)); | 2991 element_id_, ElementListType::ACTIVE)); |
| 2994 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( | 2992 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( |
| 2995 element_id_, ElementListType::ACTIVE)); | 2993 element_id_, ElementListType::ACTIVE)); |
| 2996 | 2994 |
| 2997 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); | 2995 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); |
| 2998 player_impl_->UpdateState(true, events.get()); | 2996 player_impl_->UpdateState(true, events.get()); |
| 2999 | 2997 |
| 3000 element_animations_->NotifyAnimationAborted(events->events_[0]); | 2998 element_animations_->NotifyAnimationAborted(events->events_[0]); |
| 3001 EXPECT_FALSE(client_.GetHasPotentialOpacityAnimation( | 2999 EXPECT_FALSE(client_.GetHasPotentialOpacityAnimation( |
| 3002 element_id_, ElementListType::ACTIVE)); | 3000 element_id_, ElementListType::ACTIVE)); |
| 3003 EXPECT_FALSE(client_.GetOpacityIsCurrentlyAnimating(element_id_, | 3001 EXPECT_FALSE(client_.GetOpacityIsCurrentlyAnimating(element_id_, |
| 3004 ElementListType::ACTIVE)); | 3002 ElementListType::ACTIVE)); |
| 3005 | 3003 |
| 3006 // Case 4 : An animation that's not in effect. | 3004 // Case 4 : An animation that's not in effect. |
| 3007 animation_id = AddOpacityTransitionToPlayer(player_.get(), 1.0, 0.f, 0.5f, | 3005 animation_id = AddOpacityTransitionToPlayer(player_.get(), 1.0, 0.f, 0.5f, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3068 player_impl_->ActivateAnimations(); | 3066 player_impl_->ActivateAnimations(); |
| 3069 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( | 3067 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( |
| 3070 element_id_, ElementListType::PENDING)); | 3068 element_id_, ElementListType::PENDING)); |
| 3071 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( | 3069 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3072 element_id_, ElementListType::PENDING)); | 3070 element_id_, ElementListType::PENDING)); |
| 3073 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( | 3071 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( |
| 3074 element_id_, ElementListType::ACTIVE)); | 3072 element_id_, ElementListType::ACTIVE)); |
| 3075 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( | 3073 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3076 element_id_, ElementListType::ACTIVE)); | 3074 element_id_, ElementListType::ACTIVE)); |
| 3077 | 3075 |
| 3078 player_impl_->Animate(kInitialTickTime); | 3076 player_impl_->Tick(kInitialTickTime); |
| 3079 player_impl_->UpdateState(true, events.get()); | 3077 player_impl_->UpdateState(true, events.get()); |
| 3080 | 3078 |
| 3081 player_->NotifyAnimationStarted(events->events_[0]); | 3079 player_->NotifyAnimationStarted(events->events_[0]); |
| 3082 events->events_.clear(); | 3080 events->events_.clear(); |
| 3083 | 3081 |
| 3084 // Finish the animation. | 3082 // Finish the animation. |
| 3085 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 3083 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 3086 player_->UpdateState(true, nullptr); | 3084 player_->UpdateState(true, nullptr); |
| 3087 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_, | 3085 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_, |
| 3088 ElementListType::ACTIVE)); | 3086 ElementListType::ACTIVE)); |
| 3089 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_, | 3087 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_, |
| 3090 ElementListType::ACTIVE)); | 3088 ElementListType::ACTIVE)); |
| 3091 | 3089 |
| 3092 PushProperties(); | 3090 PushProperties(); |
| 3093 | 3091 |
| 3094 // animations_impl hasn't yet ticked at/past the end of the animation. | 3092 // animations_impl hasn't yet ticked at/past the end of the animation. |
| 3095 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( | 3093 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( |
| 3096 element_id_, ElementListType::PENDING)); | 3094 element_id_, ElementListType::PENDING)); |
| 3097 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( | 3095 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3098 element_id_, ElementListType::PENDING)); | 3096 element_id_, ElementListType::PENDING)); |
| 3099 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( | 3097 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( |
| 3100 element_id_, ElementListType::ACTIVE)); | 3098 element_id_, ElementListType::ACTIVE)); |
| 3101 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( | 3099 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3102 element_id_, ElementListType::ACTIVE)); | 3100 element_id_, ElementListType::ACTIVE)); |
| 3103 | 3101 |
| 3104 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 3102 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 3105 player_impl_->UpdateState(true, events.get()); | 3103 player_impl_->UpdateState(true, events.get()); |
| 3106 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( | 3104 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( |
| 3107 element_id_, ElementListType::PENDING)); | 3105 element_id_, ElementListType::PENDING)); |
| 3108 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3106 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3109 element_id_, ElementListType::PENDING)); | 3107 element_id_, ElementListType::PENDING)); |
| 3110 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( | 3108 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( |
| 3111 element_id_, ElementListType::ACTIVE)); | 3109 element_id_, ElementListType::ACTIVE)); |
| 3112 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3110 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3113 element_id_, ElementListType::ACTIVE)); | 3111 element_id_, ElementListType::ACTIVE)); |
| 3114 | 3112 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3128 element_id_, ElementListType::ACTIVE)); | 3126 element_id_, ElementListType::ACTIVE)); |
| 3129 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3127 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3130 element_id_, ElementListType::ACTIVE)); | 3128 element_id_, ElementListType::ACTIVE)); |
| 3131 | 3129 |
| 3132 player_impl_->ActivateAnimations(); | 3130 player_impl_->ActivateAnimations(); |
| 3133 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( | 3131 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( |
| 3134 element_id_, ElementListType::ACTIVE)); | 3132 element_id_, ElementListType::ACTIVE)); |
| 3135 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( | 3133 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3136 element_id_, ElementListType::ACTIVE)); | 3134 element_id_, ElementListType::ACTIVE)); |
| 3137 | 3135 |
| 3138 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 3136 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 3139 player_impl_->UpdateState(true, events.get()); | 3137 player_impl_->UpdateState(true, events.get()); |
| 3140 | 3138 |
| 3141 player_->NotifyAnimationStarted(events->events_[0]); | 3139 player_->NotifyAnimationStarted(events->events_[0]); |
| 3142 events->events_.clear(); | 3140 events->events_.clear(); |
| 3143 | 3141 |
| 3144 player_->RemoveAnimation(animation_id); | 3142 player_->RemoveAnimation(animation_id); |
| 3145 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_, | 3143 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_, |
| 3146 ElementListType::ACTIVE)); | 3144 ElementListType::ACTIVE)); |
| 3147 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_, | 3145 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_, |
| 3148 ElementListType::ACTIVE)); | 3146 ElementListType::ACTIVE)); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3179 element_id_, ElementListType::ACTIVE)); | 3177 element_id_, ElementListType::ACTIVE)); |
| 3180 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3178 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3181 element_id_, ElementListType::ACTIVE)); | 3179 element_id_, ElementListType::ACTIVE)); |
| 3182 | 3180 |
| 3183 player_impl_->ActivateAnimations(); | 3181 player_impl_->ActivateAnimations(); |
| 3184 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( | 3182 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation( |
| 3185 element_id_, ElementListType::ACTIVE)); | 3183 element_id_, ElementListType::ACTIVE)); |
| 3186 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( | 3184 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3187 element_id_, ElementListType::ACTIVE)); | 3185 element_id_, ElementListType::ACTIVE)); |
| 3188 | 3186 |
| 3189 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 3187 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 3190 player_impl_->UpdateState(true, events.get()); | 3188 player_impl_->UpdateState(true, events.get()); |
| 3191 | 3189 |
| 3192 player_->NotifyAnimationStarted(events->events_[0]); | 3190 player_->NotifyAnimationStarted(events->events_[0]); |
| 3193 events->events_.clear(); | 3191 events->events_.clear(); |
| 3194 | 3192 |
| 3195 player_impl_->AbortAnimations(TargetProperty::FILTER, false); | 3193 player_impl_->AbortAnimations(TargetProperty::FILTER, false); |
| 3196 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( | 3194 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( |
| 3197 element_id_, ElementListType::PENDING)); | 3195 element_id_, ElementListType::PENDING)); |
| 3198 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3196 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3199 element_id_, ElementListType::PENDING)); | 3197 element_id_, ElementListType::PENDING)); |
| 3200 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( | 3198 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation( |
| 3201 element_id_, ElementListType::ACTIVE)); | 3199 element_id_, ElementListType::ACTIVE)); |
| 3202 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3200 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3203 element_id_, ElementListType::ACTIVE)); | 3201 element_id_, ElementListType::ACTIVE)); |
| 3204 | 3202 |
| 3205 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); | 3203 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); |
| 3206 player_impl_->UpdateState(true, events.get()); | 3204 player_impl_->UpdateState(true, events.get()); |
| 3207 | 3205 |
| 3208 element_animations_->NotifyAnimationAborted(events->events_[0]); | 3206 element_animations_->NotifyAnimationAborted(events->events_[0]); |
| 3209 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_, | 3207 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_, |
| 3210 ElementListType::ACTIVE)); | 3208 ElementListType::ACTIVE)); |
| 3211 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_, | 3209 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_, |
| 3212 ElementListType::ACTIVE)); | 3210 ElementListType::ACTIVE)); |
| 3213 | 3211 |
| 3214 // Case 4 : An animation that's not in effect. | 3212 // Case 4 : An animation that's not in effect. |
| 3215 animation_id = AddAnimatedFilterToPlayer(player_.get(), 1.0, 0.f, 0.5f); | 3213 animation_id = AddAnimatedFilterToPlayer(player_.get(), 1.0, 0.f, 0.5f); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3234 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( | 3232 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating( |
| 3235 element_id_, ElementListType::ACTIVE)); | 3233 element_id_, ElementListType::ACTIVE)); |
| 3236 } | 3234 } |
| 3237 | 3235 |
| 3238 TEST_F(ElementAnimationsTest, ClippedOpacityValues) { | 3236 TEST_F(ElementAnimationsTest, ClippedOpacityValues) { |
| 3239 CreateTestLayer(false, false); | 3237 CreateTestLayer(false, false); |
| 3240 AttachTimelinePlayerLayer(); | 3238 AttachTimelinePlayerLayer(); |
| 3241 | 3239 |
| 3242 AddOpacityTransitionToPlayer(player_.get(), 1, 1.f, 2.f, true); | 3240 AddOpacityTransitionToPlayer(player_.get(), 1, 1.f, 2.f, true); |
| 3243 | 3241 |
| 3244 player_->Animate(kInitialTickTime); | 3242 player_->Tick(kInitialTickTime); |
| 3245 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 3243 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 3246 | 3244 |
| 3247 // Opacity values are clipped [0,1] | 3245 // Opacity values are clipped [0,1] |
| 3248 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 3246 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 3249 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 3247 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 3250 } | 3248 } |
| 3251 | 3249 |
| 3252 TEST_F(ElementAnimationsTest, ClippedNegativeOpacityValues) { | 3250 TEST_F(ElementAnimationsTest, ClippedNegativeOpacityValues) { |
| 3253 CreateTestLayer(false, false); | 3251 CreateTestLayer(false, false); |
| 3254 AttachTimelinePlayerLayer(); | 3252 AttachTimelinePlayerLayer(); |
| 3255 | 3253 |
| 3256 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, -2.f, true); | 3254 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, -2.f, true); |
| 3257 | 3255 |
| 3258 player_->Animate(kInitialTickTime); | 3256 player_->Tick(kInitialTickTime); |
| 3259 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 3257 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 3260 | 3258 |
| 3261 // Opacity values are clipped [0,1] | 3259 // Opacity values are clipped [0,1] |
| 3262 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 3260 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 3263 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 3261 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 3264 } | 3262 } |
| 3265 | 3263 |
| 3266 TEST_F(ElementAnimationsTest, PushedDeletedAnimationWaitsForActivation) { | 3264 TEST_F(ElementAnimationsTest, PushedDeletedAnimationWaitsForActivation) { |
| 3267 CreateTestLayer(true, true); | 3265 CreateTestLayer(true, true); |
| 3268 AttachTimelinePlayerLayer(); | 3266 AttachTimelinePlayerLayer(); |
| 3269 CreateImplTimelineAndPlayer(); | 3267 CreateImplTimelineAndPlayer(); |
| 3270 | 3268 |
| 3271 auto events = CreateEventsForTesting(); | 3269 auto events = CreateEventsForTesting(); |
| 3272 | 3270 |
| 3273 const int animation_id = | 3271 const int animation_id = |
| 3274 AddOpacityTransitionToPlayer(player_.get(), 1, 0.5f, 1.f, true); | 3272 AddOpacityTransitionToPlayer(player_.get(), 1, 0.5f, 1.f, true); |
| 3275 | 3273 |
| 3276 PushProperties(); | 3274 PushProperties(); |
| 3277 player_impl_->ActivateAnimations(); | 3275 player_impl_->ActivateAnimations(); |
| 3278 player_impl_->Animate(kInitialTickTime); | 3276 player_impl_->Tick(kInitialTickTime); |
| 3279 player_impl_->UpdateState(true, events.get()); | 3277 player_impl_->UpdateState(true, events.get()); |
| 3280 EXPECT_EQ(Animation::RUNNING, | 3278 EXPECT_EQ(Animation::RUNNING, |
| 3281 player_impl_->GetAnimationById(animation_id)->run_state()); | 3279 player_impl_->GetAnimationById(animation_id)->run_state()); |
| 3282 EXPECT_EQ(0.5f, | 3280 EXPECT_EQ(0.5f, |
| 3283 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); | 3281 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); |
| 3284 EXPECT_EQ(0.5f, | 3282 EXPECT_EQ(0.5f, |
| 3285 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 3283 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 3286 | 3284 |
| 3287 EXPECT_TRUE( | 3285 EXPECT_TRUE( |
| 3288 player_impl_->GetAnimationById(animation_id)->affects_pending_elements()); | 3286 player_impl_->GetAnimationById(animation_id)->affects_pending_elements()); |
| 3289 EXPECT_TRUE( | 3287 EXPECT_TRUE( |
| 3290 player_impl_->GetAnimationById(animation_id)->affects_active_elements()); | 3288 player_impl_->GetAnimationById(animation_id)->affects_active_elements()); |
| 3291 | 3289 |
| 3292 // Delete the animation on the main-thread animations. | 3290 // Delete the animation on the main-thread animations. |
| 3293 player_->RemoveAnimation( | 3291 player_->RemoveAnimation( |
| 3294 player_->GetAnimation(TargetProperty::OPACITY)->id()); | 3292 player_->GetAnimation(TargetProperty::OPACITY)->id()); |
| 3295 PushProperties(); | 3293 PushProperties(); |
| 3296 | 3294 |
| 3297 // The animation should no longer affect pending elements. | 3295 // The animation should no longer affect pending elements. |
| 3298 EXPECT_FALSE( | 3296 EXPECT_FALSE( |
| 3299 player_impl_->GetAnimationById(animation_id)->affects_pending_elements()); | 3297 player_impl_->GetAnimationById(animation_id)->affects_pending_elements()); |
| 3300 EXPECT_TRUE( | 3298 EXPECT_TRUE( |
| 3301 player_impl_->GetAnimationById(animation_id)->affects_active_elements()); | 3299 player_impl_->GetAnimationById(animation_id)->affects_active_elements()); |
| 3302 | 3300 |
| 3303 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 3301 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 3304 player_impl_->UpdateState(true, events.get()); | 3302 player_impl_->UpdateState(true, events.get()); |
| 3305 | 3303 |
| 3306 // Only the active observer should have been ticked. | 3304 // Only the active observer should have been ticked. |
| 3307 EXPECT_EQ(0.5f, | 3305 EXPECT_EQ(0.5f, |
| 3308 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); | 3306 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); |
| 3309 EXPECT_EQ(0.75f, | 3307 EXPECT_EQ(0.75f, |
| 3310 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 3308 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 3311 | 3309 |
| 3312 player_impl_->ActivateAnimations(); | 3310 player_impl_->ActivateAnimations(); |
| 3313 | 3311 |
| 3314 // Activation should cause the animation to be deleted. | 3312 // Activation should cause the animation to be deleted. |
| 3315 EXPECT_FALSE(player_impl_->has_any_animation()); | 3313 EXPECT_FALSE(player_impl_->has_any_animation()); |
| 3316 } | 3314 } |
| 3317 | 3315 |
| 3318 // Tests that an animation that affects only active elements won't block | 3316 // Tests that an animation that affects only active elements won't block |
| 3319 // an animation that affects only pending elements from starting. | 3317 // an animation that affects only pending elements from starting. |
| 3320 TEST_F(ElementAnimationsTest, StartAnimationsAffectingDifferentObservers) { | 3318 TEST_F(ElementAnimationsTest, StartAnimationsAffectingDifferentObservers) { |
| 3321 CreateTestLayer(true, true); | 3319 CreateTestLayer(true, true); |
| 3322 AttachTimelinePlayerLayer(); | 3320 AttachTimelinePlayerLayer(); |
| 3323 CreateImplTimelineAndPlayer(); | 3321 CreateImplTimelineAndPlayer(); |
| 3324 | 3322 |
| 3325 auto events = CreateEventsForTesting(); | 3323 auto events = CreateEventsForTesting(); |
| 3326 | 3324 |
| 3327 const int first_animation_id = | 3325 const int first_animation_id = |
| 3328 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 1.f, true); | 3326 AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 1.f, true); |
| 3329 | 3327 |
| 3330 PushProperties(); | 3328 PushProperties(); |
| 3331 player_impl_->ActivateAnimations(); | 3329 player_impl_->ActivateAnimations(); |
| 3332 player_impl_->Animate(kInitialTickTime); | 3330 player_impl_->Tick(kInitialTickTime); |
| 3333 player_impl_->UpdateState(true, events.get()); | 3331 player_impl_->UpdateState(true, events.get()); |
| 3334 | 3332 |
| 3335 // Remove the first animation from the main-thread animations, and add a | 3333 // Remove the first animation from the main-thread animations, and add a |
| 3336 // new animation affecting the same property. | 3334 // new animation affecting the same property. |
| 3337 player_->RemoveAnimation( | 3335 player_->RemoveAnimation( |
| 3338 player_->GetAnimation(TargetProperty::OPACITY)->id()); | 3336 player_->GetAnimation(TargetProperty::OPACITY)->id()); |
| 3339 const int second_animation_id = | 3337 const int second_animation_id = |
| 3340 AddOpacityTransitionToPlayer(player_.get(), 1, 1.f, 0.5f, true); | 3338 AddOpacityTransitionToPlayer(player_.get(), 1, 1.f, 0.5f, true); |
| 3341 PushProperties(); | 3339 PushProperties(); |
| 3342 | 3340 |
| 3343 // The original animation should only affect active elements, and the new | 3341 // The original animation should only affect active elements, and the new |
| 3344 // animation should only affect pending elements. | 3342 // animation should only affect pending elements. |
| 3345 EXPECT_FALSE(player_impl_->GetAnimationById(first_animation_id) | 3343 EXPECT_FALSE(player_impl_->GetAnimationById(first_animation_id) |
| 3346 ->affects_pending_elements()); | 3344 ->affects_pending_elements()); |
| 3347 EXPECT_TRUE(player_impl_->GetAnimationById(first_animation_id) | 3345 EXPECT_TRUE(player_impl_->GetAnimationById(first_animation_id) |
| 3348 ->affects_active_elements()); | 3346 ->affects_active_elements()); |
| 3349 EXPECT_TRUE(player_impl_->GetAnimationById(second_animation_id) | 3347 EXPECT_TRUE(player_impl_->GetAnimationById(second_animation_id) |
| 3350 ->affects_pending_elements()); | 3348 ->affects_pending_elements()); |
| 3351 EXPECT_FALSE(player_impl_->GetAnimationById(second_animation_id) | 3349 EXPECT_FALSE(player_impl_->GetAnimationById(second_animation_id) |
| 3352 ->affects_active_elements()); | 3350 ->affects_active_elements()); |
| 3353 | 3351 |
| 3354 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 3352 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 3355 player_impl_->UpdateState(true, events.get()); | 3353 player_impl_->UpdateState(true, events.get()); |
| 3356 | 3354 |
| 3357 // The original animation should still be running, and the new animation | 3355 // The original animation should still be running, and the new animation |
| 3358 // should be starting. | 3356 // should be starting. |
| 3359 EXPECT_EQ(Animation::RUNNING, | 3357 EXPECT_EQ(Animation::RUNNING, |
| 3360 player_impl_->GetAnimationById(first_animation_id)->run_state()); | 3358 player_impl_->GetAnimationById(first_animation_id)->run_state()); |
| 3361 EXPECT_EQ(Animation::STARTING, | 3359 EXPECT_EQ(Animation::STARTING, |
| 3362 player_impl_->GetAnimationById(second_animation_id)->run_state()); | 3360 player_impl_->GetAnimationById(second_animation_id)->run_state()); |
| 3363 | 3361 |
| 3364 // The active observer should have been ticked by the original animation, | 3362 // The active observer should have been ticked by the original animation, |
| 3365 // and the pending observer should have been ticked by the new animation. | 3363 // and the pending observer should have been ticked by the new animation. |
| 3366 EXPECT_EQ(1.f, | 3364 EXPECT_EQ(1.f, |
| 3367 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); | 3365 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); |
| 3368 EXPECT_EQ(0.5f, | 3366 EXPECT_EQ(0.5f, |
| 3369 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 3367 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 3370 | 3368 |
| 3371 player_impl_->ActivateAnimations(); | 3369 player_impl_->ActivateAnimations(); |
| 3372 | 3370 |
| 3373 // The original animation should have been deleted, and the new animation | 3371 // The original animation should have been deleted, and the new animation |
| 3374 // should now affect both elements. | 3372 // should now affect both elements. |
| 3375 EXPECT_FALSE(player_impl_->GetAnimationById(first_animation_id)); | 3373 EXPECT_FALSE(player_impl_->GetAnimationById(first_animation_id)); |
| 3376 EXPECT_TRUE(player_impl_->GetAnimationById(second_animation_id) | 3374 EXPECT_TRUE(player_impl_->GetAnimationById(second_animation_id) |
| 3377 ->affects_pending_elements()); | 3375 ->affects_pending_elements()); |
| 3378 EXPECT_TRUE(player_impl_->GetAnimationById(second_animation_id) | 3376 EXPECT_TRUE(player_impl_->GetAnimationById(second_animation_id) |
| 3379 ->affects_active_elements()); | 3377 ->affects_active_elements()); |
| 3380 | 3378 |
| 3381 player_impl_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 3379 player_impl_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 3382 player_impl_->UpdateState(true, events.get()); | 3380 player_impl_->UpdateState(true, events.get()); |
| 3383 | 3381 |
| 3384 // The new animation should be running, and the active observer should have | 3382 // The new animation should be running, and the active observer should have |
| 3385 // been ticked at the new animation's starting point. | 3383 // been ticked at the new animation's starting point. |
| 3386 EXPECT_EQ(Animation::RUNNING, | 3384 EXPECT_EQ(Animation::RUNNING, |
| 3387 player_impl_->GetAnimationById(second_animation_id)->run_state()); | 3385 player_impl_->GetAnimationById(second_animation_id)->run_state()); |
| 3388 EXPECT_EQ(1.f, | 3386 EXPECT_EQ(1.f, |
| 3389 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); | 3387 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); |
| 3390 EXPECT_EQ(1.f, client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 3388 EXPECT_EQ(1.f, client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 3391 } | 3389 } |
| 3392 | 3390 |
| 3393 TEST_F(ElementAnimationsTest, TestIsCurrentlyAnimatingProperty) { | 3391 TEST_F(ElementAnimationsTest, TestIsCurrentlyAnimatingProperty) { |
| 3394 CreateTestLayer(false, false); | 3392 CreateTestLayer(false, false); |
| 3395 AttachTimelinePlayerLayer(); | 3393 AttachTimelinePlayerLayer(); |
| 3396 | 3394 |
| 3397 // Create an animation that initially affects only pending elements. | 3395 // Create an animation that initially affects only pending elements. |
| 3398 std::unique_ptr<Animation> animation(CreateAnimation( | 3396 std::unique_ptr<Animation> animation(CreateAnimation( |
| 3399 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 3397 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 3400 1, TargetProperty::OPACITY)); | 3398 1, TargetProperty::OPACITY)); |
| 3401 animation->set_affects_active_elements(false); | 3399 animation->set_affects_active_elements(false); |
| 3402 | 3400 |
| 3403 player_->AddAnimation(std::move(animation)); | 3401 player_->AddAnimation(std::move(animation)); |
| 3404 player_->Animate(kInitialTickTime); | 3402 player_->Tick(kInitialTickTime); |
| 3405 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3403 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3406 ElementListType::PENDING)); | 3404 ElementListType::PENDING)); |
| 3407 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3405 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3408 ElementListType::ACTIVE)); | 3406 ElementListType::ACTIVE)); |
| 3409 player_->UpdateState(true, nullptr); | 3407 player_->UpdateState(true, nullptr); |
| 3410 EXPECT_TRUE(player_->HasActiveAnimation()); | 3408 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 3411 | 3409 |
| 3412 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3410 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3413 ElementListType::PENDING)); | 3411 ElementListType::PENDING)); |
| 3414 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3412 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3415 ElementListType::ACTIVE)); | 3413 ElementListType::ACTIVE)); |
| 3416 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, | 3414 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, |
| 3417 ElementListType::PENDING)); | 3415 ElementListType::PENDING)); |
| 3418 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, | 3416 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, |
| 3419 ElementListType::ACTIVE)); | 3417 ElementListType::ACTIVE)); |
| 3420 | 3418 |
| 3421 player_->ActivateAnimations(); | 3419 player_->ActivateAnimations(); |
| 3422 | 3420 |
| 3423 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3421 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3424 ElementListType::PENDING)); | 3422 ElementListType::PENDING)); |
| 3425 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3423 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3426 ElementListType::ACTIVE)); | 3424 ElementListType::ACTIVE)); |
| 3427 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, | 3425 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, |
| 3428 ElementListType::PENDING)); | 3426 ElementListType::PENDING)); |
| 3429 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, | 3427 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, |
| 3430 ElementListType::ACTIVE)); | 3428 ElementListType::ACTIVE)); |
| 3431 | 3429 |
| 3432 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(10)); | 3430 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(10)); |
| 3433 player_->UpdateState(true, nullptr); | 3431 player_->UpdateState(true, nullptr); |
| 3434 | 3432 |
| 3435 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3433 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3436 ElementListType::PENDING)); | 3434 ElementListType::PENDING)); |
| 3437 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3435 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3438 ElementListType::ACTIVE)); | 3436 ElementListType::ACTIVE)); |
| 3439 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, | 3437 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, |
| 3440 ElementListType::PENDING)); | 3438 ElementListType::PENDING)); |
| 3441 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, | 3439 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, |
| 3442 ElementListType::ACTIVE)); | 3440 ElementListType::ACTIVE)); |
| 3443 | 3441 |
| 3444 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 3442 EXPECT_EQ(0.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 3445 | 3443 |
| 3446 // Tick past the end of the animation. | 3444 // Tick past the end of the animation. |
| 3447 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1100)); | 3445 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(1100)); |
| 3448 player_->UpdateState(true, nullptr); | 3446 player_->UpdateState(true, nullptr); |
| 3449 | 3447 |
| 3450 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3448 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3451 ElementListType::PENDING)); | 3449 ElementListType::PENDING)); |
| 3452 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3450 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3453 ElementListType::ACTIVE)); | 3451 ElementListType::ACTIVE)); |
| 3454 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, | 3452 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, |
| 3455 ElementListType::PENDING)); | 3453 ElementListType::PENDING)); |
| 3456 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, | 3454 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, |
| 3457 ElementListType::ACTIVE)); | 3455 ElementListType::ACTIVE)); |
| 3458 | 3456 |
| 3459 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); | 3457 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); |
| 3460 } | 3458 } |
| 3461 | 3459 |
| 3462 TEST_F(ElementAnimationsTest, TestIsAnimatingPropertyTimeOffsetFillMode) { | 3460 TEST_F(ElementAnimationsTest, TestIsAnimatingPropertyTimeOffsetFillMode) { |
| 3463 CreateTestLayer(false, false); | 3461 CreateTestLayer(false, false); |
| 3464 AttachTimelinePlayerLayer(); | 3462 AttachTimelinePlayerLayer(); |
| 3465 | 3463 |
| 3466 // Create an animation that initially affects only pending elements, and has | 3464 // Create an animation that initially affects only pending elements, and has |
| 3467 // a start delay of 2 seconds. | 3465 // a start delay of 2 seconds. |
| 3468 std::unique_ptr<Animation> animation(CreateAnimation( | 3466 std::unique_ptr<Animation> animation(CreateAnimation( |
| 3469 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 3467 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 3470 1, TargetProperty::OPACITY)); | 3468 1, TargetProperty::OPACITY)); |
| 3471 animation->set_fill_mode(Animation::FillMode::NONE); | 3469 animation->set_fill_mode(Animation::FillMode::NONE); |
| 3472 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000)); | 3470 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000)); |
| 3473 animation->set_affects_active_elements(false); | 3471 animation->set_affects_active_elements(false); |
| 3474 | 3472 |
| 3475 player_->AddAnimation(std::move(animation)); | 3473 player_->AddAnimation(std::move(animation)); |
| 3476 | 3474 |
| 3477 player_->Animate(kInitialTickTime); | 3475 player_->Tick(kInitialTickTime); |
| 3478 | 3476 |
| 3479 // Since the animation has a start delay, the elements it affects have a | 3477 // Since the animation has a start delay, the elements it affects have a |
| 3480 // potentially running transform animation but aren't currently animating | 3478 // potentially running transform animation but aren't currently animating |
| 3481 // transform. | 3479 // transform. |
| 3482 EXPECT_TRUE(player_->IsPotentiallyAnimatingProperty( | 3480 EXPECT_TRUE(player_->IsPotentiallyAnimatingProperty( |
| 3483 TargetProperty::OPACITY, ElementListType::PENDING)); | 3481 TargetProperty::OPACITY, ElementListType::PENDING)); |
| 3484 EXPECT_FALSE(player_->IsPotentiallyAnimatingProperty( | 3482 EXPECT_FALSE(player_->IsPotentiallyAnimatingProperty( |
| 3485 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3483 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
| 3486 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3484 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3487 ElementListType::PENDING)); | 3485 ElementListType::PENDING)); |
| 3488 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3486 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3489 ElementListType::ACTIVE)); | 3487 ElementListType::ACTIVE)); |
| 3490 EXPECT_TRUE(player_->HasActiveAnimation()); | 3488 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 3491 EXPECT_FALSE(player_->IsPotentiallyAnimatingProperty( | 3489 EXPECT_FALSE(player_->IsPotentiallyAnimatingProperty( |
| 3492 TargetProperty::FILTER, ElementListType::PENDING)); | 3490 TargetProperty::FILTER, ElementListType::PENDING)); |
| 3493 EXPECT_FALSE(player_->IsPotentiallyAnimatingProperty( | 3491 EXPECT_FALSE(player_->IsPotentiallyAnimatingProperty( |
| 3494 TargetProperty::FILTER, ElementListType::ACTIVE)); | 3492 TargetProperty::FILTER, ElementListType::ACTIVE)); |
| 3495 | 3493 |
| 3496 player_->ActivateAnimations(); | 3494 player_->ActivateAnimations(); |
| 3497 | 3495 |
| 3498 EXPECT_TRUE(player_->IsPotentiallyAnimatingProperty( | 3496 EXPECT_TRUE(player_->IsPotentiallyAnimatingProperty( |
| 3499 TargetProperty::OPACITY, ElementListType::PENDING)); | 3497 TargetProperty::OPACITY, ElementListType::PENDING)); |
| 3500 EXPECT_TRUE(player_->IsPotentiallyAnimatingProperty(TargetProperty::OPACITY, | 3498 EXPECT_TRUE(player_->IsPotentiallyAnimatingProperty(TargetProperty::OPACITY, |
| 3501 ElementListType::ACTIVE)); | 3499 ElementListType::ACTIVE)); |
| 3502 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3500 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3503 ElementListType::PENDING)); | 3501 ElementListType::PENDING)); |
| 3504 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3502 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3505 ElementListType::ACTIVE)); | 3503 ElementListType::ACTIVE)); |
| 3506 EXPECT_TRUE(player_->HasActiveAnimation()); | 3504 EXPECT_TRUE(player_->HasTickingAnimation()); |
| 3507 EXPECT_FALSE(player_->IsPotentiallyAnimatingProperty( | 3505 EXPECT_FALSE(player_->IsPotentiallyAnimatingProperty( |
| 3508 TargetProperty::FILTER, ElementListType::PENDING)); | 3506 TargetProperty::FILTER, ElementListType::PENDING)); |
| 3509 EXPECT_FALSE(player_->IsPotentiallyAnimatingProperty( | 3507 EXPECT_FALSE(player_->IsPotentiallyAnimatingProperty( |
| 3510 TargetProperty::FILTER, ElementListType::ACTIVE)); | 3508 TargetProperty::FILTER, ElementListType::ACTIVE)); |
| 3511 | 3509 |
| 3512 player_->UpdateState(true, nullptr); | 3510 player_->UpdateState(true, nullptr); |
| 3513 | 3511 |
| 3514 // Tick past the start delay. | 3512 // Tick past the start delay. |
| 3515 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 3513 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 3516 player_->UpdateState(true, nullptr); | 3514 player_->UpdateState(true, nullptr); |
| 3517 EXPECT_TRUE(player_->IsPotentiallyAnimatingProperty( | 3515 EXPECT_TRUE(player_->IsPotentiallyAnimatingProperty( |
| 3518 TargetProperty::OPACITY, ElementListType::PENDING)); | 3516 TargetProperty::OPACITY, ElementListType::PENDING)); |
| 3519 EXPECT_TRUE(player_->IsPotentiallyAnimatingProperty(TargetProperty::OPACITY, | 3517 EXPECT_TRUE(player_->IsPotentiallyAnimatingProperty(TargetProperty::OPACITY, |
| 3520 ElementListType::ACTIVE)); | 3518 ElementListType::ACTIVE)); |
| 3521 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3519 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3522 ElementListType::PENDING)); | 3520 ElementListType::PENDING)); |
| 3523 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3521 EXPECT_TRUE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3524 ElementListType::ACTIVE)); | 3522 ElementListType::ACTIVE)); |
| 3525 | 3523 |
| 3526 // After the animaton finishes, the elements it affects have neither a | 3524 // After the animaton finishes, the elements it affects have neither a |
| 3527 // potentially running transform animation nor a currently running transform | 3525 // potentially running transform animation nor a currently running transform |
| 3528 // animation. | 3526 // animation. |
| 3529 player_->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); | 3527 player_->Tick(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); |
| 3530 player_->UpdateState(true, nullptr); | 3528 player_->UpdateState(true, nullptr); |
| 3531 EXPECT_FALSE(player_->IsPotentiallyAnimatingProperty( | 3529 EXPECT_FALSE(player_->IsPotentiallyAnimatingProperty( |
| 3532 TargetProperty::OPACITY, ElementListType::PENDING)); | 3530 TargetProperty::OPACITY, ElementListType::PENDING)); |
| 3533 EXPECT_FALSE(player_->IsPotentiallyAnimatingProperty( | 3531 EXPECT_FALSE(player_->IsPotentiallyAnimatingProperty( |
| 3534 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3532 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
| 3535 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3533 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3536 ElementListType::PENDING)); | 3534 ElementListType::PENDING)); |
| 3537 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, | 3535 EXPECT_FALSE(player_->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3538 ElementListType::ACTIVE)); | 3536 ElementListType::ACTIVE)); |
| 3539 } | 3537 } |
| 3540 | 3538 |
| 3541 TEST_F(ElementAnimationsTest, DestroyTestMainLayerBeforePushProperties) { | 3539 TEST_F(ElementAnimationsTest, DestroyTestMainLayerBeforePushProperties) { |
| 3542 CreateTestLayer(false, false); | 3540 CreateTestLayer(false, false); |
| 3543 AttachTimelinePlayerLayer(); | 3541 AttachTimelinePlayerLayer(); |
| 3544 EXPECT_EQ(0u, host_->active_players_for_testing().size()); | 3542 EXPECT_EQ(0u, host_->ticking_players_for_testing().size()); |
| 3545 | 3543 |
| 3546 player_->AddAnimation(CreateAnimation( | 3544 player_->AddAnimation(CreateAnimation( |
| 3547 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), | 3545 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), |
| 3548 2, TargetProperty::OPACITY)); | 3546 2, TargetProperty::OPACITY)); |
| 3549 EXPECT_EQ(1u, host_->active_players_for_testing().size()); | 3547 EXPECT_EQ(1u, host_->ticking_players_for_testing().size()); |
| 3550 | 3548 |
| 3551 DestroyTestMainLayer(); | 3549 DestroyTestMainLayer(); |
| 3552 EXPECT_EQ(0u, host_->active_players_for_testing().size()); | 3550 EXPECT_EQ(0u, host_->ticking_players_for_testing().size()); |
| 3553 | 3551 |
| 3554 PushProperties(); | 3552 PushProperties(); |
| 3555 EXPECT_EQ(0u, host_->active_players_for_testing().size()); | 3553 EXPECT_EQ(0u, host_->ticking_players_for_testing().size()); |
| 3556 EXPECT_EQ(0u, host_impl_->active_players_for_testing().size()); | 3554 EXPECT_EQ(0u, host_impl_->ticking_players_for_testing().size()); |
| 3557 } | 3555 } |
| 3558 | 3556 |
| 3559 } // namespace | 3557 } // namespace |
| 3560 } // namespace cc | 3558 } // namespace cc |
| OLD | NEW |