| 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/test/animation_timelines_test_common.h" | 5 #include "cc/test/animation_timelines_test_common.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "cc/animation/animation_events.h" | 8 #include "cc/animation/animation_events.h" |
| 9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
| 10 #include "cc/animation/animation_player.h" | 10 #include "cc/animation/animation_player.h" |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 : layers_in_pending_tree_; | 348 : layers_in_pending_tree_; |
| 349 auto kv = layers_in_tree.find(element_id); | 349 auto kv = layers_in_tree.find(element_id); |
| 350 if (kv == layers_in_tree.end()) | 350 if (kv == layers_in_tree.end()) |
| 351 return nullptr; | 351 return nullptr; |
| 352 | 352 |
| 353 DCHECK(kv->second); | 353 DCHECK(kv->second); |
| 354 return kv->second.get(); | 354 return kv->second.get(); |
| 355 } | 355 } |
| 356 | 356 |
| 357 TestAnimationDelegate::TestAnimationDelegate() | 357 TestAnimationDelegate::TestAnimationDelegate() |
| 358 : started_(false), | 358 : started_(0), |
| 359 finished_(false), | 359 finished_(0), |
| 360 aborted_(false), | 360 aborted_(0), |
| 361 takeover_(false), | 361 takeover_(0), |
| 362 start_time_(base::TimeTicks()) {} | 362 start_time_(base::TimeTicks()) {} |
| 363 | 363 |
| 364 void TestAnimationDelegate::NotifyAnimationStarted( | 364 void TestAnimationDelegate::NotifyAnimationStarted( |
| 365 base::TimeTicks monotonic_time, | 365 base::TimeTicks monotonic_time, |
| 366 TargetProperty::Type target_property, | 366 TargetProperty::Type target_property, |
| 367 int group) { | 367 int group) { |
| 368 started_ = true; | 368 started_++; |
| 369 start_time_ = monotonic_time; | 369 start_time_ = monotonic_time; |
| 370 } | 370 } |
| 371 | 371 |
| 372 void TestAnimationDelegate::NotifyAnimationFinished( | 372 void TestAnimationDelegate::NotifyAnimationFinished( |
| 373 base::TimeTicks monotonic_time, | 373 base::TimeTicks monotonic_time, |
| 374 TargetProperty::Type target_property, | 374 TargetProperty::Type target_property, |
| 375 int group) { | 375 int group) { |
| 376 finished_ = true; | 376 finished_++; |
| 377 } | 377 } |
| 378 | 378 |
| 379 void TestAnimationDelegate::NotifyAnimationAborted( | 379 void TestAnimationDelegate::NotifyAnimationAborted( |
| 380 base::TimeTicks monotonic_time, | 380 base::TimeTicks monotonic_time, |
| 381 TargetProperty::Type target_property, | 381 TargetProperty::Type target_property, |
| 382 int group) { | 382 int group) { |
| 383 aborted_ = true; | 383 aborted_++; |
| 384 } | 384 } |
| 385 | 385 |
| 386 void TestAnimationDelegate::NotifyAnimationTakeover( | 386 void TestAnimationDelegate::NotifyAnimationTakeover( |
| 387 base::TimeTicks monotonic_time, | 387 base::TimeTicks monotonic_time, |
| 388 TargetProperty::Type target_property, | 388 TargetProperty::Type target_property, |
| 389 double animation_start_time, | 389 double animation_start_time, |
| 390 std::unique_ptr<AnimationCurve> curve) { | 390 std::unique_ptr<AnimationCurve> curve) { |
| 391 takeover_ = true; | 391 takeover_++; |
| 392 } | 392 } |
| 393 | 393 |
| 394 AnimationTimelinesTest::AnimationTimelinesTest() | 394 AnimationTimelinesTest::AnimationTimelinesTest() |
| 395 : client_(ThreadInstance::MAIN), | 395 : client_(ThreadInstance::MAIN), |
| 396 client_impl_(ThreadInstance::IMPL), | 396 client_impl_(ThreadInstance::IMPL), |
| 397 host_(nullptr), | 397 host_(nullptr), |
| 398 host_impl_(nullptr), | 398 host_impl_(nullptr), |
| 399 timeline_id_(AnimationIdProvider::NextTimelineId()), | 399 timeline_id_(AnimationIdProvider::NextTimelineId()), |
| 400 player_id_(AnimationIdProvider::NextPlayerId()), | 400 player_id_(AnimationIdProvider::NextPlayerId()), |
| 401 next_test_layer_id_(0) { | 401 next_test_layer_id_(0) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 | 488 |
| 489 host_->AnimateLayers(time); | 489 host_->AnimateLayers(time); |
| 490 host_->UpdateAnimationState(true, nullptr); | 490 host_->UpdateAnimationState(true, nullptr); |
| 491 host_->SetAnimationEvents(std::move(events)); | 491 host_->SetAnimationEvents(std::move(events)); |
| 492 } | 492 } |
| 493 | 493 |
| 494 AnimationPlayer* AnimationTimelinesTest::GetPlayerForElementId( | 494 AnimationPlayer* AnimationTimelinesTest::GetPlayerForElementId( |
| 495 ElementId element_id) { | 495 ElementId element_id) { |
| 496 const scoped_refptr<ElementAnimations> element_animations = | 496 const scoped_refptr<ElementAnimations> element_animations = |
| 497 host_->GetElementAnimationsForElementId(element_id); | 497 host_->GetElementAnimationsForElementId(element_id); |
| 498 return element_animations ? element_animations->players_list().head()->value() | 498 return element_animations |
| 499 : nullptr; | 499 ? base::ObserverList<AnimationPlayer>::Iterator( |
| 500 &element_animations->players_list()) |
| 501 .GetNext() |
| 502 : nullptr; |
| 500 } | 503 } |
| 501 | 504 |
| 502 AnimationPlayer* AnimationTimelinesTest::GetImplPlayerForLayerId( | 505 AnimationPlayer* AnimationTimelinesTest::GetImplPlayerForLayerId( |
| 503 ElementId element_id) { | 506 ElementId element_id) { |
| 504 const scoped_refptr<ElementAnimations> element_animations = | 507 const scoped_refptr<ElementAnimations> element_animations = |
| 505 host_impl_->GetElementAnimationsForElementId(element_id); | 508 host_impl_->GetElementAnimationsForElementId(element_id); |
| 506 return element_animations ? element_animations->players_list().head()->value() | 509 return element_animations |
| 507 : nullptr; | 510 ? base::ObserverList<AnimationPlayer>::Iterator( |
| 511 &element_animations->players_list()) |
| 512 .GetNext() |
| 513 : nullptr; |
| 508 } | 514 } |
| 509 | 515 |
| 510 int AnimationTimelinesTest::NextTestLayerId() { | 516 int AnimationTimelinesTest::NextTestLayerId() { |
| 511 next_test_layer_id_++; | 517 next_test_layer_id_++; |
| 512 return next_test_layer_id_; | 518 return next_test_layer_id_; |
| 513 } | 519 } |
| 514 | 520 |
| 515 } // namespace cc | 521 } // namespace cc |
| OLD | NEW |