Index: ui/compositor/layer_animator_unittest.cc |
diff --git a/ui/compositor/layer_animator_unittest.cc b/ui/compositor/layer_animator_unittest.cc |
index a94d8d470097b51464525efeef298f2df86fff91..e13e42e05cfe369ce8305ee288f64d1462ac184d 100644 |
--- a/ui/compositor/layer_animator_unittest.cc |
+++ b/ui/compositor/layer_animator_unittest.cc |
@@ -150,10 +150,10 @@ TEST(LayerAnimatorTest, ImplicitAnimation) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
base::TimeTicks now = base::TimeTicks::Now(); |
- animator->SetOpacity(0.5); |
+ animator->SetBrightness(0.5); |
EXPECT_TRUE(animator->is_animating()); |
element->Step(now + base::TimeDelta::FromSeconds(1)); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), 0.5); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), 0.5); |
} |
// Checks that if the animator is a default animator, that implicit animations |
@@ -163,9 +163,9 @@ TEST(LayerAnimatorTest, NoImplicitAnimation) { |
animator->set_disable_timer_for_test(true); |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- animator->SetOpacity(0.5); |
+ animator->SetBrightness(0.5); |
EXPECT_FALSE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), 0.5); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), 0.5); |
} |
// Checks that StopAnimatingProperty stops animation for that property, and also |
@@ -230,8 +230,8 @@ TEST(LayerAnimatorTest, AbortAllAnimations) { |
CheckApproximatelyEqual(initial_bounds, delegate.GetBoundsForAnimation()); |
} |
-// Schedule an animation that can run immediately. This is the trivial case and |
-// should result in the animation being started immediately. |
+// Schedule a non-threaded animation that can run immediately. This is the |
+// trivial case and should result in the animation being started immediately. |
TEST(LayerAnimatorTest, ScheduleAnimationThatCanRunImmediately) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
AnimationContainerElement* element = animator.get(); |
@@ -239,36 +239,85 @@ TEST(LayerAnimatorTest, ScheduleAnimationThatCanRunImmediately) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- double start_opacity(0.0); |
- double middle_opacity(0.5); |
- double target_opacity(1.0); |
+ double start_brightness(0.0); |
+ double middle_brightness(0.5); |
+ double target_brightness(1.0); |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetBrightnessFromAnimation(start_brightness); |
animator->ScheduleAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); |
+ LayerAnimationElement::CreateBrightnessElement(target_brightness, |
+ delta))); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
base::TimeTicks start_time = animator->last_step_time(); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_FALSE(animator->is_animating()); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
+} |
+ |
+// Schedule a threaded animation that can run immediately. |
+TEST(LayerAnimatorTest, ScheduleThreadedAnimationThatCanRunImmediately) { |
+ LayerAnimator::TestController test_controller( |
+ LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = test_controller.animator(); |
+ test_controller.animator()->set_disable_timer_for_test(true); |
+ TestLayerAnimationDelegate delegate; |
+ test_controller.animator()->SetDelegate(&delegate); |
+ |
+ double start_opacity(0.0); |
+ double target_opacity(1.0); |
+ |
+ base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
+ |
+ delegate.SetOpacityFromAnimation(start_opacity); |
+ |
+ test_controller.animator()->ScheduleAnimation( |
+ new LayerAnimationSequence( |
+ LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); |
+ |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ |
+ base::TimeTicks start_time = test_controller.animator()->last_step_time(); |
+ base::TimeTicks effective_start = start_time + delta; |
+ |
+ test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent( |
+ cc::AnimationEvent::Started, |
+ 0, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ animation_group_id(), |
+ cc::Animation::Opacity, |
+ (effective_start - base::TimeTicks()).InSecondsF())); |
+ |
+ element->Step(effective_start + delta/2); |
+ |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ EXPECT_FLOAT_EQ( |
+ 0.5, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ last_progressed_fraction()); |
+ |
+ element->Step(effective_start + delta); |
+ |
+ EXPECT_FALSE(test_controller.animator()->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
} |
-// Schedule two animations on separate properties. Both animations should |
-// start immediately and should progress in lock step. |
+// Schedule two non-threaded animations on separate properties. Both animations |
+// should start immediately and should progress in lock step. |
TEST(LayerAnimatorTest, ScheduleTwoAnimationsThatCanRunImmediately) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
AnimationContainerElement* element = animator.get(); |
@@ -276,9 +325,9 @@ TEST(LayerAnimatorTest, ScheduleTwoAnimationsThatCanRunImmediately) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- double start_opacity(0.0); |
- double middle_opacity(0.5); |
- double target_opacity(1.0); |
+ double start_brightness(0.0); |
+ double middle_brightness(0.5); |
+ double target_brightness(1.0); |
gfx::Rect start_bounds, target_bounds, middle_bounds; |
start_bounds = target_bounds = middle_bounds = gfx::Rect(0, 0, 50, 50); |
@@ -287,19 +336,20 @@ TEST(LayerAnimatorTest, ScheduleTwoAnimationsThatCanRunImmediately) { |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetBrightnessFromAnimation(start_brightness); |
delegate.SetBoundsFromAnimation(start_bounds); |
animator->ScheduleAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); |
+ LayerAnimationElement::CreateBrightnessElement(target_brightness, |
+ delta))); |
animator->ScheduleAnimation( |
new LayerAnimationSequence( |
LayerAnimationElement::CreateBoundsElement(target_bounds, delta))); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds); |
base::TimeTicks start_time = animator->last_step_time(); |
@@ -307,12 +357,77 @@ TEST(LayerAnimatorTest, ScheduleTwoAnimationsThatCanRunImmediately) { |
element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), middle_bounds); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_FALSE(animator->is_animating()); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
+ CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds); |
+} |
+ |
+// Schedule a threaded and a non-threaded animation on separate properties. Both |
+// animations should progress in lock step. |
+TEST(LayerAnimatorTest, ScheduleThreadedAndNonThreadedAnimations) { |
+ LayerAnimator::TestController test_controller( |
+ LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = test_controller.animator(); |
+ test_controller.animator()->set_disable_timer_for_test(true); |
+ TestLayerAnimationDelegate delegate; |
+ test_controller.animator()->SetDelegate(&delegate); |
+ |
+ double start_opacity(0.0); |
+ double target_opacity(1.0); |
+ |
+ gfx::Rect start_bounds, target_bounds, middle_bounds; |
+ start_bounds = target_bounds = middle_bounds = gfx::Rect(0, 0, 50, 50); |
+ start_bounds.set_x(-90); |
+ target_bounds.set_x(90); |
+ |
+ base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
+ |
+ delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetBoundsFromAnimation(start_bounds); |
+ |
+ std::vector<LayerAnimationSequence*> animations; |
+ animations.push_back( |
+ new LayerAnimationSequence( |
+ LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); |
+ |
+ animations.push_back( |
+ new LayerAnimationSequence( |
+ LayerAnimationElement::CreateBoundsElement(target_bounds, delta))); |
+ |
+ test_controller.animator()->ScheduleTogether(animations); |
+ |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds); |
+ |
+ base::TimeTicks start_time = test_controller.animator()->last_step_time(); |
+ base::TimeTicks effective_start = start_time + delta; |
+ |
+ test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent( |
+ cc::AnimationEvent::Started, |
+ 0, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ animation_group_id(), |
+ cc::Animation::Opacity, |
+ (effective_start - base::TimeTicks()).InSecondsF())); |
+ |
+ element->Step(effective_start + delta/2); |
+ |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ EXPECT_FLOAT_EQ( |
+ 0.5, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ last_progressed_fraction()); |
+ CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), middle_bounds); |
+ |
+ element->Step(effective_start + delta); |
+ |
+ EXPECT_FALSE(test_controller.animator()->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds); |
} |
@@ -326,49 +441,51 @@ TEST(LayerAnimatorTest, ScheduleTwoAnimationsOnSameProperty) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- double start_opacity(0.0); |
- double middle_opacity(0.5); |
- double target_opacity(1.0); |
+ double start_brightness(0.0); |
+ double middle_brightness(0.5); |
+ double target_brightness(1.0); |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetBrightnessFromAnimation(start_brightness); |
animator->ScheduleAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); |
+ LayerAnimationElement::CreateBrightnessElement(target_brightness, |
+ delta))); |
animator->ScheduleAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(start_opacity, delta))); |
+ LayerAnimationElement::CreateBrightnessElement(start_brightness, |
+ delta))); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
base::TimeTicks start_time = animator->last_step_time(); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_FALSE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
} |
-// Schedule [{o}, {o,b}, {b}] and ensure that {b} doesn't run right away. That |
+// Schedule [{g}, {g,b}, {b}] and ensure that {b} doesn't run right away. That |
// is, ensure that all animations targetting a particular property are run in |
// order. |
TEST(LayerAnimatorTest, ScheduleBlockedAnimation) { |
@@ -378,9 +495,9 @@ TEST(LayerAnimatorTest, ScheduleBlockedAnimation) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- double start_opacity(0.0); |
- double middle_opacity(0.5); |
- double target_opacity(1.0); |
+ double start_grayscale(0.0); |
+ double middle_grayscale(0.5); |
+ double target_grayscale(1.0); |
gfx::Rect start_bounds, target_bounds, middle_bounds; |
start_bounds = target_bounds = middle_bounds = gfx::Rect(0, 0, 50, 50); |
@@ -389,28 +506,30 @@ TEST(LayerAnimatorTest, ScheduleBlockedAnimation) { |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetGrayscaleFromAnimation(start_grayscale); |
delegate.SetBoundsFromAnimation(start_bounds); |
animator->ScheduleAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); |
+ LayerAnimationElement::CreateGrayscaleElement(target_grayscale, |
+ delta))); |
- scoped_ptr<LayerAnimationSequence> bounds_and_opacity( |
+ scoped_ptr<LayerAnimationSequence> bounds_and_grayscale( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(start_opacity, delta))); |
+ LayerAnimationElement::CreateGrayscaleElement(start_grayscale, |
+ delta))); |
- bounds_and_opacity->AddElement( |
+ bounds_and_grayscale->AddElement( |
LayerAnimationElement::CreateBoundsElement(target_bounds, delta)); |
- animator->ScheduleAnimation(bounds_and_opacity.release()); |
+ animator->ScheduleAnimation(bounds_and_grayscale.release()); |
animator->ScheduleAnimation( |
new LayerAnimationSequence( |
LayerAnimationElement::CreateBoundsElement(start_bounds, delta))); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds); |
base::TimeTicks start_time = animator->last_step_time(); |
@@ -418,37 +537,37 @@ TEST(LayerAnimatorTest, ScheduleBlockedAnimation) { |
element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), middle_grayscale); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), target_grayscale); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(3000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(4000)); |
EXPECT_FALSE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds); |
} |
-// Schedule {o} and then schedule {o} and {b} together. In this case, since |
+// Schedule {g} and then schedule {g} and {b} together. In this case, since |
// ScheduleTogether is being used, the bounds animation should not start until |
-// the second opacity animation starts. |
+// the second grayscale animation starts. |
TEST(LayerAnimatorTest, ScheduleTogether) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
AnimationContainerElement* element = animator.get(); |
@@ -456,8 +575,8 @@ TEST(LayerAnimatorTest, ScheduleTogether) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- double start_opacity(0.0); |
- double target_opacity(1.0); |
+ double start_grayscale(0.0); |
+ double target_grayscale(1.0); |
gfx::Rect start_bounds, target_bounds, middle_bounds; |
start_bounds = target_bounds = gfx::Rect(0, 0, 50, 50); |
@@ -466,23 +585,24 @@ TEST(LayerAnimatorTest, ScheduleTogether) { |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetGrayscaleFromAnimation(start_grayscale); |
delegate.SetBoundsFromAnimation(start_bounds); |
animator->ScheduleAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); |
+ LayerAnimationElement::CreateGrayscaleElement(target_grayscale, |
+ delta))); |
std::vector<LayerAnimationSequence*> sequences; |
sequences.push_back(new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(start_opacity, delta))); |
+ LayerAnimationElement::CreateGrayscaleElement(start_grayscale, delta))); |
sequences.push_back(new LayerAnimationSequence( |
LayerAnimationElement::CreateBoundsElement(target_bounds, delta))); |
animator->ScheduleTogether(sequences); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds); |
base::TimeTicks start_time = animator->last_step_time(); |
@@ -490,18 +610,18 @@ TEST(LayerAnimatorTest, ScheduleTogether) { |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), target_grayscale); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_FALSE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds); |
} |
-// Start animation (that can run immediately). This is the trivial case (see |
-// the trival case for ScheduleAnimation). |
+// Start non-threaded animation (that can run immediately). This is the trivial |
+// case (see the trival case for ScheduleAnimation). |
TEST(LayerAnimatorTest, StartAnimationThatCanRunImmediately) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
AnimationContainerElement* element = animator.get(); |
@@ -509,31 +629,79 @@ TEST(LayerAnimatorTest, StartAnimationThatCanRunImmediately) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- double start_opacity(0.0); |
- double middle_opacity(0.5); |
- double target_opacity(1.0); |
+ double start_brightness(0.0); |
+ double middle_brightness(0.5); |
+ double target_brightness(1.0); |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetBrightnessFromAnimation(start_brightness); |
animator->StartAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); |
+ LayerAnimationElement::CreateBrightnessElement(target_brightness, |
+ delta))); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
base::TimeTicks start_time = animator->last_step_time(); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(500)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_FALSE(animator->is_animating()); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
+} |
+ |
+// Start threaded animation (that can run immediately). |
+TEST(LayerAnimatorTest, StartThreadedAnimationThatCanRunImmediately) { |
+ LayerAnimator::TestController test_controller( |
+ LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = test_controller.animator(); |
+ test_controller.animator()->set_disable_timer_for_test(true); |
+ TestLayerAnimationDelegate delegate; |
+ test_controller.animator()->SetDelegate(&delegate); |
+ |
+ double start_opacity(0.0); |
+ double target_opacity(1.0); |
+ |
+ base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
+ |
+ delegate.SetOpacityFromAnimation(start_opacity); |
+ |
+ test_controller.animator()->StartAnimation( |
+ new LayerAnimationSequence( |
+ LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); |
+ |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ |
+ base::TimeTicks start_time = test_controller.animator()->last_step_time(); |
+ base::TimeTicks effective_start = start_time + delta; |
+ |
+ test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent( |
+ cc::AnimationEvent::Started, |
+ 0, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ animation_group_id(), |
+ cc::Animation::Opacity, |
+ (effective_start - base::TimeTicks()).InSecondsF())); |
+ |
+ element->Step(effective_start + delta/2); |
+ |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ EXPECT_FLOAT_EQ( |
+ 0.5, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ last_progressed_fraction()); |
+ |
+ element->Step(effective_start + delta); |
+ EXPECT_FALSE(test_controller.animator()->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
} |
@@ -565,7 +733,7 @@ TEST(LayerAnimatorTest, PreemptBySettingNewTarget) { |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
} |
-// Preempt by animating to new target. |
+// Preempt by animating to new target, with a non-threaded animation. |
TEST(LayerAnimatorTest, PreemptByImmediatelyAnimatingToNewTarget) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
AnimationContainerElement* element = animator.get(); |
@@ -573,20 +741,21 @@ TEST(LayerAnimatorTest, PreemptByImmediatelyAnimatingToNewTarget) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- double start_opacity(0.0); |
- double middle_opacity(0.5); |
- double target_opacity(1.0); |
+ double start_brightness(0.0); |
+ double middle_brightness(0.5); |
+ double target_brightness(1.0); |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetBrightnessFromAnimation(start_brightness); |
animator->set_preemption_strategy( |
LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
animator->StartAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); |
+ LayerAnimationElement::CreateBrightnessElement(target_brightness, |
+ delta))); |
base::TimeTicks start_time = animator->last_step_time(); |
@@ -594,26 +763,102 @@ TEST(LayerAnimatorTest, PreemptByImmediatelyAnimatingToNewTarget) { |
animator->StartAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(start_opacity, delta))); |
+ LayerAnimationElement::CreateBrightnessElement(start_brightness, |
+ delta))); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
animator->StartAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(start_opacity, delta))); |
+ LayerAnimationElement::CreateBrightnessElement(start_brightness, |
+ delta))); |
EXPECT_TRUE(animator->is_animating()); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), |
- 0.5 * (start_opacity + middle_opacity)); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), |
+ 0.5 * (start_brightness + middle_brightness)); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
EXPECT_FALSE(animator->is_animating()); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
+} |
+ |
+// Preempt by animating to new target, with a threaded animation. |
+TEST(LayerAnimatorTest, PreemptThreadedByImmediatelyAnimatingToNewTarget) { |
+ LayerAnimator::TestController test_controller( |
+ LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = test_controller.animator(); |
+ test_controller.animator()->set_disable_timer_for_test(true); |
+ TestLayerAnimationDelegate delegate; |
+ test_controller.animator()->SetDelegate(&delegate); |
+ |
+ double start_opacity(0.0); |
+ double middle_opacity(0.5); |
+ double target_opacity(1.0); |
+ |
+ base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
+ |
+ delegate.SetOpacityFromAnimation(start_opacity); |
+ |
+ test_controller.animator()->set_preemption_strategy( |
+ LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
+ |
+ test_controller.animator()->StartAnimation( |
+ new LayerAnimationSequence( |
+ LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); |
+ |
+ base::TimeTicks start_time = test_controller.animator()->last_step_time(); |
+ base::TimeTicks effective_start = start_time + delta; |
+ |
+ test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent( |
+ cc::AnimationEvent::Started, |
+ 0, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ animation_group_id(), |
+ cc::Animation::Opacity, |
+ (effective_start - base::TimeTicks()).InSecondsF())); |
+ |
+ element->Step(effective_start + delta/2); |
+ |
+ test_controller.animator()->StartAnimation( |
+ new LayerAnimationSequence( |
+ LayerAnimationElement::CreateOpacityElement(start_opacity, delta))); |
+ |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ |
+ test_controller.animator()->StartAnimation( |
+ new LayerAnimationSequence( |
+ LayerAnimationElement::CreateOpacityElement(start_opacity, delta))); |
+ |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ |
+ base::TimeTicks second_effective_start = effective_start + delta; |
+ |
+ test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent( |
+ cc::AnimationEvent::Started, |
+ 0, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ animation_group_id(), |
+ cc::Animation::Opacity, |
+ (second_effective_start - base::TimeTicks()).InSecondsF())); |
+ |
+ element->Step(second_effective_start + delta/2); |
+ |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ EXPECT_FLOAT_EQ( |
+ 0.5, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ last_progressed_fraction()); |
+ |
+ element->Step(second_effective_start + delta); |
+ |
+ EXPECT_FALSE(test_controller.animator()->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
} |
@@ -625,19 +870,20 @@ TEST(LayerAnimatorTest, PreemptEnqueueNewAnimation) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- double start_opacity(0.0); |
- double middle_opacity(0.5); |
- double target_opacity(1.0); |
+ double start_brightness(0.0); |
+ double middle_brightness(0.5); |
+ double target_brightness(1.0); |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetBrightnessFromAnimation(start_brightness); |
animator->set_preemption_strategy(LayerAnimator::ENQUEUE_NEW_ANIMATION); |
animator->StartAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); |
+ LayerAnimationElement::CreateBrightnessElement(target_brightness, |
+ delta))); |
base::TimeTicks start_time = animator->last_step_time(); |
@@ -645,27 +891,28 @@ TEST(LayerAnimatorTest, PreemptEnqueueNewAnimation) { |
animator->StartAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(start_opacity, delta))); |
+ LayerAnimationElement::CreateBrightnessElement(start_brightness, |
+ delta))); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
EXPECT_TRUE(animator->is_animating()); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_FALSE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
} |
// Start an animation when there are sequences waiting in the queue. In this |
@@ -678,19 +925,20 @@ TEST(LayerAnimatorTest, PreemptyByReplacingQueuedAnimations) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- double start_opacity(0.0); |
- double middle_opacity(0.5); |
- double target_opacity(1.0); |
+ double start_brightness(0.0); |
+ double middle_brightness(0.5); |
+ double target_brightness(1.0); |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetBrightnessFromAnimation(start_brightness); |
animator->set_preemption_strategy(LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
animator->StartAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); |
+ LayerAnimationElement::CreateBrightnessElement(target_brightness, |
+ delta))); |
base::TimeTicks start_time = animator->last_step_time(); |
@@ -698,31 +946,33 @@ TEST(LayerAnimatorTest, PreemptyByReplacingQueuedAnimations) { |
animator->StartAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(middle_opacity, delta))); |
+ LayerAnimationElement::CreateBrightnessElement(middle_brightness, |
+ delta))); |
// Queue should now have two animations. Starting a third should replace the |
// second. |
animator->StartAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(start_opacity, delta))); |
+ LayerAnimationElement::CreateBrightnessElement(start_brightness, |
+ delta))); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_FALSE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
} |
TEST(LayerAnimatorTest, StartTogetherSetsLastStepTime) { |
@@ -731,14 +981,14 @@ TEST(LayerAnimatorTest, StartTogetherSetsLastStepTime) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- double start_opacity(0.0); |
- double target_opacity(1.0); |
+ double start_grayscale(0.0); |
+ double target_grayscale(1.0); |
double start_brightness(0.1); |
double target_brightness(0.9); |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetGrayscaleFromAnimation(start_grayscale); |
delegate.SetBrightnessFromAnimation(start_brightness); |
animator->set_preemption_strategy( |
@@ -748,7 +998,8 @@ TEST(LayerAnimatorTest, StartTogetherSetsLastStepTime) { |
animator->StartTogether( |
CreateMultiSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta), |
+ LayerAnimationElement::CreateGrayscaleElement(target_grayscale, |
+ delta), |
LayerAnimationElement::CreateBrightnessElement(target_brightness, |
delta) |
)); |
@@ -808,9 +1059,9 @@ TEST(LayerAnimatorTest, MultiPreemptByImmediatelyAnimatingToNewTarget) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- double start_opacity(0.0); |
- double middle_opacity(0.5); |
- double target_opacity(1.0); |
+ double start_grayscale(0.0); |
+ double middle_grayscale(0.5); |
+ double target_grayscale(1.0); |
double start_brightness(0.1); |
double middle_brightness(0.2); |
@@ -818,7 +1069,7 @@ TEST(LayerAnimatorTest, MultiPreemptByImmediatelyAnimatingToNewTarget) { |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetGrayscaleFromAnimation(start_grayscale); |
delegate.SetBrightnessFromAnimation(start_brightness); |
animator->set_preemption_strategy( |
@@ -826,7 +1077,8 @@ TEST(LayerAnimatorTest, MultiPreemptByImmediatelyAnimatingToNewTarget) { |
animator->StartTogether( |
CreateMultiSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta), |
+ LayerAnimationElement::CreateGrayscaleElement(target_grayscale, |
+ delta), |
LayerAnimationElement::CreateBrightnessElement(target_brightness, |
delta) |
)); |
@@ -837,17 +1089,17 @@ TEST(LayerAnimatorTest, MultiPreemptByImmediatelyAnimatingToNewTarget) { |
animator->StartTogether( |
CreateMultiSequence( |
- LayerAnimationElement::CreateOpacityElement(start_opacity, delta), |
+ LayerAnimationElement::CreateGrayscaleElement(start_grayscale, delta), |
LayerAnimationElement::CreateBrightnessElement(start_brightness, |
delta))); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), middle_grayscale); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
animator->StartTogether( |
CreateMultiSequence( |
- LayerAnimationElement::CreateOpacityElement(start_opacity, delta), |
+ LayerAnimationElement::CreateGrayscaleElement(start_grayscale, delta), |
LayerAnimationElement::CreateBrightnessElement(start_brightness, |
delta))); |
@@ -856,14 +1108,104 @@ TEST(LayerAnimatorTest, MultiPreemptByImmediatelyAnimatingToNewTarget) { |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), |
- 0.5 * (start_opacity + middle_opacity)); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), |
+ 0.5 * (start_grayscale + middle_grayscale)); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), |
0.5 * (start_brightness + middle_brightness)); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
EXPECT_FALSE(animator->is_animating()); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
+} |
+ |
+// Preempt a threaded animation by animating to new target. |
+TEST(LayerAnimatorTest, MultiPreemptThreadedByImmediatelyAnimatingToNewTarget) { |
+ LayerAnimator::TestController test_controller( |
+ LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = test_controller.animator(); |
+ test_controller.animator()->set_disable_timer_for_test(true); |
+ TestLayerAnimationDelegate delegate; |
+ test_controller.animator()->SetDelegate(&delegate); |
+ |
+ double start_opacity(0.0); |
+ double middle_opacity(0.5); |
+ double target_opacity(1.0); |
+ |
+ double start_brightness(0.1); |
+ double middle_brightness(0.2); |
+ double target_brightness(0.3); |
+ |
+ base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
+ |
+ delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetBrightnessFromAnimation(start_brightness); |
+ |
+ test_controller.animator()->set_preemption_strategy( |
+ LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
+ |
+ test_controller.animator()->StartTogether( |
+ CreateMultiSequence( |
+ LayerAnimationElement::CreateOpacityElement(target_opacity, delta), |
+ LayerAnimationElement::CreateBrightnessElement(target_brightness, |
+ delta) |
+ )); |
+ |
+ base::TimeTicks start_time = test_controller.animator()->last_step_time(); |
+ base::TimeTicks effective_start = start_time + delta; |
+ |
+ test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent( |
+ cc::AnimationEvent::Started, |
+ 0, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ animation_group_id(), |
+ cc::Animation::Opacity, |
+ (effective_start - base::TimeTicks()).InSecondsF())); |
+ |
+ element->Step(effective_start + delta/2); |
+ |
+ test_controller.animator()->StartTogether( |
+ CreateMultiSequence( |
+ LayerAnimationElement::CreateOpacityElement(start_opacity, delta), |
+ LayerAnimationElement::CreateBrightnessElement(start_brightness, |
+ delta))); |
+ |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
+ |
+ test_controller.animator()->StartTogether( |
+ CreateMultiSequence( |
+ LayerAnimationElement::CreateOpacityElement(start_opacity, delta), |
+ LayerAnimationElement::CreateBrightnessElement(start_brightness, |
+ delta))); |
+ |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ |
+ base::TimeTicks second_effective_start = effective_start + delta; |
+ |
+ test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent( |
+ cc::AnimationEvent::Started, |
+ 0, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ animation_group_id(), |
+ cc::Animation::Opacity, |
+ (second_effective_start - base::TimeTicks()).InSecondsF())); |
+ |
+ element->Step(second_effective_start + delta/2); |
+ |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ EXPECT_FLOAT_EQ( |
+ 0.5, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ last_progressed_fraction()); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), |
+ 0.5 * (start_brightness + middle_brightness)); |
+ |
+ element->Step(second_effective_start + delta); |
+ |
+ EXPECT_FALSE(test_controller.animator()->is_animating()); |
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
} |
@@ -876,9 +1218,9 @@ TEST(LayerAnimatorTest, MultiPreemptEnqueueNewAnimation) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- double start_opacity(0.0); |
- double middle_opacity(0.5); |
- double target_opacity(1.0); |
+ double start_grayscale(0.0); |
+ double middle_grayscale(0.5); |
+ double target_grayscale(1.0); |
double start_brightness(0.1); |
double middle_brightness(0.2); |
@@ -886,14 +1228,15 @@ TEST(LayerAnimatorTest, MultiPreemptEnqueueNewAnimation) { |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetGrayscaleFromAnimation(start_grayscale); |
delegate.SetBrightnessFromAnimation(start_brightness); |
animator->set_preemption_strategy(LayerAnimator::ENQUEUE_NEW_ANIMATION); |
animator->StartTogether( |
CreateMultiSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta), |
+ LayerAnimationElement::CreateGrayscaleElement(target_grayscale, |
+ delta), |
LayerAnimationElement::CreateBrightnessElement(target_brightness, |
delta))); |
@@ -903,12 +1246,12 @@ TEST(LayerAnimatorTest, MultiPreemptEnqueueNewAnimation) { |
animator->StartTogether( |
CreateMultiSequence( |
- LayerAnimationElement::CreateOpacityElement(start_opacity, delta), |
+ LayerAnimationElement::CreateGrayscaleElement(start_grayscale, delta), |
LayerAnimationElement::CreateBrightnessElement(start_brightness, |
delta))); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), middle_grayscale); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
EXPECT_TRUE(animator->is_animating()); |
@@ -916,19 +1259,19 @@ TEST(LayerAnimatorTest, MultiPreemptEnqueueNewAnimation) { |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), target_grayscale); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), middle_grayscale); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_FALSE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
} |
@@ -942,9 +1285,9 @@ TEST(LayerAnimatorTest, MultiPreemptByReplacingQueuedAnimations) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- double start_opacity(0.0); |
- double middle_opacity(0.5); |
- double target_opacity(1.0); |
+ double start_grayscale(0.0); |
+ double middle_grayscale(0.5); |
+ double target_grayscale(1.0); |
double start_brightness(0.1); |
double middle_brightness(0.2); |
@@ -952,14 +1295,15 @@ TEST(LayerAnimatorTest, MultiPreemptByReplacingQueuedAnimations) { |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetGrayscaleFromAnimation(start_grayscale); |
delegate.SetBrightnessFromAnimation(start_brightness); |
animator->set_preemption_strategy(LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
animator->StartTogether( |
CreateMultiSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta), |
+ LayerAnimationElement::CreateGrayscaleElement(target_grayscale, |
+ delta), |
LayerAnimationElement::CreateBrightnessElement(target_brightness, |
delta))); |
@@ -969,7 +1313,8 @@ TEST(LayerAnimatorTest, MultiPreemptByReplacingQueuedAnimations) { |
animator->StartTogether( |
CreateMultiSequence( |
- LayerAnimationElement::CreateOpacityElement(middle_opacity, delta), |
+ LayerAnimationElement::CreateGrayscaleElement(middle_grayscale, |
+ delta), |
LayerAnimationElement::CreateBrightnessElement(middle_brightness, |
delta))); |
@@ -977,34 +1322,34 @@ TEST(LayerAnimatorTest, MultiPreemptByReplacingQueuedAnimations) { |
// second. |
animator->StartTogether( |
CreateMultiSequence( |
- LayerAnimationElement::CreateOpacityElement(start_opacity, delta), |
+ LayerAnimationElement::CreateGrayscaleElement(start_grayscale, delta), |
LayerAnimationElement::CreateBrightnessElement(start_brightness, |
delta))); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), middle_grayscale); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), target_grayscale); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), middle_grayscale); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), middle_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_FALSE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), start_grayscale); |
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
} |
//------------------------------------------------------- |
-// Test that cyclic sequences continue to animate. |
+// Test that non-threaded cyclic sequences continue to animate. |
TEST(LayerAnimatorTest, CyclicSequences) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
AnimationContainerElement* element = animator.get(); |
@@ -1012,19 +1357,20 @@ TEST(LayerAnimatorTest, CyclicSequences) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- double start_opacity(0.0); |
- double target_opacity(1.0); |
+ double start_brightness(0.0); |
+ double target_brightness(1.0); |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetBrightnessFromAnimation(start_brightness); |
scoped_ptr<LayerAnimationSequence> sequence( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); |
+ LayerAnimationElement::CreateBrightnessElement(target_brightness, |
+ delta))); |
sequence->AddElement( |
- LayerAnimationElement::CreateOpacityElement(start_opacity, delta)); |
+ LayerAnimationElement::CreateBrightnessElement(start_brightness, delta)); |
sequence->set_is_cyclic(true); |
@@ -1035,35 +1381,140 @@ TEST(LayerAnimatorTest, CyclicSequences) { |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(3000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
// Skip ahead by a lot. |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000000000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), start_brightness); |
// Skip ahead by a lot. |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000001000)); |
EXPECT_TRUE(animator->is_animating()); |
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), target_brightness); |
- animator->StopAnimatingProperty(LayerAnimationElement::OPACITY); |
+ animator->StopAnimatingProperty(LayerAnimationElement::BRIGHTNESS); |
EXPECT_FALSE(animator->is_animating()); |
} |
+// Test that threaded cyclic sequences continue to animate. |
+TEST(LayerAnimatorTest, ThreadedCyclicSequences) { |
+ LayerAnimator::TestController test_controller( |
+ LayerAnimator::CreateDefaultAnimator()); |
+ AnimationContainerElement* element = test_controller.animator(); |
+ test_controller.animator()->set_disable_timer_for_test(true); |
+ TestLayerAnimationDelegate delegate; |
+ test_controller.animator()->SetDelegate(&delegate); |
+ |
+ double start_opacity(0.0); |
+ double target_opacity(1.0); |
+ |
+ base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
+ |
+ delegate.SetOpacityFromAnimation(start_opacity); |
+ |
+ scoped_ptr<LayerAnimationSequence> sequence( |
+ new LayerAnimationSequence( |
+ LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); |
+ |
+ sequence->AddElement( |
+ LayerAnimationElement::CreateOpacityElement(start_opacity, delta)); |
+ |
+ sequence->set_is_cyclic(true); |
+ |
+ test_controller.animator()->StartAnimation(sequence.release()); |
+ |
+ base::TimeTicks start_time = test_controller.animator()->last_step_time(); |
+ base::TimeTicks effective_start = start_time + delta; |
+ |
+ test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent( |
+ cc::AnimationEvent::Started, |
+ 0, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ animation_group_id(), |
+ cc::Animation::Opacity, |
+ (effective_start - base::TimeTicks()).InSecondsF())); |
+ |
+ element->Step(effective_start + delta); |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
+ |
+ base::TimeTicks second_effective_start = effective_start + 2 * delta; |
+ test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent( |
+ cc::AnimationEvent::Started, |
+ 0, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ animation_group_id(), |
+ cc::Animation::Opacity, |
+ (second_effective_start - base::TimeTicks()).InSecondsF())); |
+ |
+ element->Step(second_effective_start + delta); |
+ |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ |
+ base::TimeTicks third_effective_start = second_effective_start + 2 * delta; |
+ test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent( |
+ cc::AnimationEvent::Started, |
+ 0, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ animation_group_id(), |
+ cc::Animation::Opacity, |
+ (third_effective_start - base::TimeTicks()).InSecondsF())); |
+ |
+ element->Step(third_effective_start + delta); |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
+ |
+ base::TimeTicks fourth_effective_start = third_effective_start + 2 * delta; |
+ test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent( |
+ cc::AnimationEvent::Started, |
+ 0, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ animation_group_id(), |
+ cc::Animation::Opacity, |
+ (fourth_effective_start - base::TimeTicks()).InSecondsF())); |
+ |
+ // Skip ahead by a lot. |
+ element->Step(fourth_effective_start + 1000 * delta); |
+ |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); |
+ |
+ base::TimeTicks fifth_effective_start = fourth_effective_start + 1001 * delta; |
+ test_controller.animator()->OnThreadedAnimationStarted(cc::AnimationEvent( |
+ cc::AnimationEvent::Started, |
+ 0, |
+ test_controller.GetRunningSequence(LayerAnimationElement::OPACITY)-> |
+ animation_group_id(), |
+ cc::Animation::Opacity, |
+ (fifth_effective_start - base::TimeTicks()).InSecondsF())); |
+ |
+ // Skip ahead by a lot. |
+ element->Step(fifth_effective_start + 999 * delta); |
+ |
+ EXPECT_TRUE(test_controller.animator()->is_animating()); |
+ EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); |
+ |
+ test_controller.animator()->StopAnimatingProperty( |
+ LayerAnimationElement::OPACITY); |
+ |
+ EXPECT_FALSE(test_controller.animator()->is_animating()); |
+} |
+ |
TEST(LayerAnimatorTest, AddObserverExplicit) { |
scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); |
AnimationContainerElement* element = animator.get(); |
@@ -1078,10 +1529,10 @@ TEST(LayerAnimatorTest, AddObserverExplicit) { |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- delegate.SetOpacityFromAnimation(0.0f); |
+ delegate.SetBrightnessFromAnimation(0.0f); |
LayerAnimationSequence* sequence = new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(1.0f, delta)); |
+ LayerAnimationElement::CreateBrightnessElement(1.0f, delta)); |
animator->StartAnimation(sequence); |
@@ -1095,7 +1546,7 @@ TEST(LayerAnimatorTest, AddObserverExplicit) { |
// |sequence| has been destroyed. Recreate it to test abort. |
sequence = new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(1.0f, delta)); |
+ LayerAnimationElement::CreateBrightnessElement(1.0f, delta)); |
animator->StartAnimation(sequence); |
@@ -1115,19 +1566,19 @@ TEST(LayerAnimatorTest, ImplicitAnimationObservers) { |
animator->SetDelegate(&delegate); |
EXPECT_FALSE(observer.animations_completed()); |
- animator->SetOpacity(1.0f); |
+ animator->SetBrightness(1.0f); |
{ |
ScopedLayerAnimationSettings settings(animator.get()); |
settings.AddObserver(&observer); |
- animator->SetOpacity(0.0f); |
+ animator->SetBrightness(0.0f); |
} |
EXPECT_FALSE(observer.animations_completed()); |
base::TimeTicks start_time = animator->last_step_time(); |
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
EXPECT_TRUE(observer.animations_completed()); |
- EXPECT_FLOAT_EQ(0.0f, delegate.GetOpacityForAnimation()); |
+ EXPECT_FLOAT_EQ(0.0f, delegate.GetBrightnessForAnimation()); |
} |
// Tests that an observer added to a scoped settings object is still notified |
@@ -1140,20 +1591,20 @@ TEST(LayerAnimatorTest, InterruptedImplicitAnimationObservers) { |
animator->SetDelegate(&delegate); |
EXPECT_FALSE(observer.animations_completed()); |
- animator->SetOpacity(1.0f); |
+ animator->SetBrightness(1.0f); |
{ |
ScopedLayerAnimationSettings settings(animator.get()); |
settings.AddObserver(&observer); |
- animator->SetOpacity(0.0f); |
+ animator->SetBrightness(0.0f); |
} |
EXPECT_FALSE(observer.animations_completed()); |
// This should interrupt the implicit animation causing the observer to be |
// notified immediately. |
- animator->SetOpacity(1.0f); |
+ animator->SetBrightness(1.0f); |
EXPECT_TRUE(observer.animations_completed()); |
- EXPECT_FLOAT_EQ(1.0f, delegate.GetOpacityForAnimation()); |
+ EXPECT_FLOAT_EQ(1.0f, delegate.GetBrightnessForAnimation()); |
} |
// Tests that an observer added to a scoped settings object is not notified |
@@ -1169,13 +1620,13 @@ TEST(LayerAnimatorTest, ImplicitObserversAtAnimatorDestruction) { |
EXPECT_FALSE(observer_notify.animations_completed()); |
EXPECT_FALSE(observer_do_not_notify.animations_completed()); |
- animator->SetOpacity(1.0f); |
+ animator->SetBrightness(1.0f); |
{ |
ScopedLayerAnimationSettings settings(animator.get()); |
settings.AddObserver(&observer_notify); |
settings.AddObserver(&observer_do_not_notify); |
- animator->SetOpacity(0.0f); |
+ animator->SetBrightness(0.0f); |
} |
EXPECT_FALSE(observer_notify.animations_completed()); |
@@ -1198,7 +1649,7 @@ TEST(LayerAnimatorTest, RemoveObserverShouldRemoveFromSequences) { |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
LayerAnimationSequence* sequence = new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(1.0f, delta)); |
+ LayerAnimationElement::CreateBrightnessElement(1.0f, delta)); |
sequence->AddObserver(&observer); |
sequence->AddObserver(&removed_observer); |
@@ -1258,14 +1709,14 @@ TEST(LayerAnimatorTest, ObserverAttachedAfterAnimationStarted) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- delegate.SetOpacityFromAnimation(0.0f); |
+ delegate.SetBrightnessFromAnimation(0.0f); |
{ |
ScopedLayerAnimationSettings setter(animator.get()); |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
LayerAnimationSequence* sequence = new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(1.0f, delta)); |
+ LayerAnimationElement::CreateBrightnessElement(1.0f, delta)); |
animator->StartAnimation(sequence); |
base::TimeTicks start_time = animator->last_step_time(); |
@@ -1291,10 +1742,10 @@ TEST(LayerAnimatorTest, ObserverDetachedBeforeAnimationFinished) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- delegate.SetOpacityFromAnimation(0.0f); |
+ delegate.SetBrightnessFromAnimation(0.0f); |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
LayerAnimationSequence* sequence = new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(1.0f, delta)); |
+ LayerAnimationElement::CreateBrightnessElement(1.0f, delta)); |
{ |
ScopedLayerAnimationSettings setter(animator.get()); |
@@ -1326,16 +1777,16 @@ TEST(LayerAnimatorTest, ObserverDeletesAnimations) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- double start_opacity(0.0); |
- double target_opacity(1.0); |
+ double start_brightness(0.0); |
+ double target_brightness(1.0); |
gfx::Rect start_bounds(0, 0, 50, 50); |
gfx::Rect target_bounds(5, 5, 5, 5); |
- delegate.SetOpacityFromAnimation(start_opacity); |
+ delegate.SetBrightnessFromAnimation(start_brightness); |
delegate.SetBoundsFromAnimation(start_bounds); |
- base::TimeDelta opacity_delta = base::TimeDelta::FromSeconds(1); |
+ base::TimeDelta brightness_delta = base::TimeDelta::FromSeconds(1); |
base::TimeDelta halfway_delta = base::TimeDelta::FromSeconds(2); |
base::TimeDelta bounds_delta = base::TimeDelta::FromSeconds(3); |
@@ -1349,8 +1800,8 @@ TEST(LayerAnimatorTest, ObserverDeletesAnimations) { |
animator->StartAnimation( |
new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement( |
- target_opacity, opacity_delta))); |
+ LayerAnimationElement::CreateBrightnessElement( |
+ target_brightness, brightness_delta))); |
animator->StartAnimation(to_delete); |
@@ -1636,7 +2087,7 @@ TEST(LayerAnimatorTest, ObserverDeletesAnimatorAfterFinishingAnimation) { |
TestLayerAnimationDelegate delegate; |
animator->SetDelegate(&delegate); |
- delegate.SetOpacityFromAnimation(0.0f); |
+ delegate.SetBrightnessFromAnimation(0.0f); |
gfx::Rect start_bounds(0, 0, 50, 50); |
gfx::Rect target_bounds(10, 10, 100, 100); |
@@ -1644,9 +2095,9 @@ TEST(LayerAnimatorTest, ObserverDeletesAnimatorAfterFinishingAnimation) { |
delegate.SetBoundsFromAnimation(start_bounds); |
base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
- LayerAnimationSequence* opacity_sequence = new LayerAnimationSequence( |
- LayerAnimationElement::CreateOpacityElement(1.0f, delta)); |
- animator->StartAnimation(opacity_sequence); |
+ LayerAnimationSequence* brightness_sequence = new LayerAnimationSequence( |
+ LayerAnimationElement::CreateBrightnessElement(1.0f, delta)); |
+ animator->StartAnimation(brightness_sequence); |
delta = base::TimeDelta::FromSeconds(2); |
LayerAnimationSequence* bounds_sequence = new LayerAnimationSequence( |