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..231956113ea75473abaa9c3cfc1704bd4aeb578a 100644 |
| --- a/cc/animation/layer_animation_controller_unittest.cc |
| +++ b/cc/animation/layer_animation_controller_unittest.cc |
| @@ -20,10 +20,19 @@ |
| namespace cc { |
| namespace { |
| +base::TimeTicks GetTimeTicks(double time) { |
|
mithro-old
2014/04/16 13:33:17
A better name is "double seconds".
Sikugu_
2014/04/24 15:19:31
Done.
|
| + return base::TimeTicks::FromInternalValue(time * |
| + base::Time::kMicrosecondsPerSecond); |
| +} |
| + |
| +base::TimeDelta GetTimeDelta(double offset) { |
| + return GetTimeTicks(offset) - base::TimeTicks(); |
| +} |
| + |
| // 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); |
|
mithro-old
2014/04/16 13:33:17
Why didn't you do a
-----------------------------
Sikugu_
2014/04/24 15:19:31
Done.
|
| scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve, |
| int id, |
| @@ -91,7 +100,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)); |
|
mithro-old
2014/04/16 13:33:17
Why didn't you just do;
--------------------------
danakj
2014/04/16 15:06:58
+1 FromMilliseconds instead of converting from dou
Sikugu_
2014/04/24 15:19:31
Done.
Sikugu_
2014/04/24 15:19:31
Done.
|
| controller->UpdateState(true, NULL); |
| EXPECT_EQ(controller->GetAnimation(group_id, |
| Animation::Opacity)->start_time(), |
| @@ -112,7 +121,7 @@ TEST(LayerAnimationControllerTest, UseSpecifiedStartTimes) { |
| AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
| int group_id = controller->GetAnimation(Animation::Opacity)->group(); |
| - const double start_time = 123; |
| + const base::TimeTicks start_time = GetTimeTicks(123); |
| controller->GetAnimation(Animation::Opacity)->set_start_time(start_time); |
| controller->PushAnimationUpdatesTo(controller_impl.get()); |
| @@ -139,7 +148,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 +201,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 +222,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 +277,8 @@ TEST(LayerAnimationControllerTest, SyncPause) { |
| Animation::Opacity)->run_state()); |
| // Pause the main-thread animation. |
| - controller->PauseAnimation(animation_id, kInitialTickTime + 1.0); |
| + controller->PauseAnimation(animation_id, |
| + GetTimeDelta(1.0) + GetTimeDelta(1.0)); |
| EXPECT_EQ(Animation::Paused, |
| controller->GetAnimation(group_id, |
| Animation::Opacity)->run_state()); |
| @@ -342,7 +352,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 +360,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 +382,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 +426,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 +458,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 +512,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 +555,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 +563,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 +609,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 +673,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 +751,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 +806,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 +889,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 +930,23 @@ 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, |
| + kInitialTickTime + GetTimeDelta(2))); |
| + controller->Animate(kInitialTickTime + GetTimeDelta(5.0)); |
| controller->UpdateState(true, events.get()); |
| EXPECT_EQ(1.f, dummy.opacity()); |
| EXPECT_FALSE(controller->HasActiveAnimation()); |
| @@ -961,11 +975,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 +1012,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 +1049,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 +1094,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 +1102,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 +1128,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 +1176,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, kInitialTickTime + GetTimeDelta(0.75)); |
| EXPECT_FALSE(controller->HasActiveAnimation()); |
| EXPECT_EQ(0.75f, dummy.opacity()); |
| } |
| @@ -1206,29 +1220,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, kInitialTickTime + GetTimeDelta(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, kInitialTickTime + GetTimeDelta(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 +1275,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, kInitialTickTime + GetTimeDelta(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 +1350,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 +1364,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 +1401,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 +1410,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 +1421,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 +1430,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()); |
| } |
| @@ -1461,7 +1475,7 @@ TEST(LayerAnimationControllerTest, TransformAnimationBounds) { |
| bounds.ToString()); |
| controller_impl->GetAnimation(1, Animation::Transform) |
| - ->SetRunState(Animation::Finished, 0.0); |
| + ->SetRunState(Animation::Finished, GetTimeTicks(0.0)); |
| // Only the unfinished animation should affect the animated bounds. |
| EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); |
| @@ -1469,7 +1483,7 @@ TEST(LayerAnimationControllerTest, TransformAnimationBounds) { |
| bounds.ToString()); |
| controller_impl->GetAnimation(2, Animation::Transform) |
| - ->SetRunState(Animation::Finished, 0.0); |
| + ->SetRunState(Animation::Finished, GetTimeTicks(0.0)); |
| // There are no longer any running animations. |
| EXPECT_FALSE(controller_impl->HasTransformAnimationThatInflatesBounds()); |
| @@ -1524,7 +1538,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 +1637,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 +1677,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 +1689,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 +1730,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 |
| @@ -1776,7 +1790,7 @@ TEST(LayerAnimationControllerTest, HasAnimationThatAffectsScale) { |
| EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale()); |
| controller_impl->GetAnimation(3, Animation::Transform) |
| - ->SetRunState(Animation::Finished, 0.0); |
| + ->SetRunState(Animation::Finished, GetTimeTicks(0.0)); |
| // Only unfinished animations should be considered by |
| // HasAnimationThatAffectsScale. |
| @@ -1832,7 +1846,7 @@ TEST(LayerAnimationControllerTest, HasOnlyTranslationTransforms) { |
| EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms()); |
| controller_impl->GetAnimation(3, Animation::Transform) |
| - ->SetRunState(Animation::Finished, 0.0); |
| + ->SetRunState(Animation::Finished, GetTimeTicks(0.0)); |
| // Only unfinished animations should be considered by |
| // HasOnlyTranslationTransforms. |
| @@ -1898,9 +1912,9 @@ TEST(LayerAnimationControllerTest, MaximumScale) { |
| EXPECT_FALSE(controller_impl->MaximumScale(&max_scale)); |
| controller_impl->GetAnimation(3, Animation::Transform) |
| - ->SetRunState(Animation::Finished, 0.0); |
| + ->SetRunState(Animation::Finished, GetTimeTicks(0.0)); |
| controller_impl->GetAnimation(2, Animation::Transform) |
| - ->SetRunState(Animation::Finished, 0.0); |
| + ->SetRunState(Animation::Finished, GetTimeTicks(0.0)); |
| // Only unfinished animations should be considered by |
| // MaximumScale. |