| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/compositor/layer_animator.h" | 5 #include "ui/compositor/layer_animator.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 2358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2369 EXPECT_EQ(start_opacity, delegate.GetOpacityForAnimation()); | 2369 EXPECT_EQ(start_opacity, delegate.GetOpacityForAnimation()); |
| 2370 | 2370 |
| 2371 settings.SetPreemptionStrategy( | 2371 settings.SetPreemptionStrategy( |
| 2372 LayerAnimator::ENQUEUE_NEW_ANIMATION); | 2372 LayerAnimator::ENQUEUE_NEW_ANIMATION); |
| 2373 settings.SetTransitionDuration(base::TimeDelta()); | 2373 settings.SetTransitionDuration(base::TimeDelta()); |
| 2374 animator->SetOpacity(magic_opacity); | 2374 animator->SetOpacity(magic_opacity); |
| 2375 | 2375 |
| 2376 EXPECT_EQ(start_opacity, delegate.GetOpacityForAnimation()); | 2376 EXPECT_EQ(start_opacity, delegate.GetOpacityForAnimation()); |
| 2377 } | 2377 } |
| 2378 | 2378 |
| 2379 TEST(LayerAnimatorTest, TestScopedCounterAnimation) { | |
| 2380 Layer parent, child; | |
| 2381 parent.Add(&child); | |
| 2382 | |
| 2383 gfx::Transform parent_begin, parent_end; | |
| 2384 | |
| 2385 parent_end.Scale3d(2.0, 0.5, 1.0); | |
| 2386 | |
| 2387 // Parent animates from identity to the end value. The counter animation will | |
| 2388 // start at the end value and animate back to identity. | |
| 2389 gfx::Transform child_begin(parent_end); | |
| 2390 | |
| 2391 child.SetTransform(child_begin); | |
| 2392 parent.SetTransform(parent_begin); | |
| 2393 | |
| 2394 EXPECT_FALSE(child.GetAnimator()->is_animating()); | |
| 2395 | |
| 2396 ScopedLayerAnimationSettings settings(parent.GetAnimator()); | |
| 2397 settings.SetInverselyAnimatedBaseLayer(&parent); | |
| 2398 settings.AddInverselyAnimatedLayer(&child); | |
| 2399 | |
| 2400 parent.SetTransform(parent_end); | |
| 2401 | |
| 2402 EXPECT_TRUE(child.GetAnimator()->is_animating()); | |
| 2403 EXPECT_TRUE(child.GetTargetTransform().IsIdentity()) | |
| 2404 << child.GetTargetTransform().ToString(); | |
| 2405 | |
| 2406 } | |
| 2407 | |
| 2408 class CollectionLayerAnimationDelegate : public TestLayerAnimationDelegate { | 2379 class CollectionLayerAnimationDelegate : public TestLayerAnimationDelegate { |
| 2409 public: | 2380 public: |
| 2410 CollectionLayerAnimationDelegate() : collection(NULL) {} | 2381 CollectionLayerAnimationDelegate() : collection(NULL) {} |
| 2411 ~CollectionLayerAnimationDelegate() override {} | 2382 ~CollectionLayerAnimationDelegate() override {} |
| 2412 | 2383 |
| 2413 // LayerAnimationDelegate: | 2384 // LayerAnimationDelegate: |
| 2414 LayerAnimatorCollection* GetLayerAnimatorCollection() override { | 2385 LayerAnimatorCollection* GetLayerAnimatorCollection() override { |
| 2415 return &collection; | 2386 return &collection; |
| 2416 } | 2387 } |
| 2417 | 2388 |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2823 EXPECT_EQ(observer.last_ended_sequence(), nullptr); | 2794 EXPECT_EQ(observer.last_ended_sequence(), nullptr); |
| 2824 EXPECT_EQ(observer.last_detached_sequence(), first_sequence); | 2795 EXPECT_EQ(observer.last_detached_sequence(), first_sequence); |
| 2825 | 2796 |
| 2826 EXPECT_TRUE(observer.AbortedEpochIsBeforeDetachedEpoch()); | 2797 EXPECT_TRUE(observer.AbortedEpochIsBeforeDetachedEpoch()); |
| 2827 EXPECT_TRUE(observer.AbortedEpochIsBeforeStartedEpoch()); | 2798 EXPECT_TRUE(observer.AbortedEpochIsBeforeStartedEpoch()); |
| 2828 EXPECT_TRUE(observer.AttachedEpochIsBeforeScheduledEpoch()); | 2799 EXPECT_TRUE(observer.AttachedEpochIsBeforeScheduledEpoch()); |
| 2829 EXPECT_TRUE(observer.ScheduledEpochIsBeforeStartedEpoch()); | 2800 EXPECT_TRUE(observer.ScheduledEpochIsBeforeStartedEpoch()); |
| 2830 } | 2801 } |
| 2831 | 2802 |
| 2832 } // namespace ui | 2803 } // namespace ui |
| OLD | NEW |