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

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

Issue 2110683004: cc: Move filters to the effect tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/element_animations.cc ('k') | cc/layers/layer.h » ('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 3065 matching lines...) Expand 10 before | Expand all | Expand 10 after
3076 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( 3076 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating(
3077 element_id_, ElementListType::ACTIVE)); 3077 element_id_, ElementListType::ACTIVE));
3078 3078
3079 animations_impl->ActivateAnimations(); 3079 animations_impl->ActivateAnimations();
3080 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation( 3080 EXPECT_TRUE(client_impl_.GetHasPotentialOpacityAnimation(
3081 element_id_, ElementListType::ACTIVE)); 3081 element_id_, ElementListType::ACTIVE));
3082 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating( 3082 EXPECT_FALSE(client_impl_.GetOpacityIsCurrentlyAnimating(
3083 element_id_, ElementListType::ACTIVE)); 3083 element_id_, ElementListType::ACTIVE));
3084 } 3084 }
3085 3085
3086 TEST_F(ElementAnimationsTest, ObserverNotifiedWhenFilterAnimationChanges) {
3087 CreateTestLayer(true, true);
3088 AttachTimelinePlayerLayer();
3089 CreateImplTimelineAndPlayer();
3090
3091 scoped_refptr<ElementAnimations> animations = element_animations();
3092 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
3093
3094 auto events = host_impl_->CreateEvents();
3095
3096 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_,
3097 ElementListType::ACTIVE));
3098 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_,
3099 ElementListType::ACTIVE));
3100 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation(
3101 element_id_, ElementListType::PENDING));
3102 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating(
3103 element_id_, ElementListType::PENDING));
3104 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation(
3105 element_id_, ElementListType::ACTIVE));
3106 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating(
3107 element_id_, ElementListType::ACTIVE));
3108
3109 // Case 1: An animation that's allowed to run until its finish point.
3110 AddAnimatedFilterToElementAnimations(animations.get(), 1.0, 0.f, 1.f);
3111 EXPECT_TRUE(client_.GetHasPotentialFilterAnimation(element_id_,
3112 ElementListType::ACTIVE));
3113 EXPECT_TRUE(client_.GetFilterIsCurrentlyAnimating(element_id_,
3114 ElementListType::ACTIVE));
3115
3116 animations->PushPropertiesTo(animations_impl.get());
3117 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation(
3118 element_id_, ElementListType::PENDING));
3119 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating(
3120 element_id_, ElementListType::PENDING));
3121 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation(
3122 element_id_, ElementListType::ACTIVE));
3123 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating(
3124 element_id_, ElementListType::ACTIVE));
3125
3126 animations_impl->ActivateAnimations();
3127 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation(
3128 element_id_, ElementListType::PENDING));
3129 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating(
3130 element_id_, ElementListType::PENDING));
3131 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation(
3132 element_id_, ElementListType::ACTIVE));
3133 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating(
3134 element_id_, ElementListType::ACTIVE));
3135
3136 animations_impl->Animate(kInitialTickTime);
3137 animations_impl->UpdateState(true, events.get());
3138
3139 animations->NotifyAnimationStarted(events->events_[0]);
3140 events->events_.clear();
3141
3142 // Finish the animation.
3143 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
3144 animations->UpdateState(true, nullptr);
3145 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_,
3146 ElementListType::ACTIVE));
3147 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_,
3148 ElementListType::ACTIVE));
3149
3150 animations->PushPropertiesTo(animations_impl.get());
3151
3152 // animations_impl hasn't yet ticked at/past the end of the animation.
3153 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation(
3154 element_id_, ElementListType::PENDING));
3155 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating(
3156 element_id_, ElementListType::PENDING));
3157 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation(
3158 element_id_, ElementListType::ACTIVE));
3159 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating(
3160 element_id_, ElementListType::ACTIVE));
3161
3162 animations_impl->Animate(kInitialTickTime +
3163 TimeDelta::FromMilliseconds(1000));
3164 animations_impl->UpdateState(true, events.get());
3165 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation(
3166 element_id_, ElementListType::PENDING));
3167 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating(
3168 element_id_, ElementListType::PENDING));
3169 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation(
3170 element_id_, ElementListType::ACTIVE));
3171 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating(
3172 element_id_, ElementListType::ACTIVE));
3173
3174 // Case 2: An animation that's removed before it finishes.
3175 int animation_id =
3176 AddAnimatedFilterToElementAnimations(animations.get(), 10.0, 0.f, 1.f);
3177 EXPECT_TRUE(client_.GetHasPotentialFilterAnimation(element_id_,
3178 ElementListType::ACTIVE));
3179 EXPECT_TRUE(client_.GetFilterIsCurrentlyAnimating(element_id_,
3180 ElementListType::ACTIVE));
3181
3182 animations->PushPropertiesTo(animations_impl.get());
3183 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation(
3184 element_id_, ElementListType::PENDING));
3185 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating(
3186 element_id_, ElementListType::PENDING));
3187 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation(
3188 element_id_, ElementListType::ACTIVE));
3189 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating(
3190 element_id_, ElementListType::ACTIVE));
3191
3192 animations_impl->ActivateAnimations();
3193 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation(
3194 element_id_, ElementListType::ACTIVE));
3195 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating(
3196 element_id_, ElementListType::ACTIVE));
3197
3198 animations_impl->Animate(kInitialTickTime +
3199 TimeDelta::FromMilliseconds(2000));
3200 animations_impl->UpdateState(true, events.get());
3201
3202 animations->NotifyAnimationStarted(events->events_[0]);
3203 events->events_.clear();
3204
3205 animations->RemoveAnimation(animation_id);
3206 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_,
3207 ElementListType::ACTIVE));
3208 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_,
3209 ElementListType::ACTIVE));
3210
3211 animations->PushPropertiesTo(animations_impl.get());
3212 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation(
3213 element_id_, ElementListType::PENDING));
3214 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating(
3215 element_id_, ElementListType::PENDING));
3216 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation(
3217 element_id_, ElementListType::ACTIVE));
3218 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating(
3219 element_id_, ElementListType::ACTIVE));
3220
3221 animations_impl->ActivateAnimations();
3222 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation(
3223 element_id_, ElementListType::ACTIVE));
3224 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating(
3225 element_id_, ElementListType::ACTIVE));
3226
3227 // Case 3: An animation that's aborted before it finishes.
3228 animation_id =
3229 AddAnimatedFilterToElementAnimations(animations.get(), 10.0, 0.f, 0.5f);
3230 EXPECT_TRUE(client_.GetHasPotentialFilterAnimation(element_id_,
3231 ElementListType::ACTIVE));
3232 EXPECT_TRUE(client_.GetFilterIsCurrentlyAnimating(element_id_,
3233 ElementListType::ACTIVE));
3234
3235 animations->PushPropertiesTo(animations_impl.get());
3236 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation(
3237 element_id_, ElementListType::PENDING));
3238 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating(
3239 element_id_, ElementListType::PENDING));
3240 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation(
3241 element_id_, ElementListType::ACTIVE));
3242 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating(
3243 element_id_, ElementListType::ACTIVE));
3244
3245 animations_impl->ActivateAnimations();
3246 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation(
3247 element_id_, ElementListType::ACTIVE));
3248 EXPECT_TRUE(client_impl_.GetFilterIsCurrentlyAnimating(
3249 element_id_, ElementListType::ACTIVE));
3250
3251 animations_impl->Animate(kInitialTickTime +
3252 TimeDelta::FromMilliseconds(2000));
3253 animations_impl->UpdateState(true, events.get());
3254
3255 animations->NotifyAnimationStarted(events->events_[0]);
3256 events->events_.clear();
3257
3258 animations_impl->AbortAnimations(TargetProperty::FILTER);
3259 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation(
3260 element_id_, ElementListType::PENDING));
3261 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating(
3262 element_id_, ElementListType::PENDING));
3263 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation(
3264 element_id_, ElementListType::ACTIVE));
3265 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating(
3266 element_id_, ElementListType::ACTIVE));
3267
3268 animations_impl->Animate(kInitialTickTime +
3269 TimeDelta::FromMilliseconds(4000));
3270 animations_impl->UpdateState(true, events.get());
3271
3272 animations->NotifyAnimationAborted(events->events_[0]);
3273 EXPECT_FALSE(client_.GetHasPotentialFilterAnimation(element_id_,
3274 ElementListType::ACTIVE));
3275 EXPECT_FALSE(client_.GetFilterIsCurrentlyAnimating(element_id_,
3276 ElementListType::ACTIVE));
3277
3278 // Case 4 : An animation that's not in effect.
3279 animation_id =
3280 AddAnimatedFilterToElementAnimations(animations.get(), 1.0, 0.f, 0.5f);
3281 animations->GetAnimationById(animation_id)
3282 ->set_time_offset(base::TimeDelta::FromMilliseconds(-10000));
3283 animations->GetAnimationById(animation_id)
3284 ->set_fill_mode(Animation::FillMode::NONE);
3285
3286 animations->PushPropertiesTo(animations_impl.get());
3287 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation(
3288 element_id_, ElementListType::PENDING));
3289 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating(
3290 element_id_, ElementListType::PENDING));
3291 EXPECT_FALSE(client_impl_.GetHasPotentialFilterAnimation(
3292 element_id_, ElementListType::ACTIVE));
3293 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating(
3294 element_id_, ElementListType::ACTIVE));
3295
3296 animations_impl->ActivateAnimations();
3297 EXPECT_TRUE(client_impl_.GetHasPotentialFilterAnimation(
3298 element_id_, ElementListType::ACTIVE));
3299 EXPECT_FALSE(client_impl_.GetFilterIsCurrentlyAnimating(
3300 element_id_, ElementListType::ACTIVE));
3301 }
3302
3086 TEST_F(ElementAnimationsTest, ClippedOpacityValues) { 3303 TEST_F(ElementAnimationsTest, ClippedOpacityValues) {
3087 CreateTestLayer(false, false); 3304 CreateTestLayer(false, false);
3088 AttachTimelinePlayerLayer(); 3305 AttachTimelinePlayerLayer();
3089 3306
3090 scoped_refptr<ElementAnimations> animations = element_animations(); 3307 scoped_refptr<ElementAnimations> animations = element_animations();
3091 3308
3092 AddOpacityTransitionToElementAnimations(animations.get(), 1, 1.f, 2.f, true); 3309 AddOpacityTransitionToElementAnimations(animations.get(), 1, 1.f, 2.f, true);
3093 3310
3094 animations->Animate(kInitialTickTime); 3311 animations->Animate(kInitialTickTime);
3095 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE)); 3312 EXPECT_EQ(1.f, client_.GetOpacity(element_id_, ElementListType::ACTIVE));
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
3398 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( 3615 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty(
3399 TargetProperty::OPACITY, ElementListType::ACTIVE)); 3616 TargetProperty::OPACITY, ElementListType::ACTIVE));
3400 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3617 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3401 TargetProperty::OPACITY, ElementListType::PENDING)); 3618 TargetProperty::OPACITY, ElementListType::PENDING));
3402 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3619 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3403 TargetProperty::OPACITY, ElementListType::ACTIVE)); 3620 TargetProperty::OPACITY, ElementListType::ACTIVE));
3404 } 3621 }
3405 3622
3406 } // namespace 3623 } // namespace
3407 } // namespace cc 3624 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/element_animations.cc ('k') | cc/layers/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698