Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: cc/animation/layer_animation_controller_unittest.cc

Issue 231133002: CC::Animations should use TimeTicks & TimeDelta to represent time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing TOT. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/layer_animation_controller.cc ('k') | cc/trees/layer_tree_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 base::TimeTicks GetTimeTicks(double time) {
24 return base::TimeTicks::FromInternalValue(time *
25 base::Time::kMicrosecondsPerSecond);
26 }
27
28 base::TimeDelta GetTimeDelta(double offset) {
29 return GetTimeTicks(offset) - base::TimeTicks();
ajuma 2014/04/10 14:26:59 Instead of this function, how about just using bas
Sikugu_ 2014/04/24 15:19:31 Done.
30 }
31
23 // A LayerAnimationController cannot be ticked at 0.0, since an animation 32 // 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 33 // with start time 0.0 is treated as an animation whose start time has
25 // not yet been set. 34 // not yet been set.
26 const double kInitialTickTime = 1.0; 35 const base::TimeTicks kInitialTickTime = GetTimeTicks(1.0);
ajuma 2014/04/10 14:26:59 Note that this is adding a static intializer. I'd
Sikugu_ 2014/04/24 15:19:31 Done.
36 // TODO(sikugu): Remove double time once we have the TimeTicks/Deltas
37 // in place for Animations.
38 const double kInitialDoubleTime = 1.0;
27 39
28 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve, 40 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve,
29 int id, 41 int id,
30 Animation::TargetProperty property) { 42 Animation::TargetProperty property) {
31 return Animation::Create(curve.Pass(), 0, id, property); 43 return Animation::Create(curve.Pass(), 0, id, property);
32 } 44 }
33 45
34 TEST(LayerAnimationControllerTest, SyncNewAnimation) { 46 TEST(LayerAnimationControllerTest, SyncNewAnimation) {
35 FakeLayerAnimationValueObserver dummy_impl; 47 FakeLayerAnimationValueObserver dummy_impl;
36 scoped_refptr<LayerAnimationController> controller_impl( 48 scoped_refptr<LayerAnimationController> controller_impl(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 96
85 // Synchronize the start times. 97 // Synchronize the start times.
86 EXPECT_EQ(1u, events.size()); 98 EXPECT_EQ(1u, events.size());
87 controller->NotifyAnimationStarted(events[0]); 99 controller->NotifyAnimationStarted(events[0]);
88 EXPECT_EQ(controller->GetAnimation(group_id, 100 EXPECT_EQ(controller->GetAnimation(group_id,
89 Animation::Opacity)->start_time(), 101 Animation::Opacity)->start_time(),
90 controller_impl->GetAnimation(group_id, 102 controller_impl->GetAnimation(group_id,
91 Animation::Opacity)->start_time()); 103 Animation::Opacity)->start_time());
92 104
93 // Start the animation on the main thread. Should not affect the start time. 105 // Start the animation on the main thread. Should not affect the start time.
94 controller->Animate(kInitialTickTime + 0.5); 106 controller->Animate(kInitialTickTime + GetTimeDelta(0.5));
95 controller->UpdateState(true, NULL); 107 controller->UpdateState(true, NULL);
96 EXPECT_EQ(controller->GetAnimation(group_id, 108 EXPECT_EQ(controller->GetAnimation(group_id,
97 Animation::Opacity)->start_time(), 109 Animation::Opacity)->start_time(),
98 controller_impl->GetAnimation(group_id, 110 controller_impl->GetAnimation(group_id,
99 Animation::Opacity)->start_time()); 111 Animation::Opacity)->start_time());
100 } 112 }
101 113
102 TEST(LayerAnimationControllerTest, UseSpecifiedStartTimes) { 114 TEST(LayerAnimationControllerTest, UseSpecifiedStartTimes) {
103 FakeLayerAnimationValueObserver dummy_impl; 115 FakeLayerAnimationValueObserver dummy_impl;
104 scoped_refptr<LayerAnimationController> controller_impl( 116 scoped_refptr<LayerAnimationController> controller_impl(
(...skipping 27 matching lines...) Expand all
132 144
133 EXPECT_EQ(start_time, 145 EXPECT_EQ(start_time,
134 controller->GetAnimation(group_id, 146 controller->GetAnimation(group_id,
135 Animation::Opacity)->start_time()); 147 Animation::Opacity)->start_time());
136 EXPECT_EQ(controller->GetAnimation(group_id, 148 EXPECT_EQ(controller->GetAnimation(group_id,
137 Animation::Opacity)->start_time(), 149 Animation::Opacity)->start_time(),
138 controller_impl->GetAnimation(group_id, 150 controller_impl->GetAnimation(group_id,
139 Animation::Opacity)->start_time()); 151 Animation::Opacity)->start_time());
140 152
141 // Start the animation on the main thread. Should not affect the start time. 153 // Start the animation on the main thread. Should not affect the start time.
142 controller->Animate(kInitialTickTime + 0.5); 154 controller->Animate(kInitialTickTime + GetTimeDelta(0.5));
143 controller->UpdateState(true, NULL); 155 controller->UpdateState(true, NULL);
144 EXPECT_EQ(start_time, 156 EXPECT_EQ(start_time,
145 controller->GetAnimation(group_id, 157 controller->GetAnimation(group_id,
146 Animation::Opacity)->start_time()); 158 Animation::Opacity)->start_time());
147 EXPECT_EQ(controller->GetAnimation(group_id, 159 EXPECT_EQ(controller->GetAnimation(group_id,
148 Animation::Opacity)->start_time(), 160 Animation::Opacity)->start_time(),
149 controller_impl->GetAnimation(group_id, 161 controller_impl->GetAnimation(group_id,
150 Animation::Opacity)->start_time()); 162 Animation::Opacity)->start_time());
151 } 163 }
152 164
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); 197 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size());
186 198
187 controller_impl->Animate(kInitialTickTime); 199 controller_impl->Animate(kInitialTickTime);
188 controller_impl->UpdateState(true, events.get()); 200 controller_impl->UpdateState(true, events.get());
189 EXPECT_EQ(1u, events->size()); 201 EXPECT_EQ(1u, events->size());
190 controller->NotifyAnimationStarted((*events)[0]); 202 controller->NotifyAnimationStarted((*events)[0]);
191 203
192 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); 204 EXPECT_EQ(1u, registrar->active_animation_controllers().size());
193 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); 205 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size());
194 206
195 controller->Animate(kInitialTickTime + 0.5); 207 controller->Animate(kInitialTickTime + GetTimeDelta(0.5));
196 controller->UpdateState(true, NULL); 208 controller->UpdateState(true, NULL);
197 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); 209 EXPECT_EQ(1u, registrar->active_animation_controllers().size());
198 210
199 controller->Animate(kInitialTickTime + 1.0); 211 controller->Animate(kInitialTickTime + GetTimeDelta(1.0));
200 controller->UpdateState(true, NULL); 212 controller->UpdateState(true, NULL);
201 EXPECT_EQ(Animation::Finished, 213 EXPECT_EQ(Animation::Finished,
202 controller->GetAnimation(Animation::Opacity)->run_state()); 214 controller->GetAnimation(Animation::Opacity)->run_state());
203 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); 215 EXPECT_EQ(1u, registrar->active_animation_controllers().size());
204 216
205 events.reset(new AnimationEventsVector); 217 events.reset(new AnimationEventsVector);
206 controller_impl->Animate(kInitialTickTime + 1.5); 218 controller_impl->Animate(kInitialTickTime + GetTimeDelta(1.5));
207 controller_impl->UpdateState(true, events.get()); 219 controller_impl->UpdateState(true, events.get());
208 220
209 EXPECT_EQ(Animation::WaitingForDeletion, 221 EXPECT_EQ(Animation::WaitingForDeletion,
210 controller_impl->GetAnimation(Animation::Opacity)->run_state()); 222 controller_impl->GetAnimation(Animation::Opacity)->run_state());
211 // The impl thread controller should have de-activated. 223 // The impl thread controller should have de-activated.
212 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); 224 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size());
213 225
214 EXPECT_EQ(1u, events->size()); 226 EXPECT_EQ(1u, events->size());
215 controller->NotifyAnimationFinished((*events)[0]); 227 controller->NotifyAnimationFinished((*events)[0]);
216 controller->Animate(kInitialTickTime + 1.5); 228 controller->Animate(kInitialTickTime + GetTimeDelta(1.5));
217 controller->UpdateState(true, NULL); 229 controller->UpdateState(true, NULL);
218 230
219 EXPECT_EQ(Animation::WaitingForDeletion, 231 EXPECT_EQ(Animation::WaitingForDeletion,
220 controller->GetAnimation(Animation::Opacity)->run_state()); 232 controller->GetAnimation(Animation::Opacity)->run_state());
221 // The main thread controller should have de-activated. 233 // The main thread controller should have de-activated.
222 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); 234 EXPECT_EQ(0u, registrar->active_animation_controllers().size());
223 235
224 controller->PushAnimationUpdatesTo(controller_impl.get()); 236 controller->PushAnimationUpdatesTo(controller_impl.get());
225 EXPECT_FALSE(controller->has_any_animation()); 237 EXPECT_FALSE(controller->has_any_animation());
226 EXPECT_FALSE(controller_impl->has_any_animation()); 238 EXPECT_FALSE(controller_impl->has_any_animation());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 controller->Animate(kInitialTickTime); 273 controller->Animate(kInitialTickTime);
262 controller->UpdateState(true, NULL); 274 controller->UpdateState(true, NULL);
263 EXPECT_EQ(Animation::Running, 275 EXPECT_EQ(Animation::Running,
264 controller_impl->GetAnimation(group_id, 276 controller_impl->GetAnimation(group_id,
265 Animation::Opacity)->run_state()); 277 Animation::Opacity)->run_state());
266 EXPECT_EQ(Animation::Running, 278 EXPECT_EQ(Animation::Running,
267 controller->GetAnimation(group_id, 279 controller->GetAnimation(group_id,
268 Animation::Opacity)->run_state()); 280 Animation::Opacity)->run_state());
269 281
270 // Pause the main-thread animation. 282 // Pause the main-thread animation.
271 controller->PauseAnimation(animation_id, kInitialTickTime + 1.0); 283 controller->PauseAnimation(animation_id, kInitialDoubleTime + 1.0);
272 EXPECT_EQ(Animation::Paused, 284 EXPECT_EQ(Animation::Paused,
273 controller->GetAnimation(group_id, 285 controller->GetAnimation(group_id,
274 Animation::Opacity)->run_state()); 286 Animation::Opacity)->run_state());
275 287
276 // The pause run state change should make it to the impl thread controller. 288 // The pause run state change should make it to the impl thread controller.
277 controller->PushAnimationUpdatesTo(controller_impl.get()); 289 controller->PushAnimationUpdatesTo(controller_impl.get());
278 EXPECT_EQ(Animation::Paused, 290 EXPECT_EQ(Animation::Paused,
279 controller_impl->GetAnimation(group_id, 291 controller_impl->GetAnimation(group_id,
280 Animation::Opacity)->run_state()); 292 Animation::Opacity)->run_state());
281 } 293 }
(...skipping 19 matching lines...) Expand all
301 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); 313 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity));
302 EXPECT_EQ(Animation::WaitingForTargetAvailability, 314 EXPECT_EQ(Animation::WaitingForTargetAvailability,
303 controller_impl->GetAnimation(group_id, 315 controller_impl->GetAnimation(group_id,
304 Animation::Opacity)->run_state()); 316 Animation::Opacity)->run_state());
305 317
306 // Notify main thread controller that the animation has started. 318 // Notify main thread controller that the animation has started.
307 AnimationEvent animation_started_event(AnimationEvent::Started, 319 AnimationEvent animation_started_event(AnimationEvent::Started,
308 0, 320 0,
309 group_id, 321 group_id,
310 Animation::Opacity, 322 Animation::Opacity,
311 kInitialTickTime); 323 kInitialDoubleTime);
312 controller->NotifyAnimationStarted(animation_started_event); 324 controller->NotifyAnimationStarted(animation_started_event);
313 325
314 // Force animation to complete on impl thread. 326 // Force animation to complete on impl thread.
315 controller_impl->RemoveAnimation(animation_id); 327 controller_impl->RemoveAnimation(animation_id);
316 328
317 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); 329 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity));
318 330
319 controller->PushAnimationUpdatesTo(controller_impl.get()); 331 controller->PushAnimationUpdatesTo(controller_impl.get());
320 332
321 // Even though the main thread has a 'new' animation, it should not be pushed 333 // Even though the main thread has a 'new' animation, it should not be pushed
(...skipping 13 matching lines...) Expand all
335 scoped_refptr<LayerAnimationController> controller_impl( 347 scoped_refptr<LayerAnimationController> controller_impl(
336 LayerAnimationController::Create(0)); 348 LayerAnimationController::Create(0));
337 controller->AddValueObserver(&dummy); 349 controller->AddValueObserver(&dummy);
338 controller_impl->AddValueObserver(&dummy_impl); 350 controller_impl->AddValueObserver(&dummy_impl);
339 351
340 AddOpacityTransitionToController(controller.get(), 1.0, 0.0f, 1.0f, false); 352 AddOpacityTransitionToController(controller.get(), 1.0, 0.0f, 1.0f, false);
341 controller->Animate(kInitialTickTime); 353 controller->Animate(kInitialTickTime);
342 controller->UpdateState(true, NULL); 354 controller->UpdateState(true, NULL);
343 controller->PushAnimationUpdatesTo(controller_impl.get()); 355 controller->PushAnimationUpdatesTo(controller_impl.get());
344 356
345 controller_impl->Animate(kInitialTickTime + 0.5); 357 controller_impl->Animate(kInitialTickTime + GetTimeDelta(0.5));
346 controller_impl->UpdateState(true, events.get()); 358 controller_impl->UpdateState(true, events.get());
347 359
348 // There should be a Started event for the animation. 360 // There should be a Started event for the animation.
349 EXPECT_EQ(1u, events->size()); 361 EXPECT_EQ(1u, events->size());
350 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); 362 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type);
351 controller->NotifyAnimationStarted((*events)[0]); 363 controller->NotifyAnimationStarted((*events)[0]);
352 364
353 controller->Animate(kInitialTickTime + 1.0); 365 controller->Animate(kInitialTickTime + GetTimeDelta(1.0));
354 controller->UpdateState(true, NULL); 366 controller->UpdateState(true, NULL);
355 367
356 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); 368 EXPECT_FALSE(dummy.animation_waiting_for_deletion());
357 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); 369 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion());
358 370
359 events.reset(new AnimationEventsVector); 371 events.reset(new AnimationEventsVector);
360 controller_impl->Animate(kInitialTickTime + 2.0); 372 controller_impl->Animate(kInitialTickTime + GetTimeDelta(2.0));
361 controller_impl->UpdateState(true, events.get()); 373 controller_impl->UpdateState(true, events.get());
362 374
363 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); 375 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion());
364 376
365 // There should be a Finished event for the animation. 377 // There should be a Finished event for the animation.
366 EXPECT_EQ(1u, events->size()); 378 EXPECT_EQ(1u, events->size());
367 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); 379 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type);
368 380
369 // Neither controller should have deleted the animation yet. 381 // Neither controller should have deleted the animation yet.
370 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); 382 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity));
371 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity)); 383 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity));
372 384
373 controller->NotifyAnimationFinished((*events)[0]); 385 controller->NotifyAnimationFinished((*events)[0]);
374 386
375 controller->Animate(kInitialTickTime + 3.0); 387 controller->Animate(kInitialTickTime + GetTimeDelta(3.0));
376 controller->UpdateState(true, NULL); 388 controller->UpdateState(true, NULL);
377 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); 389 EXPECT_TRUE(dummy.animation_waiting_for_deletion());
378 390
379 controller->PushAnimationUpdatesTo(controller_impl.get()); 391 controller->PushAnimationUpdatesTo(controller_impl.get());
380 392
381 // Both controllers should now have deleted the animation. 393 // Both controllers should now have deleted the animation.
382 EXPECT_FALSE(controller->has_any_animation()); 394 EXPECT_FALSE(controller->has_any_animation());
383 EXPECT_FALSE(controller_impl->has_any_animation()); 395 EXPECT_FALSE(controller_impl->has_any_animation());
384 } 396 }
385 397
(...skipping 23 matching lines...) Expand all
409 Animation::Opacity)); 421 Animation::Opacity));
410 422
411 controller->AddAnimation(to_add.Pass()); 423 controller->AddAnimation(to_add.Pass());
412 controller->Animate(kInitialTickTime); 424 controller->Animate(kInitialTickTime);
413 controller->UpdateState(true, events.get()); 425 controller->UpdateState(true, events.get());
414 EXPECT_TRUE(controller->HasActiveAnimation()); 426 EXPECT_TRUE(controller->HasActiveAnimation());
415 EXPECT_EQ(0.f, dummy.opacity()); 427 EXPECT_EQ(0.f, dummy.opacity());
416 // A non-impl-only animation should not generate property updates. 428 // A non-impl-only animation should not generate property updates.
417 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 429 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
418 EXPECT_FALSE(event); 430 EXPECT_FALSE(event);
419 controller->Animate(kInitialTickTime + 1.0); 431 controller->Animate(kInitialTickTime + GetTimeDelta(1.0));
420 controller->UpdateState(true, events.get()); 432 controller->UpdateState(true, events.get());
421 EXPECT_EQ(1.f, dummy.opacity()); 433 EXPECT_EQ(1.f, dummy.opacity());
422 EXPECT_FALSE(controller->HasActiveAnimation()); 434 EXPECT_FALSE(controller->HasActiveAnimation());
423 event = GetMostRecentPropertyUpdateEvent(events.get()); 435 event = GetMostRecentPropertyUpdateEvent(events.get());
424 EXPECT_FALSE(event); 436 EXPECT_FALSE(event);
425 } 437 }
426 438
427 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { 439 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) {
428 scoped_ptr<AnimationEventsVector> events( 440 scoped_ptr<AnimationEventsVector> events(
429 make_scoped_ptr(new AnimationEventsVector)); 441 make_scoped_ptr(new AnimationEventsVector));
(...skipping 11 matching lines...) Expand all
441 controller_impl->AddAnimation(to_add.Pass()); 453 controller_impl->AddAnimation(to_add.Pass());
442 controller_impl->Animate(kInitialTickTime); 454 controller_impl->Animate(kInitialTickTime);
443 controller_impl->UpdateState(true, events.get()); 455 controller_impl->UpdateState(true, events.get());
444 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 456 EXPECT_TRUE(controller_impl->HasActiveAnimation());
445 EXPECT_EQ(0.f, dummy_impl.opacity()); 457 EXPECT_EQ(0.f, dummy_impl.opacity());
446 EXPECT_EQ(2u, events->size()); 458 EXPECT_EQ(2u, events->size());
447 const AnimationEvent* start_opacity_event = 459 const AnimationEvent* start_opacity_event =
448 GetMostRecentPropertyUpdateEvent(events.get()); 460 GetMostRecentPropertyUpdateEvent(events.get());
449 EXPECT_EQ(0.f, start_opacity_event->opacity); 461 EXPECT_EQ(0.f, start_opacity_event->opacity);
450 462
451 controller_impl->Animate(kInitialTickTime + 1.0); 463 controller_impl->Animate(kInitialTickTime + GetTimeDelta(1.0));
452 controller_impl->UpdateState(true, events.get()); 464 controller_impl->UpdateState(true, events.get());
453 EXPECT_EQ(1.f, dummy_impl.opacity()); 465 EXPECT_EQ(1.f, dummy_impl.opacity());
454 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 466 EXPECT_FALSE(controller_impl->HasActiveAnimation());
455 EXPECT_EQ(4u, events->size()); 467 EXPECT_EQ(4u, events->size());
456 const AnimationEvent* end_opacity_event = 468 const AnimationEvent* end_opacity_event =
457 GetMostRecentPropertyUpdateEvent(events.get()); 469 GetMostRecentPropertyUpdateEvent(events.get());
458 EXPECT_EQ(1.f, end_opacity_event->opacity); 470 EXPECT_EQ(1.f, end_opacity_event->opacity);
459 } 471 }
460 472
461 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) { 473 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 EXPECT_EQ(2u, events->size()); 507 EXPECT_EQ(2u, events->size());
496 const AnimationEvent* start_transform_event = 508 const AnimationEvent* start_transform_event =
497 GetMostRecentPropertyUpdateEvent(events.get()); 509 GetMostRecentPropertyUpdateEvent(events.get());
498 ASSERT_TRUE(start_transform_event); 510 ASSERT_TRUE(start_transform_event);
499 EXPECT_EQ(gfx::Transform(), start_transform_event->transform); 511 EXPECT_EQ(gfx::Transform(), start_transform_event->transform);
500 EXPECT_TRUE(start_transform_event->is_impl_only); 512 EXPECT_TRUE(start_transform_event->is_impl_only);
501 513
502 gfx::Transform expected_transform; 514 gfx::Transform expected_transform;
503 expected_transform.Translate(delta_x, delta_y); 515 expected_transform.Translate(delta_x, delta_y);
504 516
505 controller_impl->Animate(kInitialTickTime + 1.0); 517 controller_impl->Animate(kInitialTickTime + GetTimeDelta(1.0));
506 controller_impl->UpdateState(true, events.get()); 518 controller_impl->UpdateState(true, events.get());
507 EXPECT_EQ(expected_transform, dummy_impl.transform()); 519 EXPECT_EQ(expected_transform, dummy_impl.transform());
508 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 520 EXPECT_FALSE(controller_impl->HasActiveAnimation());
509 EXPECT_EQ(4u, events->size()); 521 EXPECT_EQ(4u, events->size());
510 const AnimationEvent* end_transform_event = 522 const AnimationEvent* end_transform_event =
511 GetMostRecentPropertyUpdateEvent(events.get()); 523 GetMostRecentPropertyUpdateEvent(events.get());
512 EXPECT_EQ(expected_transform, end_transform_event->transform); 524 EXPECT_EQ(expected_transform, end_transform_event->transform);
513 EXPECT_TRUE(end_transform_event->is_impl_only); 525 EXPECT_TRUE(end_transform_event->is_impl_only);
514 } 526 }
515 527
(...skipping 22 matching lines...) Expand all
538 controller->AddAnimation(animation.Pass()); 550 controller->AddAnimation(animation.Pass());
539 551
540 controller->Animate(kInitialTickTime); 552 controller->Animate(kInitialTickTime);
541 controller->UpdateState(true, events.get()); 553 controller->UpdateState(true, events.get());
542 EXPECT_TRUE(controller->HasActiveAnimation()); 554 EXPECT_TRUE(controller->HasActiveAnimation());
543 EXPECT_EQ(start_filters, dummy.filters()); 555 EXPECT_EQ(start_filters, dummy.filters());
544 // A non-impl-only animation should not generate property updates. 556 // A non-impl-only animation should not generate property updates.
545 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 557 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
546 EXPECT_FALSE(event); 558 EXPECT_FALSE(event);
547 559
548 controller->Animate(kInitialTickTime + 0.5); 560 controller->Animate(kInitialTickTime + GetTimeDelta(0.5));
549 controller->UpdateState(true, events.get()); 561 controller->UpdateState(true, events.get());
550 EXPECT_EQ(1u, dummy.filters().size()); 562 EXPECT_EQ(1u, dummy.filters().size());
551 EXPECT_EQ(FilterOperation::CreateBrightnessFilter(1.5f), 563 EXPECT_EQ(FilterOperation::CreateBrightnessFilter(1.5f),
552 dummy.filters().at(0)); 564 dummy.filters().at(0));
553 event = GetMostRecentPropertyUpdateEvent(events.get()); 565 event = GetMostRecentPropertyUpdateEvent(events.get());
554 EXPECT_FALSE(event); 566 EXPECT_FALSE(event);
555 567
556 controller->Animate(kInitialTickTime + 1.0); 568 controller->Animate(kInitialTickTime + GetTimeDelta(1.0));
557 controller->UpdateState(true, events.get()); 569 controller->UpdateState(true, events.get());
558 EXPECT_EQ(end_filters, dummy.filters()); 570 EXPECT_EQ(end_filters, dummy.filters());
559 EXPECT_FALSE(controller->HasActiveAnimation()); 571 EXPECT_FALSE(controller->HasActiveAnimation());
560 event = GetMostRecentPropertyUpdateEvent(events.get()); 572 event = GetMostRecentPropertyUpdateEvent(events.get());
561 EXPECT_FALSE(event); 573 EXPECT_FALSE(event);
562 } 574 }
563 575
564 TEST(LayerAnimationControllerTest, FilterTransitionOnImplOnly) { 576 TEST(LayerAnimationControllerTest, FilterTransitionOnImplOnly) {
565 scoped_ptr<AnimationEventsVector> events( 577 scoped_ptr<AnimationEventsVector> events(
566 make_scoped_ptr(new AnimationEventsVector)); 578 make_scoped_ptr(new AnimationEventsVector));
(...skipping 25 matching lines...) Expand all
592 controller_impl->UpdateState(true, events.get()); 604 controller_impl->UpdateState(true, events.get());
593 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 605 EXPECT_TRUE(controller_impl->HasActiveAnimation());
594 EXPECT_EQ(start_filters, dummy_impl.filters()); 606 EXPECT_EQ(start_filters, dummy_impl.filters());
595 EXPECT_EQ(2u, events->size()); 607 EXPECT_EQ(2u, events->size());
596 const AnimationEvent* start_filter_event = 608 const AnimationEvent* start_filter_event =
597 GetMostRecentPropertyUpdateEvent(events.get()); 609 GetMostRecentPropertyUpdateEvent(events.get());
598 EXPECT_TRUE(start_filter_event); 610 EXPECT_TRUE(start_filter_event);
599 EXPECT_EQ(start_filters, start_filter_event->filters); 611 EXPECT_EQ(start_filters, start_filter_event->filters);
600 EXPECT_TRUE(start_filter_event->is_impl_only); 612 EXPECT_TRUE(start_filter_event->is_impl_only);
601 613
602 controller_impl->Animate(kInitialTickTime + 1.0); 614 controller_impl->Animate(kInitialTickTime + GetTimeDelta(1.0));
603 controller_impl->UpdateState(true, events.get()); 615 controller_impl->UpdateState(true, events.get());
604 EXPECT_EQ(end_filters, dummy_impl.filters()); 616 EXPECT_EQ(end_filters, dummy_impl.filters());
605 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 617 EXPECT_FALSE(controller_impl->HasActiveAnimation());
606 EXPECT_EQ(4u, events->size()); 618 EXPECT_EQ(4u, events->size());
607 const AnimationEvent* end_filter_event = 619 const AnimationEvent* end_filter_event =
608 GetMostRecentPropertyUpdateEvent(events.get()); 620 GetMostRecentPropertyUpdateEvent(events.get());
609 EXPECT_TRUE(end_filter_event); 621 EXPECT_TRUE(end_filter_event);
610 EXPECT_EQ(end_filters, end_filter_event->filters); 622 EXPECT_EQ(end_filters, end_filter_event->filters);
611 EXPECT_TRUE(end_filter_event->is_impl_only); 623 EXPECT_TRUE(end_filter_event->is_impl_only);
612 } 624 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 668
657 controller_impl->Animate(kInitialTickTime); 669 controller_impl->Animate(kInitialTickTime);
658 controller_impl->UpdateState(true, events.get()); 670 controller_impl->UpdateState(true, events.get());
659 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 671 EXPECT_TRUE(controller_impl->HasActiveAnimation());
660 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); 672 EXPECT_EQ(initial_value, dummy_impl.scroll_offset());
661 // Scroll offset animations should not generate property updates. 673 // Scroll offset animations should not generate property updates.
662 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 674 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
663 EXPECT_FALSE(event); 675 EXPECT_FALSE(event);
664 676
665 controller->NotifyAnimationStarted((*events)[0]); 677 controller->NotifyAnimationStarted((*events)[0]);
666 controller->Animate(kInitialTickTime + duration/2.0); 678 controller->Animate(kInitialTickTime + GetTimeDelta(duration / 2.0));
667 controller->UpdateState(true, NULL); 679 controller->UpdateState(true, NULL);
668 EXPECT_TRUE(controller->HasActiveAnimation()); 680 EXPECT_TRUE(controller->HasActiveAnimation());
669 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), dummy.scroll_offset()); 681 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), dummy.scroll_offset());
670 682
671 controller_impl->Animate(kInitialTickTime + duration/2.0); 683 controller_impl->Animate(kInitialTickTime + GetTimeDelta(duration / 2.0));
672 controller_impl->UpdateState(true, events.get()); 684 controller_impl->UpdateState(true, events.get());
673 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), 685 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f),
674 dummy_impl.scroll_offset()); 686 dummy_impl.scroll_offset());
675 event = GetMostRecentPropertyUpdateEvent(events.get()); 687 event = GetMostRecentPropertyUpdateEvent(events.get());
676 EXPECT_FALSE(event); 688 EXPECT_FALSE(event);
677 689
678 controller_impl->Animate(kInitialTickTime + duration); 690 controller_impl->Animate(kInitialTickTime + GetTimeDelta(duration));
679 controller_impl->UpdateState(true, events.get()); 691 controller_impl->UpdateState(true, events.get());
680 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); 692 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset());
681 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 693 EXPECT_FALSE(controller_impl->HasActiveAnimation());
682 event = GetMostRecentPropertyUpdateEvent(events.get()); 694 event = GetMostRecentPropertyUpdateEvent(events.get());
683 EXPECT_FALSE(event); 695 EXPECT_FALSE(event);
684 696
685 controller->Animate(kInitialTickTime + duration); 697 controller->Animate(kInitialTickTime + GetTimeDelta(duration));
686 controller->UpdateState(true, NULL); 698 controller->UpdateState(true, NULL);
687 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset()); 699 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset());
688 EXPECT_FALSE(controller->HasActiveAnimation()); 700 EXPECT_FALSE(controller->HasActiveAnimation());
689 } 701 }
690 702
691 // Ensure that when the impl controller doesn't have a value provider, 703 // 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 704 // the main-thread controller's value provider is used to obtain the intial
693 // scroll offset. 705 // scroll offset.
694 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionNoImplProvider) { 706 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionNoImplProvider) {
695 FakeLayerAnimationValueObserver dummy_impl; 707 FakeLayerAnimationValueObserver dummy_impl;
(...skipping 17 matching lines...) Expand all
713 EaseInOutTimingFunction::Create().Pass())); 725 EaseInOutTimingFunction::Create().Pass()));
714 726
715 scoped_ptr<Animation> animation(Animation::Create( 727 scoped_ptr<Animation> animation(Animation::Create(
716 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); 728 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset));
717 animation->set_needs_synchronized_start_time(true); 729 animation->set_needs_synchronized_start_time(true);
718 controller->AddAnimation(animation.Pass()); 730 controller->AddAnimation(animation.Pass());
719 731
720 dummy_provider.set_scroll_offset(initial_value); 732 dummy_provider.set_scroll_offset(initial_value);
721 controller->PushAnimationUpdatesTo(controller_impl.get()); 733 controller->PushAnimationUpdatesTo(controller_impl.get());
722 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); 734 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset));
723 double duration = controller_impl->GetAnimation( 735 double duration = controller_impl->GetAnimation(
ajuma 2014/04/10 14:26:59 If we convert this duration to a TimeDelta, then w
Sikugu_ 2014/04/24 15:19:31 Done.
724 Animation::ScrollOffset)->curve()->Duration(); 736 Animation::ScrollOffset)->curve()->Duration();
725 737
726 EXPECT_EQ( 738 EXPECT_EQ(
727 duration, 739 duration,
728 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); 740 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration());
729 741
730 controller->Animate(kInitialTickTime); 742 controller->Animate(kInitialTickTime);
731 controller->UpdateState(true, NULL); 743 controller->UpdateState(true, NULL);
732 EXPECT_TRUE(controller->HasActiveAnimation()); 744 EXPECT_TRUE(controller->HasActiveAnimation());
733 EXPECT_EQ(initial_value, dummy.scroll_offset()); 745 EXPECT_EQ(initial_value, dummy.scroll_offset());
734 746
735 controller_impl->Animate(kInitialTickTime); 747 controller_impl->Animate(kInitialTickTime);
736 controller_impl->UpdateState(true, events.get()); 748 controller_impl->UpdateState(true, events.get());
737 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 749 EXPECT_TRUE(controller_impl->HasActiveAnimation());
738 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); 750 EXPECT_EQ(initial_value, dummy_impl.scroll_offset());
739 // Scroll offset animations should not generate property updates. 751 // Scroll offset animations should not generate property updates.
740 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 752 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
741 EXPECT_FALSE(event); 753 EXPECT_FALSE(event);
742 754
743 controller->NotifyAnimationStarted((*events)[0]); 755 controller->NotifyAnimationStarted((*events)[0]);
744 controller->Animate(kInitialTickTime + duration/2.0); 756 controller->Animate(kInitialTickTime + GetTimeDelta(duration / 2.0));
745 controller->UpdateState(true, NULL); 757 controller->UpdateState(true, NULL);
746 EXPECT_TRUE(controller->HasActiveAnimation()); 758 EXPECT_TRUE(controller->HasActiveAnimation());
747 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), dummy.scroll_offset()); 759 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), dummy.scroll_offset());
748 760
749 controller_impl->Animate(kInitialTickTime + duration/2.0); 761 controller_impl->Animate(kInitialTickTime + GetTimeDelta(duration / 2.0));
750 controller_impl->UpdateState(true, events.get()); 762 controller_impl->UpdateState(true, events.get());
751 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), 763 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f),
752 dummy_impl.scroll_offset()); 764 dummy_impl.scroll_offset());
753 event = GetMostRecentPropertyUpdateEvent(events.get()); 765 event = GetMostRecentPropertyUpdateEvent(events.get());
754 EXPECT_FALSE(event); 766 EXPECT_FALSE(event);
755 767
756 controller_impl->Animate(kInitialTickTime + duration); 768 controller_impl->Animate(kInitialTickTime + GetTimeDelta(duration));
757 controller_impl->UpdateState(true, events.get()); 769 controller_impl->UpdateState(true, events.get());
758 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); 770 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset());
759 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 771 EXPECT_FALSE(controller_impl->HasActiveAnimation());
760 event = GetMostRecentPropertyUpdateEvent(events.get()); 772 event = GetMostRecentPropertyUpdateEvent(events.get());
761 EXPECT_FALSE(event); 773 EXPECT_FALSE(event);
762 774
763 controller->Animate(kInitialTickTime + duration); 775 controller->Animate(kInitialTickTime + GetTimeDelta(duration));
764 controller->UpdateState(true, NULL); 776 controller->UpdateState(true, NULL);
765 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset()); 777 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset());
766 EXPECT_FALSE(controller->HasActiveAnimation()); 778 EXPECT_FALSE(controller->HasActiveAnimation());
767 } 779 }
768 780
769 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionOnImplOnly) { 781 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionOnImplOnly) {
770 FakeLayerAnimationValueObserver dummy_impl; 782 FakeLayerAnimationValueObserver dummy_impl;
771 scoped_refptr<LayerAnimationController> controller_impl( 783 scoped_refptr<LayerAnimationController> controller_impl(
772 LayerAnimationController::Create(0)); 784 LayerAnimationController::Create(0));
773 controller_impl->AddValueObserver(&dummy_impl); 785 controller_impl->AddValueObserver(&dummy_impl);
(...skipping 15 matching lines...) Expand all
789 controller_impl->AddAnimation(animation.Pass()); 801 controller_impl->AddAnimation(animation.Pass());
790 802
791 controller_impl->Animate(kInitialTickTime); 803 controller_impl->Animate(kInitialTickTime);
792 controller_impl->UpdateState(true, events.get()); 804 controller_impl->UpdateState(true, events.get());
793 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 805 EXPECT_TRUE(controller_impl->HasActiveAnimation());
794 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); 806 EXPECT_EQ(initial_value, dummy_impl.scroll_offset());
795 // Scroll offset animations should not generate property updates. 807 // Scroll offset animations should not generate property updates.
796 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 808 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
797 EXPECT_FALSE(event); 809 EXPECT_FALSE(event);
798 810
799 controller_impl->Animate(kInitialTickTime + duration/2.0); 811 controller_impl->Animate(kInitialTickTime + GetTimeDelta(duration / 2.0));
800 controller_impl->UpdateState(true, events.get()); 812 controller_impl->UpdateState(true, events.get());
801 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), 813 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f),
802 dummy_impl.scroll_offset()); 814 dummy_impl.scroll_offset());
803 event = GetMostRecentPropertyUpdateEvent(events.get()); 815 event = GetMostRecentPropertyUpdateEvent(events.get());
804 EXPECT_FALSE(event); 816 EXPECT_FALSE(event);
805 817
806 controller_impl->Animate(kInitialTickTime + duration); 818 controller_impl->Animate(kInitialTickTime + GetTimeDelta(duration));
807 controller_impl->UpdateState(true, events.get()); 819 controller_impl->UpdateState(true, events.get());
808 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); 820 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset());
809 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 821 EXPECT_FALSE(controller_impl->HasActiveAnimation());
810 event = GetMostRecentPropertyUpdateEvent(events.get()); 822 event = GetMostRecentPropertyUpdateEvent(events.get());
811 EXPECT_FALSE(event); 823 EXPECT_FALSE(event);
812 } 824 }
813 825
814 class FakeAnimationDelegate : public AnimationDelegate { 826 class FakeAnimationDelegate : public AnimationDelegate {
815 public: 827 public:
816 FakeAnimationDelegate() 828 FakeAnimationDelegate()
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); 884 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type);
873 EXPECT_TRUE((*events)[1].is_impl_only); 885 EXPECT_TRUE((*events)[1].is_impl_only);
874 886
875 // Passing on the start event to the main thread controller should cause the 887 // Passing on the start event to the main thread controller should cause the
876 // delegate to get notified. 888 // delegate to get notified.
877 EXPECT_FALSE(delegate.started()); 889 EXPECT_FALSE(delegate.started());
878 controller->NotifyAnimationStarted((*events)[0]); 890 controller->NotifyAnimationStarted((*events)[0]);
879 EXPECT_TRUE(delegate.started()); 891 EXPECT_TRUE(delegate.started());
880 892
881 events.reset(new AnimationEventsVector); 893 events.reset(new AnimationEventsVector);
882 controller_impl->Animate(kInitialTickTime + 1.0); 894 controller_impl->Animate(kInitialTickTime + GetTimeDelta(1.0));
883 controller_impl->UpdateState(true, events.get()); 895 controller_impl->UpdateState(true, events.get());
884 896
885 // We should receive 2 events (a finished notification and a property update). 897 // We should receive 2 events (a finished notification and a property update).
886 EXPECT_EQ(2u, events->size()); 898 EXPECT_EQ(2u, events->size());
887 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); 899 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type);
888 EXPECT_TRUE((*events)[0].is_impl_only); 900 EXPECT_TRUE((*events)[0].is_impl_only);
889 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); 901 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type);
890 EXPECT_TRUE((*events)[1].is_impl_only); 902 EXPECT_TRUE((*events)[1].is_impl_only);
891 903
892 // Passing on the finished event to the main thread controller should cause 904 // Passing on the finished event to the main thread controller should cause
(...skipping 20 matching lines...) Expand all
913 Animation::Opacity)); 925 Animation::Opacity));
914 to_add->set_needs_synchronized_start_time(true); 926 to_add->set_needs_synchronized_start_time(true);
915 927
916 // We should pause at the first keyframe indefinitely waiting for that 928 // We should pause at the first keyframe indefinitely waiting for that
917 // animation to start. 929 // animation to start.
918 controller->AddAnimation(to_add.Pass()); 930 controller->AddAnimation(to_add.Pass());
919 controller->Animate(kInitialTickTime); 931 controller->Animate(kInitialTickTime);
920 controller->UpdateState(true, events.get()); 932 controller->UpdateState(true, events.get());
921 EXPECT_TRUE(controller->HasActiveAnimation()); 933 EXPECT_TRUE(controller->HasActiveAnimation());
922 EXPECT_EQ(0.f, dummy.opacity()); 934 EXPECT_EQ(0.f, dummy.opacity());
923 controller->Animate(kInitialTickTime + 1.0); 935 controller->Animate(kInitialTickTime + GetTimeDelta(1.0));
924 controller->UpdateState(true, events.get()); 936 controller->UpdateState(true, events.get());
925 EXPECT_TRUE(controller->HasActiveAnimation()); 937 EXPECT_TRUE(controller->HasActiveAnimation());
926 EXPECT_EQ(0.f, dummy.opacity()); 938 EXPECT_EQ(0.f, dummy.opacity());
927 controller->Animate(kInitialTickTime + 2.0); 939 controller->Animate(kInitialTickTime + GetTimeDelta(2.0));
928 controller->UpdateState(true, events.get()); 940 controller->UpdateState(true, events.get());
929 EXPECT_TRUE(controller->HasActiveAnimation()); 941 EXPECT_TRUE(controller->HasActiveAnimation());
930 EXPECT_EQ(0.f, dummy.opacity()); 942 EXPECT_EQ(0.f, dummy.opacity());
931 943
932 // Send the synchronized start time. 944 // Send the synchronized start time.
933 controller->NotifyAnimationStarted(AnimationEvent( 945 controller->NotifyAnimationStarted(AnimationEvent(AnimationEvent::Started,
934 AnimationEvent::Started, 0, 1, Animation::Opacity, kInitialTickTime + 2)); 946 0,
935 controller->Animate(kInitialTickTime + 5.0); 947 1,
948 Animation::Opacity,
949 kInitialDoubleTime + 2));
950 controller->Animate(kInitialTickTime + GetTimeDelta(5.0));
936 controller->UpdateState(true, events.get()); 951 controller->UpdateState(true, events.get());
937 EXPECT_EQ(1.f, dummy.opacity()); 952 EXPECT_EQ(1.f, dummy.opacity());
938 EXPECT_FALSE(controller->HasActiveAnimation()); 953 EXPECT_FALSE(controller->HasActiveAnimation());
939 } 954 }
940 955
941 // Tests that two queued animations affecting the same property run in sequence. 956 // Tests that two queued animations affecting the same property run in sequence.
942 TEST(LayerAnimationControllerTest, TrivialQueuing) { 957 TEST(LayerAnimationControllerTest, TrivialQueuing) {
943 scoped_ptr<AnimationEventsVector> events( 958 scoped_ptr<AnimationEventsVector> events(
944 make_scoped_ptr(new AnimationEventsVector)); 959 make_scoped_ptr(new AnimationEventsVector));
945 FakeLayerAnimationValueObserver dummy; 960 FakeLayerAnimationValueObserver dummy;
946 scoped_refptr<LayerAnimationController> controller( 961 scoped_refptr<LayerAnimationController> controller(
947 LayerAnimationController::Create(0)); 962 LayerAnimationController::Create(0));
948 controller->AddValueObserver(&dummy); 963 controller->AddValueObserver(&dummy);
949 964
950 controller->AddAnimation(CreateAnimation( 965 controller->AddAnimation(CreateAnimation(
951 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 966 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
952 1, 967 1,
953 Animation::Opacity)); 968 Animation::Opacity));
954 controller->AddAnimation(CreateAnimation( 969 controller->AddAnimation(CreateAnimation(
955 scoped_ptr<AnimationCurve>( 970 scoped_ptr<AnimationCurve>(
956 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), 971 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(),
957 2, 972 2,
958 Animation::Opacity)); 973 Animation::Opacity));
959 974
960 controller->Animate(kInitialTickTime); 975 controller->Animate(kInitialTickTime);
961 controller->UpdateState(true, events.get()); 976 controller->UpdateState(true, events.get());
962 EXPECT_TRUE(controller->HasActiveAnimation()); 977 EXPECT_TRUE(controller->HasActiveAnimation());
963 EXPECT_EQ(0.f, dummy.opacity()); 978 EXPECT_EQ(0.f, dummy.opacity());
964 controller->Animate(kInitialTickTime + 1.0); 979 controller->Animate(kInitialTickTime + GetTimeDelta(1.0));
965 controller->UpdateState(true, events.get()); 980 controller->UpdateState(true, events.get());
966 EXPECT_TRUE(controller->HasActiveAnimation()); 981 EXPECT_TRUE(controller->HasActiveAnimation());
967 EXPECT_EQ(1.f, dummy.opacity()); 982 EXPECT_EQ(1.f, dummy.opacity());
968 controller->Animate(kInitialTickTime + 2.0); 983 controller->Animate(kInitialTickTime + GetTimeDelta(2.0));
969 controller->UpdateState(true, events.get()); 984 controller->UpdateState(true, events.get());
970 EXPECT_EQ(0.5f, dummy.opacity()); 985 EXPECT_EQ(0.5f, dummy.opacity());
971 EXPECT_FALSE(controller->HasActiveAnimation()); 986 EXPECT_FALSE(controller->HasActiveAnimation());
972 } 987 }
973 988
974 // Tests interrupting a transition with another transition. 989 // Tests interrupting a transition with another transition.
975 TEST(LayerAnimationControllerTest, Interrupt) { 990 TEST(LayerAnimationControllerTest, Interrupt) {
976 scoped_ptr<AnimationEventsVector> events( 991 scoped_ptr<AnimationEventsVector> events(
977 make_scoped_ptr(new AnimationEventsVector)); 992 make_scoped_ptr(new AnimationEventsVector));
978 FakeLayerAnimationValueObserver dummy; 993 FakeLayerAnimationValueObserver dummy;
(...skipping 12 matching lines...) Expand all
991 scoped_ptr<Animation> to_add(CreateAnimation( 1006 scoped_ptr<Animation> to_add(CreateAnimation(
992 scoped_ptr<AnimationCurve>( 1007 scoped_ptr<AnimationCurve>(
993 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), 1008 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(),
994 2, 1009 2,
995 Animation::Opacity)); 1010 Animation::Opacity));
996 controller->AbortAnimations(Animation::Opacity); 1011 controller->AbortAnimations(Animation::Opacity);
997 controller->AddAnimation(to_add.Pass()); 1012 controller->AddAnimation(to_add.Pass());
998 1013
999 // Since the previous animation was aborted, the new animation should start 1014 // Since the previous animation was aborted, the new animation should start
1000 // right in this call to animate. 1015 // right in this call to animate.
1001 controller->Animate(kInitialTickTime + 0.5); 1016 controller->Animate(kInitialTickTime + GetTimeDelta(0.5));
1002 controller->UpdateState(true, events.get()); 1017 controller->UpdateState(true, events.get());
1003 EXPECT_TRUE(controller->HasActiveAnimation()); 1018 EXPECT_TRUE(controller->HasActiveAnimation());
1004 EXPECT_EQ(1.f, dummy.opacity()); 1019 EXPECT_EQ(1.f, dummy.opacity());
1005 controller->Animate(kInitialTickTime + 1.5); 1020 controller->Animate(kInitialTickTime + GetTimeDelta(1.5));
1006 controller->UpdateState(true, events.get()); 1021 controller->UpdateState(true, events.get());
1007 EXPECT_EQ(0.5f, dummy.opacity()); 1022 EXPECT_EQ(0.5f, dummy.opacity());
1008 EXPECT_FALSE(controller->HasActiveAnimation()); 1023 EXPECT_FALSE(controller->HasActiveAnimation());
1009 } 1024 }
1010 1025
1011 // Tests scheduling two animations to run together when only one property is 1026 // Tests scheduling two animations to run together when only one property is
1012 // free. 1027 // free.
1013 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { 1028 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) {
1014 scoped_ptr<AnimationEventsVector> events( 1029 scoped_ptr<AnimationEventsVector> events(
1015 make_scoped_ptr(new AnimationEventsVector)); 1030 make_scoped_ptr(new AnimationEventsVector));
(...skipping 12 matching lines...) Expand all
1028 Animation::Transform)); 1043 Animation::Transform));
1029 controller->AddAnimation(CreateAnimation( 1044 controller->AddAnimation(CreateAnimation(
1030 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1045 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1031 2, 1046 2,
1032 Animation::Opacity)); 1047 Animation::Opacity));
1033 1048
1034 controller->Animate(kInitialTickTime); 1049 controller->Animate(kInitialTickTime);
1035 controller->UpdateState(true, events.get()); 1050 controller->UpdateState(true, events.get());
1036 EXPECT_EQ(0.f, dummy.opacity()); 1051 EXPECT_EQ(0.f, dummy.opacity());
1037 EXPECT_TRUE(controller->HasActiveAnimation()); 1052 EXPECT_TRUE(controller->HasActiveAnimation());
1038 controller->Animate(kInitialTickTime + 1.0); 1053 controller->Animate(kInitialTickTime + GetTimeDelta(1.0));
1039 controller->UpdateState(true, events.get()); 1054 controller->UpdateState(true, events.get());
1040 // Should not have started the float transition yet. 1055 // Should not have started the float transition yet.
1041 EXPECT_TRUE(controller->HasActiveAnimation()); 1056 EXPECT_TRUE(controller->HasActiveAnimation());
1042 EXPECT_EQ(0.f, dummy.opacity()); 1057 EXPECT_EQ(0.f, dummy.opacity());
1043 // The float animation should have started at time 1 and should be done. 1058 // The float animation should have started at time 1 and should be done.
1044 controller->Animate(kInitialTickTime + 2.0); 1059 controller->Animate(kInitialTickTime + GetTimeDelta(2.0));
1045 controller->UpdateState(true, events.get()); 1060 controller->UpdateState(true, events.get());
1046 EXPECT_EQ(1.f, dummy.opacity()); 1061 EXPECT_EQ(1.f, dummy.opacity());
1047 EXPECT_FALSE(controller->HasActiveAnimation()); 1062 EXPECT_FALSE(controller->HasActiveAnimation());
1048 } 1063 }
1049 1064
1050 // Tests scheduling two animations to run together with different lengths and 1065 // Tests scheduling two animations to run together with different lengths and
1051 // another animation queued to start when the shorter animation finishes (should 1066 // another animation queued to start when the shorter animation finishes (should
1052 // wait for both to finish). 1067 // wait for both to finish).
1053 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { 1068 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) {
1054 scoped_ptr<AnimationEventsVector> events( 1069 scoped_ptr<AnimationEventsVector> events(
(...skipping 18 matching lines...) Expand all
1073 Animation::Opacity)); 1088 Animation::Opacity));
1074 1089
1075 // Animations with id 1 should both start now. 1090 // Animations with id 1 should both start now.
1076 controller->Animate(kInitialTickTime); 1091 controller->Animate(kInitialTickTime);
1077 controller->UpdateState(true, events.get()); 1092 controller->UpdateState(true, events.get());
1078 EXPECT_TRUE(controller->HasActiveAnimation()); 1093 EXPECT_TRUE(controller->HasActiveAnimation());
1079 EXPECT_EQ(0.f, dummy.opacity()); 1094 EXPECT_EQ(0.f, dummy.opacity());
1080 // The opacity animation should have finished at time 1, but the group 1095 // 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 1096 // of animations with id 1 don't finish until time 2 because of the length
1082 // of the transform animation. 1097 // of the transform animation.
1083 controller->Animate(kInitialTickTime + 2.0); 1098 controller->Animate(kInitialTickTime + GetTimeDelta(2.0));
1084 controller->UpdateState(true, events.get()); 1099 controller->UpdateState(true, events.get());
1085 // Should not have started the float transition yet. 1100 // Should not have started the float transition yet.
1086 EXPECT_TRUE(controller->HasActiveAnimation()); 1101 EXPECT_TRUE(controller->HasActiveAnimation());
1087 EXPECT_EQ(1.f, dummy.opacity()); 1102 EXPECT_EQ(1.f, dummy.opacity());
1088 1103
1089 // The second opacity animation should start at time 2 and should be done by 1104 // The second opacity animation should start at time 2 and should be done by
1090 // time 3. 1105 // time 3.
1091 controller->Animate(kInitialTickTime + 3.0); 1106 controller->Animate(kInitialTickTime + GetTimeDelta(3.0));
1092 controller->UpdateState(true, events.get()); 1107 controller->UpdateState(true, events.get());
1093 EXPECT_EQ(0.5f, dummy.opacity()); 1108 EXPECT_EQ(0.5f, dummy.opacity());
1094 EXPECT_FALSE(controller->HasActiveAnimation()); 1109 EXPECT_FALSE(controller->HasActiveAnimation());
1095 } 1110 }
1096 1111
1097 // Test that a looping animation loops and for the correct number of iterations. 1112 // Test that a looping animation loops and for the correct number of iterations.
1098 TEST(LayerAnimationControllerTest, TrivialLooping) { 1113 TEST(LayerAnimationControllerTest, TrivialLooping) {
1099 scoped_ptr<AnimationEventsVector> events( 1114 scoped_ptr<AnimationEventsVector> events(
1100 make_scoped_ptr(new AnimationEventsVector)); 1115 make_scoped_ptr(new AnimationEventsVector));
1101 FakeLayerAnimationValueObserver dummy; 1116 FakeLayerAnimationValueObserver dummy;
1102 scoped_refptr<LayerAnimationController> controller( 1117 scoped_refptr<LayerAnimationController> controller(
1103 LayerAnimationController::Create(0)); 1118 LayerAnimationController::Create(0));
1104 controller->AddValueObserver(&dummy); 1119 controller->AddValueObserver(&dummy);
1105 1120
1106 scoped_ptr<Animation> to_add(CreateAnimation( 1121 scoped_ptr<Animation> to_add(CreateAnimation(
1107 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1122 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1108 1, 1123 1,
1109 Animation::Opacity)); 1124 Animation::Opacity));
1110 to_add->set_iterations(3); 1125 to_add->set_iterations(3);
1111 controller->AddAnimation(to_add.Pass()); 1126 controller->AddAnimation(to_add.Pass());
1112 1127
1113 controller->Animate(kInitialTickTime); 1128 controller->Animate(kInitialTickTime);
1114 controller->UpdateState(true, events.get()); 1129 controller->UpdateState(true, events.get());
1115 EXPECT_TRUE(controller->HasActiveAnimation()); 1130 EXPECT_TRUE(controller->HasActiveAnimation());
1116 EXPECT_EQ(0.f, dummy.opacity()); 1131 EXPECT_EQ(0.f, dummy.opacity());
1117 controller->Animate(kInitialTickTime + 1.25); 1132 controller->Animate(kInitialTickTime + GetTimeDelta(1.25));
1118 controller->UpdateState(true, events.get()); 1133 controller->UpdateState(true, events.get());
1119 EXPECT_TRUE(controller->HasActiveAnimation()); 1134 EXPECT_TRUE(controller->HasActiveAnimation());
1120 EXPECT_EQ(0.25f, dummy.opacity()); 1135 EXPECT_EQ(0.25f, dummy.opacity());
1121 controller->Animate(kInitialTickTime + 1.75); 1136 controller->Animate(kInitialTickTime + GetTimeDelta(1.75));
1122 controller->UpdateState(true, events.get()); 1137 controller->UpdateState(true, events.get());
1123 EXPECT_TRUE(controller->HasActiveAnimation()); 1138 EXPECT_TRUE(controller->HasActiveAnimation());
1124 EXPECT_EQ(0.75f, dummy.opacity()); 1139 EXPECT_EQ(0.75f, dummy.opacity());
1125 controller->Animate(kInitialTickTime + 2.25); 1140 controller->Animate(kInitialTickTime + GetTimeDelta(2.25));
1126 controller->UpdateState(true, events.get()); 1141 controller->UpdateState(true, events.get());
1127 EXPECT_TRUE(controller->HasActiveAnimation()); 1142 EXPECT_TRUE(controller->HasActiveAnimation());
1128 EXPECT_EQ(0.25f, dummy.opacity()); 1143 EXPECT_EQ(0.25f, dummy.opacity());
1129 controller->Animate(kInitialTickTime + 2.75); 1144 controller->Animate(kInitialTickTime + GetTimeDelta(2.75));
1130 controller->UpdateState(true, events.get()); 1145 controller->UpdateState(true, events.get());
1131 EXPECT_TRUE(controller->HasActiveAnimation()); 1146 EXPECT_TRUE(controller->HasActiveAnimation());
1132 EXPECT_EQ(0.75f, dummy.opacity()); 1147 EXPECT_EQ(0.75f, dummy.opacity());
1133 controller->Animate(kInitialTickTime + 3.0); 1148 controller->Animate(kInitialTickTime + GetTimeDelta(3.0));
1134 controller->UpdateState(true, events.get()); 1149 controller->UpdateState(true, events.get());
1135 EXPECT_FALSE(controller->HasActiveAnimation()); 1150 EXPECT_FALSE(controller->HasActiveAnimation());
1136 EXPECT_EQ(1.f, dummy.opacity()); 1151 EXPECT_EQ(1.f, dummy.opacity());
1137 1152
1138 // Just be extra sure. 1153 // Just be extra sure.
1139 controller->Animate(kInitialTickTime + 4.0); 1154 controller->Animate(kInitialTickTime + GetTimeDelta(4.0));
1140 controller->UpdateState(true, events.get()); 1155 controller->UpdateState(true, events.get());
1141 EXPECT_EQ(1.f, dummy.opacity()); 1156 EXPECT_EQ(1.f, dummy.opacity());
1142 } 1157 }
1143 1158
1144 // Test that an infinitely looping animation does indeed go until aborted. 1159 // Test that an infinitely looping animation does indeed go until aborted.
1145 TEST(LayerAnimationControllerTest, InfiniteLooping) { 1160 TEST(LayerAnimationControllerTest, InfiniteLooping) {
1146 scoped_ptr<AnimationEventsVector> events( 1161 scoped_ptr<AnimationEventsVector> events(
1147 make_scoped_ptr(new AnimationEventsVector)); 1162 make_scoped_ptr(new AnimationEventsVector));
1148 FakeLayerAnimationValueObserver dummy; 1163 FakeLayerAnimationValueObserver dummy;
1149 scoped_refptr<LayerAnimationController> controller( 1164 scoped_refptr<LayerAnimationController> controller(
1150 LayerAnimationController::Create(0)); 1165 LayerAnimationController::Create(0));
1151 controller->AddValueObserver(&dummy); 1166 controller->AddValueObserver(&dummy);
1152 1167
1153 const int id = 1; 1168 const int id = 1;
1154 scoped_ptr<Animation> to_add(CreateAnimation( 1169 scoped_ptr<Animation> to_add(CreateAnimation(
1155 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1170 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1156 id, 1171 id,
1157 Animation::Opacity)); 1172 Animation::Opacity));
1158 to_add->set_iterations(-1); 1173 to_add->set_iterations(-1);
1159 controller->AddAnimation(to_add.Pass()); 1174 controller->AddAnimation(to_add.Pass());
1160 1175
1161 controller->Animate(kInitialTickTime); 1176 controller->Animate(kInitialTickTime);
1162 controller->UpdateState(true, events.get()); 1177 controller->UpdateState(true, events.get());
1163 EXPECT_TRUE(controller->HasActiveAnimation()); 1178 EXPECT_TRUE(controller->HasActiveAnimation());
1164 EXPECT_EQ(0.f, dummy.opacity()); 1179 EXPECT_EQ(0.f, dummy.opacity());
1165 controller->Animate(kInitialTickTime + 1.25); 1180 controller->Animate(kInitialTickTime + GetTimeDelta(1.25));
1166 controller->UpdateState(true, events.get()); 1181 controller->UpdateState(true, events.get());
1167 EXPECT_TRUE(controller->HasActiveAnimation()); 1182 EXPECT_TRUE(controller->HasActiveAnimation());
1168 EXPECT_EQ(0.25f, dummy.opacity()); 1183 EXPECT_EQ(0.25f, dummy.opacity());
1169 controller->Animate(kInitialTickTime + 1.75); 1184 controller->Animate(kInitialTickTime + GetTimeDelta(1.75));
1170 controller->UpdateState(true, events.get()); 1185 controller->UpdateState(true, events.get());
1171 EXPECT_TRUE(controller->HasActiveAnimation()); 1186 EXPECT_TRUE(controller->HasActiveAnimation());
1172 EXPECT_EQ(0.75f, dummy.opacity()); 1187 EXPECT_EQ(0.75f, dummy.opacity());
1173 1188
1174 controller->Animate(kInitialTickTime + 1073741824.25); 1189 controller->Animate(kInitialTickTime + GetTimeDelta(1073741824.25));
1175 controller->UpdateState(true, events.get()); 1190 controller->UpdateState(true, events.get());
1176 EXPECT_TRUE(controller->HasActiveAnimation()); 1191 EXPECT_TRUE(controller->HasActiveAnimation());
1177 EXPECT_EQ(0.25f, dummy.opacity()); 1192 EXPECT_EQ(0.25f, dummy.opacity());
1178 controller->Animate(kInitialTickTime + 1073741824.75); 1193 controller->Animate(kInitialTickTime + GetTimeDelta(1073741824.75));
1179 controller->UpdateState(true, events.get()); 1194 controller->UpdateState(true, events.get());
1180 EXPECT_TRUE(controller->HasActiveAnimation()); 1195 EXPECT_TRUE(controller->HasActiveAnimation());
1181 EXPECT_EQ(0.75f, dummy.opacity()); 1196 EXPECT_EQ(0.75f, dummy.opacity());
1182 1197
1183 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); 1198 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity));
1184 controller->GetAnimation(id, Animation::Opacity)->SetRunState( 1199 controller->GetAnimation(id, Animation::Opacity)
1185 Animation::Aborted, kInitialTickTime + 0.75); 1200 ->SetRunState(Animation::Aborted, kInitialDoubleTime + 0.75);
1186 EXPECT_FALSE(controller->HasActiveAnimation()); 1201 EXPECT_FALSE(controller->HasActiveAnimation());
1187 EXPECT_EQ(0.75f, dummy.opacity()); 1202 EXPECT_EQ(0.75f, dummy.opacity());
1188 } 1203 }
1189 1204
1190 // Test that pausing and resuming work as expected. 1205 // Test that pausing and resuming work as expected.
1191 TEST(LayerAnimationControllerTest, PauseResume) { 1206 TEST(LayerAnimationControllerTest, PauseResume) {
1192 scoped_ptr<AnimationEventsVector> events( 1207 scoped_ptr<AnimationEventsVector> events(
1193 make_scoped_ptr(new AnimationEventsVector)); 1208 make_scoped_ptr(new AnimationEventsVector));
1194 FakeLayerAnimationValueObserver dummy; 1209 FakeLayerAnimationValueObserver dummy;
1195 scoped_refptr<LayerAnimationController> controller( 1210 scoped_refptr<LayerAnimationController> controller(
1196 LayerAnimationController::Create(0)); 1211 LayerAnimationController::Create(0));
1197 controller->AddValueObserver(&dummy); 1212 controller->AddValueObserver(&dummy);
1198 1213
1199 const int id = 1; 1214 const int id = 1;
1200 controller->AddAnimation(CreateAnimation( 1215 controller->AddAnimation(CreateAnimation(
1201 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1216 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1202 id, 1217 id,
1203 Animation::Opacity)); 1218 Animation::Opacity));
1204 1219
1205 controller->Animate(kInitialTickTime); 1220 controller->Animate(kInitialTickTime);
1206 controller->UpdateState(true, events.get()); 1221 controller->UpdateState(true, events.get());
1207 EXPECT_TRUE(controller->HasActiveAnimation()); 1222 EXPECT_TRUE(controller->HasActiveAnimation());
1208 EXPECT_EQ(0.f, dummy.opacity()); 1223 EXPECT_EQ(0.f, dummy.opacity());
1209 controller->Animate(kInitialTickTime + 0.5); 1224 controller->Animate(kInitialTickTime + GetTimeDelta(0.5));
1210 controller->UpdateState(true, events.get()); 1225 controller->UpdateState(true, events.get());
1211 EXPECT_TRUE(controller->HasActiveAnimation()); 1226 EXPECT_TRUE(controller->HasActiveAnimation());
1212 EXPECT_EQ(0.5f, dummy.opacity()); 1227 EXPECT_EQ(0.5f, dummy.opacity());
1213 1228
1214 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); 1229 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity));
1215 controller->GetAnimation(id, Animation::Opacity)->SetRunState( 1230 controller->GetAnimation(id, Animation::Opacity)
1216 Animation::Paused, kInitialTickTime + 0.5); 1231 ->SetRunState(Animation::Paused, kInitialDoubleTime + 0.5);
1217 1232
1218 controller->Animate(kInitialTickTime + 1024.0); 1233 controller->Animate(kInitialTickTime + GetTimeDelta(1024.0));
1219 controller->UpdateState(true, events.get()); 1234 controller->UpdateState(true, events.get());
1220 EXPECT_TRUE(controller->HasActiveAnimation()); 1235 EXPECT_TRUE(controller->HasActiveAnimation());
1221 EXPECT_EQ(0.5f, dummy.opacity()); 1236 EXPECT_EQ(0.5f, dummy.opacity());
1222 1237
1223 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); 1238 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity));
1224 controller->GetAnimation(id, Animation::Opacity)->SetRunState( 1239 controller->GetAnimation(id, Animation::Opacity)
1225 Animation::Running, kInitialTickTime + 1024); 1240 ->SetRunState(Animation::Running, kInitialDoubleTime + 1024);
1226 1241
1227 controller->Animate(kInitialTickTime + 1024.25); 1242 controller->Animate(kInitialTickTime + GetTimeDelta(1024.25));
1228 controller->UpdateState(true, events.get()); 1243 controller->UpdateState(true, events.get());
1229 EXPECT_TRUE(controller->HasActiveAnimation()); 1244 EXPECT_TRUE(controller->HasActiveAnimation());
1230 EXPECT_EQ(0.75f, dummy.opacity()); 1245 EXPECT_EQ(0.75f, dummy.opacity());
1231 controller->Animate(kInitialTickTime + 1024.5); 1246 controller->Animate(kInitialTickTime + GetTimeDelta(1024.5));
1232 controller->UpdateState(true, events.get()); 1247 controller->UpdateState(true, events.get());
1233 EXPECT_FALSE(controller->HasActiveAnimation()); 1248 EXPECT_FALSE(controller->HasActiveAnimation());
1234 EXPECT_EQ(1.f, dummy.opacity()); 1249 EXPECT_EQ(1.f, dummy.opacity());
1235 } 1250 }
1236 1251
1237 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { 1252 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) {
1238 scoped_ptr<AnimationEventsVector> events( 1253 scoped_ptr<AnimationEventsVector> events(
1239 make_scoped_ptr(new AnimationEventsVector)); 1254 make_scoped_ptr(new AnimationEventsVector));
1240 FakeLayerAnimationValueObserver dummy; 1255 FakeLayerAnimationValueObserver dummy;
1241 scoped_refptr<LayerAnimationController> controller( 1256 scoped_refptr<LayerAnimationController> controller(
(...skipping 12 matching lines...) Expand all
1254 controller->AddAnimation(CreateAnimation( 1269 controller->AddAnimation(CreateAnimation(
1255 scoped_ptr<AnimationCurve>( 1270 scoped_ptr<AnimationCurve>(
1256 new FakeFloatTransition(1.0, 1.f, 0.75f)).Pass(), 1271 new FakeFloatTransition(1.0, 1.f, 0.75f)).Pass(),
1257 2, 1272 2,
1258 Animation::Opacity)); 1273 Animation::Opacity));
1259 1274
1260 controller->Animate(kInitialTickTime); 1275 controller->Animate(kInitialTickTime);
1261 controller->UpdateState(true, events.get()); 1276 controller->UpdateState(true, events.get());
1262 EXPECT_TRUE(controller->HasActiveAnimation()); 1277 EXPECT_TRUE(controller->HasActiveAnimation());
1263 EXPECT_EQ(0.f, dummy.opacity()); 1278 EXPECT_EQ(0.f, dummy.opacity());
1264 controller->Animate(kInitialTickTime + 1.0); 1279 controller->Animate(kInitialTickTime + GetTimeDelta(1.0));
1265 controller->UpdateState(true, events.get()); 1280 controller->UpdateState(true, events.get());
1266 EXPECT_TRUE(controller->HasActiveAnimation()); 1281 EXPECT_TRUE(controller->HasActiveAnimation());
1267 EXPECT_EQ(0.5f, dummy.opacity()); 1282 EXPECT_EQ(0.5f, dummy.opacity());
1268 1283
1269 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); 1284 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity));
1270 controller->GetAnimation(id, Animation::Opacity)->SetRunState( 1285 controller->GetAnimation(id, Animation::Opacity)
1271 Animation::Aborted, kInitialTickTime + 1.0); 1286 ->SetRunState(Animation::Aborted, kInitialDoubleTime + 1.0);
1272 controller->Animate(kInitialTickTime + 1.0); 1287 controller->Animate(kInitialTickTime + GetTimeDelta(1.0));
1273 controller->UpdateState(true, events.get()); 1288 controller->UpdateState(true, events.get());
1274 EXPECT_TRUE(controller->HasActiveAnimation()); 1289 EXPECT_TRUE(controller->HasActiveAnimation());
1275 EXPECT_EQ(1.f, dummy.opacity()); 1290 EXPECT_EQ(1.f, dummy.opacity());
1276 controller->Animate(kInitialTickTime + 2.0); 1291 controller->Animate(kInitialTickTime + GetTimeDelta(2.0));
1277 controller->UpdateState(true, events.get()); 1292 controller->UpdateState(true, events.get());
1278 EXPECT_TRUE(!controller->HasActiveAnimation()); 1293 EXPECT_TRUE(!controller->HasActiveAnimation());
1279 EXPECT_EQ(0.75f, dummy.opacity()); 1294 EXPECT_EQ(0.75f, dummy.opacity());
1280 } 1295 }
1281 1296
1282 TEST(LayerAnimationControllerTest, PushUpdatesWhenSynchronizedStartTimeNeeded) { 1297 TEST(LayerAnimationControllerTest, PushUpdatesWhenSynchronizedStartTimeNeeded) {
1283 FakeLayerAnimationValueObserver dummy_impl; 1298 FakeLayerAnimationValueObserver dummy_impl;
1284 scoped_refptr<LayerAnimationController> controller_impl( 1299 scoped_refptr<LayerAnimationController> controller_impl(
1285 LayerAnimationController::Create(0)); 1300 LayerAnimationController::Create(0));
1286 controller_impl->AddValueObserver(&dummy_impl); 1301 controller_impl->AddValueObserver(&dummy_impl);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 1344
1330 controller->Animate(kInitialTickTime); 1345 controller->Animate(kInitialTickTime);
1331 controller->UpdateState(true, events.get()); 1346 controller->UpdateState(true, events.get());
1332 1347
1333 controller->AddAnimation(CreateAnimation( 1348 controller->AddAnimation(CreateAnimation(
1334 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1349 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1335 2, 1350 2,
1336 Animation::Opacity)); 1351 Animation::Opacity));
1337 1352
1338 // Animate but don't UpdateState. 1353 // Animate but don't UpdateState.
1339 controller->Animate(kInitialTickTime + 1.0); 1354 controller->Animate(kInitialTickTime + GetTimeDelta(1.0));
1340 1355
1341 controller->Animate(kInitialTickTime + 2.0); 1356 controller->Animate(kInitialTickTime + GetTimeDelta(2.0));
1342 events.reset(new AnimationEventsVector); 1357 events.reset(new AnimationEventsVector);
1343 controller->UpdateState(true, events.get()); 1358 controller->UpdateState(true, events.get());
1344 1359
1345 // Should have one Started event and one Finished event. 1360 // Should have one Started event and one Finished event.
1346 EXPECT_EQ(2u, events->size()); 1361 EXPECT_EQ(2u, events->size());
1347 EXPECT_NE((*events)[0].type, (*events)[1].type); 1362 EXPECT_NE((*events)[0].type, (*events)[1].type);
1348 1363
1349 // The float transition should still be at its starting point. 1364 // The float transition should still be at its starting point.
1350 EXPECT_TRUE(controller->HasActiveAnimation()); 1365 EXPECT_TRUE(controller->HasActiveAnimation());
1351 EXPECT_EQ(0.f, dummy.opacity()); 1366 EXPECT_EQ(0.f, dummy.opacity());
1352 1367
1353 controller->Animate(kInitialTickTime + 3.0); 1368 controller->Animate(kInitialTickTime + GetTimeDelta(3.0));
1354 controller->UpdateState(true, events.get()); 1369 controller->UpdateState(true, events.get());
1355 1370
1356 // The float tranisition should now be done. 1371 // The float tranisition should now be done.
1357 EXPECT_EQ(1.f, dummy.opacity()); 1372 EXPECT_EQ(1.f, dummy.opacity());
1358 EXPECT_FALSE(controller->HasActiveAnimation()); 1373 EXPECT_FALSE(controller->HasActiveAnimation());
1359 } 1374 }
1360 1375
1361 // Tests that an animation controller with only an inactive observer gets ticked 1376 // Tests that an animation controller with only an inactive observer gets ticked
1362 // but doesn't progress animations past the Starting state. 1377 // but doesn't progress animations past the Starting state.
1363 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { 1378 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) {
(...skipping 16 matching lines...) Expand all
1380 controller->UpdateState(true, events.get()); 1395 controller->UpdateState(true, events.get());
1381 EXPECT_EQ(0u, events->size()); 1396 EXPECT_EQ(0u, events->size());
1382 EXPECT_EQ(Animation::WaitingForTargetAvailability, 1397 EXPECT_EQ(Animation::WaitingForTargetAvailability,
1383 controller->GetAnimation(id, Animation::Opacity)->run_state()); 1398 controller->GetAnimation(id, Animation::Opacity)->run_state());
1384 1399
1385 controller->AddValueObserver(&inactive_dummy); 1400 controller->AddValueObserver(&inactive_dummy);
1386 1401
1387 // With only an inactive observer, the animation should progress to the 1402 // With only an inactive observer, the animation should progress to the
1388 // Starting state and get ticked at its starting point, but should not 1403 // Starting state and get ticked at its starting point, but should not
1389 // progress to Running. 1404 // progress to Running.
1390 controller->Animate(kInitialTickTime + 1.0); 1405 controller->Animate(kInitialTickTime + GetTimeDelta(1.0));
1391 controller->UpdateState(true, events.get()); 1406 controller->UpdateState(true, events.get());
1392 EXPECT_EQ(0u, events->size()); 1407 EXPECT_EQ(0u, events->size());
1393 EXPECT_EQ(Animation::Starting, 1408 EXPECT_EQ(Animation::Starting,
1394 controller->GetAnimation(id, Animation::Opacity)->run_state()); 1409 controller->GetAnimation(id, Animation::Opacity)->run_state());
1395 EXPECT_EQ(0.5f, inactive_dummy.opacity()); 1410 EXPECT_EQ(0.5f, inactive_dummy.opacity());
1396 1411
1397 // Even when already in the Starting state, the animation should stay 1412 // Even when already in the Starting state, the animation should stay
1398 // there, and shouldn't be ticked past its starting point. 1413 // there, and shouldn't be ticked past its starting point.
1399 controller->Animate(kInitialTickTime + 2.0); 1414 controller->Animate(kInitialTickTime + GetTimeDelta(2.0));
1400 controller->UpdateState(true, events.get()); 1415 controller->UpdateState(true, events.get());
1401 EXPECT_EQ(0u, events->size()); 1416 EXPECT_EQ(0u, events->size());
1402 EXPECT_EQ(Animation::Starting, 1417 EXPECT_EQ(Animation::Starting,
1403 controller->GetAnimation(id, Animation::Opacity)->run_state()); 1418 controller->GetAnimation(id, Animation::Opacity)->run_state());
1404 EXPECT_EQ(0.5f, inactive_dummy.opacity()); 1419 EXPECT_EQ(0.5f, inactive_dummy.opacity());
1405 1420
1406 controller->AddValueObserver(&dummy); 1421 controller->AddValueObserver(&dummy);
1407 1422
1408 // Now that an active observer has been added, the animation should still 1423 // 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. 1424 // initially tick at its starting point, but should now progress to Running.
1410 controller->Animate(kInitialTickTime + 3.0); 1425 controller->Animate(kInitialTickTime + GetTimeDelta(3.0));
1411 controller->UpdateState(true, events.get()); 1426 controller->UpdateState(true, events.get());
1412 EXPECT_EQ(1u, events->size()); 1427 EXPECT_EQ(1u, events->size());
1413 EXPECT_EQ(Animation::Running, 1428 EXPECT_EQ(Animation::Running,
1414 controller->GetAnimation(id, Animation::Opacity)->run_state()); 1429 controller->GetAnimation(id, Animation::Opacity)->run_state());
1415 EXPECT_EQ(0.5f, inactive_dummy.opacity()); 1430 EXPECT_EQ(0.5f, inactive_dummy.opacity());
1416 EXPECT_EQ(0.5f, dummy.opacity()); 1431 EXPECT_EQ(0.5f, dummy.opacity());
1417 1432
1418 // The animation should now tick past its starting point. 1433 // The animation should now tick past its starting point.
1419 controller->Animate(kInitialTickTime + 3.5); 1434 controller->Animate(kInitialTickTime + GetTimeDelta(3.5));
1420 EXPECT_NE(0.5f, inactive_dummy.opacity()); 1435 EXPECT_NE(0.5f, inactive_dummy.opacity());
1421 EXPECT_NE(0.5f, dummy.opacity()); 1436 EXPECT_NE(0.5f, dummy.opacity());
1422 } 1437 }
1423 1438
1424 TEST(LayerAnimationControllerTest, TransformAnimationBounds) { 1439 TEST(LayerAnimationControllerTest, TransformAnimationBounds) {
1425 scoped_refptr<LayerAnimationController> controller_impl( 1440 scoped_refptr<LayerAnimationController> controller_impl(
1426 LayerAnimationController::Create(0)); 1441 LayerAnimationController::Create(0));
1427 1442
1428 scoped_ptr<KeyframedTransformAnimationCurve> curve1( 1443 scoped_ptr<KeyframedTransformAnimationCurve> curve1(
1429 KeyframedTransformAnimationCurve::Create()); 1444 KeyframedTransformAnimationCurve::Create());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), 1532 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(),
1518 4, 1533 4,
1519 Animation::Transform)); 1534 Animation::Transform));
1520 controller->AddAnimation(CreateAnimation( 1535 controller->AddAnimation(CreateAnimation(
1521 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1536 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1522 5, 1537 5,
1523 Animation::Opacity)); 1538 Animation::Opacity));
1524 1539
1525 controller->Animate(kInitialTickTime); 1540 controller->Animate(kInitialTickTime);
1526 controller->UpdateState(true, NULL); 1541 controller->UpdateState(true, NULL);
1527 controller->Animate(kInitialTickTime + 1.0); 1542 controller->Animate(kInitialTickTime + GetTimeDelta(1.0));
1528 controller->UpdateState(true, NULL); 1543 controller->UpdateState(true, NULL);
1529 1544
1530 EXPECT_EQ(Animation::Finished, 1545 EXPECT_EQ(Animation::Finished,
1531 controller->GetAnimation(1, Animation::Transform)->run_state()); 1546 controller->GetAnimation(1, Animation::Transform)->run_state());
1532 EXPECT_EQ(Animation::Finished, 1547 EXPECT_EQ(Animation::Finished,
1533 controller->GetAnimation(2, Animation::Opacity)->run_state()); 1548 controller->GetAnimation(2, Animation::Opacity)->run_state());
1534 EXPECT_EQ(Animation::Running, 1549 EXPECT_EQ(Animation::Running,
1535 controller->GetAnimation(3, Animation::Transform)->run_state()); 1550 controller->GetAnimation(3, Animation::Transform)->run_state());
1536 EXPECT_EQ(Animation::WaitingForTargetAvailability, 1551 EXPECT_EQ(Animation::WaitingForTargetAvailability,
1537 controller->GetAnimation(4, Animation::Transform)->run_state()); 1552 controller->GetAnimation(4, Animation::Transform)->run_state());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); 1631 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion());
1617 EXPECT_EQ(1u, events.size()); 1632 EXPECT_EQ(1u, events.size());
1618 EXPECT_EQ(AnimationEvent::Aborted, events[0].type); 1633 EXPECT_EQ(AnimationEvent::Aborted, events[0].type);
1619 EXPECT_EQ(Animation::WaitingForDeletion, 1634 EXPECT_EQ(Animation::WaitingForDeletion,
1620 controller_impl->GetAnimation(Animation::Opacity)->run_state()); 1635 controller_impl->GetAnimation(Animation::Opacity)->run_state());
1621 1636
1622 controller->NotifyAnimationAborted(events[0]); 1637 controller->NotifyAnimationAborted(events[0]);
1623 EXPECT_EQ(Animation::Aborted, 1638 EXPECT_EQ(Animation::Aborted,
1624 controller->GetAnimation(Animation::Opacity)->run_state()); 1639 controller->GetAnimation(Animation::Opacity)->run_state());
1625 1640
1626 controller->Animate(kInitialTickTime + 0.5); 1641 controller->Animate(kInitialTickTime + GetTimeDelta(0.5));
1627 controller->UpdateState(true, NULL); 1642 controller->UpdateState(true, NULL);
1628 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); 1643 EXPECT_TRUE(dummy.animation_waiting_for_deletion());
1629 EXPECT_EQ(Animation::WaitingForDeletion, 1644 EXPECT_EQ(Animation::WaitingForDeletion,
1630 controller->GetAnimation(Animation::Opacity)->run_state()); 1645 controller->GetAnimation(Animation::Opacity)->run_state());
1631 1646
1632 controller->PushAnimationUpdatesTo(controller_impl.get()); 1647 controller->PushAnimationUpdatesTo(controller_impl.get());
1633 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity)); 1648 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity));
1634 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); 1649 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity));
1635 } 1650 }
1636 1651
(...skipping 19 matching lines...) Expand all
1656 1671
1657 controller_impl->Animate(kInitialTickTime); 1672 controller_impl->Animate(kInitialTickTime);
1658 controller_impl->UpdateState(true, events.get()); 1673 controller_impl->UpdateState(true, events.get());
1659 1674
1660 // Both animations should have started. 1675 // Both animations should have started.
1661 EXPECT_EQ(2u, events->size()); 1676 EXPECT_EQ(2u, events->size());
1662 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); 1677 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type);
1663 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); 1678 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type);
1664 1679
1665 events.reset(new AnimationEventsVector); 1680 events.reset(new AnimationEventsVector);
1666 controller_impl->Animate(kInitialTickTime + 1.0); 1681 controller_impl->Animate(kInitialTickTime + GetTimeDelta(1.0));
1667 controller_impl->UpdateState(true, events.get()); 1682 controller_impl->UpdateState(true, events.get());
1668 1683
1669 // The opacity animation should be finished, but should not have generated 1684 // The opacity animation should be finished, but should not have generated
1670 // a Finished event yet. 1685 // a Finished event yet.
1671 EXPECT_EQ(0u, events->size()); 1686 EXPECT_EQ(0u, events->size());
1672 EXPECT_EQ(Animation::Finished, 1687 EXPECT_EQ(Animation::Finished,
1673 controller_impl->GetAnimation(1, Animation::Opacity)->run_state()); 1688 controller_impl->GetAnimation(1, Animation::Opacity)->run_state());
1674 EXPECT_EQ(Animation::Running, 1689 EXPECT_EQ(Animation::Running,
1675 controller_impl->GetAnimation(1, 1690 controller_impl->GetAnimation(1,
1676 Animation::Transform)->run_state()); 1691 Animation::Transform)->run_state());
1677 1692
1678 controller_impl->Animate(kInitialTickTime + 2.0); 1693 controller_impl->Animate(kInitialTickTime + GetTimeDelta(2.0));
1679 controller_impl->UpdateState(true, events.get()); 1694 controller_impl->UpdateState(true, events.get());
1680 1695
1681 // Both animations should have generated Finished events. 1696 // Both animations should have generated Finished events.
1682 EXPECT_EQ(2u, events->size()); 1697 EXPECT_EQ(2u, events->size());
1683 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); 1698 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type);
1684 EXPECT_EQ(AnimationEvent::Finished, (*events)[1].type); 1699 EXPECT_EQ(AnimationEvent::Finished, (*events)[1].type);
1685 } 1700 }
1686 1701
1687 // Ensure that when a group has a mix of aborted and finished animations, 1702 // 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 1703 // we generate a Finished event for the finished animation and an Aborted
(...skipping 20 matching lines...) Expand all
1709 controller_impl->UpdateState(true, events.get()); 1724 controller_impl->UpdateState(true, events.get());
1710 1725
1711 // Both animations should have started. 1726 // Both animations should have started.
1712 EXPECT_EQ(2u, events->size()); 1727 EXPECT_EQ(2u, events->size());
1713 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); 1728 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type);
1714 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); 1729 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type);
1715 1730
1716 controller_impl->AbortAnimations(Animation::Opacity); 1731 controller_impl->AbortAnimations(Animation::Opacity);
1717 1732
1718 events.reset(new AnimationEventsVector); 1733 events.reset(new AnimationEventsVector);
1719 controller_impl->Animate(kInitialTickTime + 1.0); 1734 controller_impl->Animate(kInitialTickTime + GetTimeDelta(1.0));
1720 controller_impl->UpdateState(true, events.get()); 1735 controller_impl->UpdateState(true, events.get());
1721 1736
1722 // We should have exactly 2 events: a Finished event for the tranform 1737 // We should have exactly 2 events: a Finished event for the tranform
1723 // animation, and an Aborted event for the opacity animation. 1738 // animation, and an Aborted event for the opacity animation.
1724 EXPECT_EQ(2u, events->size()); 1739 EXPECT_EQ(2u, events->size());
1725 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); 1740 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type);
1726 EXPECT_EQ(Animation::Transform, (*events)[0].target_property); 1741 EXPECT_EQ(Animation::Transform, (*events)[0].target_property);
1727 EXPECT_EQ(AnimationEvent::Aborted, (*events)[1].type); 1742 EXPECT_EQ(AnimationEvent::Aborted, (*events)[1].type);
1728 EXPECT_EQ(Animation::Opacity, (*events)[1].target_property); 1743 EXPECT_EQ(Animation::Opacity, (*events)[1].target_property);
1729 } 1744 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 ->SetRunState(Animation::Finished, 0.0); 1918 ->SetRunState(Animation::Finished, 0.0);
1904 1919
1905 // Only unfinished animations should be considered by 1920 // Only unfinished animations should be considered by
1906 // MaximumScale. 1921 // MaximumScale.
1907 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); 1922 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale));
1908 EXPECT_EQ(4.f, max_scale); 1923 EXPECT_EQ(4.f, max_scale);
1909 } 1924 }
1910 1925
1911 } // namespace 1926 } // namespace
1912 } // namespace cc 1927 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/layer_animation_controller.cc ('k') | cc/trees/layer_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698