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

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

Issue 2322693003: CC Animation: Rename has_any_animation and make implementattion out-of-line (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/element_animations.cc ('k') | ui/compositor/layer_animator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/animation/element_animations.h" 5 #include "cc/animation/element_animations.h"
6 6
7 #include "cc/animation/animation_delegate.h" 7 #include "cc/animation/animation_delegate.h"
8 #include "cc/animation/animation_host.h" 8 #include "cc/animation/animation_host.h"
9 #include "cc/animation/animation_id_provider.h" 9 #include "cc/animation/animation_id_provider.h"
10 #include "cc/animation/animation_player.h" 10 #include "cc/animation/animation_player.h"
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); 511 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500));
512 animations->UpdateState(true, nullptr); 512 animations->UpdateState(true, nullptr);
513 513
514 EXPECT_EQ(Animation::WAITING_FOR_DELETION, 514 EXPECT_EQ(Animation::WAITING_FOR_DELETION,
515 animations->GetAnimation(TargetProperty::OPACITY)->run_state()); 515 animations->GetAnimation(TargetProperty::OPACITY)->run_state());
516 // The main thread animations should have de-activated. 516 // The main thread animations should have de-activated.
517 EXPECT_EQ(0u, host->active_element_animations_for_testing().size()); 517 EXPECT_EQ(0u, host->active_element_animations_for_testing().size());
518 518
519 animations->PushPropertiesTo(animations_impl.get()); 519 animations->PushPropertiesTo(animations_impl.get());
520 animations_impl->ActivateAnimations(); 520 animations_impl->ActivateAnimations();
521 EXPECT_FALSE(animations->has_any_animation()); 521 EXPECT_FALSE(animations->HasAnyAnimation());
522 EXPECT_FALSE(animations_impl->has_any_animation()); 522 EXPECT_FALSE(animations_impl->HasAnyAnimation());
523 EXPECT_EQ(0u, host->active_element_animations_for_testing().size()); 523 EXPECT_EQ(0u, host->active_element_animations_for_testing().size());
524 EXPECT_EQ(0u, host_impl->active_element_animations_for_testing().size()); 524 EXPECT_EQ(0u, host_impl->active_element_animations_for_testing().size());
525 } 525 }
526 526
527 TEST_F(ElementAnimationsTest, SyncPause) { 527 TEST_F(ElementAnimationsTest, SyncPause) {
528 CreateTestLayer(true, false); 528 CreateTestLayer(true, false);
529 AttachTimelinePlayerLayer(); 529 AttachTimelinePlayerLayer();
530 CreateImplTimelineAndPlayer(); 530 CreateImplTimelineAndPlayer();
531 531
532 scoped_refptr<ElementAnimations> animations = element_animations(); 532 scoped_refptr<ElementAnimations> animations = element_animations();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); 703 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
704 animations->UpdateState(true, nullptr); 704 animations->UpdateState(true, nullptr);
705 EXPECT_TRUE(host_->needs_push_properties()); 705 EXPECT_TRUE(host_->needs_push_properties());
706 706
707 animations->PushPropertiesTo(animations_impl.get()); 707 animations->PushPropertiesTo(animations_impl.get());
708 708
709 // Both animationss should now have deleted the animation. The impl animations 709 // Both animationss should now have deleted the animation. The impl animations
710 // should have deleted the animation even though activation has not occurred, 710 // should have deleted the animation even though activation has not occurred,
711 // since the animation was already waiting for deletion when 711 // since the animation was already waiting for deletion when
712 // PushPropertiesTo was called. 712 // PushPropertiesTo was called.
713 EXPECT_FALSE(animations->has_any_animation()); 713 EXPECT_FALSE(animations->HasAnyAnimation());
714 EXPECT_FALSE(animations_impl->has_any_animation()); 714 EXPECT_FALSE(animations_impl->HasAnyAnimation());
715 } 715 }
716 716
717 // Tests that transitioning opacity from 0 to 1 works as expected. 717 // Tests that transitioning opacity from 0 to 1 works as expected.
718 718
719 static std::unique_ptr<Animation> CreateAnimation( 719 static std::unique_ptr<Animation> CreateAnimation(
720 std::unique_ptr<AnimationCurve> curve, 720 std::unique_ptr<AnimationCurve> curve,
721 int group_id, 721 int group_id,
722 TargetProperty::Type property) { 722 TargetProperty::Type property) {
723 return Animation::Create(std::move(curve), 0, group_id, property); 723 return Animation::Create(std::move(curve), 0, group_id, property);
724 } 724 }
(...skipping 2782 matching lines...) Expand 10 before | Expand all | Expand 10 after
3507 3507
3508 // Only the active observer should have been ticked. 3508 // Only the active observer should have been ticked.
3509 EXPECT_EQ(0.5f, 3509 EXPECT_EQ(0.5f,
3510 client_impl_.GetOpacity(element_id_, ElementListType::PENDING)); 3510 client_impl_.GetOpacity(element_id_, ElementListType::PENDING));
3511 EXPECT_EQ(0.75f, 3511 EXPECT_EQ(0.75f,
3512 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE)); 3512 client_impl_.GetOpacity(element_id_, ElementListType::ACTIVE));
3513 3513
3514 animations_impl->ActivateAnimations(); 3514 animations_impl->ActivateAnimations();
3515 3515
3516 // Activation should cause the animation to be deleted. 3516 // Activation should cause the animation to be deleted.
3517 EXPECT_FALSE(animations_impl->has_any_animation()); 3517 EXPECT_FALSE(animations_impl->HasAnyAnimation());
3518 } 3518 }
3519 3519
3520 // Tests that an animation that affects only active elements won't block 3520 // Tests that an animation that affects only active elements won't block
3521 // an animation that affects only pending elements from starting. 3521 // an animation that affects only pending elements from starting.
3522 TEST_F(ElementAnimationsTest, StartAnimationsAffectingDifferentObservers) { 3522 TEST_F(ElementAnimationsTest, StartAnimationsAffectingDifferentObservers) {
3523 CreateTestLayer(true, true); 3523 CreateTestLayer(true, true);
3524 AttachTimelinePlayerLayer(); 3524 AttachTimelinePlayerLayer();
3525 CreateImplTimelineAndPlayer(); 3525 CreateImplTimelineAndPlayer();
3526 3526
3527 scoped_refptr<ElementAnimations> animations = element_animations(); 3527 scoped_refptr<ElementAnimations> animations = element_animations();
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
3745 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( 3745 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty(
3746 TargetProperty::OPACITY, ElementListType::ACTIVE)); 3746 TargetProperty::OPACITY, ElementListType::ACTIVE));
3747 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3747 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3748 TargetProperty::OPACITY, ElementListType::PENDING)); 3748 TargetProperty::OPACITY, ElementListType::PENDING));
3749 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3749 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3750 TargetProperty::OPACITY, ElementListType::ACTIVE)); 3750 TargetProperty::OPACITY, ElementListType::ACTIVE));
3751 } 3751 }
3752 3752
3753 } // namespace 3753 } // namespace
3754 } // namespace cc 3754 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/element_animations.cc ('k') | ui/compositor/layer_animator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698