Chromium Code Reviews| Index: cc/animation/layer_animation_controller_unittest.cc |
| diff --git a/cc/animation/layer_animation_controller_unittest.cc b/cc/animation/layer_animation_controller_unittest.cc |
| index 4dca3f625689d6d0d45257cc4537b710237264c9..6cd76cf8f1e128c055c90be3439e4b001712da23 100644 |
| --- a/cc/animation/layer_animation_controller_unittest.cc |
| +++ b/cc/animation/layer_animation_controller_unittest.cc |
| @@ -20,10 +20,22 @@ |
| namespace cc { |
| namespace { |
| +base::TimeTicks GetTimeTicks(double time) { |
| + return base::TimeTicks::FromInternalValue(time * |
| + base::Time::kMicrosecondsPerSecond); |
| +} |
| + |
| +base::TimeDelta GetTimeDelta(double offset) { |
| + return GetTimeTicks(offset) - base::TimeTicks(); |
|
ajuma
2014/04/10 14:26:59
Instead of this function, how about just using bas
Sikugu_
2014/04/24 15:19:31
Done.
|
| +} |
| + |
| // A LayerAnimationController cannot be ticked at 0.0, since an animation |
| // with start time 0.0 is treated as an animation whose start time has |
| // not yet been set. |
| -const double kInitialTickTime = 1.0; |
| +const base::TimeTicks kInitialTickTime = GetTimeTicks(1.0); |
|
ajuma
2014/04/10 14:26:59
Note that this is adding a static intializer. I'd
Sikugu_
2014/04/24 15:19:31
Done.
|
| +// TODO(sikugu): Remove double time once we have the TimeTicks/Deltas |
| +// in place for Animations. |
| +const double kInitialDoubleTime = 1.0; |
| scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve, |
| int id, |
| @@ -91,7 +103,7 @@ TEST(LayerAnimationControllerTest, DoNotClobberStartTimes) { |
| Animation::Opacity)->start_time()); |
| // Start the animation on the main thread. Should not affect the start time. |
| - controller->Animate(kInitialTickTime + 0.5); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(0.5)); |
| controller->UpdateState(true, NULL); |
| EXPECT_EQ(controller->GetAnimation(group_id, |
| Animation::Opacity)->start_time(), |
| @@ -139,7 +151,7 @@ TEST(LayerAnimationControllerTest, UseSpecifiedStartTimes) { |
| Animation::Opacity)->start_time()); |
| // Start the animation on the main thread. Should not affect the start time. |
| - controller->Animate(kInitialTickTime + 0.5); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(0.5)); |
| controller->UpdateState(true, NULL); |
| EXPECT_EQ(start_time, |
| controller->GetAnimation(group_id, |
| @@ -192,18 +204,18 @@ TEST(LayerAnimationControllerTest, Activation) { |
| EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
| EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); |
| - controller->Animate(kInitialTickTime + 0.5); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(0.5)); |
| controller->UpdateState(true, NULL); |
| EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
| - controller->Animate(kInitialTickTime + 1.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller->UpdateState(true, NULL); |
| EXPECT_EQ(Animation::Finished, |
| controller->GetAnimation(Animation::Opacity)->run_state()); |
| EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
| events.reset(new AnimationEventsVector); |
| - controller_impl->Animate(kInitialTickTime + 1.5); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(1.5)); |
| controller_impl->UpdateState(true, events.get()); |
| EXPECT_EQ(Animation::WaitingForDeletion, |
| @@ -213,7 +225,7 @@ TEST(LayerAnimationControllerTest, Activation) { |
| EXPECT_EQ(1u, events->size()); |
| controller->NotifyAnimationFinished((*events)[0]); |
| - controller->Animate(kInitialTickTime + 1.5); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.5)); |
| controller->UpdateState(true, NULL); |
| EXPECT_EQ(Animation::WaitingForDeletion, |
| @@ -268,7 +280,7 @@ TEST(LayerAnimationControllerTest, SyncPause) { |
| Animation::Opacity)->run_state()); |
| // Pause the main-thread animation. |
| - controller->PauseAnimation(animation_id, kInitialTickTime + 1.0); |
| + controller->PauseAnimation(animation_id, kInitialDoubleTime + 1.0); |
| EXPECT_EQ(Animation::Paused, |
| controller->GetAnimation(group_id, |
| Animation::Opacity)->run_state()); |
| @@ -308,7 +320,7 @@ TEST(LayerAnimationControllerTest, DoNotSyncFinishedAnimation) { |
| 0, |
| group_id, |
| Animation::Opacity, |
| - kInitialTickTime); |
| + kInitialDoubleTime); |
| controller->NotifyAnimationStarted(animation_started_event); |
| // Force animation to complete on impl thread. |
| @@ -342,7 +354,7 @@ TEST(LayerAnimationControllerTest, AnimationsAreDeleted) { |
| controller->UpdateState(true, NULL); |
| controller->PushAnimationUpdatesTo(controller_impl.get()); |
| - controller_impl->Animate(kInitialTickTime + 0.5); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(0.5)); |
| controller_impl->UpdateState(true, events.get()); |
| // There should be a Started event for the animation. |
| @@ -350,14 +362,14 @@ TEST(LayerAnimationControllerTest, AnimationsAreDeleted) { |
| EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); |
| controller->NotifyAnimationStarted((*events)[0]); |
| - controller->Animate(kInitialTickTime + 1.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller->UpdateState(true, NULL); |
| EXPECT_FALSE(dummy.animation_waiting_for_deletion()); |
| EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); |
| events.reset(new AnimationEventsVector); |
| - controller_impl->Animate(kInitialTickTime + 2.0); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(2.0)); |
| controller_impl->UpdateState(true, events.get()); |
| EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); |
| @@ -372,7 +384,7 @@ TEST(LayerAnimationControllerTest, AnimationsAreDeleted) { |
| controller->NotifyAnimationFinished((*events)[0]); |
| - controller->Animate(kInitialTickTime + 3.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(3.0)); |
| controller->UpdateState(true, NULL); |
| EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
| @@ -416,7 +428,7 @@ TEST(LayerAnimationControllerTest, TrivialTransition) { |
| // A non-impl-only animation should not generate property updates. |
| const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| EXPECT_FALSE(event); |
| - controller->Animate(kInitialTickTime + 1.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_EQ(1.f, dummy.opacity()); |
| EXPECT_FALSE(controller->HasActiveAnimation()); |
| @@ -448,7 +460,7 @@ TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { |
| GetMostRecentPropertyUpdateEvent(events.get()); |
| EXPECT_EQ(0.f, start_opacity_event->opacity); |
| - controller_impl->Animate(kInitialTickTime + 1.0); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller_impl->UpdateState(true, events.get()); |
| EXPECT_EQ(1.f, dummy_impl.opacity()); |
| EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
| @@ -502,7 +514,7 @@ TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) { |
| gfx::Transform expected_transform; |
| expected_transform.Translate(delta_x, delta_y); |
| - controller_impl->Animate(kInitialTickTime + 1.0); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller_impl->UpdateState(true, events.get()); |
| EXPECT_EQ(expected_transform, dummy_impl.transform()); |
| EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
| @@ -545,7 +557,7 @@ TEST(LayerAnimationControllerTest, FilterTransition) { |
| const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| EXPECT_FALSE(event); |
| - controller->Animate(kInitialTickTime + 0.5); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(0.5)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_EQ(1u, dummy.filters().size()); |
| EXPECT_EQ(FilterOperation::CreateBrightnessFilter(1.5f), |
| @@ -553,7 +565,7 @@ TEST(LayerAnimationControllerTest, FilterTransition) { |
| event = GetMostRecentPropertyUpdateEvent(events.get()); |
| EXPECT_FALSE(event); |
| - controller->Animate(kInitialTickTime + 1.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_EQ(end_filters, dummy.filters()); |
| EXPECT_FALSE(controller->HasActiveAnimation()); |
| @@ -599,7 +611,7 @@ TEST(LayerAnimationControllerTest, FilterTransitionOnImplOnly) { |
| EXPECT_EQ(start_filters, start_filter_event->filters); |
| EXPECT_TRUE(start_filter_event->is_impl_only); |
| - controller_impl->Animate(kInitialTickTime + 1.0); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller_impl->UpdateState(true, events.get()); |
| EXPECT_EQ(end_filters, dummy_impl.filters()); |
| EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
| @@ -663,26 +675,26 @@ TEST(LayerAnimationControllerTest, ScrollOffsetTransition) { |
| EXPECT_FALSE(event); |
| controller->NotifyAnimationStarted((*events)[0]); |
| - controller->Animate(kInitialTickTime + duration/2.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(duration / 2.0)); |
| controller->UpdateState(true, NULL); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), dummy.scroll_offset()); |
| - controller_impl->Animate(kInitialTickTime + duration/2.0); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(duration / 2.0)); |
| controller_impl->UpdateState(true, events.get()); |
| EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), |
| dummy_impl.scroll_offset()); |
| event = GetMostRecentPropertyUpdateEvent(events.get()); |
| EXPECT_FALSE(event); |
| - controller_impl->Animate(kInitialTickTime + duration); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(duration)); |
| controller_impl->UpdateState(true, events.get()); |
| EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); |
| EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
| event = GetMostRecentPropertyUpdateEvent(events.get()); |
| EXPECT_FALSE(event); |
| - controller->Animate(kInitialTickTime + duration); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(duration)); |
| controller->UpdateState(true, NULL); |
| EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset()); |
| EXPECT_FALSE(controller->HasActiveAnimation()); |
| @@ -741,26 +753,26 @@ TEST(LayerAnimationControllerTest, ScrollOffsetTransitionNoImplProvider) { |
| EXPECT_FALSE(event); |
| controller->NotifyAnimationStarted((*events)[0]); |
| - controller->Animate(kInitialTickTime + duration/2.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(duration / 2.0)); |
| controller->UpdateState(true, NULL); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), dummy.scroll_offset()); |
| - controller_impl->Animate(kInitialTickTime + duration/2.0); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(duration / 2.0)); |
| controller_impl->UpdateState(true, events.get()); |
| EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), |
| dummy_impl.scroll_offset()); |
| event = GetMostRecentPropertyUpdateEvent(events.get()); |
| EXPECT_FALSE(event); |
| - controller_impl->Animate(kInitialTickTime + duration); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(duration)); |
| controller_impl->UpdateState(true, events.get()); |
| EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); |
| EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
| event = GetMostRecentPropertyUpdateEvent(events.get()); |
| EXPECT_FALSE(event); |
| - controller->Animate(kInitialTickTime + duration); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(duration)); |
| controller->UpdateState(true, NULL); |
| EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset()); |
| EXPECT_FALSE(controller->HasActiveAnimation()); |
| @@ -796,14 +808,14 @@ TEST(LayerAnimationControllerTest, ScrollOffsetTransitionOnImplOnly) { |
| const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| EXPECT_FALSE(event); |
| - controller_impl->Animate(kInitialTickTime + duration/2.0); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(duration / 2.0)); |
| controller_impl->UpdateState(true, events.get()); |
| EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), |
| dummy_impl.scroll_offset()); |
| event = GetMostRecentPropertyUpdateEvent(events.get()); |
| EXPECT_FALSE(event); |
| - controller_impl->Animate(kInitialTickTime + duration); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(duration)); |
| controller_impl->UpdateState(true, events.get()); |
| EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); |
| EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
| @@ -879,7 +891,7 @@ TEST(LayerAnimationControllerTest, |
| EXPECT_TRUE(delegate.started()); |
| events.reset(new AnimationEventsVector); |
| - controller_impl->Animate(kInitialTickTime + 1.0); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller_impl->UpdateState(true, events.get()); |
| // We should receive 2 events (a finished notification and a property update). |
| @@ -920,19 +932,22 @@ TEST(LayerAnimationControllerTest, |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 1.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 2.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(2.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.f, dummy.opacity()); |
| // Send the synchronized start time. |
| - controller->NotifyAnimationStarted(AnimationEvent( |
| - AnimationEvent::Started, 0, 1, Animation::Opacity, kInitialTickTime + 2)); |
| - controller->Animate(kInitialTickTime + 5.0); |
| + controller->NotifyAnimationStarted(AnimationEvent(AnimationEvent::Started, |
| + 0, |
| + 1, |
| + Animation::Opacity, |
| + kInitialDoubleTime + 2)); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(5.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_EQ(1.f, dummy.opacity()); |
| EXPECT_FALSE(controller->HasActiveAnimation()); |
| @@ -961,11 +976,11 @@ TEST(LayerAnimationControllerTest, TrivialQueuing) { |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 1.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(1.f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 2.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(2.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_EQ(0.5f, dummy.opacity()); |
| EXPECT_FALSE(controller->HasActiveAnimation()); |
| @@ -998,11 +1013,11 @@ TEST(LayerAnimationControllerTest, Interrupt) { |
| // Since the previous animation was aborted, the new animation should start |
| // right in this call to animate. |
| - controller->Animate(kInitialTickTime + 0.5); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(0.5)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(1.f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 1.5); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.5)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_EQ(0.5f, dummy.opacity()); |
| EXPECT_FALSE(controller->HasActiveAnimation()); |
| @@ -1035,13 +1050,13 @@ TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { |
| controller->UpdateState(true, events.get()); |
| EXPECT_EQ(0.f, dummy.opacity()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| - controller->Animate(kInitialTickTime + 1.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller->UpdateState(true, events.get()); |
| // Should not have started the float transition yet. |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.f, dummy.opacity()); |
| // The float animation should have started at time 1 and should be done. |
| - controller->Animate(kInitialTickTime + 2.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(2.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_EQ(1.f, dummy.opacity()); |
| EXPECT_FALSE(controller->HasActiveAnimation()); |
| @@ -1080,7 +1095,7 @@ TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { |
| // The opacity animation should have finished at time 1, but the group |
| // of animations with id 1 don't finish until time 2 because of the length |
| // of the transform animation. |
| - controller->Animate(kInitialTickTime + 2.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(2.0)); |
| controller->UpdateState(true, events.get()); |
| // Should not have started the float transition yet. |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| @@ -1088,7 +1103,7 @@ TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { |
| // The second opacity animation should start at time 2 and should be done by |
| // time 3. |
| - controller->Animate(kInitialTickTime + 3.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(3.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_EQ(0.5f, dummy.opacity()); |
| EXPECT_FALSE(controller->HasActiveAnimation()); |
| @@ -1114,29 +1129,29 @@ TEST(LayerAnimationControllerTest, TrivialLooping) { |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 1.25); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.25)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.25f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 1.75); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.75)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.75f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 2.25); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(2.25)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.25f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 2.75); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(2.75)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.75f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 3.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(3.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_FALSE(controller->HasActiveAnimation()); |
| EXPECT_EQ(1.f, dummy.opacity()); |
| // Just be extra sure. |
| - controller->Animate(kInitialTickTime + 4.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(4.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_EQ(1.f, dummy.opacity()); |
| } |
| @@ -1162,27 +1177,27 @@ TEST(LayerAnimationControllerTest, InfiniteLooping) { |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 1.25); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.25)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.25f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 1.75); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.75)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.75f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 1073741824.25); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1073741824.25)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.25f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 1073741824.75); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1073741824.75)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.75f, dummy.opacity()); |
| EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); |
| - controller->GetAnimation(id, Animation::Opacity)->SetRunState( |
| - Animation::Aborted, kInitialTickTime + 0.75); |
| + controller->GetAnimation(id, Animation::Opacity) |
| + ->SetRunState(Animation::Aborted, kInitialDoubleTime + 0.75); |
| EXPECT_FALSE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.75f, dummy.opacity()); |
| } |
| @@ -1206,29 +1221,29 @@ TEST(LayerAnimationControllerTest, PauseResume) { |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 0.5); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(0.5)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.5f, dummy.opacity()); |
| EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); |
| - controller->GetAnimation(id, Animation::Opacity)->SetRunState( |
| - Animation::Paused, kInitialTickTime + 0.5); |
| + controller->GetAnimation(id, Animation::Opacity) |
| + ->SetRunState(Animation::Paused, kInitialDoubleTime + 0.5); |
| - controller->Animate(kInitialTickTime + 1024.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1024.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.5f, dummy.opacity()); |
| EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); |
| - controller->GetAnimation(id, Animation::Opacity)->SetRunState( |
| - Animation::Running, kInitialTickTime + 1024); |
| + controller->GetAnimation(id, Animation::Opacity) |
| + ->SetRunState(Animation::Running, kInitialDoubleTime + 1024); |
| - controller->Animate(kInitialTickTime + 1024.25); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1024.25)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.75f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 1024.5); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1024.5)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_FALSE(controller->HasActiveAnimation()); |
| EXPECT_EQ(1.f, dummy.opacity()); |
| @@ -1261,19 +1276,19 @@ TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 1.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.5f, dummy.opacity()); |
| EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); |
| - controller->GetAnimation(id, Animation::Opacity)->SetRunState( |
| - Animation::Aborted, kInitialTickTime + 1.0); |
| - controller->Animate(kInitialTickTime + 1.0); |
| + controller->GetAnimation(id, Animation::Opacity) |
| + ->SetRunState(Animation::Aborted, kInitialDoubleTime + 1.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(1.f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 2.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(2.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_TRUE(!controller->HasActiveAnimation()); |
| EXPECT_EQ(0.75f, dummy.opacity()); |
| @@ -1336,9 +1351,9 @@ TEST(LayerAnimationControllerTest, SkipUpdateState) { |
| Animation::Opacity)); |
| // Animate but don't UpdateState. |
| - controller->Animate(kInitialTickTime + 1.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| - controller->Animate(kInitialTickTime + 2.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(2.0)); |
| events.reset(new AnimationEventsVector); |
| controller->UpdateState(true, events.get()); |
| @@ -1350,7 +1365,7 @@ TEST(LayerAnimationControllerTest, SkipUpdateState) { |
| EXPECT_TRUE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.f, dummy.opacity()); |
| - controller->Animate(kInitialTickTime + 3.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(3.0)); |
| controller->UpdateState(true, events.get()); |
| // The float tranisition should now be done. |
| @@ -1387,7 +1402,7 @@ TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { |
| // With only an inactive observer, the animation should progress to the |
| // Starting state and get ticked at its starting point, but should not |
| // progress to Running. |
| - controller->Animate(kInitialTickTime + 1.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_EQ(0u, events->size()); |
| EXPECT_EQ(Animation::Starting, |
| @@ -1396,7 +1411,7 @@ TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { |
| // Even when already in the Starting state, the animation should stay |
| // there, and shouldn't be ticked past its starting point. |
| - controller->Animate(kInitialTickTime + 2.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(2.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_EQ(0u, events->size()); |
| EXPECT_EQ(Animation::Starting, |
| @@ -1407,7 +1422,7 @@ TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { |
| // Now that an active observer has been added, the animation should still |
| // initially tick at its starting point, but should now progress to Running. |
| - controller->Animate(kInitialTickTime + 3.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(3.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_EQ(1u, events->size()); |
| EXPECT_EQ(Animation::Running, |
| @@ -1416,7 +1431,7 @@ TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { |
| EXPECT_EQ(0.5f, dummy.opacity()); |
| // The animation should now tick past its starting point. |
| - controller->Animate(kInitialTickTime + 3.5); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(3.5)); |
| EXPECT_NE(0.5f, inactive_dummy.opacity()); |
| EXPECT_NE(0.5f, dummy.opacity()); |
| } |
| @@ -1524,7 +1539,7 @@ TEST(LayerAnimationControllerTest, AbortAnimations) { |
| controller->Animate(kInitialTickTime); |
| controller->UpdateState(true, NULL); |
| - controller->Animate(kInitialTickTime + 1.0); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller->UpdateState(true, NULL); |
| EXPECT_EQ(Animation::Finished, |
| @@ -1623,7 +1638,7 @@ TEST(LayerAnimationControllerTest, ImplThreadAbortedAnimationGetsDeleted) { |
| EXPECT_EQ(Animation::Aborted, |
| controller->GetAnimation(Animation::Opacity)->run_state()); |
| - controller->Animate(kInitialTickTime + 0.5); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(0.5)); |
| controller->UpdateState(true, NULL); |
| EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
| EXPECT_EQ(Animation::WaitingForDeletion, |
| @@ -1663,7 +1678,7 @@ TEST(LayerAnimationControllerTest, FinishedEventsForGroup) { |
| EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); |
| events.reset(new AnimationEventsVector); |
| - controller_impl->Animate(kInitialTickTime + 1.0); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller_impl->UpdateState(true, events.get()); |
| // The opacity animation should be finished, but should not have generated |
| @@ -1675,7 +1690,7 @@ TEST(LayerAnimationControllerTest, FinishedEventsForGroup) { |
| controller_impl->GetAnimation(1, |
| Animation::Transform)->run_state()); |
| - controller_impl->Animate(kInitialTickTime + 2.0); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(2.0)); |
| controller_impl->UpdateState(true, events.get()); |
| // Both animations should have generated Finished events. |
| @@ -1716,7 +1731,7 @@ TEST(LayerAnimationControllerTest, FinishedAndAbortedEventsForGroup) { |
| controller_impl->AbortAnimations(Animation::Opacity); |
| events.reset(new AnimationEventsVector); |
| - controller_impl->Animate(kInitialTickTime + 1.0); |
| + controller_impl->Animate(kInitialTickTime + GetTimeDelta(1.0)); |
| controller_impl->UpdateState(true, events.get()); |
| // We should have exactly 2 events: a Finished event for the tranform |