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/gfx/compositor/layer_animator.h" | 5 #include "ui/gfx/compositor/layer_animator.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 | 1003 |
1004 // This should interrupt the running sequence causing us to immediately set | 1004 // This should interrupt the running sequence causing us to immediately set |
1005 // the target value. The sequence should alse be destructed. | 1005 // the target value. The sequence should alse be destructed. |
1006 animator->StartAnimation(sequence.release()); | 1006 animator->StartAnimation(sequence.release()); |
1007 | 1007 |
1008 EXPECT_FALSE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS)); | 1008 EXPECT_FALSE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS)); |
1009 EXPECT_EQ(0, num_live_instances); | 1009 EXPECT_EQ(0, num_live_instances); |
1010 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds); | 1010 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds); |
1011 } | 1011 } |
1012 | 1012 |
| 1013 // Verifies GetTargetOpacity() works when multiple sequences are scheduled. |
| 1014 TEST(LayerAnimatorTest, GetTargetOpacity) { |
| 1015 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
| 1016 animator->set_preemption_strategy(LayerAnimator::ENQUEUE_NEW_ANIMATION); |
| 1017 animator->set_disable_timer_for_test(true); |
| 1018 TestLayerAnimationDelegate delegate; |
| 1019 animator->SetDelegate(&delegate); |
| 1020 |
| 1021 delegate.SetOpacityFromAnimation(0.0); |
| 1022 |
| 1023 { |
| 1024 ScopedLayerAnimationSettings settings(animator.get()); |
| 1025 animator->SetOpacity(0.5); |
| 1026 EXPECT_EQ(0.5, animator->GetTargetOpacity()); |
| 1027 |
| 1028 // Because the strategy is ENQUEUE_NEW_ANIMATION the target should now be 1. |
| 1029 animator->SetOpacity(1.0); |
| 1030 EXPECT_EQ(1.0, animator->GetTargetOpacity()); |
| 1031 } |
| 1032 } |
| 1033 |
1013 } // namespace ui | 1034 } // namespace ui |
OLD | NEW |