| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/animation/layer_animation_controller.h" | 5 #include "cc/animation/layer_animation_controller.h" |
| 6 | 6 |
| 7 #include "cc/animation/animation.h" | 7 #include "cc/animation/animation.h" |
| 8 #include "cc/animation/animation_curve.h" | 8 #include "cc/animation/animation_curve.h" |
| 9 #include "cc/animation/animation_delegate.h" | 9 #include "cc/animation/animation_delegate.h" |
| 10 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
| 11 #include "cc/animation/keyframed_animation_curve.h" | 11 #include "cc/animation/keyframed_animation_curve.h" |
| 12 #include "cc/animation/scroll_offset_animation_curve.h" | 12 #include "cc/animation/scroll_offset_animation_curve.h" |
| 13 #include "cc/animation/transform_operations.h" | 13 #include "cc/animation/transform_operations.h" |
| 14 #include "cc/test/animation_test_common.h" | 14 #include "cc/test/animation_test_common.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/gfx/box_f.h" | 17 #include "ui/gfx/box_f.h" |
| 18 #include "ui/gfx/transform.h" | 18 #include "ui/gfx/transform.h" |
| 19 | 19 |
| 20 namespace cc { | 20 namespace cc { |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // A LayerAnimationController cannot be ticked at 0.0, since an animation | 23 // A LayerAnimationController cannot be ticked at 0.0, since an animation |
| 24 // with start time 0.0 is treated as an animation whose start time has | 24 // with start time 0.0 is treated as an animation whose start time has |
| 25 // not yet been set. | 25 // not yet been set. |
| 26 const double kInitialTickTime = 1.0; | 26 const double kInitialTickTime = 1.0; |
| 27 base::TimeTicks GetTimeTicks(double time) { |
| 28 return base::TimeTicks::FromInternalValue(time * |
| 29 base::Time::kMicrosecondsPerSecond); |
| 30 } |
| 27 | 31 |
| 28 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve, | 32 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve, |
| 29 int id, | 33 int id, |
| 30 Animation::TargetProperty property) { | 34 Animation::TargetProperty property) { |
| 31 return Animation::Create(curve.Pass(), 0, id, property); | 35 return Animation::Create(curve.Pass(), 0, id, property); |
| 32 } | 36 } |
| 33 | 37 |
| 34 TEST(LayerAnimationControllerTest, SyncNewAnimation) { | 38 TEST(LayerAnimationControllerTest, SyncNewAnimation) { |
| 35 FakeLayerAnimationValueObserver dummy_impl; | 39 FakeLayerAnimationValueObserver dummy_impl; |
| 36 scoped_refptr<LayerAnimationController> controller_impl( | 40 scoped_refptr<LayerAnimationController> controller_impl( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 int group_id = controller->GetAnimation(Animation::Opacity)->group(); | 76 int group_id = controller->GetAnimation(Animation::Opacity)->group(); |
| 73 | 77 |
| 74 controller->PushAnimationUpdatesTo(controller_impl.get()); | 78 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 75 | 79 |
| 76 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 80 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
| 77 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 81 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
| 78 controller_impl->GetAnimation(group_id, | 82 controller_impl->GetAnimation(group_id, |
| 79 Animation::Opacity)->run_state()); | 83 Animation::Opacity)->run_state()); |
| 80 | 84 |
| 81 AnimationEventsVector events; | 85 AnimationEventsVector events; |
| 82 controller_impl->Animate(kInitialTickTime); | 86 controller_impl->Animate(GetTimeTicks(kInitialTickTime)); |
| 83 controller_impl->UpdateState(true, &events); | 87 controller_impl->UpdateState(true, &events); |
| 84 | 88 |
| 85 // Synchronize the start times. | 89 // Synchronize the start times. |
| 86 EXPECT_EQ(1u, events.size()); | 90 EXPECT_EQ(1u, events.size()); |
| 87 controller->NotifyAnimationStarted(events[0]); | 91 controller->NotifyAnimationStarted(events[0]); |
| 88 EXPECT_EQ(controller->GetAnimation(group_id, | 92 EXPECT_EQ(controller->GetAnimation(group_id, |
| 89 Animation::Opacity)->start_time(), | 93 Animation::Opacity)->start_time(), |
| 90 controller_impl->GetAnimation(group_id, | 94 controller_impl->GetAnimation(group_id, |
| 91 Animation::Opacity)->start_time()); | 95 Animation::Opacity)->start_time()); |
| 92 | 96 |
| 93 // Start the animation on the main thread. Should not affect the start time. | 97 // Start the animation on the main thread. Should not affect the start time. |
| 94 controller->Animate(kInitialTickTime + 0.5); | 98 controller->Animate(GetTimeTicks(kInitialTickTime + 0.5)); |
| 95 controller->UpdateState(true, NULL); | 99 controller->UpdateState(true, NULL); |
| 96 EXPECT_EQ(controller->GetAnimation(group_id, | 100 EXPECT_EQ(controller->GetAnimation(group_id, |
| 97 Animation::Opacity)->start_time(), | 101 Animation::Opacity)->start_time(), |
| 98 controller_impl->GetAnimation(group_id, | 102 controller_impl->GetAnimation(group_id, |
| 99 Animation::Opacity)->start_time()); | 103 Animation::Opacity)->start_time()); |
| 100 } | 104 } |
| 101 | 105 |
| 102 TEST(LayerAnimationControllerTest, UseSpecifiedStartTimes) { | 106 TEST(LayerAnimationControllerTest, UseSpecifiedStartTimes) { |
| 103 FakeLayerAnimationValueObserver dummy_impl; | 107 FakeLayerAnimationValueObserver dummy_impl; |
| 104 scoped_refptr<LayerAnimationController> controller_impl( | 108 scoped_refptr<LayerAnimationController> controller_impl( |
| 105 LayerAnimationController::Create(0)); | 109 LayerAnimationController::Create(0)); |
| 106 controller_impl->AddValueObserver(&dummy_impl); | 110 controller_impl->AddValueObserver(&dummy_impl); |
| 107 FakeLayerAnimationValueObserver dummy; | 111 FakeLayerAnimationValueObserver dummy; |
| 108 scoped_refptr<LayerAnimationController> controller( | 112 scoped_refptr<LayerAnimationController> controller( |
| 109 LayerAnimationController::Create(0)); | 113 LayerAnimationController::Create(0)); |
| 110 controller->AddValueObserver(&dummy); | 114 controller->AddValueObserver(&dummy); |
| 111 | 115 |
| 112 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); | 116 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
| 113 int group_id = controller->GetAnimation(Animation::Opacity)->group(); | 117 int group_id = controller->GetAnimation(Animation::Opacity)->group(); |
| 114 | 118 |
| 115 const double start_time = 123; | 119 const double start_time = 123; |
| 116 controller->GetAnimation(Animation::Opacity)->set_start_time(start_time); | 120 controller->GetAnimation(Animation::Opacity) |
| 121 ->set_start_time(GetTimeTicks(start_time)); |
| 117 | 122 |
| 118 controller->PushAnimationUpdatesTo(controller_impl.get()); | 123 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 119 | 124 |
| 120 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 125 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
| 121 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 126 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
| 122 controller_impl->GetAnimation(group_id, | 127 controller_impl->GetAnimation(group_id, |
| 123 Animation::Opacity)->run_state()); | 128 Animation::Opacity)->run_state()); |
| 124 | 129 |
| 125 AnimationEventsVector events; | 130 AnimationEventsVector events; |
| 126 controller_impl->Animate(kInitialTickTime); | 131 controller_impl->Animate(GetTimeTicks(kInitialTickTime)); |
| 127 controller_impl->UpdateState(true, &events); | 132 controller_impl->UpdateState(true, &events); |
| 128 | 133 |
| 129 // Synchronize the start times. | 134 // Synchronize the start times. |
| 130 EXPECT_EQ(1u, events.size()); | 135 EXPECT_EQ(1u, events.size()); |
| 131 controller->NotifyAnimationStarted(events[0]); | 136 controller->NotifyAnimationStarted(events[0]); |
| 132 | 137 |
| 133 EXPECT_EQ(start_time, | 138 EXPECT_EQ(start_time, |
| 134 controller->GetAnimation(group_id, | 139 controller->GetAnimation(group_id, |
| 135 Animation::Opacity)->start_time()); | 140 Animation::Opacity)->start_time()); |
| 136 EXPECT_EQ(controller->GetAnimation(group_id, | 141 EXPECT_EQ(controller->GetAnimation(group_id, |
| 137 Animation::Opacity)->start_time(), | 142 Animation::Opacity)->start_time(), |
| 138 controller_impl->GetAnimation(group_id, | 143 controller_impl->GetAnimation(group_id, |
| 139 Animation::Opacity)->start_time()); | 144 Animation::Opacity)->start_time()); |
| 140 | 145 |
| 141 // Start the animation on the main thread. Should not affect the start time. | 146 // Start the animation on the main thread. Should not affect the start time. |
| 142 controller->Animate(kInitialTickTime + 0.5); | 147 controller->Animate(GetTimeTicks(kInitialTickTime + 0.5)); |
| 143 controller->UpdateState(true, NULL); | 148 controller->UpdateState(true, NULL); |
| 144 EXPECT_EQ(start_time, | 149 EXPECT_EQ(start_time, |
| 145 controller->GetAnimation(group_id, | 150 controller->GetAnimation(group_id, |
| 146 Animation::Opacity)->start_time()); | 151 Animation::Opacity)->start_time()); |
| 147 EXPECT_EQ(controller->GetAnimation(group_id, | 152 EXPECT_EQ(controller->GetAnimation(group_id, |
| 148 Animation::Opacity)->start_time(), | 153 Animation::Opacity)->start_time(), |
| 149 controller_impl->GetAnimation(group_id, | 154 controller_impl->GetAnimation(group_id, |
| 150 Animation::Opacity)->start_time()); | 155 Animation::Opacity)->start_time()); |
| 151 } | 156 } |
| 152 | 157 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 177 | 182 |
| 178 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); | 183 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
| 179 // The main thread controller should now be active. | 184 // The main thread controller should now be active. |
| 180 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 185 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
| 181 | 186 |
| 182 controller->PushAnimationUpdatesTo(controller_impl.get()); | 187 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 183 // Both controllers should now be active. | 188 // Both controllers should now be active. |
| 184 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 189 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
| 185 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); | 190 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); |
| 186 | 191 |
| 187 controller_impl->Animate(kInitialTickTime); | 192 controller_impl->Animate(GetTimeTicks(kInitialTickTime)); |
| 188 controller_impl->UpdateState(true, events.get()); | 193 controller_impl->UpdateState(true, events.get()); |
| 189 EXPECT_EQ(1u, events->size()); | 194 EXPECT_EQ(1u, events->size()); |
| 190 controller->NotifyAnimationStarted((*events)[0]); | 195 controller->NotifyAnimationStarted((*events)[0]); |
| 191 | 196 |
| 192 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 197 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
| 193 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); | 198 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); |
| 194 | 199 |
| 195 controller->Animate(kInitialTickTime + 0.5); | 200 controller->Animate(GetTimeTicks(kInitialTickTime + 0.5)); |
| 196 controller->UpdateState(true, NULL); | 201 controller->UpdateState(true, NULL); |
| 197 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 202 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
| 198 | 203 |
| 199 controller->Animate(kInitialTickTime + 1.0); | 204 controller->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 200 controller->UpdateState(true, NULL); | 205 controller->UpdateState(true, NULL); |
| 201 EXPECT_EQ(Animation::Finished, | 206 EXPECT_EQ(Animation::Finished, |
| 202 controller->GetAnimation(Animation::Opacity)->run_state()); | 207 controller->GetAnimation(Animation::Opacity)->run_state()); |
| 203 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 208 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
| 204 | 209 |
| 205 events.reset(new AnimationEventsVector); | 210 events.reset(new AnimationEventsVector); |
| 206 controller_impl->Animate(kInitialTickTime + 1.5); | 211 controller_impl->Animate(GetTimeTicks(kInitialTickTime + 1.5)); |
| 207 controller_impl->UpdateState(true, events.get()); | 212 controller_impl->UpdateState(true, events.get()); |
| 208 | 213 |
| 209 EXPECT_EQ(Animation::WaitingForDeletion, | 214 EXPECT_EQ(Animation::WaitingForDeletion, |
| 210 controller_impl->GetAnimation(Animation::Opacity)->run_state()); | 215 controller_impl->GetAnimation(Animation::Opacity)->run_state()); |
| 211 // The impl thread controller should have de-activated. | 216 // The impl thread controller should have de-activated. |
| 212 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); | 217 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); |
| 213 | 218 |
| 214 EXPECT_EQ(1u, events->size()); | 219 EXPECT_EQ(1u, events->size()); |
| 215 controller->NotifyAnimationFinished((*events)[0]); | 220 controller->NotifyAnimationFinished((*events)[0]); |
| 216 controller->Animate(kInitialTickTime + 1.5); | 221 controller->Animate(GetTimeTicks(kInitialTickTime + 1.5)); |
| 217 controller->UpdateState(true, NULL); | 222 controller->UpdateState(true, NULL); |
| 218 | 223 |
| 219 EXPECT_EQ(Animation::WaitingForDeletion, | 224 EXPECT_EQ(Animation::WaitingForDeletion, |
| 220 controller->GetAnimation(Animation::Opacity)->run_state()); | 225 controller->GetAnimation(Animation::Opacity)->run_state()); |
| 221 // The main thread controller should have de-activated. | 226 // The main thread controller should have de-activated. |
| 222 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); | 227 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); |
| 223 | 228 |
| 224 controller->PushAnimationUpdatesTo(controller_impl.get()); | 229 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 225 EXPECT_FALSE(controller->has_any_animation()); | 230 EXPECT_FALSE(controller->has_any_animation()); |
| 226 EXPECT_FALSE(controller_impl->has_any_animation()); | 231 EXPECT_FALSE(controller_impl->has_any_animation()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 249 | 254 |
| 250 controller->PushAnimationUpdatesTo(controller_impl.get()); | 255 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 251 | 256 |
| 252 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 257 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
| 253 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 258 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
| 254 controller_impl->GetAnimation(group_id, | 259 controller_impl->GetAnimation(group_id, |
| 255 Animation::Opacity)->run_state()); | 260 Animation::Opacity)->run_state()); |
| 256 | 261 |
| 257 // Start the animations on each controller. | 262 // Start the animations on each controller. |
| 258 AnimationEventsVector events; | 263 AnimationEventsVector events; |
| 259 controller_impl->Animate(kInitialTickTime); | 264 controller_impl->Animate(GetTimeTicks(kInitialTickTime)); |
| 260 controller_impl->UpdateState(true, &events); | 265 controller_impl->UpdateState(true, &events); |
| 261 controller->Animate(kInitialTickTime); | 266 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 262 controller->UpdateState(true, NULL); | 267 controller->UpdateState(true, NULL); |
| 263 EXPECT_EQ(Animation::Running, | 268 EXPECT_EQ(Animation::Running, |
| 264 controller_impl->GetAnimation(group_id, | 269 controller_impl->GetAnimation(group_id, |
| 265 Animation::Opacity)->run_state()); | 270 Animation::Opacity)->run_state()); |
| 266 EXPECT_EQ(Animation::Running, | 271 EXPECT_EQ(Animation::Running, |
| 267 controller->GetAnimation(group_id, | 272 controller->GetAnimation(group_id, |
| 268 Animation::Opacity)->run_state()); | 273 Animation::Opacity)->run_state()); |
| 269 | 274 |
| 270 // Pause the main-thread animation. | 275 // Pause the main-thread animation. |
| 271 controller->PauseAnimation(animation_id, kInitialTickTime + 1.0); | 276 controller->PauseAnimation(animation_id, |
| 277 GetTimeTicks(kInitialTickTime + 1.0)); |
| 272 EXPECT_EQ(Animation::Paused, | 278 EXPECT_EQ(Animation::Paused, |
| 273 controller->GetAnimation(group_id, | 279 controller->GetAnimation(group_id, |
| 274 Animation::Opacity)->run_state()); | 280 Animation::Opacity)->run_state()); |
| 275 | 281 |
| 276 // The pause run state change should make it to the impl thread controller. | 282 // The pause run state change should make it to the impl thread controller. |
| 277 controller->PushAnimationUpdatesTo(controller_impl.get()); | 283 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 278 EXPECT_EQ(Animation::Paused, | 284 EXPECT_EQ(Animation::Paused, |
| 279 controller_impl->GetAnimation(group_id, | 285 controller_impl->GetAnimation(group_id, |
| 280 Animation::Opacity)->run_state()); | 286 Animation::Opacity)->run_state()); |
| 281 } | 287 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 301 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 307 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
| 302 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 308 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
| 303 controller_impl->GetAnimation(group_id, | 309 controller_impl->GetAnimation(group_id, |
| 304 Animation::Opacity)->run_state()); | 310 Animation::Opacity)->run_state()); |
| 305 | 311 |
| 306 // Notify main thread controller that the animation has started. | 312 // Notify main thread controller that the animation has started. |
| 307 AnimationEvent animation_started_event(AnimationEvent::Started, | 313 AnimationEvent animation_started_event(AnimationEvent::Started, |
| 308 0, | 314 0, |
| 309 group_id, | 315 group_id, |
| 310 Animation::Opacity, | 316 Animation::Opacity, |
| 311 kInitialTickTime); | 317 GetTimeTicks(kInitialTickTime)); |
| 312 controller->NotifyAnimationStarted(animation_started_event); | 318 controller->NotifyAnimationStarted(animation_started_event); |
| 313 | 319 |
| 314 // Force animation to complete on impl thread. | 320 // Force animation to complete on impl thread. |
| 315 controller_impl->RemoveAnimation(animation_id); | 321 controller_impl->RemoveAnimation(animation_id); |
| 316 | 322 |
| 317 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 323 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
| 318 | 324 |
| 319 controller->PushAnimationUpdatesTo(controller_impl.get()); | 325 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 320 | 326 |
| 321 // Even though the main thread has a 'new' animation, it should not be pushed | 327 // Even though the main thread has a 'new' animation, it should not be pushed |
| 322 // because the animation has already completed on the impl thread. | 328 // because the animation has already completed on the impl thread. |
| 323 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 329 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
| 324 } | 330 } |
| 325 | 331 |
| 326 // Ensure that a finished animation is eventually deleted by both the | 332 // Ensure that a finished animation is eventually deleted by both the |
| 327 // main-thread and the impl-thread controllers. | 333 // main-thread and the impl-thread controllers. |
| 328 TEST(LayerAnimationControllerTest, AnimationsAreDeleted) { | 334 TEST(LayerAnimationControllerTest, AnimationsAreDeleted) { |
| 329 FakeLayerAnimationValueObserver dummy; | 335 FakeLayerAnimationValueObserver dummy; |
| 330 FakeLayerAnimationValueObserver dummy_impl; | 336 FakeLayerAnimationValueObserver dummy_impl; |
| 331 scoped_ptr<AnimationEventsVector> events( | 337 scoped_ptr<AnimationEventsVector> events( |
| 332 make_scoped_ptr(new AnimationEventsVector)); | 338 make_scoped_ptr(new AnimationEventsVector)); |
| 333 scoped_refptr<LayerAnimationController> controller( | 339 scoped_refptr<LayerAnimationController> controller( |
| 334 LayerAnimationController::Create(0)); | 340 LayerAnimationController::Create(0)); |
| 335 scoped_refptr<LayerAnimationController> controller_impl( | 341 scoped_refptr<LayerAnimationController> controller_impl( |
| 336 LayerAnimationController::Create(0)); | 342 LayerAnimationController::Create(0)); |
| 337 controller->AddValueObserver(&dummy); | 343 controller->AddValueObserver(&dummy); |
| 338 controller_impl->AddValueObserver(&dummy_impl); | 344 controller_impl->AddValueObserver(&dummy_impl); |
| 339 | 345 |
| 340 AddOpacityTransitionToController(controller.get(), 1.0, 0.0f, 1.0f, false); | 346 AddOpacityTransitionToController(controller.get(), 1.0, 0.0f, 1.0f, false); |
| 341 controller->Animate(kInitialTickTime); | 347 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 342 controller->UpdateState(true, NULL); | 348 controller->UpdateState(true, NULL); |
| 343 controller->PushAnimationUpdatesTo(controller_impl.get()); | 349 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 344 | 350 |
| 345 controller_impl->Animate(kInitialTickTime + 0.5); | 351 controller_impl->Animate(GetTimeTicks(kInitialTickTime + 0.5)); |
| 346 controller_impl->UpdateState(true, events.get()); | 352 controller_impl->UpdateState(true, events.get()); |
| 347 | 353 |
| 348 // There should be a Started event for the animation. | 354 // There should be a Started event for the animation. |
| 349 EXPECT_EQ(1u, events->size()); | 355 EXPECT_EQ(1u, events->size()); |
| 350 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); | 356 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); |
| 351 controller->NotifyAnimationStarted((*events)[0]); | 357 controller->NotifyAnimationStarted((*events)[0]); |
| 352 | 358 |
| 353 controller->Animate(kInitialTickTime + 1.0); | 359 controller->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 354 controller->UpdateState(true, NULL); | 360 controller->UpdateState(true, NULL); |
| 355 | 361 |
| 356 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 362 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); |
| 357 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); | 363 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); |
| 358 | 364 |
| 359 events.reset(new AnimationEventsVector); | 365 events.reset(new AnimationEventsVector); |
| 360 controller_impl->Animate(kInitialTickTime + 2.0); | 366 controller_impl->Animate(GetTimeTicks(kInitialTickTime + 2.0)); |
| 361 controller_impl->UpdateState(true, events.get()); | 367 controller_impl->UpdateState(true, events.get()); |
| 362 | 368 |
| 363 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); | 369 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); |
| 364 | 370 |
| 365 // There should be a Finished event for the animation. | 371 // There should be a Finished event for the animation. |
| 366 EXPECT_EQ(1u, events->size()); | 372 EXPECT_EQ(1u, events->size()); |
| 367 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); | 373 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
| 368 | 374 |
| 369 // Neither controller should have deleted the animation yet. | 375 // Neither controller should have deleted the animation yet. |
| 370 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); | 376 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); |
| 371 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity)); | 377 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity)); |
| 372 | 378 |
| 373 controller->NotifyAnimationFinished((*events)[0]); | 379 controller->NotifyAnimationFinished((*events)[0]); |
| 374 | 380 |
| 375 controller->Animate(kInitialTickTime + 3.0); | 381 controller->Animate(GetTimeTicks(kInitialTickTime + 3.0)); |
| 376 controller->UpdateState(true, NULL); | 382 controller->UpdateState(true, NULL); |
| 377 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 383 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
| 378 | 384 |
| 379 controller->PushAnimationUpdatesTo(controller_impl.get()); | 385 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 380 | 386 |
| 381 // Both controllers should now have deleted the animation. | 387 // Both controllers should now have deleted the animation. |
| 382 EXPECT_FALSE(controller->has_any_animation()); | 388 EXPECT_FALSE(controller->has_any_animation()); |
| 383 EXPECT_FALSE(controller_impl->has_any_animation()); | 389 EXPECT_FALSE(controller_impl->has_any_animation()); |
| 384 } | 390 } |
| 385 | 391 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 402 scoped_refptr<LayerAnimationController> controller( | 408 scoped_refptr<LayerAnimationController> controller( |
| 403 LayerAnimationController::Create(0)); | 409 LayerAnimationController::Create(0)); |
| 404 controller->AddValueObserver(&dummy); | 410 controller->AddValueObserver(&dummy); |
| 405 | 411 |
| 406 scoped_ptr<Animation> to_add(CreateAnimation( | 412 scoped_ptr<Animation> to_add(CreateAnimation( |
| 407 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 413 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 408 1, | 414 1, |
| 409 Animation::Opacity)); | 415 Animation::Opacity)); |
| 410 | 416 |
| 411 controller->AddAnimation(to_add.Pass()); | 417 controller->AddAnimation(to_add.Pass()); |
| 412 controller->Animate(kInitialTickTime); | 418 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 413 controller->UpdateState(true, events.get()); | 419 controller->UpdateState(true, events.get()); |
| 414 EXPECT_TRUE(controller->HasActiveAnimation()); | 420 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 415 EXPECT_EQ(0.f, dummy.opacity()); | 421 EXPECT_EQ(0.f, dummy.opacity()); |
| 416 // A non-impl-only animation should not generate property updates. | 422 // A non-impl-only animation should not generate property updates. |
| 417 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 423 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 418 EXPECT_FALSE(event); | 424 EXPECT_FALSE(event); |
| 419 controller->Animate(kInitialTickTime + 1.0); | 425 controller->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 420 controller->UpdateState(true, events.get()); | 426 controller->UpdateState(true, events.get()); |
| 421 EXPECT_EQ(1.f, dummy.opacity()); | 427 EXPECT_EQ(1.f, dummy.opacity()); |
| 422 EXPECT_FALSE(controller->HasActiveAnimation()); | 428 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 423 event = GetMostRecentPropertyUpdateEvent(events.get()); | 429 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 424 EXPECT_FALSE(event); | 430 EXPECT_FALSE(event); |
| 425 } | 431 } |
| 426 | 432 |
| 427 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { | 433 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { |
| 428 scoped_ptr<AnimationEventsVector> events( | 434 scoped_ptr<AnimationEventsVector> events( |
| 429 make_scoped_ptr(new AnimationEventsVector)); | 435 make_scoped_ptr(new AnimationEventsVector)); |
| 430 FakeLayerAnimationValueObserver dummy_impl; | 436 FakeLayerAnimationValueObserver dummy_impl; |
| 431 scoped_refptr<LayerAnimationController> controller_impl( | 437 scoped_refptr<LayerAnimationController> controller_impl( |
| 432 LayerAnimationController::Create(0)); | 438 LayerAnimationController::Create(0)); |
| 433 controller_impl->AddValueObserver(&dummy_impl); | 439 controller_impl->AddValueObserver(&dummy_impl); |
| 434 | 440 |
| 435 scoped_ptr<Animation> to_add(CreateAnimation( | 441 scoped_ptr<Animation> to_add(CreateAnimation( |
| 436 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 442 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 437 1, | 443 1, |
| 438 Animation::Opacity)); | 444 Animation::Opacity)); |
| 439 to_add->set_is_impl_only(true); | 445 to_add->set_is_impl_only(true); |
| 440 | 446 |
| 441 controller_impl->AddAnimation(to_add.Pass()); | 447 controller_impl->AddAnimation(to_add.Pass()); |
| 442 controller_impl->Animate(kInitialTickTime); | 448 controller_impl->Animate(GetTimeTicks(kInitialTickTime)); |
| 443 controller_impl->UpdateState(true, events.get()); | 449 controller_impl->UpdateState(true, events.get()); |
| 444 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 450 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
| 445 EXPECT_EQ(0.f, dummy_impl.opacity()); | 451 EXPECT_EQ(0.f, dummy_impl.opacity()); |
| 446 EXPECT_EQ(2u, events->size()); | 452 EXPECT_EQ(2u, events->size()); |
| 447 const AnimationEvent* start_opacity_event = | 453 const AnimationEvent* start_opacity_event = |
| 448 GetMostRecentPropertyUpdateEvent(events.get()); | 454 GetMostRecentPropertyUpdateEvent(events.get()); |
| 449 EXPECT_EQ(0.f, start_opacity_event->opacity); | 455 EXPECT_EQ(0.f, start_opacity_event->opacity); |
| 450 | 456 |
| 451 controller_impl->Animate(kInitialTickTime + 1.0); | 457 controller_impl->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 452 controller_impl->UpdateState(true, events.get()); | 458 controller_impl->UpdateState(true, events.get()); |
| 453 EXPECT_EQ(1.f, dummy_impl.opacity()); | 459 EXPECT_EQ(1.f, dummy_impl.opacity()); |
| 454 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 460 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
| 455 EXPECT_EQ(4u, events->size()); | 461 EXPECT_EQ(4u, events->size()); |
| 456 const AnimationEvent* end_opacity_event = | 462 const AnimationEvent* end_opacity_event = |
| 457 GetMostRecentPropertyUpdateEvent(events.get()); | 463 GetMostRecentPropertyUpdateEvent(events.get()); |
| 458 EXPECT_EQ(1.f, end_opacity_event->opacity); | 464 EXPECT_EQ(1.f, end_opacity_event->opacity); |
| 459 } | 465 } |
| 460 | 466 |
| 461 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) { | 467 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 481 operations.AppendTranslate(delta_x, delta_y, 0); | 487 operations.AppendTranslate(delta_x, delta_y, 0); |
| 482 curve->AddKeyframe( | 488 curve->AddKeyframe( |
| 483 TransformKeyframe::Create(1, operations, scoped_ptr<TimingFunction>())); | 489 TransformKeyframe::Create(1, operations, scoped_ptr<TimingFunction>())); |
| 484 | 490 |
| 485 scoped_ptr<Animation> animation(Animation::Create( | 491 scoped_ptr<Animation> animation(Animation::Create( |
| 486 curve.PassAs<AnimationCurve>(), 1, 0, Animation::Transform)); | 492 curve.PassAs<AnimationCurve>(), 1, 0, Animation::Transform)); |
| 487 animation->set_is_impl_only(true); | 493 animation->set_is_impl_only(true); |
| 488 controller_impl->AddAnimation(animation.Pass()); | 494 controller_impl->AddAnimation(animation.Pass()); |
| 489 | 495 |
| 490 // Run animation. | 496 // Run animation. |
| 491 controller_impl->Animate(kInitialTickTime); | 497 controller_impl->Animate(GetTimeTicks(kInitialTickTime)); |
| 492 controller_impl->UpdateState(true, events.get()); | 498 controller_impl->UpdateState(true, events.get()); |
| 493 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 499 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
| 494 EXPECT_EQ(gfx::Transform(), dummy_impl.transform()); | 500 EXPECT_EQ(gfx::Transform(), dummy_impl.transform()); |
| 495 EXPECT_EQ(2u, events->size()); | 501 EXPECT_EQ(2u, events->size()); |
| 496 const AnimationEvent* start_transform_event = | 502 const AnimationEvent* start_transform_event = |
| 497 GetMostRecentPropertyUpdateEvent(events.get()); | 503 GetMostRecentPropertyUpdateEvent(events.get()); |
| 498 ASSERT_TRUE(start_transform_event); | 504 ASSERT_TRUE(start_transform_event); |
| 499 EXPECT_EQ(gfx::Transform(), start_transform_event->transform); | 505 EXPECT_EQ(gfx::Transform(), start_transform_event->transform); |
| 500 EXPECT_TRUE(start_transform_event->is_impl_only); | 506 EXPECT_TRUE(start_transform_event->is_impl_only); |
| 501 | 507 |
| 502 gfx::Transform expected_transform; | 508 gfx::Transform expected_transform; |
| 503 expected_transform.Translate(delta_x, delta_y); | 509 expected_transform.Translate(delta_x, delta_y); |
| 504 | 510 |
| 505 controller_impl->Animate(kInitialTickTime + 1.0); | 511 controller_impl->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 506 controller_impl->UpdateState(true, events.get()); | 512 controller_impl->UpdateState(true, events.get()); |
| 507 EXPECT_EQ(expected_transform, dummy_impl.transform()); | 513 EXPECT_EQ(expected_transform, dummy_impl.transform()); |
| 508 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 514 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
| 509 EXPECT_EQ(4u, events->size()); | 515 EXPECT_EQ(4u, events->size()); |
| 510 const AnimationEvent* end_transform_event = | 516 const AnimationEvent* end_transform_event = |
| 511 GetMostRecentPropertyUpdateEvent(events.get()); | 517 GetMostRecentPropertyUpdateEvent(events.get()); |
| 512 EXPECT_EQ(expected_transform, end_transform_event->transform); | 518 EXPECT_EQ(expected_transform, end_transform_event->transform); |
| 513 EXPECT_TRUE(end_transform_event->is_impl_only); | 519 EXPECT_TRUE(end_transform_event->is_impl_only); |
| 514 } | 520 } |
| 515 | 521 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 530 FilterKeyframe::Create(0, start_filters, scoped_ptr<TimingFunction>())); | 536 FilterKeyframe::Create(0, start_filters, scoped_ptr<TimingFunction>())); |
| 531 FilterOperations end_filters; | 537 FilterOperations end_filters; |
| 532 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); | 538 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); |
| 533 curve->AddKeyframe( | 539 curve->AddKeyframe( |
| 534 FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>())); | 540 FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>())); |
| 535 | 541 |
| 536 scoped_ptr<Animation> animation(Animation::Create( | 542 scoped_ptr<Animation> animation(Animation::Create( |
| 537 curve.PassAs<AnimationCurve>(), 1, 0, Animation::Filter)); | 543 curve.PassAs<AnimationCurve>(), 1, 0, Animation::Filter)); |
| 538 controller->AddAnimation(animation.Pass()); | 544 controller->AddAnimation(animation.Pass()); |
| 539 | 545 |
| 540 controller->Animate(kInitialTickTime); | 546 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 541 controller->UpdateState(true, events.get()); | 547 controller->UpdateState(true, events.get()); |
| 542 EXPECT_TRUE(controller->HasActiveAnimation()); | 548 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 543 EXPECT_EQ(start_filters, dummy.filters()); | 549 EXPECT_EQ(start_filters, dummy.filters()); |
| 544 // A non-impl-only animation should not generate property updates. | 550 // A non-impl-only animation should not generate property updates. |
| 545 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 551 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 546 EXPECT_FALSE(event); | 552 EXPECT_FALSE(event); |
| 547 | 553 |
| 548 controller->Animate(kInitialTickTime + 0.5); | 554 controller->Animate(GetTimeTicks(kInitialTickTime + 0.5)); |
| 549 controller->UpdateState(true, events.get()); | 555 controller->UpdateState(true, events.get()); |
| 550 EXPECT_EQ(1u, dummy.filters().size()); | 556 EXPECT_EQ(1u, dummy.filters().size()); |
| 551 EXPECT_EQ(FilterOperation::CreateBrightnessFilter(1.5f), | 557 EXPECT_EQ(FilterOperation::CreateBrightnessFilter(1.5f), |
| 552 dummy.filters().at(0)); | 558 dummy.filters().at(0)); |
| 553 event = GetMostRecentPropertyUpdateEvent(events.get()); | 559 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 554 EXPECT_FALSE(event); | 560 EXPECT_FALSE(event); |
| 555 | 561 |
| 556 controller->Animate(kInitialTickTime + 1.0); | 562 controller->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 557 controller->UpdateState(true, events.get()); | 563 controller->UpdateState(true, events.get()); |
| 558 EXPECT_EQ(end_filters, dummy.filters()); | 564 EXPECT_EQ(end_filters, dummy.filters()); |
| 559 EXPECT_FALSE(controller->HasActiveAnimation()); | 565 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 560 event = GetMostRecentPropertyUpdateEvent(events.get()); | 566 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 561 EXPECT_FALSE(event); | 567 EXPECT_FALSE(event); |
| 562 } | 568 } |
| 563 | 569 |
| 564 TEST(LayerAnimationControllerTest, FilterTransitionOnImplOnly) { | 570 TEST(LayerAnimationControllerTest, FilterTransitionOnImplOnly) { |
| 565 scoped_ptr<AnimationEventsVector> events( | 571 scoped_ptr<AnimationEventsVector> events( |
| 566 make_scoped_ptr(new AnimationEventsVector)); | 572 make_scoped_ptr(new AnimationEventsVector)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 581 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); | 587 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); |
| 582 curve->AddKeyframe( | 588 curve->AddKeyframe( |
| 583 FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>())); | 589 FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>())); |
| 584 | 590 |
| 585 scoped_ptr<Animation> animation(Animation::Create( | 591 scoped_ptr<Animation> animation(Animation::Create( |
| 586 curve.PassAs<AnimationCurve>(), 1, 0, Animation::Filter)); | 592 curve.PassAs<AnimationCurve>(), 1, 0, Animation::Filter)); |
| 587 animation->set_is_impl_only(true); | 593 animation->set_is_impl_only(true); |
| 588 controller_impl->AddAnimation(animation.Pass()); | 594 controller_impl->AddAnimation(animation.Pass()); |
| 589 | 595 |
| 590 // Run animation. | 596 // Run animation. |
| 591 controller_impl->Animate(kInitialTickTime); | 597 controller_impl->Animate(GetTimeTicks(kInitialTickTime)); |
| 592 controller_impl->UpdateState(true, events.get()); | 598 controller_impl->UpdateState(true, events.get()); |
| 593 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 599 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
| 594 EXPECT_EQ(start_filters, dummy_impl.filters()); | 600 EXPECT_EQ(start_filters, dummy_impl.filters()); |
| 595 EXPECT_EQ(2u, events->size()); | 601 EXPECT_EQ(2u, events->size()); |
| 596 const AnimationEvent* start_filter_event = | 602 const AnimationEvent* start_filter_event = |
| 597 GetMostRecentPropertyUpdateEvent(events.get()); | 603 GetMostRecentPropertyUpdateEvent(events.get()); |
| 598 EXPECT_TRUE(start_filter_event); | 604 EXPECT_TRUE(start_filter_event); |
| 599 EXPECT_EQ(start_filters, start_filter_event->filters); | 605 EXPECT_EQ(start_filters, start_filter_event->filters); |
| 600 EXPECT_TRUE(start_filter_event->is_impl_only); | 606 EXPECT_TRUE(start_filter_event->is_impl_only); |
| 601 | 607 |
| 602 controller_impl->Animate(kInitialTickTime + 1.0); | 608 controller_impl->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 603 controller_impl->UpdateState(true, events.get()); | 609 controller_impl->UpdateState(true, events.get()); |
| 604 EXPECT_EQ(end_filters, dummy_impl.filters()); | 610 EXPECT_EQ(end_filters, dummy_impl.filters()); |
| 605 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 611 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
| 606 EXPECT_EQ(4u, events->size()); | 612 EXPECT_EQ(4u, events->size()); |
| 607 const AnimationEvent* end_filter_event = | 613 const AnimationEvent* end_filter_event = |
| 608 GetMostRecentPropertyUpdateEvent(events.get()); | 614 GetMostRecentPropertyUpdateEvent(events.get()); |
| 609 EXPECT_TRUE(end_filter_event); | 615 EXPECT_TRUE(end_filter_event); |
| 610 EXPECT_EQ(end_filters, end_filter_event->filters); | 616 EXPECT_EQ(end_filters, end_filter_event->filters); |
| 611 EXPECT_TRUE(end_filter_event->is_impl_only); | 617 EXPECT_TRUE(end_filter_event->is_impl_only); |
| 612 } | 618 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 642 dummy_provider_impl.set_scroll_offset(initial_value); | 648 dummy_provider_impl.set_scroll_offset(initial_value); |
| 643 controller->PushAnimationUpdatesTo(controller_impl.get()); | 649 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 644 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); | 650 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); |
| 645 double duration = controller_impl->GetAnimation( | 651 double duration = controller_impl->GetAnimation( |
| 646 Animation::ScrollOffset)->curve()->Duration(); | 652 Animation::ScrollOffset)->curve()->Duration(); |
| 647 | 653 |
| 648 EXPECT_EQ( | 654 EXPECT_EQ( |
| 649 duration, | 655 duration, |
| 650 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); | 656 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); |
| 651 | 657 |
| 652 controller->Animate(kInitialTickTime); | 658 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 653 controller->UpdateState(true, NULL); | 659 controller->UpdateState(true, NULL); |
| 654 EXPECT_TRUE(controller->HasActiveAnimation()); | 660 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 655 EXPECT_EQ(initial_value, dummy.scroll_offset()); | 661 EXPECT_EQ(initial_value, dummy.scroll_offset()); |
| 656 | 662 |
| 657 controller_impl->Animate(kInitialTickTime); | 663 controller_impl->Animate(GetTimeTicks(kInitialTickTime)); |
| 658 controller_impl->UpdateState(true, events.get()); | 664 controller_impl->UpdateState(true, events.get()); |
| 659 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 665 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
| 660 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 666 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
| 661 // Scroll offset animations should not generate property updates. | 667 // Scroll offset animations should not generate property updates. |
| 662 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 668 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 663 EXPECT_FALSE(event); | 669 EXPECT_FALSE(event); |
| 664 | 670 |
| 665 controller->NotifyAnimationStarted((*events)[0]); | 671 controller->NotifyAnimationStarted((*events)[0]); |
| 666 controller->Animate(kInitialTickTime + duration/2.0); | 672 controller->Animate(GetTimeTicks(kInitialTickTime + dur) ation / 2.0); |
| 667 controller->UpdateState(true, NULL); | 673 controller->UpdateState(true, NULL); |
| 668 EXPECT_TRUE(controller->HasActiveAnimation()); | 674 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 669 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), dummy.scroll_offset()); | 675 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), dummy.scroll_offset()); |
| 670 | 676 |
| 671 controller_impl->Animate(kInitialTickTime + duration/2.0); | 677 controller_impl->Animate(GetTimeTicks(kInitialTickTime + dur) ation / 2.0); |
| 672 controller_impl->UpdateState(true, events.get()); | 678 controller_impl->UpdateState(true, events.get()); |
| 673 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), | 679 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), |
| 674 dummy_impl.scroll_offset()); | 680 dummy_impl.scroll_offset()); |
| 675 event = GetMostRecentPropertyUpdateEvent(events.get()); | 681 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 676 EXPECT_FALSE(event); | 682 EXPECT_FALSE(event); |
| 677 | 683 |
| 678 controller_impl->Animate(kInitialTickTime + duration); | 684 controller_impl->Animate(GetTimeTicks(kInitialTickTime + dur) ation); |
| 679 controller_impl->UpdateState(true, events.get()); | 685 controller_impl->UpdateState(true, events.get()); |
| 680 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); | 686 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); |
| 681 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 687 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
| 682 event = GetMostRecentPropertyUpdateEvent(events.get()); | 688 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 683 EXPECT_FALSE(event); | 689 EXPECT_FALSE(event); |
| 684 | 690 |
| 685 controller->Animate(kInitialTickTime + duration); | 691 controller->Animate(GetTimeTicks(kInitialTickTime + dur) ation); |
| 686 controller->UpdateState(true, NULL); | 692 controller->UpdateState(true, NULL); |
| 687 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset()); | 693 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset()); |
| 688 EXPECT_FALSE(controller->HasActiveAnimation()); | 694 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 689 } | 695 } |
| 690 | 696 |
| 691 // Ensure that when the impl controller doesn't have a value provider, | 697 // Ensure that when the impl controller doesn't have a value provider, |
| 692 // the main-thread controller's value provider is used to obtain the intial | 698 // the main-thread controller's value provider is used to obtain the intial |
| 693 // scroll offset. | 699 // scroll offset. |
| 694 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionNoImplProvider) { | 700 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionNoImplProvider) { |
| 695 FakeLayerAnimationValueObserver dummy_impl; | 701 FakeLayerAnimationValueObserver dummy_impl; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 720 dummy_provider.set_scroll_offset(initial_value); | 726 dummy_provider.set_scroll_offset(initial_value); |
| 721 controller->PushAnimationUpdatesTo(controller_impl.get()); | 727 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 722 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); | 728 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); |
| 723 double duration = controller_impl->GetAnimation( | 729 double duration = controller_impl->GetAnimation( |
| 724 Animation::ScrollOffset)->curve()->Duration(); | 730 Animation::ScrollOffset)->curve()->Duration(); |
| 725 | 731 |
| 726 EXPECT_EQ( | 732 EXPECT_EQ( |
| 727 duration, | 733 duration, |
| 728 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); | 734 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); |
| 729 | 735 |
| 730 controller->Animate(kInitialTickTime); | 736 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 731 controller->UpdateState(true, NULL); | 737 controller->UpdateState(true, NULL); |
| 732 EXPECT_TRUE(controller->HasActiveAnimation()); | 738 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 733 EXPECT_EQ(initial_value, dummy.scroll_offset()); | 739 EXPECT_EQ(initial_value, dummy.scroll_offset()); |
| 734 | 740 |
| 735 controller_impl->Animate(kInitialTickTime); | 741 controller_impl->Animate(GetTimeTicks(kInitialTickTime)); |
| 736 controller_impl->UpdateState(true, events.get()); | 742 controller_impl->UpdateState(true, events.get()); |
| 737 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 743 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
| 738 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 744 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
| 739 // Scroll offset animations should not generate property updates. | 745 // Scroll offset animations should not generate property updates. |
| 740 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 746 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 741 EXPECT_FALSE(event); | 747 EXPECT_FALSE(event); |
| 742 | 748 |
| 743 controller->NotifyAnimationStarted((*events)[0]); | 749 controller->NotifyAnimationStarted((*events)[0]); |
| 744 controller->Animate(kInitialTickTime + duration/2.0); | 750 controller->Animate(GetTimeTicks(kInitialTickTime + dur) ation / 2.0); |
| 745 controller->UpdateState(true, NULL); | 751 controller->UpdateState(true, NULL); |
| 746 EXPECT_TRUE(controller->HasActiveAnimation()); | 752 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 747 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), dummy.scroll_offset()); | 753 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), dummy.scroll_offset()); |
| 748 | 754 |
| 749 controller_impl->Animate(kInitialTickTime + duration/2.0); | 755 controller_impl->Animate(GetTimeTicks(kInitialTickTime + dur) ation / 2.0); |
| 750 controller_impl->UpdateState(true, events.get()); | 756 controller_impl->UpdateState(true, events.get()); |
| 751 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), | 757 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), |
| 752 dummy_impl.scroll_offset()); | 758 dummy_impl.scroll_offset()); |
| 753 event = GetMostRecentPropertyUpdateEvent(events.get()); | 759 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 754 EXPECT_FALSE(event); | 760 EXPECT_FALSE(event); |
| 755 | 761 |
| 756 controller_impl->Animate(kInitialTickTime + duration); | 762 controller_impl->Animate(GetTimeTicks(kInitialTickTime + dur) ation); |
| 757 controller_impl->UpdateState(true, events.get()); | 763 controller_impl->UpdateState(true, events.get()); |
| 758 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); | 764 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); |
| 759 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 765 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
| 760 event = GetMostRecentPropertyUpdateEvent(events.get()); | 766 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 761 EXPECT_FALSE(event); | 767 EXPECT_FALSE(event); |
| 762 | 768 |
| 763 controller->Animate(kInitialTickTime + duration); | 769 controller->Animate(GetTimeTicks(kInitialTickTime + dur) ation); |
| 764 controller->UpdateState(true, NULL); | 770 controller->UpdateState(true, NULL); |
| 765 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset()); | 771 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset()); |
| 766 EXPECT_FALSE(controller->HasActiveAnimation()); | 772 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 767 } | 773 } |
| 768 | 774 |
| 769 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionOnImplOnly) { | 775 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionOnImplOnly) { |
| 770 FakeLayerAnimationValueObserver dummy_impl; | 776 FakeLayerAnimationValueObserver dummy_impl; |
| 771 scoped_refptr<LayerAnimationController> controller_impl( | 777 scoped_refptr<LayerAnimationController> controller_impl( |
| 772 LayerAnimationController::Create(0)); | 778 LayerAnimationController::Create(0)); |
| 773 controller_impl->AddValueObserver(&dummy_impl); | 779 controller_impl->AddValueObserver(&dummy_impl); |
| 774 scoped_ptr<AnimationEventsVector> events( | 780 scoped_ptr<AnimationEventsVector> events( |
| 775 make_scoped_ptr(new AnimationEventsVector)); | 781 make_scoped_ptr(new AnimationEventsVector)); |
| 776 | 782 |
| 777 gfx::Vector2dF initial_value(100.f, 300.f); | 783 gfx::Vector2dF initial_value(100.f, 300.f); |
| 778 gfx::Vector2dF target_value(300.f, 200.f); | 784 gfx::Vector2dF target_value(300.f, 200.f); |
| 779 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 785 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
| 780 ScrollOffsetAnimationCurve::Create( | 786 ScrollOffsetAnimationCurve::Create( |
| 781 target_value, | 787 target_value, |
| 782 EaseInOutTimingFunction::Create().Pass())); | 788 EaseInOutTimingFunction::Create().Pass())); |
| 783 curve->SetInitialValue(initial_value); | 789 curve->SetInitialValue(initial_value); |
| 784 double duration = curve->Duration(); | 790 double duration = curve->Duration(); |
| 785 | 791 |
| 786 scoped_ptr<Animation> animation(Animation::Create( | 792 scoped_ptr<Animation> animation(Animation::Create( |
| 787 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); | 793 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); |
| 788 animation->set_is_impl_only(true); | 794 animation->set_is_impl_only(true); |
| 789 controller_impl->AddAnimation(animation.Pass()); | 795 controller_impl->AddAnimation(animation.Pass()); |
| 790 | 796 |
| 791 controller_impl->Animate(kInitialTickTime); | 797 controller_impl->Animate(GetTimeTicks(kInitialTickTime)); |
| 792 controller_impl->UpdateState(true, events.get()); | 798 controller_impl->UpdateState(true, events.get()); |
| 793 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 799 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
| 794 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 800 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
| 795 // Scroll offset animations should not generate property updates. | 801 // Scroll offset animations should not generate property updates. |
| 796 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 802 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 797 EXPECT_FALSE(event); | 803 EXPECT_FALSE(event); |
| 798 | 804 |
| 799 controller_impl->Animate(kInitialTickTime + duration/2.0); | 805 controller_impl->Animate(GetTimeTicks(kInitialTickTime + dur) ation / 2.0); |
| 800 controller_impl->UpdateState(true, events.get()); | 806 controller_impl->UpdateState(true, events.get()); |
| 801 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), | 807 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), |
| 802 dummy_impl.scroll_offset()); | 808 dummy_impl.scroll_offset()); |
| 803 event = GetMostRecentPropertyUpdateEvent(events.get()); | 809 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 804 EXPECT_FALSE(event); | 810 EXPECT_FALSE(event); |
| 805 | 811 |
| 806 controller_impl->Animate(kInitialTickTime + duration); | 812 controller_impl->Animate(GetTimeTicks(kInitialTickTime + dur) ation); |
| 807 controller_impl->UpdateState(true, events.get()); | 813 controller_impl->UpdateState(true, events.get()); |
| 808 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); | 814 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); |
| 809 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 815 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
| 810 event = GetMostRecentPropertyUpdateEvent(events.get()); | 816 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 811 EXPECT_FALSE(event); | 817 EXPECT_FALSE(event); |
| 812 } | 818 } |
| 813 | 819 |
| 814 class FakeAnimationDelegate : public AnimationDelegate { | 820 class FakeAnimationDelegate : public AnimationDelegate { |
| 815 public: | 821 public: |
| 816 FakeAnimationDelegate() | 822 FakeAnimationDelegate() |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 FakeAnimationDelegate delegate; | 861 FakeAnimationDelegate delegate; |
| 856 controller->set_layer_animation_delegate(&delegate); | 862 controller->set_layer_animation_delegate(&delegate); |
| 857 | 863 |
| 858 scoped_ptr<Animation> to_add(CreateAnimation( | 864 scoped_ptr<Animation> to_add(CreateAnimation( |
| 859 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 865 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 860 1, | 866 1, |
| 861 Animation::Opacity)); | 867 Animation::Opacity)); |
| 862 to_add->set_is_impl_only(true); | 868 to_add->set_is_impl_only(true); |
| 863 controller_impl->AddAnimation(to_add.Pass()); | 869 controller_impl->AddAnimation(to_add.Pass()); |
| 864 | 870 |
| 865 controller_impl->Animate(kInitialTickTime); | 871 controller_impl->Animate(GetTimeTicks(kInitialTickTime)); |
| 866 controller_impl->UpdateState(true, events.get()); | 872 controller_impl->UpdateState(true, events.get()); |
| 867 | 873 |
| 868 // We should receive 2 events (a started notification and a property update). | 874 // We should receive 2 events (a started notification and a property update). |
| 869 EXPECT_EQ(2u, events->size()); | 875 EXPECT_EQ(2u, events->size()); |
| 870 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); | 876 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); |
| 871 EXPECT_TRUE((*events)[0].is_impl_only); | 877 EXPECT_TRUE((*events)[0].is_impl_only); |
| 872 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); | 878 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); |
| 873 EXPECT_TRUE((*events)[1].is_impl_only); | 879 EXPECT_TRUE((*events)[1].is_impl_only); |
| 874 | 880 |
| 875 // Passing on the start event to the main thread controller should cause the | 881 // Passing on the start event to the main thread controller should cause the |
| 876 // delegate to get notified. | 882 // delegate to get notified. |
| 877 EXPECT_FALSE(delegate.started()); | 883 EXPECT_FALSE(delegate.started()); |
| 878 controller->NotifyAnimationStarted((*events)[0]); | 884 controller->NotifyAnimationStarted((*events)[0]); |
| 879 EXPECT_TRUE(delegate.started()); | 885 EXPECT_TRUE(delegate.started()); |
| 880 | 886 |
| 881 events.reset(new AnimationEventsVector); | 887 events.reset(new AnimationEventsVector); |
| 882 controller_impl->Animate(kInitialTickTime + 1.0); | 888 controller_impl->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 883 controller_impl->UpdateState(true, events.get()); | 889 controller_impl->UpdateState(true, events.get()); |
| 884 | 890 |
| 885 // We should receive 2 events (a finished notification and a property update). | 891 // We should receive 2 events (a finished notification and a property update). |
| 886 EXPECT_EQ(2u, events->size()); | 892 EXPECT_EQ(2u, events->size()); |
| 887 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); | 893 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
| 888 EXPECT_TRUE((*events)[0].is_impl_only); | 894 EXPECT_TRUE((*events)[0].is_impl_only); |
| 889 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); | 895 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); |
| 890 EXPECT_TRUE((*events)[1].is_impl_only); | 896 EXPECT_TRUE((*events)[1].is_impl_only); |
| 891 | 897 |
| 892 // Passing on the finished event to the main thread controller should cause | 898 // Passing on the finished event to the main thread controller should cause |
| (...skipping 16 matching lines...) Expand all Loading... |
| 909 | 915 |
| 910 scoped_ptr<Animation> to_add(CreateAnimation( | 916 scoped_ptr<Animation> to_add(CreateAnimation( |
| 911 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 917 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 912 1, | 918 1, |
| 913 Animation::Opacity)); | 919 Animation::Opacity)); |
| 914 to_add->set_needs_synchronized_start_time(true); | 920 to_add->set_needs_synchronized_start_time(true); |
| 915 | 921 |
| 916 // We should pause at the first keyframe indefinitely waiting for that | 922 // We should pause at the first keyframe indefinitely waiting for that |
| 917 // animation to start. | 923 // animation to start. |
| 918 controller->AddAnimation(to_add.Pass()); | 924 controller->AddAnimation(to_add.Pass()); |
| 919 controller->Animate(kInitialTickTime); | 925 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 920 controller->UpdateState(true, events.get()); | 926 controller->UpdateState(true, events.get()); |
| 921 EXPECT_TRUE(controller->HasActiveAnimation()); | 927 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 922 EXPECT_EQ(0.f, dummy.opacity()); | 928 EXPECT_EQ(0.f, dummy.opacity()); |
| 923 controller->Animate(kInitialTickTime + 1.0); | 929 controller->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 924 controller->UpdateState(true, events.get()); | 930 controller->UpdateState(true, events.get()); |
| 925 EXPECT_TRUE(controller->HasActiveAnimation()); | 931 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 926 EXPECT_EQ(0.f, dummy.opacity()); | 932 EXPECT_EQ(0.f, dummy.opacity()); |
| 927 controller->Animate(kInitialTickTime + 2.0); | 933 controller->Animate(GetTimeTicks(kInitialTickTime + 2.0)); |
| 928 controller->UpdateState(true, events.get()); | 934 controller->UpdateState(true, events.get()); |
| 929 EXPECT_TRUE(controller->HasActiveAnimation()); | 935 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 930 EXPECT_EQ(0.f, dummy.opacity()); | 936 EXPECT_EQ(0.f, dummy.opacity()); |
| 931 | 937 |
| 932 // Send the synchronized start time. | 938 // Send the synchronized start time. |
| 933 controller->NotifyAnimationStarted(AnimationEvent( | 939 controller->NotifyAnimationStarted( |
| 934 AnimationEvent::Started, 0, 1, Animation::Opacity, kInitialTickTime + 2)); | 940 AnimationEvent(AnimationEvent::Started, |
| 935 controller->Animate(kInitialTickTime + 5.0); | 941 0, |
| 942 1, |
| 943 Animation::Opacity, |
| 944 GetTimeTicks(kInitialTickTime + 2))); |
| 945 controller->Animate(GetTimeTicks(kInitialTickTime + 5.0)); |
| 936 controller->UpdateState(true, events.get()); | 946 controller->UpdateState(true, events.get()); |
| 937 EXPECT_EQ(1.f, dummy.opacity()); | 947 EXPECT_EQ(1.f, dummy.opacity()); |
| 938 EXPECT_FALSE(controller->HasActiveAnimation()); | 948 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 939 } | 949 } |
| 940 | 950 |
| 941 // Tests that two queued animations affecting the same property run in sequence. | 951 // Tests that two queued animations affecting the same property run in sequence. |
| 942 TEST(LayerAnimationControllerTest, TrivialQueuing) { | 952 TEST(LayerAnimationControllerTest, TrivialQueuing) { |
| 943 scoped_ptr<AnimationEventsVector> events( | 953 scoped_ptr<AnimationEventsVector> events( |
| 944 make_scoped_ptr(new AnimationEventsVector)); | 954 make_scoped_ptr(new AnimationEventsVector)); |
| 945 FakeLayerAnimationValueObserver dummy; | 955 FakeLayerAnimationValueObserver dummy; |
| 946 scoped_refptr<LayerAnimationController> controller( | 956 scoped_refptr<LayerAnimationController> controller( |
| 947 LayerAnimationController::Create(0)); | 957 LayerAnimationController::Create(0)); |
| 948 controller->AddValueObserver(&dummy); | 958 controller->AddValueObserver(&dummy); |
| 949 | 959 |
| 950 controller->AddAnimation(CreateAnimation( | 960 controller->AddAnimation(CreateAnimation( |
| 951 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 961 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 952 1, | 962 1, |
| 953 Animation::Opacity)); | 963 Animation::Opacity)); |
| 954 controller->AddAnimation(CreateAnimation( | 964 controller->AddAnimation(CreateAnimation( |
| 955 scoped_ptr<AnimationCurve>( | 965 scoped_ptr<AnimationCurve>( |
| 956 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), | 966 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), |
| 957 2, | 967 2, |
| 958 Animation::Opacity)); | 968 Animation::Opacity)); |
| 959 | 969 |
| 960 controller->Animate(kInitialTickTime); | 970 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 961 controller->UpdateState(true, events.get()); | 971 controller->UpdateState(true, events.get()); |
| 962 EXPECT_TRUE(controller->HasActiveAnimation()); | 972 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 963 EXPECT_EQ(0.f, dummy.opacity()); | 973 EXPECT_EQ(0.f, dummy.opacity()); |
| 964 controller->Animate(kInitialTickTime + 1.0); | 974 controller->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 965 controller->UpdateState(true, events.get()); | 975 controller->UpdateState(true, events.get()); |
| 966 EXPECT_TRUE(controller->HasActiveAnimation()); | 976 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 967 EXPECT_EQ(1.f, dummy.opacity()); | 977 EXPECT_EQ(1.f, dummy.opacity()); |
| 968 controller->Animate(kInitialTickTime + 2.0); | 978 controller->Animate(GetTimeTicks(kInitialTickTime + 2.0)); |
| 969 controller->UpdateState(true, events.get()); | 979 controller->UpdateState(true, events.get()); |
| 970 EXPECT_EQ(0.5f, dummy.opacity()); | 980 EXPECT_EQ(0.5f, dummy.opacity()); |
| 971 EXPECT_FALSE(controller->HasActiveAnimation()); | 981 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 972 } | 982 } |
| 973 | 983 |
| 974 // Tests interrupting a transition with another transition. | 984 // Tests interrupting a transition with another transition. |
| 975 TEST(LayerAnimationControllerTest, Interrupt) { | 985 TEST(LayerAnimationControllerTest, Interrupt) { |
| 976 scoped_ptr<AnimationEventsVector> events( | 986 scoped_ptr<AnimationEventsVector> events( |
| 977 make_scoped_ptr(new AnimationEventsVector)); | 987 make_scoped_ptr(new AnimationEventsVector)); |
| 978 FakeLayerAnimationValueObserver dummy; | 988 FakeLayerAnimationValueObserver dummy; |
| 979 scoped_refptr<LayerAnimationController> controller( | 989 scoped_refptr<LayerAnimationController> controller( |
| 980 LayerAnimationController::Create(0)); | 990 LayerAnimationController::Create(0)); |
| 981 controller->AddValueObserver(&dummy); | 991 controller->AddValueObserver(&dummy); |
| 982 controller->AddAnimation(CreateAnimation( | 992 controller->AddAnimation(CreateAnimation( |
| 983 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 993 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 984 1, | 994 1, |
| 985 Animation::Opacity)); | 995 Animation::Opacity)); |
| 986 controller->Animate(kInitialTickTime); | 996 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 987 controller->UpdateState(true, events.get()); | 997 controller->UpdateState(true, events.get()); |
| 988 EXPECT_TRUE(controller->HasActiveAnimation()); | 998 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 989 EXPECT_EQ(0.f, dummy.opacity()); | 999 EXPECT_EQ(0.f, dummy.opacity()); |
| 990 | 1000 |
| 991 scoped_ptr<Animation> to_add(CreateAnimation( | 1001 scoped_ptr<Animation> to_add(CreateAnimation( |
| 992 scoped_ptr<AnimationCurve>( | 1002 scoped_ptr<AnimationCurve>( |
| 993 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), | 1003 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), |
| 994 2, | 1004 2, |
| 995 Animation::Opacity)); | 1005 Animation::Opacity)); |
| 996 controller->AbortAnimations(Animation::Opacity); | 1006 controller->AbortAnimations(Animation::Opacity); |
| 997 controller->AddAnimation(to_add.Pass()); | 1007 controller->AddAnimation(to_add.Pass()); |
| 998 | 1008 |
| 999 // Since the previous animation was aborted, the new animation should start | 1009 // Since the previous animation was aborted, the new animation should start |
| 1000 // right in this call to animate. | 1010 // right in this call to animate. |
| 1001 controller->Animate(kInitialTickTime + 0.5); | 1011 controller->Animate(GetTimeTicks(kInitialTickTime + 0.5)); |
| 1002 controller->UpdateState(true, events.get()); | 1012 controller->UpdateState(true, events.get()); |
| 1003 EXPECT_TRUE(controller->HasActiveAnimation()); | 1013 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1004 EXPECT_EQ(1.f, dummy.opacity()); | 1014 EXPECT_EQ(1.f, dummy.opacity()); |
| 1005 controller->Animate(kInitialTickTime + 1.5); | 1015 controller->Animate(GetTimeTicks(kInitialTickTime + 1.5)); |
| 1006 controller->UpdateState(true, events.get()); | 1016 controller->UpdateState(true, events.get()); |
| 1007 EXPECT_EQ(0.5f, dummy.opacity()); | 1017 EXPECT_EQ(0.5f, dummy.opacity()); |
| 1008 EXPECT_FALSE(controller->HasActiveAnimation()); | 1018 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 1009 } | 1019 } |
| 1010 | 1020 |
| 1011 // Tests scheduling two animations to run together when only one property is | 1021 // Tests scheduling two animations to run together when only one property is |
| 1012 // free. | 1022 // free. |
| 1013 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { | 1023 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { |
| 1014 scoped_ptr<AnimationEventsVector> events( | 1024 scoped_ptr<AnimationEventsVector> events( |
| 1015 make_scoped_ptr(new AnimationEventsVector)); | 1025 make_scoped_ptr(new AnimationEventsVector)); |
| 1016 FakeLayerAnimationValueObserver dummy; | 1026 FakeLayerAnimationValueObserver dummy; |
| 1017 scoped_refptr<LayerAnimationController> controller( | 1027 scoped_refptr<LayerAnimationController> controller( |
| 1018 LayerAnimationController::Create(0)); | 1028 LayerAnimationController::Create(0)); |
| 1019 controller->AddValueObserver(&dummy); | 1029 controller->AddValueObserver(&dummy); |
| 1020 | 1030 |
| 1021 controller->AddAnimation(CreateAnimation( | 1031 controller->AddAnimation(CreateAnimation( |
| 1022 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), | 1032 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), |
| 1023 1, | 1033 1, |
| 1024 Animation::Transform)); | 1034 Animation::Transform)); |
| 1025 controller->AddAnimation(CreateAnimation( | 1035 controller->AddAnimation(CreateAnimation( |
| 1026 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), | 1036 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), |
| 1027 2, | 1037 2, |
| 1028 Animation::Transform)); | 1038 Animation::Transform)); |
| 1029 controller->AddAnimation(CreateAnimation( | 1039 controller->AddAnimation(CreateAnimation( |
| 1030 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1040 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 1031 2, | 1041 2, |
| 1032 Animation::Opacity)); | 1042 Animation::Opacity)); |
| 1033 | 1043 |
| 1034 controller->Animate(kInitialTickTime); | 1044 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 1035 controller->UpdateState(true, events.get()); | 1045 controller->UpdateState(true, events.get()); |
| 1036 EXPECT_EQ(0.f, dummy.opacity()); | 1046 EXPECT_EQ(0.f, dummy.opacity()); |
| 1037 EXPECT_TRUE(controller->HasActiveAnimation()); | 1047 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1038 controller->Animate(kInitialTickTime + 1.0); | 1048 controller->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 1039 controller->UpdateState(true, events.get()); | 1049 controller->UpdateState(true, events.get()); |
| 1040 // Should not have started the float transition yet. | 1050 // Should not have started the float transition yet. |
| 1041 EXPECT_TRUE(controller->HasActiveAnimation()); | 1051 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1042 EXPECT_EQ(0.f, dummy.opacity()); | 1052 EXPECT_EQ(0.f, dummy.opacity()); |
| 1043 // The float animation should have started at time 1 and should be done. | 1053 // The float animation should have started at time 1 and should be done. |
| 1044 controller->Animate(kInitialTickTime + 2.0); | 1054 controller->Animate(GetTimeTicks(kInitialTickTime + 2.0)); |
| 1045 controller->UpdateState(true, events.get()); | 1055 controller->UpdateState(true, events.get()); |
| 1046 EXPECT_EQ(1.f, dummy.opacity()); | 1056 EXPECT_EQ(1.f, dummy.opacity()); |
| 1047 EXPECT_FALSE(controller->HasActiveAnimation()); | 1057 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 1048 } | 1058 } |
| 1049 | 1059 |
| 1050 // Tests scheduling two animations to run together with different lengths and | 1060 // Tests scheduling two animations to run together with different lengths and |
| 1051 // another animation queued to start when the shorter animation finishes (should | 1061 // another animation queued to start when the shorter animation finishes (should |
| 1052 // wait for both to finish). | 1062 // wait for both to finish). |
| 1053 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { | 1063 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { |
| 1054 scoped_ptr<AnimationEventsVector> events( | 1064 scoped_ptr<AnimationEventsVector> events( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1066 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1076 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 1067 1, | 1077 1, |
| 1068 Animation::Opacity)); | 1078 Animation::Opacity)); |
| 1069 controller->AddAnimation(CreateAnimation( | 1079 controller->AddAnimation(CreateAnimation( |
| 1070 scoped_ptr<AnimationCurve>( | 1080 scoped_ptr<AnimationCurve>( |
| 1071 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), | 1081 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), |
| 1072 2, | 1082 2, |
| 1073 Animation::Opacity)); | 1083 Animation::Opacity)); |
| 1074 | 1084 |
| 1075 // Animations with id 1 should both start now. | 1085 // Animations with id 1 should both start now. |
| 1076 controller->Animate(kInitialTickTime); | 1086 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 1077 controller->UpdateState(true, events.get()); | 1087 controller->UpdateState(true, events.get()); |
| 1078 EXPECT_TRUE(controller->HasActiveAnimation()); | 1088 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1079 EXPECT_EQ(0.f, dummy.opacity()); | 1089 EXPECT_EQ(0.f, dummy.opacity()); |
| 1080 // The opacity animation should have finished at time 1, but the group | 1090 // The opacity animation should have finished at time 1, but the group |
| 1081 // of animations with id 1 don't finish until time 2 because of the length | 1091 // of animations with id 1 don't finish until time 2 because of the length |
| 1082 // of the transform animation. | 1092 // of the transform animation. |
| 1083 controller->Animate(kInitialTickTime + 2.0); | 1093 controller->Animate(GetTimeTicks(kInitialTickTime + 2.0)); |
| 1084 controller->UpdateState(true, events.get()); | 1094 controller->UpdateState(true, events.get()); |
| 1085 // Should not have started the float transition yet. | 1095 // Should not have started the float transition yet. |
| 1086 EXPECT_TRUE(controller->HasActiveAnimation()); | 1096 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1087 EXPECT_EQ(1.f, dummy.opacity()); | 1097 EXPECT_EQ(1.f, dummy.opacity()); |
| 1088 | 1098 |
| 1089 // The second opacity animation should start at time 2 and should be done by | 1099 // The second opacity animation should start at time 2 and should be done by |
| 1090 // time 3. | 1100 // time 3. |
| 1091 controller->Animate(kInitialTickTime + 3.0); | 1101 controller->Animate(GetTimeTicks(kInitialTickTime + 3.0)); |
| 1092 controller->UpdateState(true, events.get()); | 1102 controller->UpdateState(true, events.get()); |
| 1093 EXPECT_EQ(0.5f, dummy.opacity()); | 1103 EXPECT_EQ(0.5f, dummy.opacity()); |
| 1094 EXPECT_FALSE(controller->HasActiveAnimation()); | 1104 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 1095 } | 1105 } |
| 1096 | 1106 |
| 1097 // Test that a looping animation loops and for the correct number of iterations. | 1107 // Test that a looping animation loops and for the correct number of iterations. |
| 1098 TEST(LayerAnimationControllerTest, TrivialLooping) { | 1108 TEST(LayerAnimationControllerTest, TrivialLooping) { |
| 1099 scoped_ptr<AnimationEventsVector> events( | 1109 scoped_ptr<AnimationEventsVector> events( |
| 1100 make_scoped_ptr(new AnimationEventsVector)); | 1110 make_scoped_ptr(new AnimationEventsVector)); |
| 1101 FakeLayerAnimationValueObserver dummy; | 1111 FakeLayerAnimationValueObserver dummy; |
| 1102 scoped_refptr<LayerAnimationController> controller( | 1112 scoped_refptr<LayerAnimationController> controller( |
| 1103 LayerAnimationController::Create(0)); | 1113 LayerAnimationController::Create(0)); |
| 1104 controller->AddValueObserver(&dummy); | 1114 controller->AddValueObserver(&dummy); |
| 1105 | 1115 |
| 1106 scoped_ptr<Animation> to_add(CreateAnimation( | 1116 scoped_ptr<Animation> to_add(CreateAnimation( |
| 1107 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1117 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 1108 1, | 1118 1, |
| 1109 Animation::Opacity)); | 1119 Animation::Opacity)); |
| 1110 to_add->set_iterations(3); | 1120 to_add->set_iterations(3); |
| 1111 controller->AddAnimation(to_add.Pass()); | 1121 controller->AddAnimation(to_add.Pass()); |
| 1112 | 1122 |
| 1113 controller->Animate(kInitialTickTime); | 1123 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 1114 controller->UpdateState(true, events.get()); | 1124 controller->UpdateState(true, events.get()); |
| 1115 EXPECT_TRUE(controller->HasActiveAnimation()); | 1125 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1116 EXPECT_EQ(0.f, dummy.opacity()); | 1126 EXPECT_EQ(0.f, dummy.opacity()); |
| 1117 controller->Animate(kInitialTickTime + 1.25); | 1127 controller->Animate(GetTimeTicks(kInitialTickTime + 1.2)5); |
| 1118 controller->UpdateState(true, events.get()); | 1128 controller->UpdateState(true, events.get()); |
| 1119 EXPECT_TRUE(controller->HasActiveAnimation()); | 1129 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1120 EXPECT_EQ(0.25f, dummy.opacity()); | 1130 EXPECT_EQ(0.25f, dummy.opacity()); |
| 1121 controller->Animate(kInitialTickTime + 1.75); | 1131 controller->Animate(GetTimeTicks(kInitialTickTime + 1.7)5); |
| 1122 controller->UpdateState(true, events.get()); | 1132 controller->UpdateState(true, events.get()); |
| 1123 EXPECT_TRUE(controller->HasActiveAnimation()); | 1133 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1124 EXPECT_EQ(0.75f, dummy.opacity()); | 1134 EXPECT_EQ(0.75f, dummy.opacity()); |
| 1125 controller->Animate(kInitialTickTime + 2.25); | 1135 controller->Animate(GetTimeTicks(kInitialTickTime + 2.2)5); |
| 1126 controller->UpdateState(true, events.get()); | 1136 controller->UpdateState(true, events.get()); |
| 1127 EXPECT_TRUE(controller->HasActiveAnimation()); | 1137 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1128 EXPECT_EQ(0.25f, dummy.opacity()); | 1138 EXPECT_EQ(0.25f, dummy.opacity()); |
| 1129 controller->Animate(kInitialTickTime + 2.75); | 1139 controller->Animate(GetTimeTicks(kInitialTickTime + 2.7)5); |
| 1130 controller->UpdateState(true, events.get()); | 1140 controller->UpdateState(true, events.get()); |
| 1131 EXPECT_TRUE(controller->HasActiveAnimation()); | 1141 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1132 EXPECT_EQ(0.75f, dummy.opacity()); | 1142 EXPECT_EQ(0.75f, dummy.opacity()); |
| 1133 controller->Animate(kInitialTickTime + 3.0); | 1143 controller->Animate(GetTimeTicks(kInitialTickTime + 3.0)); |
| 1134 controller->UpdateState(true, events.get()); | 1144 controller->UpdateState(true, events.get()); |
| 1135 EXPECT_FALSE(controller->HasActiveAnimation()); | 1145 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 1136 EXPECT_EQ(1.f, dummy.opacity()); | 1146 EXPECT_EQ(1.f, dummy.opacity()); |
| 1137 | 1147 |
| 1138 // Just be extra sure. | 1148 // Just be extra sure. |
| 1139 controller->Animate(kInitialTickTime + 4.0); | 1149 controller->Animate(GetTimeTicks(kInitialTickTime + 4.0)); |
| 1140 controller->UpdateState(true, events.get()); | 1150 controller->UpdateState(true, events.get()); |
| 1141 EXPECT_EQ(1.f, dummy.opacity()); | 1151 EXPECT_EQ(1.f, dummy.opacity()); |
| 1142 } | 1152 } |
| 1143 | 1153 |
| 1144 // Test that an infinitely looping animation does indeed go until aborted. | 1154 // Test that an infinitely looping animation does indeed go until aborted. |
| 1145 TEST(LayerAnimationControllerTest, InfiniteLooping) { | 1155 TEST(LayerAnimationControllerTest, InfiniteLooping) { |
| 1146 scoped_ptr<AnimationEventsVector> events( | 1156 scoped_ptr<AnimationEventsVector> events( |
| 1147 make_scoped_ptr(new AnimationEventsVector)); | 1157 make_scoped_ptr(new AnimationEventsVector)); |
| 1148 FakeLayerAnimationValueObserver dummy; | 1158 FakeLayerAnimationValueObserver dummy; |
| 1149 scoped_refptr<LayerAnimationController> controller( | 1159 scoped_refptr<LayerAnimationController> controller( |
| 1150 LayerAnimationController::Create(0)); | 1160 LayerAnimationController::Create(0)); |
| 1151 controller->AddValueObserver(&dummy); | 1161 controller->AddValueObserver(&dummy); |
| 1152 | 1162 |
| 1153 const int id = 1; | 1163 const int id = 1; |
| 1154 scoped_ptr<Animation> to_add(CreateAnimation( | 1164 scoped_ptr<Animation> to_add(CreateAnimation( |
| 1155 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1165 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 1156 id, | 1166 id, |
| 1157 Animation::Opacity)); | 1167 Animation::Opacity)); |
| 1158 to_add->set_iterations(-1); | 1168 to_add->set_iterations(-1); |
| 1159 controller->AddAnimation(to_add.Pass()); | 1169 controller->AddAnimation(to_add.Pass()); |
| 1160 | 1170 |
| 1161 controller->Animate(kInitialTickTime); | 1171 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 1162 controller->UpdateState(true, events.get()); | 1172 controller->UpdateState(true, events.get()); |
| 1163 EXPECT_TRUE(controller->HasActiveAnimation()); | 1173 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1164 EXPECT_EQ(0.f, dummy.opacity()); | 1174 EXPECT_EQ(0.f, dummy.opacity()); |
| 1165 controller->Animate(kInitialTickTime + 1.25); | 1175 controller->Animate(GetTimeTicks(kInitialTickTime + 1.2)5); |
| 1166 controller->UpdateState(true, events.get()); | 1176 controller->UpdateState(true, events.get()); |
| 1167 EXPECT_TRUE(controller->HasActiveAnimation()); | 1177 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1168 EXPECT_EQ(0.25f, dummy.opacity()); | 1178 EXPECT_EQ(0.25f, dummy.opacity()); |
| 1169 controller->Animate(kInitialTickTime + 1.75); | 1179 controller->Animate(GetTimeTicks(kInitialTickTime + 1.7)5); |
| 1170 controller->UpdateState(true, events.get()); | 1180 controller->UpdateState(true, events.get()); |
| 1171 EXPECT_TRUE(controller->HasActiveAnimation()); | 1181 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1172 EXPECT_EQ(0.75f, dummy.opacity()); | 1182 EXPECT_EQ(0.75f, dummy.opacity()); |
| 1173 | 1183 |
| 1174 controller->Animate(kInitialTickTime + 1073741824.25); | 1184 controller->Animate(GetTimeTicks(kInitialTickTime + 107)3741824.25); |
| 1175 controller->UpdateState(true, events.get()); | 1185 controller->UpdateState(true, events.get()); |
| 1176 EXPECT_TRUE(controller->HasActiveAnimation()); | 1186 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1177 EXPECT_EQ(0.25f, dummy.opacity()); | 1187 EXPECT_EQ(0.25f, dummy.opacity()); |
| 1178 controller->Animate(kInitialTickTime + 1073741824.75); | 1188 controller->Animate(GetTimeTicks(kInitialTickTime + 107)3741824.75); |
| 1179 controller->UpdateState(true, events.get()); | 1189 controller->UpdateState(true, events.get()); |
| 1180 EXPECT_TRUE(controller->HasActiveAnimation()); | 1190 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1181 EXPECT_EQ(0.75f, dummy.opacity()); | 1191 EXPECT_EQ(0.75f, dummy.opacity()); |
| 1182 | 1192 |
| 1183 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); | 1193 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); |
| 1184 controller->GetAnimation(id, Animation::Opacity)->SetRunState( | 1194 controller->GetAnimation(id, Animation::Opacity) |
| 1185 Animation::Aborted, kInitialTickTime + 0.75); | 1195 ->SetRunState(Animation::Aborted, GetTimeTicks(kInitialTickTime + 0.7)5); |
| 1186 EXPECT_FALSE(controller->HasActiveAnimation()); | 1196 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 1187 EXPECT_EQ(0.75f, dummy.opacity()); | 1197 EXPECT_EQ(0.75f, dummy.opacity()); |
| 1188 } | 1198 } |
| 1189 | 1199 |
| 1190 // Test that pausing and resuming work as expected. | 1200 // Test that pausing and resuming work as expected. |
| 1191 TEST(LayerAnimationControllerTest, PauseResume) { | 1201 TEST(LayerAnimationControllerTest, PauseResume) { |
| 1192 scoped_ptr<AnimationEventsVector> events( | 1202 scoped_ptr<AnimationEventsVector> events( |
| 1193 make_scoped_ptr(new AnimationEventsVector)); | 1203 make_scoped_ptr(new AnimationEventsVector)); |
| 1194 FakeLayerAnimationValueObserver dummy; | 1204 FakeLayerAnimationValueObserver dummy; |
| 1195 scoped_refptr<LayerAnimationController> controller( | 1205 scoped_refptr<LayerAnimationController> controller( |
| 1196 LayerAnimationController::Create(0)); | 1206 LayerAnimationController::Create(0)); |
| 1197 controller->AddValueObserver(&dummy); | 1207 controller->AddValueObserver(&dummy); |
| 1198 | 1208 |
| 1199 const int id = 1; | 1209 const int id = 1; |
| 1200 controller->AddAnimation(CreateAnimation( | 1210 controller->AddAnimation(CreateAnimation( |
| 1201 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1211 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 1202 id, | 1212 id, |
| 1203 Animation::Opacity)); | 1213 Animation::Opacity)); |
| 1204 | 1214 |
| 1205 controller->Animate(kInitialTickTime); | 1215 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 1206 controller->UpdateState(true, events.get()); | 1216 controller->UpdateState(true, events.get()); |
| 1207 EXPECT_TRUE(controller->HasActiveAnimation()); | 1217 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1208 EXPECT_EQ(0.f, dummy.opacity()); | 1218 EXPECT_EQ(0.f, dummy.opacity()); |
| 1209 controller->Animate(kInitialTickTime + 0.5); | 1219 controller->Animate(GetTimeTicks(kInitialTickTime + 0.5)); |
| 1210 controller->UpdateState(true, events.get()); | 1220 controller->UpdateState(true, events.get()); |
| 1211 EXPECT_TRUE(controller->HasActiveAnimation()); | 1221 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1212 EXPECT_EQ(0.5f, dummy.opacity()); | 1222 EXPECT_EQ(0.5f, dummy.opacity()); |
| 1213 | 1223 |
| 1214 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); | 1224 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); |
| 1215 controller->GetAnimation(id, Animation::Opacity)->SetRunState( | 1225 controller->GetAnimation(id, Animation::Opacity) |
| 1216 Animation::Paused, kInitialTickTime + 0.5); | 1226 ->SetRunState(Animation::Paused, GetTimeTicks(kInitialTickTime + 0.5)); |
| 1217 | 1227 |
| 1218 controller->Animate(kInitialTickTime + 1024.0); | 1228 controller->Animate(GetTimeTicks(kInitialTickTime + 102)4.0); |
| 1219 controller->UpdateState(true, events.get()); | 1229 controller->UpdateState(true, events.get()); |
| 1220 EXPECT_TRUE(controller->HasActiveAnimation()); | 1230 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1221 EXPECT_EQ(0.5f, dummy.opacity()); | 1231 EXPECT_EQ(0.5f, dummy.opacity()); |
| 1222 | 1232 |
| 1223 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); | 1233 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); |
| 1224 controller->GetAnimation(id, Animation::Opacity)->SetRunState( | 1234 controller->GetAnimation(id, Animation::Opacity) |
| 1225 Animation::Running, kInitialTickTime + 1024); | 1235 ->SetRunState(Animation::Running, GetTimeTicks(kInitialTickTime + 102)4); |
| 1226 | 1236 |
| 1227 controller->Animate(kInitialTickTime + 1024.25); | 1237 controller->Animate(GetTimeTicks(kInitialTickTime + 102)4.25); |
| 1228 controller->UpdateState(true, events.get()); | 1238 controller->UpdateState(true, events.get()); |
| 1229 EXPECT_TRUE(controller->HasActiveAnimation()); | 1239 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1230 EXPECT_EQ(0.75f, dummy.opacity()); | 1240 EXPECT_EQ(0.75f, dummy.opacity()); |
| 1231 controller->Animate(kInitialTickTime + 1024.5); | 1241 controller->Animate(GetTimeTicks(kInitialTickTime + 102)4.5); |
| 1232 controller->UpdateState(true, events.get()); | 1242 controller->UpdateState(true, events.get()); |
| 1233 EXPECT_FALSE(controller->HasActiveAnimation()); | 1243 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 1234 EXPECT_EQ(1.f, dummy.opacity()); | 1244 EXPECT_EQ(1.f, dummy.opacity()); |
| 1235 } | 1245 } |
| 1236 | 1246 |
| 1237 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { | 1247 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { |
| 1238 scoped_ptr<AnimationEventsVector> events( | 1248 scoped_ptr<AnimationEventsVector> events( |
| 1239 make_scoped_ptr(new AnimationEventsVector)); | 1249 make_scoped_ptr(new AnimationEventsVector)); |
| 1240 FakeLayerAnimationValueObserver dummy; | 1250 FakeLayerAnimationValueObserver dummy; |
| 1241 scoped_refptr<LayerAnimationController> controller( | 1251 scoped_refptr<LayerAnimationController> controller( |
| 1242 LayerAnimationController::Create(0)); | 1252 LayerAnimationController::Create(0)); |
| 1243 controller->AddValueObserver(&dummy); | 1253 controller->AddValueObserver(&dummy); |
| 1244 | 1254 |
| 1245 const int id = 1; | 1255 const int id = 1; |
| 1246 controller->AddAnimation(CreateAnimation( | 1256 controller->AddAnimation(CreateAnimation( |
| 1247 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), | 1257 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), |
| 1248 id, | 1258 id, |
| 1249 Animation::Transform)); | 1259 Animation::Transform)); |
| 1250 controller->AddAnimation(CreateAnimation( | 1260 controller->AddAnimation(CreateAnimation( |
| 1251 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), | 1261 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), |
| 1252 id, | 1262 id, |
| 1253 Animation::Opacity)); | 1263 Animation::Opacity)); |
| 1254 controller->AddAnimation(CreateAnimation( | 1264 controller->AddAnimation(CreateAnimation( |
| 1255 scoped_ptr<AnimationCurve>( | 1265 scoped_ptr<AnimationCurve>( |
| 1256 new FakeFloatTransition(1.0, 1.f, 0.75f)).Pass(), | 1266 new FakeFloatTransition(1.0, 1.f, 0.75f)).Pass(), |
| 1257 2, | 1267 2, |
| 1258 Animation::Opacity)); | 1268 Animation::Opacity)); |
| 1259 | 1269 |
| 1260 controller->Animate(kInitialTickTime); | 1270 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 1261 controller->UpdateState(true, events.get()); | 1271 controller->UpdateState(true, events.get()); |
| 1262 EXPECT_TRUE(controller->HasActiveAnimation()); | 1272 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1263 EXPECT_EQ(0.f, dummy.opacity()); | 1273 EXPECT_EQ(0.f, dummy.opacity()); |
| 1264 controller->Animate(kInitialTickTime + 1.0); | 1274 controller->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 1265 controller->UpdateState(true, events.get()); | 1275 controller->UpdateState(true, events.get()); |
| 1266 EXPECT_TRUE(controller->HasActiveAnimation()); | 1276 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1267 EXPECT_EQ(0.5f, dummy.opacity()); | 1277 EXPECT_EQ(0.5f, dummy.opacity()); |
| 1268 | 1278 |
| 1269 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); | 1279 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); |
| 1270 controller->GetAnimation(id, Animation::Opacity)->SetRunState( | 1280 controller->GetAnimation(id, Animation::Opacity) |
| 1271 Animation::Aborted, kInitialTickTime + 1.0); | 1281 ->SetRunState(Animation::Aborted, GetTimeTicks(kInitialTickTime + 1.0)); |
| 1272 controller->Animate(kInitialTickTime + 1.0); | 1282 controller->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 1273 controller->UpdateState(true, events.get()); | 1283 controller->UpdateState(true, events.get()); |
| 1274 EXPECT_TRUE(controller->HasActiveAnimation()); | 1284 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1275 EXPECT_EQ(1.f, dummy.opacity()); | 1285 EXPECT_EQ(1.f, dummy.opacity()); |
| 1276 controller->Animate(kInitialTickTime + 2.0); | 1286 controller->Animate(GetTimeTicks(kInitialTickTime + 2.0)); |
| 1277 controller->UpdateState(true, events.get()); | 1287 controller->UpdateState(true, events.get()); |
| 1278 EXPECT_TRUE(!controller->HasActiveAnimation()); | 1288 EXPECT_TRUE(!controller->HasActiveAnimation()); |
| 1279 EXPECT_EQ(0.75f, dummy.opacity()); | 1289 EXPECT_EQ(0.75f, dummy.opacity()); |
| 1280 } | 1290 } |
| 1281 | 1291 |
| 1282 TEST(LayerAnimationControllerTest, PushUpdatesWhenSynchronizedStartTimeNeeded) { | 1292 TEST(LayerAnimationControllerTest, PushUpdatesWhenSynchronizedStartTimeNeeded) { |
| 1283 FakeLayerAnimationValueObserver dummy_impl; | 1293 FakeLayerAnimationValueObserver dummy_impl; |
| 1284 scoped_refptr<LayerAnimationController> controller_impl( | 1294 scoped_refptr<LayerAnimationController> controller_impl( |
| 1285 LayerAnimationController::Create(0)); | 1295 LayerAnimationController::Create(0)); |
| 1286 controller_impl->AddValueObserver(&dummy_impl); | 1296 controller_impl->AddValueObserver(&dummy_impl); |
| 1287 scoped_ptr<AnimationEventsVector> events( | 1297 scoped_ptr<AnimationEventsVector> events( |
| 1288 make_scoped_ptr(new AnimationEventsVector)); | 1298 make_scoped_ptr(new AnimationEventsVector)); |
| 1289 FakeLayerAnimationValueObserver dummy; | 1299 FakeLayerAnimationValueObserver dummy; |
| 1290 scoped_refptr<LayerAnimationController> controller( | 1300 scoped_refptr<LayerAnimationController> controller( |
| 1291 LayerAnimationController::Create(0)); | 1301 LayerAnimationController::Create(0)); |
| 1292 controller->AddValueObserver(&dummy); | 1302 controller->AddValueObserver(&dummy); |
| 1293 | 1303 |
| 1294 scoped_ptr<Animation> to_add(CreateAnimation( | 1304 scoped_ptr<Animation> to_add(CreateAnimation( |
| 1295 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), | 1305 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), |
| 1296 0, | 1306 0, |
| 1297 Animation::Opacity)); | 1307 Animation::Opacity)); |
| 1298 to_add->set_needs_synchronized_start_time(true); | 1308 to_add->set_needs_synchronized_start_time(true); |
| 1299 controller->AddAnimation(to_add.Pass()); | 1309 controller->AddAnimation(to_add.Pass()); |
| 1300 | 1310 |
| 1301 controller->Animate(kInitialTickTime); | 1311 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 1302 controller->UpdateState(true, events.get()); | 1312 controller->UpdateState(true, events.get()); |
| 1303 EXPECT_TRUE(controller->HasActiveAnimation()); | 1313 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1304 Animation* active_animation = controller->GetAnimation(0, Animation::Opacity); | 1314 Animation* active_animation = controller->GetAnimation(0, Animation::Opacity); |
| 1305 EXPECT_TRUE(active_animation); | 1315 EXPECT_TRUE(active_animation); |
| 1306 EXPECT_TRUE(active_animation->needs_synchronized_start_time()); | 1316 EXPECT_TRUE(active_animation->needs_synchronized_start_time()); |
| 1307 | 1317 |
| 1308 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1318 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1309 | 1319 |
| 1310 active_animation = controller_impl->GetAnimation(0, Animation::Opacity); | 1320 active_animation = controller_impl->GetAnimation(0, Animation::Opacity); |
| 1311 EXPECT_TRUE(active_animation); | 1321 EXPECT_TRUE(active_animation); |
| 1312 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 1322 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
| 1313 active_animation->run_state()); | 1323 active_animation->run_state()); |
| 1314 } | 1324 } |
| 1315 | 1325 |
| 1316 // Tests that skipping a call to UpdateState works as expected. | 1326 // Tests that skipping a call to UpdateState works as expected. |
| 1317 TEST(LayerAnimationControllerTest, SkipUpdateState) { | 1327 TEST(LayerAnimationControllerTest, SkipUpdateState) { |
| 1318 scoped_ptr<AnimationEventsVector> events( | 1328 scoped_ptr<AnimationEventsVector> events( |
| 1319 make_scoped_ptr(new AnimationEventsVector)); | 1329 make_scoped_ptr(new AnimationEventsVector)); |
| 1320 FakeLayerAnimationValueObserver dummy; | 1330 FakeLayerAnimationValueObserver dummy; |
| 1321 scoped_refptr<LayerAnimationController> controller( | 1331 scoped_refptr<LayerAnimationController> controller( |
| 1322 LayerAnimationController::Create(0)); | 1332 LayerAnimationController::Create(0)); |
| 1323 controller->AddValueObserver(&dummy); | 1333 controller->AddValueObserver(&dummy); |
| 1324 | 1334 |
| 1325 controller->AddAnimation(CreateAnimation( | 1335 controller->AddAnimation(CreateAnimation( |
| 1326 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), | 1336 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), |
| 1327 1, | 1337 1, |
| 1328 Animation::Transform)); | 1338 Animation::Transform)); |
| 1329 | 1339 |
| 1330 controller->Animate(kInitialTickTime); | 1340 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 1331 controller->UpdateState(true, events.get()); | 1341 controller->UpdateState(true, events.get()); |
| 1332 | 1342 |
| 1333 controller->AddAnimation(CreateAnimation( | 1343 controller->AddAnimation(CreateAnimation( |
| 1334 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1344 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 1335 2, | 1345 2, |
| 1336 Animation::Opacity)); | 1346 Animation::Opacity)); |
| 1337 | 1347 |
| 1338 // Animate but don't UpdateState. | 1348 // Animate but don't UpdateState. |
| 1339 controller->Animate(kInitialTickTime + 1.0); | 1349 controller->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 1340 | 1350 |
| 1341 controller->Animate(kInitialTickTime + 2.0); | 1351 controller->Animate(GetTimeTicks(kInitialTickTime + 2.0)); |
| 1342 events.reset(new AnimationEventsVector); | 1352 events.reset(new AnimationEventsVector); |
| 1343 controller->UpdateState(true, events.get()); | 1353 controller->UpdateState(true, events.get()); |
| 1344 | 1354 |
| 1345 // Should have one Started event and one Finished event. | 1355 // Should have one Started event and one Finished event. |
| 1346 EXPECT_EQ(2u, events->size()); | 1356 EXPECT_EQ(2u, events->size()); |
| 1347 EXPECT_NE((*events)[0].type, (*events)[1].type); | 1357 EXPECT_NE((*events)[0].type, (*events)[1].type); |
| 1348 | 1358 |
| 1349 // The float transition should still be at its starting point. | 1359 // The float transition should still be at its starting point. |
| 1350 EXPECT_TRUE(controller->HasActiveAnimation()); | 1360 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1351 EXPECT_EQ(0.f, dummy.opacity()); | 1361 EXPECT_EQ(0.f, dummy.opacity()); |
| 1352 | 1362 |
| 1353 controller->Animate(kInitialTickTime + 3.0); | 1363 controller->Animate(GetTimeTicks(kInitialTickTime + 3.0)); |
| 1354 controller->UpdateState(true, events.get()); | 1364 controller->UpdateState(true, events.get()); |
| 1355 | 1365 |
| 1356 // The float tranisition should now be done. | 1366 // The float tranisition should now be done. |
| 1357 EXPECT_EQ(1.f, dummy.opacity()); | 1367 EXPECT_EQ(1.f, dummy.opacity()); |
| 1358 EXPECT_FALSE(controller->HasActiveAnimation()); | 1368 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 1359 } | 1369 } |
| 1360 | 1370 |
| 1361 // Tests that an animation controller with only an inactive observer gets ticked | 1371 // Tests that an animation controller with only an inactive observer gets ticked |
| 1362 // but doesn't progress animations past the Starting state. | 1372 // but doesn't progress animations past the Starting state. |
| 1363 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { | 1373 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { |
| 1364 scoped_ptr<AnimationEventsVector> events( | 1374 scoped_ptr<AnimationEventsVector> events( |
| 1365 make_scoped_ptr(new AnimationEventsVector)); | 1375 make_scoped_ptr(new AnimationEventsVector)); |
| 1366 FakeLayerAnimationValueObserver dummy; | 1376 FakeLayerAnimationValueObserver dummy; |
| 1367 FakeInactiveLayerAnimationValueObserver inactive_dummy; | 1377 FakeInactiveLayerAnimationValueObserver inactive_dummy; |
| 1368 scoped_refptr<LayerAnimationController> controller( | 1378 scoped_refptr<LayerAnimationController> controller( |
| 1369 LayerAnimationController::Create(0)); | 1379 LayerAnimationController::Create(0)); |
| 1370 | 1380 |
| 1371 const int id = 1; | 1381 const int id = 1; |
| 1372 controller->AddAnimation(CreateAnimation(scoped_ptr<AnimationCurve>( | 1382 controller->AddAnimation(CreateAnimation(scoped_ptr<AnimationCurve>( |
| 1373 new FakeFloatTransition(1.0, 0.5f, 1.f)).Pass(), | 1383 new FakeFloatTransition(1.0, 0.5f, 1.f)).Pass(), |
| 1374 id, | 1384 id, |
| 1375 Animation::Opacity)); | 1385 Animation::Opacity)); |
| 1376 | 1386 |
| 1377 // Without an observer, the animation shouldn't progress to the Starting | 1387 // Without an observer, the animation shouldn't progress to the Starting |
| 1378 // state. | 1388 // state. |
| 1379 controller->Animate(kInitialTickTime); | 1389 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 1380 controller->UpdateState(true, events.get()); | 1390 controller->UpdateState(true, events.get()); |
| 1381 EXPECT_EQ(0u, events->size()); | 1391 EXPECT_EQ(0u, events->size()); |
| 1382 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 1392 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
| 1383 controller->GetAnimation(id, Animation::Opacity)->run_state()); | 1393 controller->GetAnimation(id, Animation::Opacity)->run_state()); |
| 1384 | 1394 |
| 1385 controller->AddValueObserver(&inactive_dummy); | 1395 controller->AddValueObserver(&inactive_dummy); |
| 1386 | 1396 |
| 1387 // With only an inactive observer, the animation should progress to the | 1397 // With only an inactive observer, the animation should progress to the |
| 1388 // Starting state and get ticked at its starting point, but should not | 1398 // Starting state and get ticked at its starting point, but should not |
| 1389 // progress to Running. | 1399 // progress to Running. |
| 1390 controller->Animate(kInitialTickTime + 1.0); | 1400 controller->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 1391 controller->UpdateState(true, events.get()); | 1401 controller->UpdateState(true, events.get()); |
| 1392 EXPECT_EQ(0u, events->size()); | 1402 EXPECT_EQ(0u, events->size()); |
| 1393 EXPECT_EQ(Animation::Starting, | 1403 EXPECT_EQ(Animation::Starting, |
| 1394 controller->GetAnimation(id, Animation::Opacity)->run_state()); | 1404 controller->GetAnimation(id, Animation::Opacity)->run_state()); |
| 1395 EXPECT_EQ(0.5f, inactive_dummy.opacity()); | 1405 EXPECT_EQ(0.5f, inactive_dummy.opacity()); |
| 1396 | 1406 |
| 1397 // Even when already in the Starting state, the animation should stay | 1407 // Even when already in the Starting state, the animation should stay |
| 1398 // there, and shouldn't be ticked past its starting point. | 1408 // there, and shouldn't be ticked past its starting point. |
| 1399 controller->Animate(kInitialTickTime + 2.0); | 1409 controller->Animate(GetTimeTicks(kInitialTickTime + 2.0)); |
| 1400 controller->UpdateState(true, events.get()); | 1410 controller->UpdateState(true, events.get()); |
| 1401 EXPECT_EQ(0u, events->size()); | 1411 EXPECT_EQ(0u, events->size()); |
| 1402 EXPECT_EQ(Animation::Starting, | 1412 EXPECT_EQ(Animation::Starting, |
| 1403 controller->GetAnimation(id, Animation::Opacity)->run_state()); | 1413 controller->GetAnimation(id, Animation::Opacity)->run_state()); |
| 1404 EXPECT_EQ(0.5f, inactive_dummy.opacity()); | 1414 EXPECT_EQ(0.5f, inactive_dummy.opacity()); |
| 1405 | 1415 |
| 1406 controller->AddValueObserver(&dummy); | 1416 controller->AddValueObserver(&dummy); |
| 1407 | 1417 |
| 1408 // Now that an active observer has been added, the animation should still | 1418 // Now that an active observer has been added, the animation should still |
| 1409 // initially tick at its starting point, but should now progress to Running. | 1419 // initially tick at its starting point, but should now progress to Running. |
| 1410 controller->Animate(kInitialTickTime + 3.0); | 1420 controller->Animate(GetTimeTicks(kInitialTickTime + 3.0)); |
| 1411 controller->UpdateState(true, events.get()); | 1421 controller->UpdateState(true, events.get()); |
| 1412 EXPECT_EQ(1u, events->size()); | 1422 EXPECT_EQ(1u, events->size()); |
| 1413 EXPECT_EQ(Animation::Running, | 1423 EXPECT_EQ(Animation::Running, |
| 1414 controller->GetAnimation(id, Animation::Opacity)->run_state()); | 1424 controller->GetAnimation(id, Animation::Opacity)->run_state()); |
| 1415 EXPECT_EQ(0.5f, inactive_dummy.opacity()); | 1425 EXPECT_EQ(0.5f, inactive_dummy.opacity()); |
| 1416 EXPECT_EQ(0.5f, dummy.opacity()); | 1426 EXPECT_EQ(0.5f, dummy.opacity()); |
| 1417 | 1427 |
| 1418 // The animation should now tick past its starting point. | 1428 // The animation should now tick past its starting point. |
| 1419 controller->Animate(kInitialTickTime + 3.5); | 1429 controller->Animate(GetTimeTicks(kInitialTickTime + 3.5)); |
| 1420 EXPECT_NE(0.5f, inactive_dummy.opacity()); | 1430 EXPECT_NE(0.5f, inactive_dummy.opacity()); |
| 1421 EXPECT_NE(0.5f, dummy.opacity()); | 1431 EXPECT_NE(0.5f, dummy.opacity()); |
| 1422 } | 1432 } |
| 1423 | 1433 |
| 1424 TEST(LayerAnimationControllerTest, TransformAnimationBounds) { | 1434 TEST(LayerAnimationControllerTest, TransformAnimationBounds) { |
| 1425 scoped_refptr<LayerAnimationController> controller_impl( | 1435 scoped_refptr<LayerAnimationController> controller_impl( |
| 1426 LayerAnimationController::Create(0)); | 1436 LayerAnimationController::Create(0)); |
| 1427 | 1437 |
| 1428 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1438 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
| 1429 KeyframedTransformAnimationCurve::Create()); | 1439 KeyframedTransformAnimationCurve::Create()); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 Animation::Transform)); | 1525 Animation::Transform)); |
| 1516 controller->AddAnimation(CreateAnimation( | 1526 controller->AddAnimation(CreateAnimation( |
| 1517 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), | 1527 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), |
| 1518 4, | 1528 4, |
| 1519 Animation::Transform)); | 1529 Animation::Transform)); |
| 1520 controller->AddAnimation(CreateAnimation( | 1530 controller->AddAnimation(CreateAnimation( |
| 1521 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1531 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 1522 5, | 1532 5, |
| 1523 Animation::Opacity)); | 1533 Animation::Opacity)); |
| 1524 | 1534 |
| 1525 controller->Animate(kInitialTickTime); | 1535 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 1526 controller->UpdateState(true, NULL); | 1536 controller->UpdateState(true, NULL); |
| 1527 controller->Animate(kInitialTickTime + 1.0); | 1537 controller->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 1528 controller->UpdateState(true, NULL); | 1538 controller->UpdateState(true, NULL); |
| 1529 | 1539 |
| 1530 EXPECT_EQ(Animation::Finished, | 1540 EXPECT_EQ(Animation::Finished, |
| 1531 controller->GetAnimation(1, Animation::Transform)->run_state()); | 1541 controller->GetAnimation(1, Animation::Transform)->run_state()); |
| 1532 EXPECT_EQ(Animation::Finished, | 1542 EXPECT_EQ(Animation::Finished, |
| 1533 controller->GetAnimation(2, Animation::Opacity)->run_state()); | 1543 controller->GetAnimation(2, Animation::Opacity)->run_state()); |
| 1534 EXPECT_EQ(Animation::Running, | 1544 EXPECT_EQ(Animation::Running, |
| 1535 controller->GetAnimation(3, Animation::Transform)->run_state()); | 1545 controller->GetAnimation(3, Animation::Transform)->run_state()); |
| 1536 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 1546 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
| 1537 controller->GetAnimation(4, Animation::Transform)->run_state()); | 1547 controller->GetAnimation(4, Animation::Transform)->run_state()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 | 1579 |
| 1570 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1580 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1571 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 1581 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
| 1572 | 1582 |
| 1573 controller->AbortAnimations(Animation::Opacity); | 1583 controller->AbortAnimations(Animation::Opacity); |
| 1574 EXPECT_EQ(Animation::Aborted, | 1584 EXPECT_EQ(Animation::Aborted, |
| 1575 controller->GetAnimation(Animation::Opacity)->run_state()); | 1585 controller->GetAnimation(Animation::Opacity)->run_state()); |
| 1576 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 1586 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); |
| 1577 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); | 1587 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); |
| 1578 | 1588 |
| 1579 controller->Animate(kInitialTickTime); | 1589 controller->Animate(GetTimeTicks(kInitialTickTime)); |
| 1580 controller->UpdateState(true, NULL); | 1590 controller->UpdateState(true, NULL); |
| 1581 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 1591 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
| 1582 EXPECT_EQ(Animation::WaitingForDeletion, | 1592 EXPECT_EQ(Animation::WaitingForDeletion, |
| 1583 controller->GetAnimation(Animation::Opacity)->run_state()); | 1593 controller->GetAnimation(Animation::Opacity)->run_state()); |
| 1584 | 1594 |
| 1585 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1595 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1586 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity)); | 1596 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity)); |
| 1587 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 1597 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
| 1588 } | 1598 } |
| 1589 | 1599 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1604 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1614 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1605 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 1615 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
| 1606 | 1616 |
| 1607 controller_impl->AbortAnimations(Animation::Opacity); | 1617 controller_impl->AbortAnimations(Animation::Opacity); |
| 1608 EXPECT_EQ(Animation::Aborted, | 1618 EXPECT_EQ(Animation::Aborted, |
| 1609 controller_impl->GetAnimation(Animation::Opacity)->run_state()); | 1619 controller_impl->GetAnimation(Animation::Opacity)->run_state()); |
| 1610 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 1620 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); |
| 1611 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); | 1621 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); |
| 1612 | 1622 |
| 1613 AnimationEventsVector events; | 1623 AnimationEventsVector events; |
| 1614 controller_impl->Animate(kInitialTickTime); | 1624 controller_impl->Animate(GetTimeTicks(kInitialTickTime)); |
| 1615 controller_impl->UpdateState(true, &events); | 1625 controller_impl->UpdateState(true, &events); |
| 1616 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); | 1626 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); |
| 1617 EXPECT_EQ(1u, events.size()); | 1627 EXPECT_EQ(1u, events.size()); |
| 1618 EXPECT_EQ(AnimationEvent::Aborted, events[0].type); | 1628 EXPECT_EQ(AnimationEvent::Aborted, events[0].type); |
| 1619 EXPECT_EQ(Animation::WaitingForDeletion, | 1629 EXPECT_EQ(Animation::WaitingForDeletion, |
| 1620 controller_impl->GetAnimation(Animation::Opacity)->run_state()); | 1630 controller_impl->GetAnimation(Animation::Opacity)->run_state()); |
| 1621 | 1631 |
| 1622 controller->NotifyAnimationAborted(events[0]); | 1632 controller->NotifyAnimationAborted(events[0]); |
| 1623 EXPECT_EQ(Animation::Aborted, | 1633 EXPECT_EQ(Animation::Aborted, |
| 1624 controller->GetAnimation(Animation::Opacity)->run_state()); | 1634 controller->GetAnimation(Animation::Opacity)->run_state()); |
| 1625 | 1635 |
| 1626 controller->Animate(kInitialTickTime + 0.5); | 1636 controller->Animate(GetTimeTicks(kInitialTickTime + 0.5)); |
| 1627 controller->UpdateState(true, NULL); | 1637 controller->UpdateState(true, NULL); |
| 1628 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 1638 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
| 1629 EXPECT_EQ(Animation::WaitingForDeletion, | 1639 EXPECT_EQ(Animation::WaitingForDeletion, |
| 1630 controller->GetAnimation(Animation::Opacity)->run_state()); | 1640 controller->GetAnimation(Animation::Opacity)->run_state()); |
| 1631 | 1641 |
| 1632 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1642 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1633 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity)); | 1643 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity)); |
| 1634 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 1644 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
| 1635 } | 1645 } |
| 1636 | 1646 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1647 // Add two animations with the same group id but different durations. | 1657 // Add two animations with the same group id but different durations. |
| 1648 controller_impl->AddAnimation(CreateAnimation( | 1658 controller_impl->AddAnimation(CreateAnimation( |
| 1649 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), | 1659 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), |
| 1650 1, | 1660 1, |
| 1651 Animation::Transform)); | 1661 Animation::Transform)); |
| 1652 controller_impl->AddAnimation(CreateAnimation( | 1662 controller_impl->AddAnimation(CreateAnimation( |
| 1653 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1663 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 1654 1, | 1664 1, |
| 1655 Animation::Opacity)); | 1665 Animation::Opacity)); |
| 1656 | 1666 |
| 1657 controller_impl->Animate(kInitialTickTime); | 1667 controller_impl->Animate(GetTimeTicks(kInitialTickTime)); |
| 1658 controller_impl->UpdateState(true, events.get()); | 1668 controller_impl->UpdateState(true, events.get()); |
| 1659 | 1669 |
| 1660 // Both animations should have started. | 1670 // Both animations should have started. |
| 1661 EXPECT_EQ(2u, events->size()); | 1671 EXPECT_EQ(2u, events->size()); |
| 1662 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); | 1672 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); |
| 1663 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); | 1673 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); |
| 1664 | 1674 |
| 1665 events.reset(new AnimationEventsVector); | 1675 events.reset(new AnimationEventsVector); |
| 1666 controller_impl->Animate(kInitialTickTime + 1.0); | 1676 controller_impl->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 1667 controller_impl->UpdateState(true, events.get()); | 1677 controller_impl->UpdateState(true, events.get()); |
| 1668 | 1678 |
| 1669 // The opacity animation should be finished, but should not have generated | 1679 // The opacity animation should be finished, but should not have generated |
| 1670 // a Finished event yet. | 1680 // a Finished event yet. |
| 1671 EXPECT_EQ(0u, events->size()); | 1681 EXPECT_EQ(0u, events->size()); |
| 1672 EXPECT_EQ(Animation::Finished, | 1682 EXPECT_EQ(Animation::Finished, |
| 1673 controller_impl->GetAnimation(1, Animation::Opacity)->run_state()); | 1683 controller_impl->GetAnimation(1, Animation::Opacity)->run_state()); |
| 1674 EXPECT_EQ(Animation::Running, | 1684 EXPECT_EQ(Animation::Running, |
| 1675 controller_impl->GetAnimation(1, | 1685 controller_impl->GetAnimation(1, |
| 1676 Animation::Transform)->run_state()); | 1686 Animation::Transform)->run_state()); |
| 1677 | 1687 |
| 1678 controller_impl->Animate(kInitialTickTime + 2.0); | 1688 controller_impl->Animate(GetTimeTicks(kInitialTickTime + 2.0)); |
| 1679 controller_impl->UpdateState(true, events.get()); | 1689 controller_impl->UpdateState(true, events.get()); |
| 1680 | 1690 |
| 1681 // Both animations should have generated Finished events. | 1691 // Both animations should have generated Finished events. |
| 1682 EXPECT_EQ(2u, events->size()); | 1692 EXPECT_EQ(2u, events->size()); |
| 1683 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); | 1693 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
| 1684 EXPECT_EQ(AnimationEvent::Finished, (*events)[1].type); | 1694 EXPECT_EQ(AnimationEvent::Finished, (*events)[1].type); |
| 1685 } | 1695 } |
| 1686 | 1696 |
| 1687 // Ensure that when a group has a mix of aborted and finished animations, | 1697 // Ensure that when a group has a mix of aborted and finished animations, |
| 1688 // we generate a Finished event for the finished animation and an Aborted | 1698 // we generate a Finished event for the finished animation and an Aborted |
| 1689 // event for the aborted animation. | 1699 // event for the aborted animation. |
| 1690 TEST(LayerAnimationControllerTest, FinishedAndAbortedEventsForGroup) { | 1700 TEST(LayerAnimationControllerTest, FinishedAndAbortedEventsForGroup) { |
| 1691 scoped_ptr<AnimationEventsVector> events( | 1701 scoped_ptr<AnimationEventsVector> events( |
| 1692 make_scoped_ptr(new AnimationEventsVector)); | 1702 make_scoped_ptr(new AnimationEventsVector)); |
| 1693 FakeLayerAnimationValueObserver dummy_impl; | 1703 FakeLayerAnimationValueObserver dummy_impl; |
| 1694 scoped_refptr<LayerAnimationController> controller_impl( | 1704 scoped_refptr<LayerAnimationController> controller_impl( |
| 1695 LayerAnimationController::Create(0)); | 1705 LayerAnimationController::Create(0)); |
| 1696 controller_impl->AddValueObserver(&dummy_impl); | 1706 controller_impl->AddValueObserver(&dummy_impl); |
| 1697 | 1707 |
| 1698 // Add two animations with the same group id. | 1708 // Add two animations with the same group id. |
| 1699 controller_impl->AddAnimation(CreateAnimation( | 1709 controller_impl->AddAnimation(CreateAnimation( |
| 1700 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)).Pass(), | 1710 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)).Pass(), |
| 1701 1, | 1711 1, |
| 1702 Animation::Transform)); | 1712 Animation::Transform)); |
| 1703 controller_impl->AddAnimation(CreateAnimation( | 1713 controller_impl->AddAnimation(CreateAnimation( |
| 1704 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1714 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 1705 1, | 1715 1, |
| 1706 Animation::Opacity)); | 1716 Animation::Opacity)); |
| 1707 | 1717 |
| 1708 controller_impl->Animate(kInitialTickTime); | 1718 controller_impl->Animate(GetTimeTicks(kInitialTickTime)); |
| 1709 controller_impl->UpdateState(true, events.get()); | 1719 controller_impl->UpdateState(true, events.get()); |
| 1710 | 1720 |
| 1711 // Both animations should have started. | 1721 // Both animations should have started. |
| 1712 EXPECT_EQ(2u, events->size()); | 1722 EXPECT_EQ(2u, events->size()); |
| 1713 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); | 1723 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); |
| 1714 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); | 1724 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); |
| 1715 | 1725 |
| 1716 controller_impl->AbortAnimations(Animation::Opacity); | 1726 controller_impl->AbortAnimations(Animation::Opacity); |
| 1717 | 1727 |
| 1718 events.reset(new AnimationEventsVector); | 1728 events.reset(new AnimationEventsVector); |
| 1719 controller_impl->Animate(kInitialTickTime + 1.0); | 1729 controller_impl->Animate(GetTimeTicks(kInitialTickTime + 1.0)); |
| 1720 controller_impl->UpdateState(true, events.get()); | 1730 controller_impl->UpdateState(true, events.get()); |
| 1721 | 1731 |
| 1722 // We should have exactly 2 events: a Finished event for the tranform | 1732 // We should have exactly 2 events: a Finished event for the tranform |
| 1723 // animation, and an Aborted event for the opacity animation. | 1733 // animation, and an Aborted event for the opacity animation. |
| 1724 EXPECT_EQ(2u, events->size()); | 1734 EXPECT_EQ(2u, events->size()); |
| 1725 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); | 1735 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
| 1726 EXPECT_EQ(Animation::Transform, (*events)[0].target_property); | 1736 EXPECT_EQ(Animation::Transform, (*events)[0].target_property); |
| 1727 EXPECT_EQ(AnimationEvent::Aborted, (*events)[1].type); | 1737 EXPECT_EQ(AnimationEvent::Aborted, (*events)[1].type); |
| 1728 EXPECT_EQ(Animation::Opacity, (*events)[1].target_property); | 1738 EXPECT_EQ(Animation::Opacity, (*events)[1].target_property); |
| 1729 } | 1739 } |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1903 ->SetRunState(Animation::Finished, 0.0); | 1913 ->SetRunState(Animation::Finished, 0.0); |
| 1904 | 1914 |
| 1905 // Only unfinished animations should be considered by | 1915 // Only unfinished animations should be considered by |
| 1906 // MaximumScale. | 1916 // MaximumScale. |
| 1907 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); | 1917 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); |
| 1908 EXPECT_EQ(4.f, max_scale); | 1918 EXPECT_EQ(4.f, max_scale); |
| 1909 } | 1919 } |
| 1910 | 1920 |
| 1911 } // namespace | 1921 } // namespace |
| 1912 } // namespace cc | 1922 } // namespace cc |
| OLD | NEW |