Index: ui/compositor/layer_animator_unittest.cc |
diff --git a/ui/compositor/layer_animator_unittest.cc b/ui/compositor/layer_animator_unittest.cc |
index 3ae8c2b34ebc10928d19d6dffc0be48bdba5359c..66efca72ccf4bbc7845aa94097d0fbf072693c12 100644 |
--- a/ui/compositor/layer_animator_unittest.cc |
+++ b/ui/compositor/layer_animator_unittest.cc |
@@ -14,12 +14,9 @@ |
#include "ui/compositor/layer_animation_delegate.h" |
#include "ui/compositor/layer_animation_element.h" |
#include "ui/compositor/layer_animation_sequence.h" |
-#include "ui/compositor/layer_animator_collection.h" |
#include "ui/compositor/scoped_animation_duration_scale_mode.h" |
#include "ui/compositor/scoped_layer_animation_settings.h" |
-#include "ui/compositor/test/context_factories_for_test.h" |
#include "ui/compositor/test/layer_animator_test_controller.h" |
-#include "ui/compositor/test/test_compositor_host.h" |
#include "ui/compositor/test/test_layer_animation_delegate.h" |
#include "ui/compositor/test/test_layer_animation_observer.h" |
#include "ui/compositor/test/test_utils.h" |
@@ -27,6 +24,8 @@ |
#include "ui/gfx/rect.h" |
#include "ui/gfx/transform.h" |
+using gfx::AnimationContainerElement; |
+ |
namespace ui { |
namespace { |
@@ -197,13 +196,14 @@ class TestLayerAnimationSequence : public LayerAnimationSequence { |
TEST(LayerAnimatorTest, ImplicitAnimation) { |
scoped_refptr<LayerAnimator> animator( |
LayerAnimator::CreateImplicitAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
base::TimeTicks now = gfx::FrameTime::Now(); |
animator->SetBrightness(0.5); |
EXPECT_TRUE(animator->is_animating()); |
- animator->Step(now + base::TimeDelta::FromSeconds(1)); |
+ element->Step(now + base::TimeDelta::FromSeconds(1)); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), 0.5); |
} |
@@ -285,6 +285,7 @@ TEST(LayerAnimatorTest, AbortAllAnimations) { |
// trivial case and should result in the animation being started immediately. |
TEST(LayerAnimatorTest, ScheduleAnimationThatCanRunImmediately) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -307,12 +308,12 @@ TEST(LayerAnimatorTest, ScheduleAnimationThatCanRunImmediately) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_FALSE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
@@ -323,7 +324,7 @@ TEST(LayerAnimatorTest, ScheduleThreadedAnimationThatCanRunImmediately) { |
double epsilon = 0.00001; |
LayerAnimatorTestController test_controller( |
LayerAnimator::CreateDefaultAnimator()); |
- LayerAnimator* animator = test_controller.animator(); |
+ AnimationContainerElement* element = test_controller.animator(); |
test_controller.animator()->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
test_controller.animator()->SetDelegate(&delegate); |
@@ -353,7 +354,7 @@ TEST(LayerAnimatorTest, ScheduleThreadedAnimationThatCanRunImmediately) { |
cc::Animation::Opacity, |
effective_start)); |
- animator->Step(effective_start + delta / 2); |
+ element->Step(effective_start + delta/2); |
EXPECT_TRUE(test_controller.animator()->is_animating()); |
EXPECT_NEAR( |
@@ -362,7 +363,7 @@ TEST(LayerAnimatorTest, ScheduleThreadedAnimationThatCanRunImmediately) { |
last_progressed_fraction(), |
epsilon); |
- animator->Step(effective_start + delta); |
+ element->Step(effective_start + delta); |
EXPECT_FALSE(test_controller.animator()->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
@@ -372,6 +373,7 @@ TEST(LayerAnimatorTest, ScheduleThreadedAnimationThatCanRunImmediately) { |
// should start immediately and should progress in lock step. |
TEST(LayerAnimatorTest, ScheduleTwoAnimationsThatCanRunImmediately) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -405,13 +407,13 @@ TEST(LayerAnimatorTest, ScheduleTwoAnimationsThatCanRunImmediately) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), middle_bounds); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_FALSE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
@@ -424,7 +426,7 @@ TEST(LayerAnimatorTest, ScheduleThreadedAndNonThreadedAnimations) { |
double epsilon = 0.00001; |
LayerAnimatorTestController test_controller( |
LayerAnimator::CreateDefaultAnimator()); |
- LayerAnimator* animator = test_controller.animator(); |
+ AnimationContainerElement* element = test_controller.animator(); |
test_controller.animator()->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
test_controller.animator()->SetDelegate(&delegate); |
@@ -468,7 +470,7 @@ TEST(LayerAnimatorTest, ScheduleThreadedAndNonThreadedAnimations) { |
cc::Animation::Opacity, |
effective_start)); |
- animator->Step(effective_start + delta / 2); |
+ element->Step(effective_start + delta/2); |
EXPECT_TRUE(test_controller.animator()->is_animating()); |
EXPECT_NEAR( |
@@ -478,7 +480,7 @@ TEST(LayerAnimatorTest, ScheduleThreadedAndNonThreadedAnimations) { |
epsilon); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), middle_bounds); |
- animator->Step(effective_start + delta); |
+ element->Step(effective_start + delta); |
EXPECT_FALSE(test_controller.animator()->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
@@ -489,6 +491,7 @@ TEST(LayerAnimatorTest, ScheduleThreadedAndNonThreadedAnimations) { |
// animations should run one after another. |
TEST(LayerAnimatorTest, ScheduleTwoAnimationsOnSameProperty) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -516,22 +519,22 @@ TEST(LayerAnimatorTest, ScheduleTwoAnimationsOnSameProperty) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_FALSE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
@@ -542,6 +545,7 @@ TEST(LayerAnimatorTest, ScheduleTwoAnimationsOnSameProperty) { |
// order. |
TEST(LayerAnimatorTest, ScheduleBlockedAnimation) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -585,31 +589,31 @@ TEST(LayerAnimatorTest, ScheduleBlockedAnimation) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), middle_grayscale); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), target_grayscale); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(3000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(3000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(4000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(4000)); |
EXPECT_FALSE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
@@ -621,6 +625,7 @@ TEST(LayerAnimatorTest, ScheduleBlockedAnimation) { |
// the second grayscale animation starts. |
TEST(LayerAnimatorTest, ScheduleTogether) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -657,13 +662,13 @@ TEST(LayerAnimatorTest, ScheduleTogether) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), target_grayscale); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_FALSE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
@@ -674,6 +679,7 @@ TEST(LayerAnimatorTest, ScheduleTogether) { |
// case (see the trival case for ScheduleAnimation). |
TEST(LayerAnimatorTest, StartAnimationThatCanRunImmediately) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -696,12 +702,12 @@ TEST(LayerAnimatorTest, StartAnimationThatCanRunImmediately) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_FALSE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
@@ -712,7 +718,7 @@ TEST(LayerAnimatorTest, StartThreadedAnimationThatCanRunImmediately) { |
double epsilon = 0.00001; |
LayerAnimatorTestController test_controller( |
LayerAnimator::CreateDefaultAnimator()); |
- LayerAnimator* animator = test_controller.animator(); |
+ AnimationContainerElement* element = test_controller.animator(); |
test_controller.animator()->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
test_controller.animator()->SetDelegate(&delegate); |
@@ -742,7 +748,7 @@ TEST(LayerAnimatorTest, StartThreadedAnimationThatCanRunImmediately) { |
cc::Animation::Opacity, |
effective_start)); |
- animator->Step(effective_start + delta / 2); |
+ element->Step(effective_start + delta/2); |
EXPECT_TRUE(test_controller.animator()->is_animating()); |
EXPECT_NEAR( |
@@ -751,7 +757,7 @@ TEST(LayerAnimatorTest, StartThreadedAnimationThatCanRunImmediately) { |
last_progressed_fraction(), |
epsilon); |
- animator->Step(effective_start + delta); |
+ element->Step(effective_start + delta); |
EXPECT_FALSE(test_controller.animator()->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
} |
@@ -787,6 +793,7 @@ TEST(LayerAnimatorTest, PreemptBySettingNewTarget) { |
// Preempt by animating to new target, with a non-threaded animation. |
TEST(LayerAnimatorTest, PreemptByImmediatelyAnimatingToNewTarget) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -809,7 +816,7 @@ TEST(LayerAnimatorTest, PreemptByImmediatelyAnimatingToNewTarget) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
animator->StartAnimation( |
new LayerAnimationSequence( |
@@ -826,13 +833,13 @@ TEST(LayerAnimatorTest, PreemptByImmediatelyAnimatingToNewTarget) { |
EXPECT_TRUE(animator->is_animating()); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), |
0.5 * (start_brightness + middle_brightness)); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
EXPECT_FALSE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
@@ -843,7 +850,7 @@ TEST(LayerAnimatorTest, PreemptThreadedByImmediatelyAnimatingToNewTarget) { |
double epsilon = 0.00001; |
LayerAnimatorTestController test_controller( |
LayerAnimator::CreateDefaultAnimator()); |
- LayerAnimator* animator = test_controller.animator(); |
+ AnimationContainerElement* element = test_controller.animator(); |
test_controller.animator()->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
test_controller.animator()->SetDelegate(&delegate); |
@@ -874,7 +881,7 @@ TEST(LayerAnimatorTest, PreemptThreadedByImmediatelyAnimatingToNewTarget) { |
cc::Animation::Opacity, |
effective_start)); |
- animator->Step(effective_start + delta / 2); |
+ element->Step(effective_start + delta/2); |
test_controller.animator()->StartAnimation( |
new LayerAnimationSequence( |
@@ -899,7 +906,7 @@ TEST(LayerAnimatorTest, PreemptThreadedByImmediatelyAnimatingToNewTarget) { |
cc::Animation::Opacity, |
second_effective_start)); |
- animator->Step(second_effective_start + delta / 2); |
+ element->Step(second_effective_start + delta/2); |
EXPECT_TRUE(test_controller.animator()->is_animating()); |
EXPECT_NEAR( |
@@ -908,7 +915,7 @@ TEST(LayerAnimatorTest, PreemptThreadedByImmediatelyAnimatingToNewTarget) { |
last_progressed_fraction(), |
epsilon); |
- animator->Step(second_effective_start + delta); |
+ element->Step(second_effective_start + delta); |
EXPECT_FALSE(test_controller.animator()->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
@@ -917,6 +924,7 @@ TEST(LayerAnimatorTest, PreemptThreadedByImmediatelyAnimatingToNewTarget) { |
// Preempt by enqueuing the new animation. |
TEST(LayerAnimatorTest, PreemptEnqueueNewAnimation) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -938,7 +946,7 @@ TEST(LayerAnimatorTest, PreemptEnqueueNewAnimation) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
animator->StartAnimation( |
new LayerAnimationSequence( |
@@ -950,17 +958,17 @@ TEST(LayerAnimatorTest, PreemptEnqueueNewAnimation) { |
EXPECT_TRUE(animator->is_animating()); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_FALSE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
@@ -971,6 +979,7 @@ TEST(LayerAnimatorTest, PreemptEnqueueNewAnimation) { |
// animation started. |
TEST(LayerAnimatorTest, PreemptyByReplacingQueuedAnimations) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -992,7 +1001,7 @@ TEST(LayerAnimatorTest, PreemptyByReplacingQueuedAnimations) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
animator->StartAnimation( |
new LayerAnimationSequence( |
@@ -1009,17 +1018,17 @@ TEST(LayerAnimatorTest, PreemptyByReplacingQueuedAnimations) { |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_FALSE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
@@ -1104,6 +1113,7 @@ TEST(LayerAnimatorTest, MultiPreemptBySettingNewTarget) { |
// Preempt by animating to new target. |
TEST(LayerAnimatorTest, MultiPreemptByImmediatelyAnimatingToNewTarget) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -1134,7 +1144,7 @@ TEST(LayerAnimatorTest, MultiPreemptByImmediatelyAnimatingToNewTarget) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
animator->StartTogether( |
CreateMultiSequence( |
@@ -1154,7 +1164,7 @@ TEST(LayerAnimatorTest, MultiPreemptByImmediatelyAnimatingToNewTarget) { |
EXPECT_TRUE(animator->is_animating()); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), |
@@ -1162,7 +1172,7 @@ TEST(LayerAnimatorTest, MultiPreemptByImmediatelyAnimatingToNewTarget) { |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), |
0.5 * (start_brightness + middle_brightness)); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
EXPECT_FALSE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
@@ -1174,7 +1184,7 @@ TEST(LayerAnimatorTest, MultiPreemptThreadedByImmediatelyAnimatingToNewTarget) { |
double epsilon = 0.00001; |
LayerAnimatorTestController test_controller( |
LayerAnimator::CreateDefaultAnimator()); |
- LayerAnimator* animator = test_controller.animator(); |
+ AnimationContainerElement* element = test_controller.animator(); |
test_controller.animator()->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
test_controller.animator()->SetDelegate(&delegate); |
@@ -1213,7 +1223,7 @@ TEST(LayerAnimatorTest, MultiPreemptThreadedByImmediatelyAnimatingToNewTarget) { |
cc::Animation::Opacity, |
effective_start)); |
- animator->Step(effective_start + delta / 2); |
+ element->Step(effective_start + delta/2); |
test_controller.animator()->StartTogether( |
CreateMultiSequence( |
@@ -1243,7 +1253,7 @@ TEST(LayerAnimatorTest, MultiPreemptThreadedByImmediatelyAnimatingToNewTarget) { |
cc::Animation::Opacity, |
second_effective_start)); |
- animator->Step(second_effective_start + delta / 2); |
+ element->Step(second_effective_start + delta/2); |
EXPECT_TRUE(test_controller.animator()->is_animating()); |
EXPECT_NEAR( |
@@ -1255,7 +1265,7 @@ TEST(LayerAnimatorTest, MultiPreemptThreadedByImmediatelyAnimatingToNewTarget) { |
0.5 * (start_brightness + middle_brightness), |
epsilon); |
- animator->Step(second_effective_start + delta); |
+ element->Step(second_effective_start + delta); |
EXPECT_FALSE(test_controller.animator()->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
@@ -1265,6 +1275,7 @@ TEST(LayerAnimatorTest, MultiPreemptThreadedByImmediatelyAnimatingToNewTarget) { |
// Preempt by enqueuing the new animation. |
TEST(LayerAnimatorTest, MultiPreemptEnqueueNewAnimation) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -1293,7 +1304,7 @@ TEST(LayerAnimatorTest, MultiPreemptEnqueueNewAnimation) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
animator->StartTogether( |
CreateMultiSequence( |
@@ -1307,19 +1318,19 @@ TEST(LayerAnimatorTest, MultiPreemptEnqueueNewAnimation) { |
EXPECT_TRUE(animator->is_animating()); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), target_grayscale); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), middle_grayscale); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_FALSE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
@@ -1331,6 +1342,7 @@ TEST(LayerAnimatorTest, MultiPreemptEnqueueNewAnimation) { |
// animation started. |
TEST(LayerAnimatorTest, MultiPreemptByReplacingQueuedAnimations) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -1359,7 +1371,7 @@ TEST(LayerAnimatorTest, MultiPreemptByReplacingQueuedAnimations) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
animator->StartTogether( |
CreateMultiSequence( |
@@ -1380,19 +1392,19 @@ TEST(LayerAnimatorTest, MultiPreemptByReplacingQueuedAnimations) { |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), middle_grayscale); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), target_grayscale); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), middle_grayscale); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_FALSE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
@@ -1402,6 +1414,7 @@ TEST(LayerAnimatorTest, MultiPreemptByReplacingQueuedAnimations) { |
// Test that non-threaded cyclic sequences continue to animate. |
TEST(LayerAnimatorTest, CyclicSequences) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -1427,29 +1440,29 @@ TEST(LayerAnimatorTest, CyclicSequences) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(3000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(3000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
// Skip ahead by a lot. |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000000000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000000000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
// Skip ahead by a lot. |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000001000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000001000)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
@@ -1463,7 +1476,7 @@ TEST(LayerAnimatorTest, CyclicSequences) { |
TEST(LayerAnimatorTest, ThreadedCyclicSequences) { |
LayerAnimatorTestController test_controller( |
LayerAnimator::CreateDefaultAnimator()); |
- LayerAnimator* animator = test_controller.animator(); |
+ AnimationContainerElement* element = test_controller.animator(); |
test_controller.animator()->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
test_controller.animator()->SetDelegate(&delegate); |
@@ -1497,7 +1510,7 @@ TEST(LayerAnimatorTest, ThreadedCyclicSequences) { |
cc::Animation::Opacity, |
effective_start)); |
- animator->Step(effective_start + delta); |
+ element->Step(effective_start + delta); |
EXPECT_TRUE(test_controller.animator()->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
@@ -1510,7 +1523,7 @@ TEST(LayerAnimatorTest, ThreadedCyclicSequences) { |
cc::Animation::Opacity, |
second_effective_start)); |
- animator->Step(second_effective_start + delta); |
+ element->Step(second_effective_start + delta); |
EXPECT_TRUE(test_controller.animator()->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
@@ -1524,7 +1537,7 @@ TEST(LayerAnimatorTest, ThreadedCyclicSequences) { |
cc::Animation::Opacity, |
third_effective_start)); |
- animator->Step(third_effective_start + delta); |
+ element->Step(third_effective_start + delta); |
EXPECT_TRUE(test_controller.animator()->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
@@ -1538,7 +1551,7 @@ TEST(LayerAnimatorTest, ThreadedCyclicSequences) { |
fourth_effective_start)); |
// Skip ahead by a lot. |
- animator->Step(fourth_effective_start + 1000 * delta); |
+ element->Step(fourth_effective_start + 1000 * delta); |
EXPECT_TRUE(test_controller.animator()->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
@@ -1553,7 +1566,7 @@ TEST(LayerAnimatorTest, ThreadedCyclicSequences) { |
fifth_effective_start)); |
// Skip ahead by a lot. |
- animator->Step(fifth_effective_start + 999 * delta); |
+ element->Step(fifth_effective_start + 999 * delta); |
EXPECT_TRUE(test_controller.animator()->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
@@ -1566,6 +1579,7 @@ TEST(LayerAnimatorTest, ThreadedCyclicSequences) { |
TEST(LayerAnimatorTest, AddObserverExplicit) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationObserver observer; |
TestLayerAnimationDelegate delegate; |
@@ -1588,7 +1602,7 @@ TEST(LayerAnimatorTest, AddObserverExplicit) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_EQ(observer.last_ended_sequence(), sequence); |
@@ -1607,6 +1621,7 @@ TEST(LayerAnimatorTest, AddObserverExplicit) { |
// when the object goes out of scope. |
TEST(LayerAnimatorTest, ImplicitAnimationObservers) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestImplicitAnimationObserver observer(false); |
TestLayerAnimationDelegate delegate; |
@@ -1623,7 +1638,7 @@ TEST(LayerAnimatorTest, ImplicitAnimationObservers) { |
EXPECT_FALSE(observer.animations_completed()); |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(observer.animations_completed()); |
EXPECT_TRUE(observer.WasAnimationCompletedForProperty( |
LayerAnimationElement::BRIGHTNESS)); |
@@ -1665,6 +1680,7 @@ TEST(LayerAnimatorTest, AnimatorKeptAliveBySettings) { |
TestLayerAnimator* animator = new TestLayerAnimator(); |
LayerAnimatorDestructionObserver destruction_observer; |
animator->SetDestructionObserver(&destruction_observer); |
+ AnimationContainerElement* element = animator; |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -1674,7 +1690,7 @@ TEST(LayerAnimatorTest, AnimatorKeptAliveBySettings) { |
ScopedLayerAnimationSettings settings(animator); |
base::TimeTicks now = gfx::FrameTime::Now(); |
animator->SetBrightness(0.5); |
- animator->Step(now + base::TimeDelta::FromSeconds(1)); |
+ element->Step(now + base::TimeDelta::FromSeconds(1)); |
EXPECT_FALSE(destruction_observer.IsAnimatorDeleted()); |
} |
// ScopedLayerAnimationSettings was destroyed, so Animator should be deleted. |
@@ -1754,6 +1770,7 @@ TEST(LayerAnimatorTest, AbortedAnimationStatusInImplicitObservers) { |
TEST(LayerAnimatorTest, RemoveObserverShouldRemoveFromSequences) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationObserver observer; |
TestLayerAnimationObserver removed_observer; |
@@ -1780,7 +1797,7 @@ TEST(LayerAnimatorTest, RemoveObserverShouldRemoveFromSequences) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_EQ(observer.last_ended_sequence(), sequence); |
EXPECT_TRUE(!removed_observer.last_ended_sequence()); |
@@ -1816,6 +1833,7 @@ TEST(LayerAnimatorTest, ObserverReleasedBeforeAnimationSequenceEnds) { |
TEST(LayerAnimatorTest, ObserverAttachedAfterAnimationStarted) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestImplicitAnimationObserver observer(false); |
@@ -1833,14 +1851,14 @@ TEST(LayerAnimatorTest, ObserverAttachedAfterAnimationStarted) { |
animator->StartAnimation(sequence); |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
setter.AddObserver(&observer); |
// Start observing an in-flight animation. |
sequence->AddObserver(&observer); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
} |
EXPECT_TRUE(observer.animations_completed()); |
@@ -1850,6 +1868,7 @@ TEST(LayerAnimatorTest, ObserverAttachedAfterAnimationStarted) { |
TEST(LayerAnimatorTest, ObserverDetachedBeforeAnimationFinished) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestImplicitAnimationObserver observer(false); |
@@ -1867,7 +1886,7 @@ TEST(LayerAnimatorTest, ObserverDetachedBeforeAnimationFinished) { |
animator->StartAnimation(sequence); |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
} |
EXPECT_FALSE(observer.animations_completed()); |
@@ -1893,6 +1912,7 @@ TEST(LayerAnimatorTest, ObserverDeletesAnimationsOnEnd) { |
ScopedAnimationDurationScaleMode normal_duration_mode( |
ScopedAnimationDurationScaleMode::NORMAL_DURATION); |
scoped_refptr<LayerAnimator> animator(new TestLayerAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -1926,7 +1946,7 @@ TEST(LayerAnimatorTest, ObserverDeletesAnimationsOnEnd) { |
ASSERT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS)); |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + halfway_delta); |
+ element->Step(start_time + halfway_delta); |
// Completing the brightness animation should have stopped the bounds |
// animation. |
@@ -1962,6 +1982,7 @@ TEST(LayerAnimatorTest, CallbackDeletesAnimationInProgress) { |
ScopedAnimationDurationScaleMode normal_duration_mode( |
ScopedAnimationDurationScaleMode::NORMAL_DURATION); |
scoped_refptr<LayerAnimator> animator(new TestLayerAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDeletingDelegate delegate(animator.get(), 30); |
animator->SetDelegate(&delegate); |
@@ -1982,14 +2003,14 @@ TEST(LayerAnimatorTest, CallbackDeletesAnimationInProgress) { |
ASSERT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS)); |
base::TimeTicks start_time = animator->last_step_time(); |
- ASSERT_NO_FATAL_FAILURE(animator->Step(start_time + bounds_delta1)); |
+ ASSERT_NO_FATAL_FAILURE(element->Step(start_time + bounds_delta1)); |
ASSERT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS)); |
// The next step should change the animated bounds past the threshold and |
// cause the animaton to stop. |
- ASSERT_NO_FATAL_FAILURE(animator->Step(start_time + bounds_delta2)); |
+ ASSERT_NO_FATAL_FAILURE(element->Step(start_time + bounds_delta2)); |
ASSERT_FALSE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS)); |
- ASSERT_NO_FATAL_FAILURE(animator->Step(start_time + final_delta)); |
+ ASSERT_NO_FATAL_FAILURE(element->Step(start_time + final_delta)); |
// Completing the animation should have stopped the bounds |
// animation. |
@@ -2179,6 +2200,7 @@ TEST(LayerAnimatorTest, GetTargetGrayscale) { |
// Verifies color property is modified appropriately. |
TEST(LayerAnimatorTest, Color) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = animator.get(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -2201,13 +2223,13 @@ TEST(LayerAnimatorTest, Color) { |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
EXPECT_TRUE(animator->is_animating()); |
EXPECT_EQ(ColorToString(middle_color), |
ColorToString(delegate.GetColorForAnimation())); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_FALSE(animator->is_animating()); |
EXPECT_EQ(ColorToString(target_color), |
@@ -2315,6 +2337,7 @@ TEST(LayerAnimatorTest, ObserverDeletesAnimatorAfterFinishingAnimation) { |
observer->set_delete_on_animation_ended(true); |
observer->set_delete_on_animation_aborted(true); |
LayerAnimator* animator = observer->animator(); |
+ AnimationContainerElement* element = observer->animator(); |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
@@ -2337,7 +2360,7 @@ TEST(LayerAnimatorTest, ObserverDeletesAnimatorAfterFinishingAnimation) { |
animator->StartAnimation(bounds_sequence); |
base::TimeTicks start_time = animator->last_step_time(); |
- animator->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
EXPECT_TRUE(observer_was_deleted); |
} |
@@ -2502,122 +2525,4 @@ TEST(LayerAnimatorTest, TestScopedCounterAnimation) { |
} |
-class CollectionLayerAnimationDelegate : public TestLayerAnimationDelegate { |
- public: |
- CollectionLayerAnimationDelegate() : collection(NULL) {} |
- virtual ~CollectionLayerAnimationDelegate() {} |
- |
- // LayerAnimationDelegate: |
- virtual LayerAnimatorCollection* GetLayerAnimatorCollection() OVERRIDE { |
- return &collection; |
- } |
- |
- private: |
- LayerAnimatorCollection collection; |
-}; |
- |
-TEST(LayerAnimatorTest, LayerAnimatorCollectionTickTime) { |
- Layer layer; |
- LayerAnimator* animator = layer.GetAnimator(); |
- CollectionLayerAnimationDelegate delegate; |
- animator->SetDelegate(&delegate); |
- |
- LayerAnimatorCollection* collection = delegate.GetLayerAnimatorCollection(); |
- base::TimeTicks null; |
- collection->Progress(null); |
- EXPECT_TRUE(collection->last_tick_time().is_null()); |
- |
- // Adding an animator to the collection should update the last tick time. |
- collection->StartAnimator(layer.GetAnimator()); |
- EXPECT_TRUE(collection->HasActiveAnimators()); |
- EXPECT_FALSE(collection->last_tick_time().is_null()); |
- |
- collection->StopAnimator(layer.GetAnimator()); |
- EXPECT_FALSE(collection->HasActiveAnimators()); |
-} |
- |
-TEST(LayerAnimatorTest, AnimatorStartedCorrectly) { |
- Layer layer; |
- LayerAnimatorTestController test_controller(layer.GetAnimator()); |
- LayerAnimator* animator = test_controller.animator(); |
- ASSERT_FALSE(animator->is_started_); |
- |
- TestLayerAnimationDelegate test_delegate; |
- animator->SetDelegate(&test_delegate); |
- double target_opacity = 1.0; |
- base::TimeDelta time_delta = base::TimeDelta::FromSeconds(1); |
- animator->ScheduleAnimation(new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, time_delta))); |
- EXPECT_FALSE(animator->is_started_); |
- |
- CollectionLayerAnimationDelegate collection_delegate; |
- animator->SetDelegate(&collection_delegate); |
- animator->UpdateAnimationState(); |
- EXPECT_TRUE(animator->is_started_); |
- animator->SetDelegate(NULL); |
-} |
- |
-TEST(LayerAnimatorTest, AnimatorRemovedFromCollectionWhenLayerIsDestroyed) { |
- scoped_ptr<Layer> layer(new Layer(LAYER_TEXTURED)); |
- LayerAnimatorTestController test_controller(layer->GetAnimator()); |
- scoped_refptr<LayerAnimator> animator = test_controller.animator(); |
- CollectionLayerAnimationDelegate collection_delegate; |
- animator->SetDelegate(&collection_delegate); |
- |
- double target_opacity = 1.0; |
- base::TimeDelta time_delta = base::TimeDelta::FromSeconds(1); |
- animator->ScheduleAnimation(new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, time_delta))); |
- |
- EXPECT_TRUE( |
- collection_delegate.GetLayerAnimatorCollection()->HasActiveAnimators()); |
- |
- layer.reset(); |
- EXPECT_EQ(NULL, animator->delegate()); |
- EXPECT_FALSE( |
- collection_delegate.GetLayerAnimatorCollection()->HasActiveAnimators()); |
-} |
- |
-TEST(LayerAnimatorTest, LayerMovedBetweenCompositorsDuringAnimation) { |
- bool enable_pixel_output = false; |
- ui::ContextFactory* context_factory = |
- InitializeContextFactoryForTests(enable_pixel_output); |
- const gfx::Rect bounds(10, 10, 100, 100); |
- scoped_ptr<TestCompositorHost> host_1( |
- TestCompositorHost::Create(bounds, context_factory)); |
- scoped_ptr<TestCompositorHost> host_2( |
- TestCompositorHost::Create(bounds, context_factory)); |
- host_1->Show(); |
- host_2->Show(); |
- |
- Compositor* compositor_1 = host_1->GetCompositor(); |
- Layer root_1; |
- compositor_1->SetRootLayer(&root_1); |
- |
- Compositor* compositor_2 = host_2->GetCompositor(); |
- Layer root_2; |
- compositor_2->SetRootLayer(&root_2); |
- |
- // Verify that neither compositor has active animators. |
- EXPECT_FALSE(compositor_1->layer_animator_collection()->HasActiveAnimators()); |
- EXPECT_FALSE(compositor_2->layer_animator_collection()->HasActiveAnimators()); |
- |
- Layer layer; |
- root_1.Add(&layer); |
- LayerAnimator* animator = layer.GetAnimator(); |
- double target_opacity = 1.0; |
- base::TimeDelta time_delta = base::TimeDelta::FromSeconds(1); |
- animator->ScheduleAnimation(new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, time_delta))); |
- EXPECT_TRUE(compositor_1->layer_animator_collection()->HasActiveAnimators()); |
- EXPECT_FALSE(compositor_2->layer_animator_collection()->HasActiveAnimators()); |
- |
- root_2.Add(&layer); |
- EXPECT_FALSE(compositor_1->layer_animator_collection()->HasActiveAnimators()); |
- EXPECT_TRUE(compositor_2->layer_animator_collection()->HasActiveAnimators()); |
- host_2.reset(); |
- host_1.reset(); |
- TerminateContextFactoryForTests(); |
-} |
- |
} // namespace ui |