| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/animation/element_animations.h" | 5 #include "cc/animation/element_animations.h" |
| 6 | 6 |
| 7 #include "cc/animation/animation_delegate.h" | 7 #include "cc/animation/animation_delegate.h" |
| 8 #include "cc/animation/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
| 9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
| 10 #include "cc/animation/animation_player.h" | 10 #include "cc/animation/animation_player.h" |
| (...skipping 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2212 | 2212 |
| 2213 // We should have exactly 2 events: a FINISHED event for the tranform | 2213 // We should have exactly 2 events: a FINISHED event for the tranform |
| 2214 // animation, and an ABORTED event for the opacity animation. | 2214 // animation, and an ABORTED event for the opacity animation. |
| 2215 EXPECT_EQ(2u, events->events_.size()); | 2215 EXPECT_EQ(2u, events->events_.size()); |
| 2216 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); | 2216 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); |
| 2217 EXPECT_EQ(TargetProperty::TRANSFORM, events->events_[0].target_property); | 2217 EXPECT_EQ(TargetProperty::TRANSFORM, events->events_[0].target_property); |
| 2218 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[1].type); | 2218 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[1].type); |
| 2219 EXPECT_EQ(TargetProperty::OPACITY, events->events_[1].target_property); | 2219 EXPECT_EQ(TargetProperty::OPACITY, events->events_[1].target_property); |
| 2220 } | 2220 } |
| 2221 | 2221 |
| 2222 TEST_F(ElementAnimationsTest, HasAnimationThatAffectsScale) { | |
| 2223 CreateTestLayer(true, false); | |
| 2224 AttachTimelinePlayerLayer(); | |
| 2225 CreateImplTimelineAndPlayer(); | |
| 2226 | |
| 2227 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | |
| 2228 | |
| 2229 EXPECT_FALSE(animations_impl->HasAnimationThatAffectsScale()); | |
| 2230 | |
| 2231 animations_impl->AddAnimation(CreateAnimation( | |
| 2232 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | |
| 2233 1, TargetProperty::OPACITY)); | |
| 2234 | |
| 2235 // Opacity animations don't affect scale. | |
| 2236 EXPECT_FALSE(animations_impl->HasAnimationThatAffectsScale()); | |
| 2237 | |
| 2238 std::unique_ptr<KeyframedTransformAnimationCurve> curve1( | |
| 2239 KeyframedTransformAnimationCurve::Create()); | |
| 2240 | |
| 2241 TransformOperations operations1; | |
| 2242 curve1->AddKeyframe( | |
| 2243 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | |
| 2244 operations1.AppendTranslate(10.0, 15.0, 0.0); | |
| 2245 curve1->AddKeyframe(TransformKeyframe::Create( | |
| 2246 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | |
| 2247 | |
| 2248 std::unique_ptr<Animation> animation( | |
| 2249 Animation::Create(std::move(curve1), 2, 2, TargetProperty::TRANSFORM)); | |
| 2250 animations_impl->AddAnimation(std::move(animation)); | |
| 2251 | |
| 2252 // Translations don't affect scale. | |
| 2253 EXPECT_FALSE(animations_impl->HasAnimationThatAffectsScale()); | |
| 2254 | |
| 2255 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( | |
| 2256 KeyframedTransformAnimationCurve::Create()); | |
| 2257 | |
| 2258 TransformOperations operations2; | |
| 2259 curve2->AddKeyframe( | |
| 2260 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | |
| 2261 operations2.AppendScale(2.0, 3.0, 4.0); | |
| 2262 curve2->AddKeyframe(TransformKeyframe::Create( | |
| 2263 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | |
| 2264 | |
| 2265 animation = | |
| 2266 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM); | |
| 2267 animations_impl->AddAnimation(std::move(animation)); | |
| 2268 | |
| 2269 EXPECT_TRUE(animations_impl->HasAnimationThatAffectsScale()); | |
| 2270 | |
| 2271 animations_impl->GetAnimationById(3)->SetRunState(Animation::FINISHED, | |
| 2272 TicksFromSecondsF(0.0)); | |
| 2273 | |
| 2274 // Only unfinished animations should be considered by | |
| 2275 // HasAnimationThatAffectsScale. | |
| 2276 EXPECT_FALSE(animations_impl->HasAnimationThatAffectsScale()); | |
| 2277 } | |
| 2278 | |
| 2279 TEST_F(ElementAnimationsTest, HasOnlyTranslationTransforms) { | 2222 TEST_F(ElementAnimationsTest, HasOnlyTranslationTransforms) { |
| 2280 CreateTestLayer(true, false); | 2223 CreateTestLayer(true, false); |
| 2281 AttachTimelinePlayerLayer(); | 2224 AttachTimelinePlayerLayer(); |
| 2282 CreateImplTimelineAndPlayer(); | 2225 CreateImplTimelineAndPlayer(); |
| 2283 | 2226 |
| 2284 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 2227 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 2285 | 2228 |
| 2286 EXPECT_TRUE( | 2229 EXPECT_TRUE( |
| 2287 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE)); | 2230 animations_impl->HasOnlyTranslationTransforms(ElementListType::ACTIVE)); |
| 2288 EXPECT_TRUE( | 2231 EXPECT_TRUE( |
| (...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3774 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( | 3717 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( |
| 3775 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3718 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
| 3776 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3719 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
| 3777 TargetProperty::OPACITY, ElementListType::PENDING)); | 3720 TargetProperty::OPACITY, ElementListType::PENDING)); |
| 3778 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3721 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
| 3779 TargetProperty::OPACITY, ElementListType::ACTIVE)); | 3722 TargetProperty::OPACITY, ElementListType::ACTIVE)); |
| 3780 } | 3723 } |
| 3781 | 3724 |
| 3782 } // namespace | 3725 } // namespace |
| 3783 } // namespace cc | 3726 } // namespace cc |
| OLD | NEW |