| 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 2236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2247 EXPECT_FALSE(animations_impl->HasAnimationThatAffectsScale()); | 2247 EXPECT_FALSE(animations_impl->HasAnimationThatAffectsScale()); |
| 2248 } | 2248 } |
| 2249 | 2249 |
| 2250 TEST_F(ElementAnimationsTest, HasOnlyTranslationTransforms) { | 2250 TEST_F(ElementAnimationsTest, HasOnlyTranslationTransforms) { |
| 2251 CreateTestLayer(true, false); | 2251 CreateTestLayer(true, false); |
| 2252 AttachTimelinePlayerLayer(); | 2252 AttachTimelinePlayerLayer(); |
| 2253 CreateImplTimelineAndPlayer(); | 2253 CreateImplTimelineAndPlayer(); |
| 2254 | 2254 |
| 2255 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 2255 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 2256 | 2256 |
| 2257 EXPECT_TRUE(animations_impl->HasOnlyTranslationTransforms( | 2257 EXPECT_TRUE( |
| 2258 ElementAnimations::ObserverType::ACTIVE)); | 2258 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); |
| 2259 EXPECT_TRUE(animations_impl->HasOnlyTranslationTransforms( | 2259 EXPECT_TRUE( |
| 2260 ElementAnimations::ObserverType::PENDING)); | 2260 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); |
| 2261 | 2261 |
| 2262 animations_impl->AddAnimation(CreateAnimation( | 2262 animations_impl->AddAnimation(CreateAnimation( |
| 2263 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 2263 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 2264 1, TargetProperty::OPACITY)); | 2264 1, TargetProperty::OPACITY)); |
| 2265 | 2265 |
| 2266 // Opacity animations aren't non-translation transforms. | 2266 // Opacity animations aren't non-translation transforms. |
| 2267 EXPECT_TRUE(animations_impl->HasOnlyTranslationTransforms( | 2267 EXPECT_TRUE( |
| 2268 ElementAnimations::ObserverType::ACTIVE)); | 2268 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); |
| 2269 EXPECT_TRUE(animations_impl->HasOnlyTranslationTransforms( | 2269 EXPECT_TRUE( |
| 2270 ElementAnimations::ObserverType::PENDING)); | 2270 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); |
| 2271 | 2271 |
| 2272 std::unique_ptr<KeyframedTransformAnimationCurve> curve1( | 2272 std::unique_ptr<KeyframedTransformAnimationCurve> curve1( |
| 2273 KeyframedTransformAnimationCurve::Create()); | 2273 KeyframedTransformAnimationCurve::Create()); |
| 2274 | 2274 |
| 2275 TransformOperations operations1; | 2275 TransformOperations operations1; |
| 2276 curve1->AddKeyframe( | 2276 curve1->AddKeyframe( |
| 2277 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2277 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 2278 operations1.AppendTranslate(10.0, 15.0, 0.0); | 2278 operations1.AppendTranslate(10.0, 15.0, 0.0); |
| 2279 curve1->AddKeyframe(TransformKeyframe::Create( | 2279 curve1->AddKeyframe(TransformKeyframe::Create( |
| 2280 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 2280 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
| 2281 | 2281 |
| 2282 std::unique_ptr<Animation> animation( | 2282 std::unique_ptr<Animation> animation( |
| 2283 Animation::Create(std::move(curve1), 2, 2, TargetProperty::TRANSFORM)); | 2283 Animation::Create(std::move(curve1), 2, 2, TargetProperty::TRANSFORM)); |
| 2284 animations_impl->AddAnimation(std::move(animation)); | 2284 animations_impl->AddAnimation(std::move(animation)); |
| 2285 | 2285 |
| 2286 // The only transform animation we've added is a translation. | 2286 // The only transform animation we've added is a translation. |
| 2287 EXPECT_TRUE(animations_impl->HasOnlyTranslationTransforms( | 2287 EXPECT_TRUE( |
| 2288 ElementAnimations::ObserverType::ACTIVE)); | 2288 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); |
| 2289 EXPECT_TRUE(animations_impl->HasOnlyTranslationTransforms( | 2289 EXPECT_TRUE( |
| 2290 ElementAnimations::ObserverType::PENDING)); | 2290 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); |
| 2291 | 2291 |
| 2292 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( | 2292 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( |
| 2293 KeyframedTransformAnimationCurve::Create()); | 2293 KeyframedTransformAnimationCurve::Create()); |
| 2294 | 2294 |
| 2295 TransformOperations operations2; | 2295 TransformOperations operations2; |
| 2296 curve2->AddKeyframe( | 2296 curve2->AddKeyframe( |
| 2297 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 2297 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
| 2298 operations2.AppendScale(2.0, 3.0, 4.0); | 2298 operations2.AppendScale(2.0, 3.0, 4.0); |
| 2299 curve2->AddKeyframe(TransformKeyframe::Create( | 2299 curve2->AddKeyframe(TransformKeyframe::Create( |
| 2300 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2300 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
| 2301 | 2301 |
| 2302 animation = | 2302 animation = |
| 2303 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM); | 2303 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM); |
| 2304 animation->set_affects_active_observers(false); | 2304 animation->set_affects_active_observers(false); |
| 2305 animations_impl->AddAnimation(std::move(animation)); | 2305 animations_impl->AddAnimation(std::move(animation)); |
| 2306 | 2306 |
| 2307 // A scale animation is not a translation. | 2307 // A scale animation is not a translation. |
| 2308 EXPECT_FALSE(animations_impl->HasOnlyTranslationTransforms( | 2308 EXPECT_FALSE( |
| 2309 ElementAnimations::ObserverType::PENDING)); | 2309 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); |
| 2310 EXPECT_TRUE(animations_impl->HasOnlyTranslationTransforms( | 2310 EXPECT_TRUE( |
| 2311 ElementAnimations::ObserverType::ACTIVE)); | 2311 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); |
| 2312 | 2312 |
| 2313 animations_impl->ActivateAnimations(); | 2313 animations_impl->ActivateAnimations(); |
| 2314 EXPECT_FALSE(animations_impl->HasOnlyTranslationTransforms( | 2314 EXPECT_FALSE( |
| 2315 ElementAnimations::ObserverType::PENDING)); | 2315 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); |
| 2316 EXPECT_FALSE(animations_impl->HasOnlyTranslationTransforms( | 2316 EXPECT_FALSE( |
| 2317 ElementAnimations::ObserverType::ACTIVE)); | 2317 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); |
| 2318 | 2318 |
| 2319 animations_impl->GetAnimationById(3)->set_affects_pending_observers(false); | 2319 animations_impl->GetAnimationById(3)->set_affects_pending_observers(false); |
| 2320 EXPECT_TRUE(animations_impl->HasOnlyTranslationTransforms( | 2320 EXPECT_TRUE( |
| 2321 ElementAnimations::ObserverType::PENDING)); | 2321 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); |
| 2322 EXPECT_FALSE(animations_impl->HasOnlyTranslationTransforms( | 2322 EXPECT_FALSE( |
| 2323 ElementAnimations::ObserverType::ACTIVE)); | 2323 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); |
| 2324 | 2324 |
| 2325 animations_impl->GetAnimationById(3)->SetRunState(Animation::FINISHED, | 2325 animations_impl->GetAnimationById(3)->SetRunState(Animation::FINISHED, |
| 2326 TicksFromSecondsF(0.0)); | 2326 TicksFromSecondsF(0.0)); |
| 2327 | 2327 |
| 2328 // Only unfinished animations should be considered by | 2328 // Only unfinished animations should be considered by |
| 2329 // HasOnlyTranslationTransforms. | 2329 // HasOnlyTranslationTransforms. |
| 2330 EXPECT_TRUE(animations_impl->HasOnlyTranslationTransforms( | 2330 EXPECT_TRUE( |
| 2331 ElementAnimations::ObserverType::PENDING)); | 2331 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::PENDING)); |
| 2332 EXPECT_TRUE(animations_impl->HasOnlyTranslationTransforms( | 2332 EXPECT_TRUE( |
| 2333 ElementAnimations::ObserverType::ACTIVE)); | 2333 animations_impl->HasOnlyTranslationTransforms(LayerTreeType::ACTIVE)); |
| 2334 } | 2334 } |
| 2335 | 2335 |
| 2336 TEST_F(ElementAnimationsTest, AnimationStartScale) { | 2336 TEST_F(ElementAnimationsTest, AnimationStartScale) { |
| 2337 CreateTestLayer(true, false); | 2337 CreateTestLayer(true, false); |
| 2338 AttachTimelinePlayerLayer(); | 2338 AttachTimelinePlayerLayer(); |
| 2339 CreateImplTimelineAndPlayer(); | 2339 CreateImplTimelineAndPlayer(); |
| 2340 | 2340 |
| 2341 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 2341 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 2342 | 2342 |
| 2343 std::unique_ptr<KeyframedTransformAnimationCurve> curve1( | 2343 std::unique_ptr<KeyframedTransformAnimationCurve> curve1( |
| 2344 KeyframedTransformAnimationCurve::Create()); | 2344 KeyframedTransformAnimationCurve::Create()); |
| 2345 | 2345 |
| 2346 TransformOperations operations1; | 2346 TransformOperations operations1; |
| 2347 operations1.AppendScale(2.0, 3.0, 4.0); | 2347 operations1.AppendScale(2.0, 3.0, 4.0); |
| 2348 curve1->AddKeyframe( | 2348 curve1->AddKeyframe( |
| 2349 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2349 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 2350 TransformOperations operations2; | 2350 TransformOperations operations2; |
| 2351 curve1->AddKeyframe(TransformKeyframe::Create( | 2351 curve1->AddKeyframe(TransformKeyframe::Create( |
| 2352 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2352 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
| 2353 std::unique_ptr<Animation> animation( | 2353 std::unique_ptr<Animation> animation( |
| 2354 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); | 2354 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); |
| 2355 animation->set_affects_active_observers(false); | 2355 animation->set_affects_active_observers(false); |
| 2356 animations_impl->AddAnimation(std::move(animation)); | 2356 animations_impl->AddAnimation(std::move(animation)); |
| 2357 | 2357 |
| 2358 float start_scale = 0.f; | 2358 float start_scale = 0.f; |
| 2359 EXPECT_TRUE(animations_impl->AnimationStartScale( | 2359 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::PENDING, |
| 2360 ElementAnimations::ObserverType::PENDING, &start_scale)); | 2360 &start_scale)); |
| 2361 EXPECT_EQ(4.f, start_scale); | 2361 EXPECT_EQ(4.f, start_scale); |
| 2362 EXPECT_TRUE(animations_impl->AnimationStartScale( | 2362 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::ACTIVE, |
| 2363 ElementAnimations::ObserverType::ACTIVE, &start_scale)); | 2363 &start_scale)); |
| 2364 EXPECT_EQ(0.f, start_scale); | 2364 EXPECT_EQ(0.f, start_scale); |
| 2365 | 2365 |
| 2366 animations_impl->ActivateAnimations(); | 2366 animations_impl->ActivateAnimations(); |
| 2367 EXPECT_TRUE(animations_impl->AnimationStartScale( | 2367 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::PENDING, |
| 2368 ElementAnimations::ObserverType::PENDING, &start_scale)); | 2368 &start_scale)); |
| 2369 EXPECT_EQ(4.f, start_scale); | 2369 EXPECT_EQ(4.f, start_scale); |
| 2370 EXPECT_TRUE(animations_impl->AnimationStartScale( | 2370 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::ACTIVE, |
| 2371 ElementAnimations::ObserverType::ACTIVE, &start_scale)); | 2371 &start_scale)); |
| 2372 EXPECT_EQ(4.f, start_scale); | 2372 EXPECT_EQ(4.f, start_scale); |
| 2373 | 2373 |
| 2374 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( | 2374 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( |
| 2375 KeyframedTransformAnimationCurve::Create()); | 2375 KeyframedTransformAnimationCurve::Create()); |
| 2376 | 2376 |
| 2377 TransformOperations operations3; | 2377 TransformOperations operations3; |
| 2378 curve2->AddKeyframe( | 2378 curve2->AddKeyframe( |
| 2379 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); | 2379 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); |
| 2380 operations3.AppendScale(6.0, 5.0, 4.0); | 2380 operations3.AppendScale(6.0, 5.0, 4.0); |
| 2381 curve2->AddKeyframe(TransformKeyframe::Create( | 2381 curve2->AddKeyframe(TransformKeyframe::Create( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2399 TransformKeyframe::Create(base::TimeDelta(), operations4, nullptr)); | 2399 TransformKeyframe::Create(base::TimeDelta(), operations4, nullptr)); |
| 2400 TransformOperations operations5; | 2400 TransformOperations operations5; |
| 2401 curve3->AddKeyframe(TransformKeyframe::Create( | 2401 curve3->AddKeyframe(TransformKeyframe::Create( |
| 2402 base::TimeDelta::FromSecondsD(1.0), operations5, nullptr)); | 2402 base::TimeDelta::FromSecondsD(1.0), operations5, nullptr)); |
| 2403 | 2403 |
| 2404 animation = | 2404 animation = |
| 2405 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); | 2405 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); |
| 2406 animation->set_affects_active_observers(false); | 2406 animation->set_affects_active_observers(false); |
| 2407 animations_impl->AddAnimation(std::move(animation)); | 2407 animations_impl->AddAnimation(std::move(animation)); |
| 2408 | 2408 |
| 2409 EXPECT_TRUE(animations_impl->AnimationStartScale( | 2409 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::PENDING, |
| 2410 ElementAnimations::ObserverType::PENDING, &start_scale)); | 2410 &start_scale)); |
| 2411 EXPECT_EQ(6.f, start_scale); | 2411 EXPECT_EQ(6.f, start_scale); |
| 2412 EXPECT_TRUE(animations_impl->AnimationStartScale( | 2412 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::ACTIVE, |
| 2413 ElementAnimations::ObserverType::ACTIVE, &start_scale)); | 2413 &start_scale)); |
| 2414 EXPECT_EQ(0.f, start_scale); | 2414 EXPECT_EQ(0.f, start_scale); |
| 2415 | 2415 |
| 2416 animations_impl->ActivateAnimations(); | 2416 animations_impl->ActivateAnimations(); |
| 2417 EXPECT_TRUE(animations_impl->AnimationStartScale( | 2417 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::PENDING, |
| 2418 ElementAnimations::ObserverType::PENDING, &start_scale)); | 2418 &start_scale)); |
| 2419 EXPECT_EQ(6.f, start_scale); | 2419 EXPECT_EQ(6.f, start_scale); |
| 2420 EXPECT_TRUE(animations_impl->AnimationStartScale( | 2420 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::ACTIVE, |
| 2421 ElementAnimations::ObserverType::ACTIVE, &start_scale)); | 2421 &start_scale)); |
| 2422 EXPECT_EQ(6.f, start_scale); | 2422 EXPECT_EQ(6.f, start_scale); |
| 2423 | 2423 |
| 2424 animations_impl->GetAnimationById(2)->SetRunState(Animation::FINISHED, | 2424 animations_impl->GetAnimationById(2)->SetRunState(Animation::FINISHED, |
| 2425 TicksFromSecondsF(0.0)); | 2425 TicksFromSecondsF(0.0)); |
| 2426 | 2426 |
| 2427 // Only unfinished animations should be considered by | 2427 // Only unfinished animations should be considered by |
| 2428 // AnimationStartScale. | 2428 // AnimationStartScale. |
| 2429 EXPECT_TRUE(animations_impl->AnimationStartScale( | 2429 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::PENDING, |
| 2430 ElementAnimations::ObserverType::PENDING, &start_scale)); | 2430 &start_scale)); |
| 2431 EXPECT_EQ(5.f, start_scale); | 2431 EXPECT_EQ(5.f, start_scale); |
| 2432 EXPECT_TRUE(animations_impl->AnimationStartScale( | 2432 EXPECT_TRUE(animations_impl->AnimationStartScale(LayerTreeType::ACTIVE, |
| 2433 ElementAnimations::ObserverType::ACTIVE, &start_scale)); | 2433 &start_scale)); |
| 2434 EXPECT_EQ(5.f, start_scale); | 2434 EXPECT_EQ(5.f, start_scale); |
| 2435 } | 2435 } |
| 2436 | 2436 |
| 2437 TEST_F(ElementAnimationsTest, MaximumTargetScale) { | 2437 TEST_F(ElementAnimationsTest, MaximumTargetScale) { |
| 2438 CreateTestLayer(true, false); | 2438 CreateTestLayer(true, false); |
| 2439 AttachTimelinePlayerLayer(); | 2439 AttachTimelinePlayerLayer(); |
| 2440 CreateImplTimelineAndPlayer(); | 2440 CreateImplTimelineAndPlayer(); |
| 2441 | 2441 |
| 2442 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 2442 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 2443 | 2443 |
| 2444 float max_scale = 0.f; | 2444 float max_scale = 0.f; |
| 2445 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2445 EXPECT_TRUE( |
| 2446 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2446 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2447 EXPECT_EQ(0.f, max_scale); | 2447 EXPECT_EQ(0.f, max_scale); |
| 2448 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2448 EXPECT_TRUE( |
| 2449 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2449 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2450 EXPECT_EQ(0.f, max_scale); | 2450 EXPECT_EQ(0.f, max_scale); |
| 2451 | 2451 |
| 2452 std::unique_ptr<KeyframedTransformAnimationCurve> curve1( | 2452 std::unique_ptr<KeyframedTransformAnimationCurve> curve1( |
| 2453 KeyframedTransformAnimationCurve::Create()); | 2453 KeyframedTransformAnimationCurve::Create()); |
| 2454 | 2454 |
| 2455 TransformOperations operations1; | 2455 TransformOperations operations1; |
| 2456 curve1->AddKeyframe( | 2456 curve1->AddKeyframe( |
| 2457 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2457 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 2458 operations1.AppendScale(2.0, 3.0, 4.0); | 2458 operations1.AppendScale(2.0, 3.0, 4.0); |
| 2459 curve1->AddKeyframe(TransformKeyframe::Create( | 2459 curve1->AddKeyframe(TransformKeyframe::Create( |
| 2460 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 2460 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
| 2461 | 2461 |
| 2462 std::unique_ptr<Animation> animation( | 2462 std::unique_ptr<Animation> animation( |
| 2463 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); | 2463 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); |
| 2464 animation->set_affects_active_observers(false); | 2464 animation->set_affects_active_observers(false); |
| 2465 animations_impl->AddAnimation(std::move(animation)); | 2465 animations_impl->AddAnimation(std::move(animation)); |
| 2466 | 2466 |
| 2467 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2467 EXPECT_TRUE( |
| 2468 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2468 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2469 EXPECT_EQ(4.f, max_scale); | 2469 EXPECT_EQ(4.f, max_scale); |
| 2470 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2470 EXPECT_TRUE( |
| 2471 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2471 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2472 EXPECT_EQ(0.f, max_scale); | 2472 EXPECT_EQ(0.f, max_scale); |
| 2473 | 2473 |
| 2474 animations_impl->ActivateAnimations(); | 2474 animations_impl->ActivateAnimations(); |
| 2475 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2475 EXPECT_TRUE( |
| 2476 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2476 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2477 EXPECT_EQ(4.f, max_scale); | 2477 EXPECT_EQ(4.f, max_scale); |
| 2478 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2478 EXPECT_TRUE( |
| 2479 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2479 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2480 EXPECT_EQ(4.f, max_scale); | 2480 EXPECT_EQ(4.f, max_scale); |
| 2481 | 2481 |
| 2482 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( | 2482 std::unique_ptr<KeyframedTransformAnimationCurve> curve2( |
| 2483 KeyframedTransformAnimationCurve::Create()); | 2483 KeyframedTransformAnimationCurve::Create()); |
| 2484 | 2484 |
| 2485 TransformOperations operations2; | 2485 TransformOperations operations2; |
| 2486 curve2->AddKeyframe( | 2486 curve2->AddKeyframe( |
| 2487 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 2487 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
| 2488 operations2.AppendScale(6.0, 5.0, 4.0); | 2488 operations2.AppendScale(6.0, 5.0, 4.0); |
| 2489 curve2->AddKeyframe(TransformKeyframe::Create( | 2489 curve2->AddKeyframe(TransformKeyframe::Create( |
| 2490 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2490 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
| 2491 | 2491 |
| 2492 animation = | 2492 animation = |
| 2493 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); | 2493 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM); |
| 2494 animation->set_affects_active_observers(false); | 2494 animation->set_affects_active_observers(false); |
| 2495 animations_impl->AddAnimation(std::move(animation)); | 2495 animations_impl->AddAnimation(std::move(animation)); |
| 2496 | 2496 |
| 2497 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2497 EXPECT_TRUE( |
| 2498 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2498 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2499 EXPECT_EQ(6.f, max_scale); | 2499 EXPECT_EQ(6.f, max_scale); |
| 2500 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2500 EXPECT_TRUE( |
| 2501 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2501 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2502 EXPECT_EQ(4.f, max_scale); | 2502 EXPECT_EQ(4.f, max_scale); |
| 2503 | 2503 |
| 2504 animations_impl->ActivateAnimations(); | 2504 animations_impl->ActivateAnimations(); |
| 2505 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2505 EXPECT_TRUE( |
| 2506 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2506 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2507 EXPECT_EQ(6.f, max_scale); | 2507 EXPECT_EQ(6.f, max_scale); |
| 2508 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2508 EXPECT_TRUE( |
| 2509 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2509 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2510 EXPECT_EQ(6.f, max_scale); | 2510 EXPECT_EQ(6.f, max_scale); |
| 2511 | 2511 |
| 2512 std::unique_ptr<KeyframedTransformAnimationCurve> curve3( | 2512 std::unique_ptr<KeyframedTransformAnimationCurve> curve3( |
| 2513 KeyframedTransformAnimationCurve::Create()); | 2513 KeyframedTransformAnimationCurve::Create()); |
| 2514 | 2514 |
| 2515 TransformOperations operations3; | 2515 TransformOperations operations3; |
| 2516 curve3->AddKeyframe( | 2516 curve3->AddKeyframe( |
| 2517 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); | 2517 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); |
| 2518 operations3.AppendPerspective(6.0); | 2518 operations3.AppendPerspective(6.0); |
| 2519 curve3->AddKeyframe(TransformKeyframe::Create( | 2519 curve3->AddKeyframe(TransformKeyframe::Create( |
| 2520 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); | 2520 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); |
| 2521 | 2521 |
| 2522 animation = | 2522 animation = |
| 2523 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); | 2523 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM); |
| 2524 animation->set_affects_active_observers(false); | 2524 animation->set_affects_active_observers(false); |
| 2525 animations_impl->AddAnimation(std::move(animation)); | 2525 animations_impl->AddAnimation(std::move(animation)); |
| 2526 | 2526 |
| 2527 EXPECT_FALSE(animations_impl->MaximumTargetScale( | 2527 EXPECT_FALSE( |
| 2528 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2528 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2529 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2529 EXPECT_TRUE( |
| 2530 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2530 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2531 EXPECT_EQ(6.f, max_scale); | 2531 EXPECT_EQ(6.f, max_scale); |
| 2532 | 2532 |
| 2533 animations_impl->ActivateAnimations(); | 2533 animations_impl->ActivateAnimations(); |
| 2534 EXPECT_FALSE(animations_impl->MaximumTargetScale( | 2534 EXPECT_FALSE( |
| 2535 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2535 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2536 EXPECT_FALSE(animations_impl->MaximumTargetScale( | 2536 EXPECT_FALSE( |
| 2537 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2537 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2538 | 2538 |
| 2539 animations_impl->GetAnimationById(3)->SetRunState(Animation::FINISHED, | 2539 animations_impl->GetAnimationById(3)->SetRunState(Animation::FINISHED, |
| 2540 TicksFromSecondsF(0.0)); | 2540 TicksFromSecondsF(0.0)); |
| 2541 animations_impl->GetAnimationById(2)->SetRunState(Animation::FINISHED, | 2541 animations_impl->GetAnimationById(2)->SetRunState(Animation::FINISHED, |
| 2542 TicksFromSecondsF(0.0)); | 2542 TicksFromSecondsF(0.0)); |
| 2543 | 2543 |
| 2544 // Only unfinished animations should be considered by | 2544 // Only unfinished animations should be considered by |
| 2545 // MaximumTargetScale. | 2545 // MaximumTargetScale. |
| 2546 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2546 EXPECT_TRUE( |
| 2547 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2547 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2548 EXPECT_EQ(4.f, max_scale); | 2548 EXPECT_EQ(4.f, max_scale); |
| 2549 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2549 EXPECT_TRUE( |
| 2550 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2550 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2551 EXPECT_EQ(4.f, max_scale); | 2551 EXPECT_EQ(4.f, max_scale); |
| 2552 } | 2552 } |
| 2553 | 2553 |
| 2554 TEST_F(ElementAnimationsTest, MaximumTargetScaleWithDirection) { | 2554 TEST_F(ElementAnimationsTest, MaximumTargetScaleWithDirection) { |
| 2555 CreateTestLayer(true, false); | 2555 CreateTestLayer(true, false); |
| 2556 AttachTimelinePlayerLayer(); | 2556 AttachTimelinePlayerLayer(); |
| 2557 CreateImplTimelineAndPlayer(); | 2557 CreateImplTimelineAndPlayer(); |
| 2558 | 2558 |
| 2559 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 2559 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| 2560 | 2560 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2573 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); | 2573 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM)); |
| 2574 Animation* animation = animation_owned.get(); | 2574 Animation* animation = animation_owned.get(); |
| 2575 animations_impl->AddAnimation(std::move(animation_owned)); | 2575 animations_impl->AddAnimation(std::move(animation_owned)); |
| 2576 | 2576 |
| 2577 float max_scale = 0.f; | 2577 float max_scale = 0.f; |
| 2578 | 2578 |
| 2579 EXPECT_GT(animation->playback_rate(), 0.0); | 2579 EXPECT_GT(animation->playback_rate(), 0.0); |
| 2580 | 2580 |
| 2581 // NORMAL direction with positive playback rate. | 2581 // NORMAL direction with positive playback rate. |
| 2582 animation->set_direction(Animation::DIRECTION_NORMAL); | 2582 animation->set_direction(Animation::DIRECTION_NORMAL); |
| 2583 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2583 EXPECT_TRUE( |
| 2584 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2584 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2585 EXPECT_EQ(6.f, max_scale); | 2585 EXPECT_EQ(6.f, max_scale); |
| 2586 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2586 EXPECT_TRUE( |
| 2587 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2587 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2588 EXPECT_EQ(6.f, max_scale); | 2588 EXPECT_EQ(6.f, max_scale); |
| 2589 | 2589 |
| 2590 // ALTERNATE direction with positive playback rate. | 2590 // ALTERNATE direction with positive playback rate. |
| 2591 animation->set_direction(Animation::DIRECTION_ALTERNATE); | 2591 animation->set_direction(Animation::DIRECTION_ALTERNATE); |
| 2592 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2592 EXPECT_TRUE( |
| 2593 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2593 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2594 EXPECT_EQ(6.f, max_scale); | 2594 EXPECT_EQ(6.f, max_scale); |
| 2595 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2595 EXPECT_TRUE( |
| 2596 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2596 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2597 EXPECT_EQ(6.f, max_scale); | 2597 EXPECT_EQ(6.f, max_scale); |
| 2598 | 2598 |
| 2599 // REVERSE direction with positive playback rate. | 2599 // REVERSE direction with positive playback rate. |
| 2600 animation->set_direction(Animation::DIRECTION_REVERSE); | 2600 animation->set_direction(Animation::DIRECTION_REVERSE); |
| 2601 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2601 EXPECT_TRUE( |
| 2602 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2602 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2603 EXPECT_EQ(3.f, max_scale); | 2603 EXPECT_EQ(3.f, max_scale); |
| 2604 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2604 EXPECT_TRUE( |
| 2605 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2605 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2606 EXPECT_EQ(3.f, max_scale); | 2606 EXPECT_EQ(3.f, max_scale); |
| 2607 | 2607 |
| 2608 // ALTERNATE reverse direction. | 2608 // ALTERNATE reverse direction. |
| 2609 animation->set_direction(Animation::DIRECTION_REVERSE); | 2609 animation->set_direction(Animation::DIRECTION_REVERSE); |
| 2610 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2610 EXPECT_TRUE( |
| 2611 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2611 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2612 EXPECT_EQ(3.f, max_scale); | 2612 EXPECT_EQ(3.f, max_scale); |
| 2613 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2613 EXPECT_TRUE( |
| 2614 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2614 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2615 EXPECT_EQ(3.f, max_scale); | 2615 EXPECT_EQ(3.f, max_scale); |
| 2616 | 2616 |
| 2617 animation->set_playback_rate(-1.0); | 2617 animation->set_playback_rate(-1.0); |
| 2618 | 2618 |
| 2619 // NORMAL direction with negative playback rate. | 2619 // NORMAL direction with negative playback rate. |
| 2620 animation->set_direction(Animation::DIRECTION_NORMAL); | 2620 animation->set_direction(Animation::DIRECTION_NORMAL); |
| 2621 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2621 EXPECT_TRUE( |
| 2622 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2622 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2623 EXPECT_EQ(3.f, max_scale); | 2623 EXPECT_EQ(3.f, max_scale); |
| 2624 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2624 EXPECT_TRUE( |
| 2625 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2625 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2626 EXPECT_EQ(3.f, max_scale); | 2626 EXPECT_EQ(3.f, max_scale); |
| 2627 | 2627 |
| 2628 // ALTERNATE direction with negative playback rate. | 2628 // ALTERNATE direction with negative playback rate. |
| 2629 animation->set_direction(Animation::DIRECTION_ALTERNATE); | 2629 animation->set_direction(Animation::DIRECTION_ALTERNATE); |
| 2630 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2630 EXPECT_TRUE( |
| 2631 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2631 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2632 EXPECT_EQ(3.f, max_scale); | 2632 EXPECT_EQ(3.f, max_scale); |
| 2633 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2633 EXPECT_TRUE( |
| 2634 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2634 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2635 EXPECT_EQ(3.f, max_scale); | 2635 EXPECT_EQ(3.f, max_scale); |
| 2636 | 2636 |
| 2637 // REVERSE direction with negative playback rate. | 2637 // REVERSE direction with negative playback rate. |
| 2638 animation->set_direction(Animation::DIRECTION_REVERSE); | 2638 animation->set_direction(Animation::DIRECTION_REVERSE); |
| 2639 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2639 EXPECT_TRUE( |
| 2640 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2640 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2641 EXPECT_EQ(6.f, max_scale); | 2641 EXPECT_EQ(6.f, max_scale); |
| 2642 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2642 EXPECT_TRUE( |
| 2643 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2643 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2644 EXPECT_EQ(6.f, max_scale); | 2644 EXPECT_EQ(6.f, max_scale); |
| 2645 | 2645 |
| 2646 // ALTERNATE reverse direction with negative playback rate. | 2646 // ALTERNATE reverse direction with negative playback rate. |
| 2647 animation->set_direction(Animation::DIRECTION_REVERSE); | 2647 animation->set_direction(Animation::DIRECTION_REVERSE); |
| 2648 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2648 EXPECT_TRUE( |
| 2649 ElementAnimations::ObserverType::PENDING, &max_scale)); | 2649 animations_impl->MaximumTargetScale(LayerTreeType::PENDING, &max_scale)); |
| 2650 EXPECT_EQ(6.f, max_scale); | 2650 EXPECT_EQ(6.f, max_scale); |
| 2651 EXPECT_TRUE(animations_impl->MaximumTargetScale( | 2651 EXPECT_TRUE( |
| 2652 ElementAnimations::ObserverType::ACTIVE, &max_scale)); | 2652 animations_impl->MaximumTargetScale(LayerTreeType::ACTIVE, &max_scale)); |
| 2653 EXPECT_EQ(6.f, max_scale); | 2653 EXPECT_EQ(6.f, max_scale); |
| 2654 } | 2654 } |
| 2655 | 2655 |
| 2656 TEST_F(ElementAnimationsTest, NewlyPushedAnimationWaitsForActivation) { | 2656 TEST_F(ElementAnimationsTest, NewlyPushedAnimationWaitsForActivation) { |
| 2657 CreateTestLayer(true, true); | 2657 CreateTestLayer(true, true); |
| 2658 AttachTimelinePlayerLayer(); | 2658 AttachTimelinePlayerLayer(); |
| 2659 CreateImplTimelineAndPlayer(); | 2659 CreateImplTimelineAndPlayer(); |
| 2660 | 2660 |
| 2661 scoped_refptr<ElementAnimations> animations = element_animations(); | 2661 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 2662 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); | 2662 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3077 scoped_refptr<ElementAnimations> animations = element_animations(); | 3077 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 3078 | 3078 |
| 3079 // Create an animation that initially affects only pending observers. | 3079 // Create an animation that initially affects only pending observers. |
| 3080 std::unique_ptr<Animation> animation(CreateAnimation( | 3080 std::unique_ptr<Animation> animation(CreateAnimation( |
| 3081 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 3081 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 3082 1, TargetProperty::OPACITY)); | 3082 1, TargetProperty::OPACITY)); |
| 3083 animation->set_affects_active_observers(false); | 3083 animation->set_affects_active_observers(false); |
| 3084 | 3084 |
| 3085 animations->AddAnimation(std::move(animation)); | 3085 animations->AddAnimation(std::move(animation)); |
| 3086 animations->Animate(kInitialTickTime); | 3086 animations->Animate(kInitialTickTime); |
| 3087 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( | 3087 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3088 TargetProperty::OPACITY, ElementAnimations::ObserverType::PENDING)); | 3088 LayerTreeType::PENDING)); |
| 3089 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3089 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3090 TargetProperty::OPACITY, ElementAnimations::ObserverType::ACTIVE)); | 3090 LayerTreeType::ACTIVE)); |
| 3091 animations->UpdateState(true, nullptr); | 3091 animations->UpdateState(true, nullptr); |
| 3092 EXPECT_TRUE(animations->HasActiveAnimation()); | 3092 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 3093 | 3093 |
| 3094 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( | 3094 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3095 TargetProperty::OPACITY, ElementAnimations::ObserverType::PENDING)); | 3095 LayerTreeType::PENDING)); |
| 3096 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3097 LayerTreeType::ACTIVE)); |
| 3096 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3098 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
| 3097 TargetProperty::OPACITY, ElementAnimations::ObserverType::ACTIVE)); | 3099 TargetProperty::FILTER, LayerTreeType::PENDING)); |
| 3098 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3100 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, |
| 3099 TargetProperty::FILTER, ElementAnimations::ObserverType::PENDING)); | 3101 LayerTreeType::ACTIVE)); |
| 3100 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | |
| 3101 TargetProperty::FILTER, ElementAnimations::ObserverType::ACTIVE)); | |
| 3102 | 3102 |
| 3103 animations->ActivateAnimations(); | 3103 animations->ActivateAnimations(); |
| 3104 | 3104 |
| 3105 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( | 3105 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3106 TargetProperty::OPACITY, ElementAnimations::ObserverType::PENDING)); | 3106 LayerTreeType::PENDING)); |
| 3107 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( | 3107 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3108 TargetProperty::OPACITY, ElementAnimations::ObserverType::ACTIVE)); | 3108 LayerTreeType::ACTIVE)); |
| 3109 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3109 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
| 3110 TargetProperty::FILTER, ElementAnimations::ObserverType::PENDING)); | 3110 TargetProperty::FILTER, LayerTreeType::PENDING)); |
| 3111 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3111 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, |
| 3112 TargetProperty::FILTER, ElementAnimations::ObserverType::ACTIVE)); | 3112 LayerTreeType::ACTIVE)); |
| 3113 | 3113 |
| 3114 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(10)); | 3114 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(10)); |
| 3115 animations->UpdateState(true, nullptr); | 3115 animations->UpdateState(true, nullptr); |
| 3116 | 3116 |
| 3117 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( | 3117 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3118 TargetProperty::OPACITY, ElementAnimations::ObserverType::PENDING)); | 3118 LayerTreeType::PENDING)); |
| 3119 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( | 3119 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3120 TargetProperty::OPACITY, ElementAnimations::ObserverType::ACTIVE)); | 3120 LayerTreeType::ACTIVE)); |
| 3121 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3121 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
| 3122 TargetProperty::FILTER, ElementAnimations::ObserverType::PENDING)); | 3122 TargetProperty::FILTER, LayerTreeType::PENDING)); |
| 3123 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3123 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, |
| 3124 TargetProperty::FILTER, ElementAnimations::ObserverType::ACTIVE)); | 3124 LayerTreeType::ACTIVE)); |
| 3125 | 3125 |
| 3126 EXPECT_EQ(0.f, client_.GetOpacity(layer_id_, LayerTreeType::ACTIVE)); | 3126 EXPECT_EQ(0.f, client_.GetOpacity(layer_id_, LayerTreeType::ACTIVE)); |
| 3127 | 3127 |
| 3128 // Tick past the end of the animation. | 3128 // Tick past the end of the animation. |
| 3129 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1100)); | 3129 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1100)); |
| 3130 animations->UpdateState(true, nullptr); | 3130 animations->UpdateState(true, nullptr); |
| 3131 | 3131 |
| 3132 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3132 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
| 3133 TargetProperty::OPACITY, ElementAnimations::ObserverType::PENDING)); | 3133 TargetProperty::OPACITY, LayerTreeType::PENDING)); |
| 3134 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3135 LayerTreeType::ACTIVE)); |
| 3134 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3136 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
| 3135 TargetProperty::OPACITY, ElementAnimations::ObserverType::ACTIVE)); | 3137 TargetProperty::FILTER, LayerTreeType::PENDING)); |
| 3136 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3138 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::FILTER, |
| 3137 TargetProperty::FILTER, ElementAnimations::ObserverType::PENDING)); | 3139 LayerTreeType::ACTIVE)); |
| 3138 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | |
| 3139 TargetProperty::FILTER, ElementAnimations::ObserverType::ACTIVE)); | |
| 3140 | 3140 |
| 3141 EXPECT_EQ(1.f, client_.GetOpacity(layer_id_, LayerTreeType::ACTIVE)); | 3141 EXPECT_EQ(1.f, client_.GetOpacity(layer_id_, LayerTreeType::ACTIVE)); |
| 3142 } | 3142 } |
| 3143 | 3143 |
| 3144 TEST_F(ElementAnimationsTest, TestIsAnimatingPropertyTimeOffsetFillMode) { | 3144 TEST_F(ElementAnimationsTest, TestIsAnimatingPropertyTimeOffsetFillMode) { |
| 3145 CreateTestLayer(false, false); | 3145 CreateTestLayer(false, false); |
| 3146 AttachTimelinePlayerLayer(); | 3146 AttachTimelinePlayerLayer(); |
| 3147 | 3147 |
| 3148 scoped_refptr<ElementAnimations> animations = element_animations(); | 3148 scoped_refptr<ElementAnimations> animations = element_animations(); |
| 3149 | 3149 |
| 3150 // Create an animation that initially affects only pending observers, and has | 3150 // Create an animation that initially affects only pending observers, and has |
| 3151 // a start delay of 2 seconds. | 3151 // a start delay of 2 seconds. |
| 3152 std::unique_ptr<Animation> animation(CreateAnimation( | 3152 std::unique_ptr<Animation> animation(CreateAnimation( |
| 3153 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 3153 std::unique_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 3154 1, TargetProperty::OPACITY)); | 3154 1, TargetProperty::OPACITY)); |
| 3155 animation->set_fill_mode(Animation::FILL_MODE_NONE); | 3155 animation->set_fill_mode(Animation::FILL_MODE_NONE); |
| 3156 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000)); | 3156 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000)); |
| 3157 animation->set_affects_active_observers(false); | 3157 animation->set_affects_active_observers(false); |
| 3158 | 3158 |
| 3159 animations->AddAnimation(std::move(animation)); | 3159 animations->AddAnimation(std::move(animation)); |
| 3160 | 3160 |
| 3161 animations->Animate(kInitialTickTime); | 3161 animations->Animate(kInitialTickTime); |
| 3162 | 3162 |
| 3163 // Since the animation has a start delay, the observers it affects have a | 3163 // Since the animation has a start delay, the observers it affects have a |
| 3164 // potentially running transform animation but aren't currently animating | 3164 // potentially running transform animation but aren't currently animating |
| 3165 // transform. | 3165 // transform. |
| 3166 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( | 3166 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( |
| 3167 TargetProperty::OPACITY, ElementAnimations::ObserverType::PENDING)); | 3167 TargetProperty::OPACITY, LayerTreeType::PENDING)); |
| 3168 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( | 3168 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( |
| 3169 TargetProperty::OPACITY, ElementAnimations::ObserverType::ACTIVE)); | 3169 TargetProperty::OPACITY, LayerTreeType::ACTIVE)); |
| 3170 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3170 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
| 3171 TargetProperty::OPACITY, ElementAnimations::ObserverType::PENDING)); | 3171 TargetProperty::OPACITY, LayerTreeType::PENDING)); |
| 3172 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3172 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3173 TargetProperty::OPACITY, ElementAnimations::ObserverType::ACTIVE)); | 3173 LayerTreeType::ACTIVE)); |
| 3174 EXPECT_TRUE(animations->HasActiveAnimation()); | 3174 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 3175 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( | 3175 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( |
| 3176 TargetProperty::FILTER, ElementAnimations::ObserverType::PENDING)); | 3176 TargetProperty::FILTER, LayerTreeType::PENDING)); |
| 3177 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( | 3177 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( |
| 3178 TargetProperty::FILTER, ElementAnimations::ObserverType::ACTIVE)); | 3178 TargetProperty::FILTER, LayerTreeType::ACTIVE)); |
| 3179 | 3179 |
| 3180 animations->ActivateAnimations(); | 3180 animations->ActivateAnimations(); |
| 3181 | 3181 |
| 3182 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( | 3182 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( |
| 3183 TargetProperty::OPACITY, ElementAnimations::ObserverType::PENDING)); | 3183 TargetProperty::OPACITY, LayerTreeType::PENDING)); |
| 3184 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( | 3184 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( |
| 3185 TargetProperty::OPACITY, ElementAnimations::ObserverType::ACTIVE)); | 3185 TargetProperty::OPACITY, LayerTreeType::ACTIVE)); |
| 3186 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3186 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
| 3187 TargetProperty::OPACITY, ElementAnimations::ObserverType::PENDING)); | 3187 TargetProperty::OPACITY, LayerTreeType::PENDING)); |
| 3188 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3188 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3189 TargetProperty::OPACITY, ElementAnimations::ObserverType::ACTIVE)); | 3189 LayerTreeType::ACTIVE)); |
| 3190 EXPECT_TRUE(animations->HasActiveAnimation()); | 3190 EXPECT_TRUE(animations->HasActiveAnimation()); |
| 3191 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( | 3191 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( |
| 3192 TargetProperty::FILTER, ElementAnimations::ObserverType::PENDING)); | 3192 TargetProperty::FILTER, LayerTreeType::PENDING)); |
| 3193 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( | 3193 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( |
| 3194 TargetProperty::FILTER, ElementAnimations::ObserverType::ACTIVE)); | 3194 TargetProperty::FILTER, LayerTreeType::ACTIVE)); |
| 3195 | 3195 |
| 3196 animations->UpdateState(true, nullptr); | 3196 animations->UpdateState(true, nullptr); |
| 3197 | 3197 |
| 3198 // Tick past the start delay. | 3198 // Tick past the start delay. |
| 3199 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 3199 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 3200 animations->UpdateState(true, nullptr); | 3200 animations->UpdateState(true, nullptr); |
| 3201 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( | 3201 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( |
| 3202 TargetProperty::OPACITY, ElementAnimations::ObserverType::PENDING)); | 3202 TargetProperty::OPACITY, LayerTreeType::PENDING)); |
| 3203 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( | 3203 EXPECT_TRUE(animations->IsPotentiallyAnimatingProperty( |
| 3204 TargetProperty::OPACITY, ElementAnimations::ObserverType::ACTIVE)); | 3204 TargetProperty::OPACITY, LayerTreeType::ACTIVE)); |
| 3205 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( | 3205 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3206 TargetProperty::OPACITY, ElementAnimations::ObserverType::PENDING)); | 3206 LayerTreeType::PENDING)); |
| 3207 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty( | 3207 EXPECT_TRUE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3208 TargetProperty::OPACITY, ElementAnimations::ObserverType::ACTIVE)); | 3208 LayerTreeType::ACTIVE)); |
| 3209 | 3209 |
| 3210 // After the animaton finishes, the observers it affects have neither a | 3210 // After the animaton finishes, the observers it affects have neither a |
| 3211 // potentially running transform animation nor a currently running transform | 3211 // potentially running transform animation nor a currently running transform |
| 3212 // animation. | 3212 // animation. |
| 3213 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); | 3213 animations->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); |
| 3214 animations->UpdateState(true, nullptr); | 3214 animations->UpdateState(true, nullptr); |
| 3215 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( | 3215 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( |
| 3216 TargetProperty::OPACITY, ElementAnimations::ObserverType::PENDING)); | 3216 TargetProperty::OPACITY, LayerTreeType::PENDING)); |
| 3217 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( | 3217 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( |
| 3218 TargetProperty::OPACITY, ElementAnimations::ObserverType::ACTIVE)); | 3218 TargetProperty::OPACITY, LayerTreeType::ACTIVE)); |
| 3219 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3219 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( |
| 3220 TargetProperty::OPACITY, ElementAnimations::ObserverType::PENDING)); | 3220 TargetProperty::OPACITY, LayerTreeType::PENDING)); |
| 3221 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( | 3221 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(TargetProperty::OPACITY, |
| 3222 TargetProperty::OPACITY, ElementAnimations::ObserverType::ACTIVE)); | 3222 LayerTreeType::ACTIVE)); |
| 3223 } | 3223 } |
| 3224 | 3224 |
| 3225 } // namespace | 3225 } // namespace |
| 3226 } // namespace cc | 3226 } // namespace cc |
| OLD | NEW |