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

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: Self review changes. Created 6 years, 7 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
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/base/time_util.h"
14 #include "cc/test/animation_test_common.h" 15 #include "cc/test/animation_test_common.h"
15 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 #include "ui/gfx/box_f.h" 18 #include "ui/gfx/box_f.h"
18 #include "ui/gfx/transform.h" 19 #include "ui/gfx/transform.h"
19 20
20 namespace cc { 21 namespace cc {
21 namespace { 22 namespace {
22 23
24 using base::TimeDelta;
25 using base::TimeTicks;
26
23 // A LayerAnimationController cannot be ticked at 0.0, since an animation 27 // 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 28 // with start time 0.0 is treated as an animation whose start time has
25 // not yet been set. 29 // not yet been set.
26 const double kInitialTickTime = 1.0; 30 const TimeTicks kInitialTickTime = TimeUtil::TicksFromSecondsF(1.0);
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 90
87 // Synchronize the start times. 91 // Synchronize the start times.
88 EXPECT_EQ(1u, events.size()); 92 EXPECT_EQ(1u, events.size());
89 controller->NotifyAnimationStarted(events[0]); 93 controller->NotifyAnimationStarted(events[0]);
90 EXPECT_EQ(controller->GetAnimation(group_id, 94 EXPECT_EQ(controller->GetAnimation(group_id,
91 Animation::Opacity)->start_time(), 95 Animation::Opacity)->start_time(),
92 controller_impl->GetAnimation(group_id, 96 controller_impl->GetAnimation(group_id,
93 Animation::Opacity)->start_time()); 97 Animation::Opacity)->start_time());
94 98
95 // Start the animation on the main thread. Should not affect the start time. 99 // Start the animation on the main thread. Should not affect the start time.
96 controller->Animate(kInitialTickTime + 0.5); 100 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
97 controller->UpdateState(true, NULL); 101 controller->UpdateState(true, NULL);
98 EXPECT_EQ(controller->GetAnimation(group_id, 102 EXPECT_EQ(controller->GetAnimation(group_id,
99 Animation::Opacity)->start_time(), 103 Animation::Opacity)->start_time(),
100 controller_impl->GetAnimation(group_id, 104 controller_impl->GetAnimation(group_id,
101 Animation::Opacity)->start_time()); 105 Animation::Opacity)->start_time());
102 } 106 }
103 107
104 TEST(LayerAnimationControllerTest, UseSpecifiedStartTimes) { 108 TEST(LayerAnimationControllerTest, UseSpecifiedStartTimes) {
105 FakeLayerAnimationValueObserver dummy_impl; 109 FakeLayerAnimationValueObserver dummy_impl;
106 scoped_refptr<LayerAnimationController> controller_impl( 110 scoped_refptr<LayerAnimationController> controller_impl(
107 LayerAnimationController::Create(0)); 111 LayerAnimationController::Create(0));
108 controller_impl->AddValueObserver(&dummy_impl); 112 controller_impl->AddValueObserver(&dummy_impl);
109 FakeLayerAnimationValueObserver dummy; 113 FakeLayerAnimationValueObserver dummy;
110 scoped_refptr<LayerAnimationController> controller( 114 scoped_refptr<LayerAnimationController> controller(
111 LayerAnimationController::Create(0)); 115 LayerAnimationController::Create(0));
112 controller->AddValueObserver(&dummy); 116 controller->AddValueObserver(&dummy);
113 117
114 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); 118 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false);
115 int group_id = controller->GetAnimation(Animation::Opacity)->group(); 119 int group_id = controller->GetAnimation(Animation::Opacity)->group();
116 120
117 const double start_time = 123; 121 const TimeTicks start_time = TimeUtil::TicksFromSecondsF(123);
118 controller->GetAnimation(Animation::Opacity)->set_start_time(start_time); 122 controller->GetAnimation(Animation::Opacity)->set_start_time(start_time);
119 123
120 controller->PushAnimationUpdatesTo(controller_impl.get()); 124 controller->PushAnimationUpdatesTo(controller_impl.get());
121 controller_impl->ActivateAnimations(); 125 controller_impl->ActivateAnimations();
122 126
123 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); 127 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity));
124 EXPECT_EQ(Animation::WaitingForTargetAvailability, 128 EXPECT_EQ(Animation::WaitingForTargetAvailability,
125 controller_impl->GetAnimation(group_id, 129 controller_impl->GetAnimation(group_id,
126 Animation::Opacity)->run_state()); 130 Animation::Opacity)->run_state());
127 131
128 AnimationEventsVector events; 132 AnimationEventsVector events;
129 controller_impl->Animate(kInitialTickTime); 133 controller_impl->Animate(kInitialTickTime);
130 controller_impl->UpdateState(true, &events); 134 controller_impl->UpdateState(true, &events);
131 135
132 // Synchronize the start times. 136 // Synchronize the start times.
133 EXPECT_EQ(1u, events.size()); 137 EXPECT_EQ(1u, events.size());
134 controller->NotifyAnimationStarted(events[0]); 138 controller->NotifyAnimationStarted(events[0]);
135 139
136 EXPECT_EQ(start_time, 140 EXPECT_EQ(start_time,
137 controller->GetAnimation(group_id, 141 controller->GetAnimation(group_id,
138 Animation::Opacity)->start_time()); 142 Animation::Opacity)->start_time());
139 EXPECT_EQ(controller->GetAnimation(group_id, 143 EXPECT_EQ(controller->GetAnimation(group_id,
140 Animation::Opacity)->start_time(), 144 Animation::Opacity)->start_time(),
141 controller_impl->GetAnimation(group_id, 145 controller_impl->GetAnimation(group_id,
142 Animation::Opacity)->start_time()); 146 Animation::Opacity)->start_time());
143 147
144 // Start the animation on the main thread. Should not affect the start time. 148 // Start the animation on the main thread. Should not affect the start time.
145 controller->Animate(kInitialTickTime + 0.5); 149 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
146 controller->UpdateState(true, NULL); 150 controller->UpdateState(true, NULL);
147 EXPECT_EQ(start_time, 151 EXPECT_EQ(start_time,
148 controller->GetAnimation(group_id, 152 controller->GetAnimation(group_id,
149 Animation::Opacity)->start_time()); 153 Animation::Opacity)->start_time());
150 EXPECT_EQ(controller->GetAnimation(group_id, 154 EXPECT_EQ(controller->GetAnimation(group_id,
151 Animation::Opacity)->start_time(), 155 Animation::Opacity)->start_time(),
152 controller_impl->GetAnimation(group_id, 156 controller_impl->GetAnimation(group_id,
153 Animation::Opacity)->start_time()); 157 Animation::Opacity)->start_time());
154 } 158 }
155 159
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); 193 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size());
190 194
191 controller_impl->Animate(kInitialTickTime); 195 controller_impl->Animate(kInitialTickTime);
192 controller_impl->UpdateState(true, events.get()); 196 controller_impl->UpdateState(true, events.get());
193 EXPECT_EQ(1u, events->size()); 197 EXPECT_EQ(1u, events->size());
194 controller->NotifyAnimationStarted((*events)[0]); 198 controller->NotifyAnimationStarted((*events)[0]);
195 199
196 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); 200 EXPECT_EQ(1u, registrar->active_animation_controllers().size());
197 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); 201 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size());
198 202
199 controller->Animate(kInitialTickTime + 0.5); 203 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
200 controller->UpdateState(true, NULL); 204 controller->UpdateState(true, NULL);
201 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); 205 EXPECT_EQ(1u, registrar->active_animation_controllers().size());
202 206
203 controller->Animate(kInitialTickTime + 1.0); 207 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
204 controller->UpdateState(true, NULL); 208 controller->UpdateState(true, NULL);
205 EXPECT_EQ(Animation::Finished, 209 EXPECT_EQ(Animation::Finished,
206 controller->GetAnimation(Animation::Opacity)->run_state()); 210 controller->GetAnimation(Animation::Opacity)->run_state());
207 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); 211 EXPECT_EQ(1u, registrar->active_animation_controllers().size());
208 212
209 events.reset(new AnimationEventsVector); 213 events.reset(new AnimationEventsVector);
210 controller_impl->Animate(kInitialTickTime + 1.5); 214 controller_impl->Animate(kInitialTickTime +
215 TimeDelta::FromMilliseconds(1500));
211 controller_impl->UpdateState(true, events.get()); 216 controller_impl->UpdateState(true, events.get());
212 217
213 EXPECT_EQ(Animation::WaitingForDeletion, 218 EXPECT_EQ(Animation::WaitingForDeletion,
214 controller_impl->GetAnimation(Animation::Opacity)->run_state()); 219 controller_impl->GetAnimation(Animation::Opacity)->run_state());
215 // The impl thread controller should have de-activated. 220 // The impl thread controller should have de-activated.
216 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); 221 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size());
217 222
218 EXPECT_EQ(1u, events->size()); 223 EXPECT_EQ(1u, events->size());
219 controller->NotifyAnimationFinished((*events)[0]); 224 controller->NotifyAnimationFinished((*events)[0]);
220 controller->Animate(kInitialTickTime + 1.5); 225 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500));
221 controller->UpdateState(true, NULL); 226 controller->UpdateState(true, NULL);
222 227
223 EXPECT_EQ(Animation::WaitingForDeletion, 228 EXPECT_EQ(Animation::WaitingForDeletion,
224 controller->GetAnimation(Animation::Opacity)->run_state()); 229 controller->GetAnimation(Animation::Opacity)->run_state());
225 // The main thread controller should have de-activated. 230 // The main thread controller should have de-activated.
226 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); 231 EXPECT_EQ(0u, registrar->active_animation_controllers().size());
227 232
228 controller->PushAnimationUpdatesTo(controller_impl.get()); 233 controller->PushAnimationUpdatesTo(controller_impl.get());
229 controller_impl->ActivateAnimations(); 234 controller_impl->ActivateAnimations();
230 EXPECT_FALSE(controller->has_any_animation()); 235 EXPECT_FALSE(controller->has_any_animation());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 controller->Animate(kInitialTickTime); 272 controller->Animate(kInitialTickTime);
268 controller->UpdateState(true, NULL); 273 controller->UpdateState(true, NULL);
269 EXPECT_EQ(Animation::Running, 274 EXPECT_EQ(Animation::Running,
270 controller_impl->GetAnimation(group_id, 275 controller_impl->GetAnimation(group_id,
271 Animation::Opacity)->run_state()); 276 Animation::Opacity)->run_state());
272 EXPECT_EQ(Animation::Running, 277 EXPECT_EQ(Animation::Running,
273 controller->GetAnimation(group_id, 278 controller->GetAnimation(group_id,
274 Animation::Opacity)->run_state()); 279 Animation::Opacity)->run_state());
275 280
276 // Pause the main-thread animation. 281 // Pause the main-thread animation.
277 controller->PauseAnimation(animation_id, kInitialTickTime + 1.0); 282 controller->PauseAnimation(
283 animation_id,
284 TimeDelta::FromMilliseconds(1000) + TimeDelta::FromMilliseconds(1000));
278 EXPECT_EQ(Animation::Paused, 285 EXPECT_EQ(Animation::Paused,
279 controller->GetAnimation(group_id, 286 controller->GetAnimation(group_id,
280 Animation::Opacity)->run_state()); 287 Animation::Opacity)->run_state());
281 288
282 // The pause run state change should make it to the impl thread controller. 289 // The pause run state change should make it to the impl thread controller.
283 controller->PushAnimationUpdatesTo(controller_impl.get()); 290 controller->PushAnimationUpdatesTo(controller_impl.get());
284 controller_impl->ActivateAnimations(); 291 controller_impl->ActivateAnimations();
285 EXPECT_EQ(Animation::Paused, 292 EXPECT_EQ(Animation::Paused,
286 controller_impl->GetAnimation(group_id, 293 controller_impl->GetAnimation(group_id,
287 Animation::Opacity)->run_state()); 294 Animation::Opacity)->run_state());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 LayerAnimationController::Create(0)); 352 LayerAnimationController::Create(0));
346 controller->AddValueObserver(&dummy); 353 controller->AddValueObserver(&dummy);
347 controller_impl->AddValueObserver(&dummy_impl); 354 controller_impl->AddValueObserver(&dummy_impl);
348 355
349 AddOpacityTransitionToController(controller.get(), 1.0, 0.0f, 1.0f, false); 356 AddOpacityTransitionToController(controller.get(), 1.0, 0.0f, 1.0f, false);
350 controller->Animate(kInitialTickTime); 357 controller->Animate(kInitialTickTime);
351 controller->UpdateState(true, NULL); 358 controller->UpdateState(true, NULL);
352 controller->PushAnimationUpdatesTo(controller_impl.get()); 359 controller->PushAnimationUpdatesTo(controller_impl.get());
353 controller_impl->ActivateAnimations(); 360 controller_impl->ActivateAnimations();
354 361
355 controller_impl->Animate(kInitialTickTime + 0.5); 362 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
356 controller_impl->UpdateState(true, events.get()); 363 controller_impl->UpdateState(true, events.get());
357 364
358 // There should be a Started event for the animation. 365 // There should be a Started event for the animation.
359 EXPECT_EQ(1u, events->size()); 366 EXPECT_EQ(1u, events->size());
360 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); 367 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type);
361 controller->NotifyAnimationStarted((*events)[0]); 368 controller->NotifyAnimationStarted((*events)[0]);
362 369
363 controller->Animate(kInitialTickTime + 1.0); 370 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
364 controller->UpdateState(true, NULL); 371 controller->UpdateState(true, NULL);
365 372
366 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); 373 EXPECT_FALSE(dummy.animation_waiting_for_deletion());
367 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); 374 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion());
368 375
369 events.reset(new AnimationEventsVector); 376 events.reset(new AnimationEventsVector);
370 controller_impl->Animate(kInitialTickTime + 2.0); 377 controller_impl->Animate(kInitialTickTime +
378 TimeDelta::FromMilliseconds(2000));
371 controller_impl->UpdateState(true, events.get()); 379 controller_impl->UpdateState(true, events.get());
372 380
373 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); 381 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion());
374 382
375 // There should be a Finished event for the animation. 383 // There should be a Finished event for the animation.
376 EXPECT_EQ(1u, events->size()); 384 EXPECT_EQ(1u, events->size());
377 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); 385 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type);
378 386
379 // Neither controller should have deleted the animation yet. 387 // Neither controller should have deleted the animation yet.
380 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); 388 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity));
381 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity)); 389 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity));
382 390
383 controller->NotifyAnimationFinished((*events)[0]); 391 controller->NotifyAnimationFinished((*events)[0]);
384 392
385 controller->Animate(kInitialTickTime + 3.0); 393 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
386 controller->UpdateState(true, NULL); 394 controller->UpdateState(true, NULL);
387 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); 395 EXPECT_TRUE(dummy.animation_waiting_for_deletion());
388 396
389 controller->PushAnimationUpdatesTo(controller_impl.get()); 397 controller->PushAnimationUpdatesTo(controller_impl.get());
390 398
391 // Both controllers should now have deleted the animation. The impl controller 399 // Both controllers should now have deleted the animation. The impl controller
392 // should have deleted the animation even though activation has not occurred, 400 // should have deleted the animation even though activation has not occurred,
393 // since the animation was already waiting for deletion when 401 // since the animation was already waiting for deletion when
394 // PushAnimationUpdatesTo was called. 402 // PushAnimationUpdatesTo was called.
395 EXPECT_FALSE(controller->has_any_animation()); 403 EXPECT_FALSE(controller->has_any_animation());
(...skipping 26 matching lines...) Expand all
422 Animation::Opacity)); 430 Animation::Opacity));
423 431
424 controller->AddAnimation(to_add.Pass()); 432 controller->AddAnimation(to_add.Pass());
425 controller->Animate(kInitialTickTime); 433 controller->Animate(kInitialTickTime);
426 controller->UpdateState(true, events.get()); 434 controller->UpdateState(true, events.get());
427 EXPECT_TRUE(controller->HasActiveAnimation()); 435 EXPECT_TRUE(controller->HasActiveAnimation());
428 EXPECT_EQ(0.f, dummy.opacity()); 436 EXPECT_EQ(0.f, dummy.opacity());
429 // A non-impl-only animation should not generate property updates. 437 // A non-impl-only animation should not generate property updates.
430 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 438 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
431 EXPECT_FALSE(event); 439 EXPECT_FALSE(event);
432 controller->Animate(kInitialTickTime + 1.0); 440 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
433 controller->UpdateState(true, events.get()); 441 controller->UpdateState(true, events.get());
434 EXPECT_EQ(1.f, dummy.opacity()); 442 EXPECT_EQ(1.f, dummy.opacity());
435 EXPECT_FALSE(controller->HasActiveAnimation()); 443 EXPECT_FALSE(controller->HasActiveAnimation());
436 event = GetMostRecentPropertyUpdateEvent(events.get()); 444 event = GetMostRecentPropertyUpdateEvent(events.get());
437 EXPECT_FALSE(event); 445 EXPECT_FALSE(event);
438 } 446 }
439 447
440 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { 448 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) {
441 scoped_ptr<AnimationEventsVector> events( 449 scoped_ptr<AnimationEventsVector> events(
442 make_scoped_ptr(new AnimationEventsVector)); 450 make_scoped_ptr(new AnimationEventsVector));
(...skipping 11 matching lines...) Expand all
454 controller_impl->AddAnimation(to_add.Pass()); 462 controller_impl->AddAnimation(to_add.Pass());
455 controller_impl->Animate(kInitialTickTime); 463 controller_impl->Animate(kInitialTickTime);
456 controller_impl->UpdateState(true, events.get()); 464 controller_impl->UpdateState(true, events.get());
457 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 465 EXPECT_TRUE(controller_impl->HasActiveAnimation());
458 EXPECT_EQ(0.f, dummy_impl.opacity()); 466 EXPECT_EQ(0.f, dummy_impl.opacity());
459 EXPECT_EQ(2u, events->size()); 467 EXPECT_EQ(2u, events->size());
460 const AnimationEvent* start_opacity_event = 468 const AnimationEvent* start_opacity_event =
461 GetMostRecentPropertyUpdateEvent(events.get()); 469 GetMostRecentPropertyUpdateEvent(events.get());
462 EXPECT_EQ(0.f, start_opacity_event->opacity); 470 EXPECT_EQ(0.f, start_opacity_event->opacity);
463 471
464 controller_impl->Animate(kInitialTickTime + 1.0); 472 controller_impl->Animate(kInitialTickTime +
473 TimeDelta::FromMilliseconds(1000));
465 controller_impl->UpdateState(true, events.get()); 474 controller_impl->UpdateState(true, events.get());
466 EXPECT_EQ(1.f, dummy_impl.opacity()); 475 EXPECT_EQ(1.f, dummy_impl.opacity());
467 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 476 EXPECT_FALSE(controller_impl->HasActiveAnimation());
468 EXPECT_EQ(4u, events->size()); 477 EXPECT_EQ(4u, events->size());
469 const AnimationEvent* end_opacity_event = 478 const AnimationEvent* end_opacity_event =
470 GetMostRecentPropertyUpdateEvent(events.get()); 479 GetMostRecentPropertyUpdateEvent(events.get());
471 EXPECT_EQ(1.f, end_opacity_event->opacity); 480 EXPECT_EQ(1.f, end_opacity_event->opacity);
472 } 481 }
473 482
474 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) { 483 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 EXPECT_EQ(2u, events->size()); 517 EXPECT_EQ(2u, events->size());
509 const AnimationEvent* start_transform_event = 518 const AnimationEvent* start_transform_event =
510 GetMostRecentPropertyUpdateEvent(events.get()); 519 GetMostRecentPropertyUpdateEvent(events.get());
511 ASSERT_TRUE(start_transform_event); 520 ASSERT_TRUE(start_transform_event);
512 EXPECT_EQ(gfx::Transform(), start_transform_event->transform); 521 EXPECT_EQ(gfx::Transform(), start_transform_event->transform);
513 EXPECT_TRUE(start_transform_event->is_impl_only); 522 EXPECT_TRUE(start_transform_event->is_impl_only);
514 523
515 gfx::Transform expected_transform; 524 gfx::Transform expected_transform;
516 expected_transform.Translate(delta_x, delta_y); 525 expected_transform.Translate(delta_x, delta_y);
517 526
518 controller_impl->Animate(kInitialTickTime + 1.0); 527 controller_impl->Animate(kInitialTickTime +
528 TimeDelta::FromMilliseconds(1000));
519 controller_impl->UpdateState(true, events.get()); 529 controller_impl->UpdateState(true, events.get());
520 EXPECT_EQ(expected_transform, dummy_impl.transform()); 530 EXPECT_EQ(expected_transform, dummy_impl.transform());
521 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 531 EXPECT_FALSE(controller_impl->HasActiveAnimation());
522 EXPECT_EQ(4u, events->size()); 532 EXPECT_EQ(4u, events->size());
523 const AnimationEvent* end_transform_event = 533 const AnimationEvent* end_transform_event =
524 GetMostRecentPropertyUpdateEvent(events.get()); 534 GetMostRecentPropertyUpdateEvent(events.get());
525 EXPECT_EQ(expected_transform, end_transform_event->transform); 535 EXPECT_EQ(expected_transform, end_transform_event->transform);
526 EXPECT_TRUE(end_transform_event->is_impl_only); 536 EXPECT_TRUE(end_transform_event->is_impl_only);
527 } 537 }
528 538
(...skipping 22 matching lines...) Expand all
551 controller->AddAnimation(animation.Pass()); 561 controller->AddAnimation(animation.Pass());
552 562
553 controller->Animate(kInitialTickTime); 563 controller->Animate(kInitialTickTime);
554 controller->UpdateState(true, events.get()); 564 controller->UpdateState(true, events.get());
555 EXPECT_TRUE(controller->HasActiveAnimation()); 565 EXPECT_TRUE(controller->HasActiveAnimation());
556 EXPECT_EQ(start_filters, dummy.filters()); 566 EXPECT_EQ(start_filters, dummy.filters());
557 // A non-impl-only animation should not generate property updates. 567 // A non-impl-only animation should not generate property updates.
558 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 568 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
559 EXPECT_FALSE(event); 569 EXPECT_FALSE(event);
560 570
561 controller->Animate(kInitialTickTime + 0.5); 571 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
562 controller->UpdateState(true, events.get()); 572 controller->UpdateState(true, events.get());
563 EXPECT_EQ(1u, dummy.filters().size()); 573 EXPECT_EQ(1u, dummy.filters().size());
564 EXPECT_EQ(FilterOperation::CreateBrightnessFilter(1.5f), 574 EXPECT_EQ(FilterOperation::CreateBrightnessFilter(1.5f),
565 dummy.filters().at(0)); 575 dummy.filters().at(0));
566 event = GetMostRecentPropertyUpdateEvent(events.get()); 576 event = GetMostRecentPropertyUpdateEvent(events.get());
567 EXPECT_FALSE(event); 577 EXPECT_FALSE(event);
568 578
569 controller->Animate(kInitialTickTime + 1.0); 579 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
570 controller->UpdateState(true, events.get()); 580 controller->UpdateState(true, events.get());
571 EXPECT_EQ(end_filters, dummy.filters()); 581 EXPECT_EQ(end_filters, dummy.filters());
572 EXPECT_FALSE(controller->HasActiveAnimation()); 582 EXPECT_FALSE(controller->HasActiveAnimation());
573 event = GetMostRecentPropertyUpdateEvent(events.get()); 583 event = GetMostRecentPropertyUpdateEvent(events.get());
574 EXPECT_FALSE(event); 584 EXPECT_FALSE(event);
575 } 585 }
576 586
577 TEST(LayerAnimationControllerTest, FilterTransitionOnImplOnly) { 587 TEST(LayerAnimationControllerTest, FilterTransitionOnImplOnly) {
578 scoped_ptr<AnimationEventsVector> events( 588 scoped_ptr<AnimationEventsVector> events(
579 make_scoped_ptr(new AnimationEventsVector)); 589 make_scoped_ptr(new AnimationEventsVector));
(...skipping 25 matching lines...) Expand all
605 controller_impl->UpdateState(true, events.get()); 615 controller_impl->UpdateState(true, events.get());
606 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 616 EXPECT_TRUE(controller_impl->HasActiveAnimation());
607 EXPECT_EQ(start_filters, dummy_impl.filters()); 617 EXPECT_EQ(start_filters, dummy_impl.filters());
608 EXPECT_EQ(2u, events->size()); 618 EXPECT_EQ(2u, events->size());
609 const AnimationEvent* start_filter_event = 619 const AnimationEvent* start_filter_event =
610 GetMostRecentPropertyUpdateEvent(events.get()); 620 GetMostRecentPropertyUpdateEvent(events.get());
611 EXPECT_TRUE(start_filter_event); 621 EXPECT_TRUE(start_filter_event);
612 EXPECT_EQ(start_filters, start_filter_event->filters); 622 EXPECT_EQ(start_filters, start_filter_event->filters);
613 EXPECT_TRUE(start_filter_event->is_impl_only); 623 EXPECT_TRUE(start_filter_event->is_impl_only);
614 624
615 controller_impl->Animate(kInitialTickTime + 1.0); 625 controller_impl->Animate(kInitialTickTime +
626 TimeDelta::FromMilliseconds(1000));
616 controller_impl->UpdateState(true, events.get()); 627 controller_impl->UpdateState(true, events.get());
617 EXPECT_EQ(end_filters, dummy_impl.filters()); 628 EXPECT_EQ(end_filters, dummy_impl.filters());
618 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 629 EXPECT_FALSE(controller_impl->HasActiveAnimation());
619 EXPECT_EQ(4u, events->size()); 630 EXPECT_EQ(4u, events->size());
620 const AnimationEvent* end_filter_event = 631 const AnimationEvent* end_filter_event =
621 GetMostRecentPropertyUpdateEvent(events.get()); 632 GetMostRecentPropertyUpdateEvent(events.get());
622 EXPECT_TRUE(end_filter_event); 633 EXPECT_TRUE(end_filter_event);
623 EXPECT_EQ(end_filters, end_filter_event->filters); 634 EXPECT_EQ(end_filters, end_filter_event->filters);
624 EXPECT_TRUE(end_filter_event->is_impl_only); 635 EXPECT_TRUE(end_filter_event->is_impl_only);
625 } 636 }
(...skipping 23 matching lines...) Expand all
649 660
650 scoped_ptr<Animation> animation(Animation::Create( 661 scoped_ptr<Animation> animation(Animation::Create(
651 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); 662 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset));
652 animation->set_needs_synchronized_start_time(true); 663 animation->set_needs_synchronized_start_time(true);
653 controller->AddAnimation(animation.Pass()); 664 controller->AddAnimation(animation.Pass());
654 665
655 dummy_provider_impl.set_scroll_offset(initial_value); 666 dummy_provider_impl.set_scroll_offset(initial_value);
656 controller->PushAnimationUpdatesTo(controller_impl.get()); 667 controller->PushAnimationUpdatesTo(controller_impl.get());
657 controller_impl->ActivateAnimations(); 668 controller_impl->ActivateAnimations();
658 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); 669 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset));
659 double duration = controller_impl->GetAnimation( 670 double duration = controller_impl->GetAnimation(Animation::ScrollOffset)
660 Animation::ScrollOffset)->curve()->Duration(); 671 ->curve()
661 672 ->Duration();
673 TimeDelta time_delta = TimeDelta::FromMicroseconds(
ajuma 2014/05/05 15:13:32 It would make the rest of the test easier to read
Sikugu_ 2014/05/07 14:49:07 Done.
Sikugu_ 2014/05/07 14:49:07 Done.
674 duration * base::Time::kMicrosecondsPerSecond);
662 EXPECT_EQ( 675 EXPECT_EQ(
663 duration, 676 duration,
664 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); 677 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration());
665
666 controller->Animate(kInitialTickTime); 678 controller->Animate(kInitialTickTime);
667 controller->UpdateState(true, NULL); 679 controller->UpdateState(true, NULL);
668 EXPECT_TRUE(controller->HasActiveAnimation()); 680 EXPECT_TRUE(controller->HasActiveAnimation());
669 EXPECT_EQ(initial_value, dummy.scroll_offset()); 681 EXPECT_EQ(initial_value, dummy.scroll_offset());
670 682
671 controller_impl->Animate(kInitialTickTime); 683 controller_impl->Animate(kInitialTickTime);
672 controller_impl->UpdateState(true, events.get()); 684 controller_impl->UpdateState(true, events.get());
673 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 685 EXPECT_TRUE(controller_impl->HasActiveAnimation());
674 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); 686 EXPECT_EQ(initial_value, dummy_impl.scroll_offset());
675 // Scroll offset animations should not generate property updates. 687 // Scroll offset animations should not generate property updates.
676 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 688 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
677 EXPECT_FALSE(event); 689 EXPECT_FALSE(event);
678
679 controller->NotifyAnimationStarted((*events)[0]); 690 controller->NotifyAnimationStarted((*events)[0]);
680 controller->Animate(kInitialTickTime + duration/2.0); 691 controller->Animate(kInitialTickTime + time_delta / 2);
681 controller->UpdateState(true, NULL); 692 controller->UpdateState(true, NULL);
682 EXPECT_TRUE(controller->HasActiveAnimation()); 693 EXPECT_TRUE(controller->HasActiveAnimation());
683 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), dummy.scroll_offset()); 694 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), dummy.scroll_offset());
684 695
685 controller_impl->Animate(kInitialTickTime + duration/2.0); 696 controller_impl->Animate(kInitialTickTime + time_delta / 2);
686 controller_impl->UpdateState(true, events.get()); 697 controller_impl->UpdateState(true, events.get());
687 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), 698 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f),
688 dummy_impl.scroll_offset()); 699 dummy_impl.scroll_offset());
689 event = GetMostRecentPropertyUpdateEvent(events.get()); 700 event = GetMostRecentPropertyUpdateEvent(events.get());
690 EXPECT_FALSE(event); 701 EXPECT_FALSE(event);
691 702
692 controller_impl->Animate(kInitialTickTime + duration); 703 controller_impl->Animate(kInitialTickTime + time_delta);
693 controller_impl->UpdateState(true, events.get()); 704 controller_impl->UpdateState(true, events.get());
694 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); 705 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset());
695 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 706 EXPECT_FALSE(controller_impl->HasActiveAnimation());
696 event = GetMostRecentPropertyUpdateEvent(events.get()); 707 event = GetMostRecentPropertyUpdateEvent(events.get());
697 EXPECT_FALSE(event); 708 EXPECT_FALSE(event);
698 709
699 controller->Animate(kInitialTickTime + duration); 710 controller->Animate(kInitialTickTime + time_delta);
700 controller->UpdateState(true, NULL); 711 controller->UpdateState(true, NULL);
701 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset()); 712 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset());
702 EXPECT_FALSE(controller->HasActiveAnimation()); 713 EXPECT_FALSE(controller->HasActiveAnimation());
703 } 714 }
704 715
705 // Ensure that when the impl controller doesn't have a value provider, 716 // Ensure that when the impl controller doesn't have a value provider,
706 // the main-thread controller's value provider is used to obtain the intial 717 // the main-thread controller's value provider is used to obtain the intial
707 // scroll offset. 718 // scroll offset.
708 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionNoImplProvider) { 719 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionNoImplProvider) {
709 FakeLayerAnimationValueObserver dummy_impl; 720 FakeLayerAnimationValueObserver dummy_impl;
(...skipping 20 matching lines...) Expand all
730 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); 741 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset));
731 animation->set_needs_synchronized_start_time(true); 742 animation->set_needs_synchronized_start_time(true);
732 controller->AddAnimation(animation.Pass()); 743 controller->AddAnimation(animation.Pass());
733 744
734 dummy_provider.set_scroll_offset(initial_value); 745 dummy_provider.set_scroll_offset(initial_value);
735 controller->PushAnimationUpdatesTo(controller_impl.get()); 746 controller->PushAnimationUpdatesTo(controller_impl.get());
736 controller_impl->ActivateAnimations(); 747 controller_impl->ActivateAnimations();
737 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); 748 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset));
738 double duration = controller_impl->GetAnimation( 749 double duration = controller_impl->GetAnimation(
739 Animation::ScrollOffset)->curve()->Duration(); 750 Animation::ScrollOffset)->curve()->Duration();
740
741 EXPECT_EQ( 751 EXPECT_EQ(
742 duration, 752 duration,
743 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); 753 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration());
744 754
745 controller->Animate(kInitialTickTime); 755 controller->Animate(kInitialTickTime);
746 controller->UpdateState(true, NULL); 756 controller->UpdateState(true, NULL);
747 EXPECT_TRUE(controller->HasActiveAnimation()); 757 EXPECT_TRUE(controller->HasActiveAnimation());
748 EXPECT_EQ(initial_value, dummy.scroll_offset()); 758 EXPECT_EQ(initial_value, dummy.scroll_offset());
749 759
750 controller_impl->Animate(kInitialTickTime); 760 controller_impl->Animate(kInitialTickTime);
751 controller_impl->UpdateState(true, events.get()); 761 controller_impl->UpdateState(true, events.get());
752 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 762 EXPECT_TRUE(controller_impl->HasActiveAnimation());
753 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); 763 EXPECT_EQ(initial_value, dummy_impl.scroll_offset());
754 // Scroll offset animations should not generate property updates. 764 // Scroll offset animations should not generate property updates.
755 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 765 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
756 EXPECT_FALSE(event); 766 EXPECT_FALSE(event);
757 767
768 TimeDelta time_delta = TimeDelta::FromMicroseconds(
ajuma 2014/05/05 15:13:32 Same comment, please rename this to duration.
Sikugu_ 2014/05/07 14:49:07 Done.
769 duration * base::Time::kMicrosecondsPerSecond);
770
758 controller->NotifyAnimationStarted((*events)[0]); 771 controller->NotifyAnimationStarted((*events)[0]);
759 controller->Animate(kInitialTickTime + duration/2.0); 772 controller->Animate(kInitialTickTime + time_delta / 2);
760 controller->UpdateState(true, NULL); 773 controller->UpdateState(true, NULL);
761 EXPECT_TRUE(controller->HasActiveAnimation()); 774 EXPECT_TRUE(controller->HasActiveAnimation());
762 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), dummy.scroll_offset()); 775 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), dummy.scroll_offset());
763 776
764 controller_impl->Animate(kInitialTickTime + duration/2.0); 777 controller_impl->Animate(kInitialTickTime + time_delta / 2);
765 controller_impl->UpdateState(true, events.get()); 778 controller_impl->UpdateState(true, events.get());
766 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), 779 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f),
767 dummy_impl.scroll_offset()); 780 dummy_impl.scroll_offset());
768 event = GetMostRecentPropertyUpdateEvent(events.get()); 781 event = GetMostRecentPropertyUpdateEvent(events.get());
769 EXPECT_FALSE(event); 782 EXPECT_FALSE(event);
770 783
771 controller_impl->Animate(kInitialTickTime + duration); 784 controller_impl->Animate(kInitialTickTime + time_delta);
772 controller_impl->UpdateState(true, events.get()); 785 controller_impl->UpdateState(true, events.get());
773 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); 786 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset());
774 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 787 EXPECT_FALSE(controller_impl->HasActiveAnimation());
775 event = GetMostRecentPropertyUpdateEvent(events.get()); 788 event = GetMostRecentPropertyUpdateEvent(events.get());
776 EXPECT_FALSE(event); 789 EXPECT_FALSE(event);
777 790
778 controller->Animate(kInitialTickTime + duration); 791 controller->Animate(kInitialTickTime + time_delta);
779 controller->UpdateState(true, NULL); 792 controller->UpdateState(true, NULL);
780 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset()); 793 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset());
781 EXPECT_FALSE(controller->HasActiveAnimation()); 794 EXPECT_FALSE(controller->HasActiveAnimation());
782 } 795 }
783 796
784 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionOnImplOnly) { 797 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionOnImplOnly) {
785 FakeLayerAnimationValueObserver dummy_impl; 798 FakeLayerAnimationValueObserver dummy_impl;
786 scoped_refptr<LayerAnimationController> controller_impl( 799 scoped_refptr<LayerAnimationController> controller_impl(
787 LayerAnimationController::Create(0)); 800 LayerAnimationController::Create(0));
788 controller_impl->AddValueObserver(&dummy_impl); 801 controller_impl->AddValueObserver(&dummy_impl);
(...skipping 15 matching lines...) Expand all
804 controller_impl->AddAnimation(animation.Pass()); 817 controller_impl->AddAnimation(animation.Pass());
805 818
806 controller_impl->Animate(kInitialTickTime); 819 controller_impl->Animate(kInitialTickTime);
807 controller_impl->UpdateState(true, events.get()); 820 controller_impl->UpdateState(true, events.get());
808 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 821 EXPECT_TRUE(controller_impl->HasActiveAnimation());
809 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); 822 EXPECT_EQ(initial_value, dummy_impl.scroll_offset());
810 // Scroll offset animations should not generate property updates. 823 // Scroll offset animations should not generate property updates.
811 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 824 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
812 EXPECT_FALSE(event); 825 EXPECT_FALSE(event);
813 826
814 controller_impl->Animate(kInitialTickTime + duration/2.0); 827 TimeDelta time_delta = TimeDelta::FromMicroseconds(
ajuma 2014/05/05 15:13:32 Here too.
Sikugu_ 2014/05/07 14:49:07 Done.
828 duration * base::Time::kMicrosecondsPerSecond);
829
830 controller_impl->Animate(kInitialTickTime + time_delta / 2);
815 controller_impl->UpdateState(true, events.get()); 831 controller_impl->UpdateState(true, events.get());
816 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), 832 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f),
817 dummy_impl.scroll_offset()); 833 dummy_impl.scroll_offset());
818 event = GetMostRecentPropertyUpdateEvent(events.get()); 834 event = GetMostRecentPropertyUpdateEvent(events.get());
819 EXPECT_FALSE(event); 835 EXPECT_FALSE(event);
820 836
821 controller_impl->Animate(kInitialTickTime + duration); 837 controller_impl->Animate(kInitialTickTime + time_delta);
822 controller_impl->UpdateState(true, events.get()); 838 controller_impl->UpdateState(true, events.get());
823 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); 839 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset());
824 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 840 EXPECT_FALSE(controller_impl->HasActiveAnimation());
825 event = GetMostRecentPropertyUpdateEvent(events.get()); 841 event = GetMostRecentPropertyUpdateEvent(events.get());
826 EXPECT_FALSE(event); 842 EXPECT_FALSE(event);
827 } 843 }
828 844
829 class FakeAnimationDelegate : public AnimationDelegate { 845 class FakeAnimationDelegate : public AnimationDelegate {
830 public: 846 public:
831 FakeAnimationDelegate() 847 FakeAnimationDelegate()
832 : started_(false), 848 : started_(false),
833 finished_(false) {} 849 finished_(false) {}
834 850
835 virtual void NotifyAnimationStarted( 851 virtual void NotifyAnimationStarted(
836 base::TimeTicks monotonic_time, 852 TimeTicks monotonic_time,
837 Animation::TargetProperty target_property) OVERRIDE { 853 Animation::TargetProperty target_property) OVERRIDE {
838 started_ = true; 854 started_ = true;
839 } 855 }
840 856
841 virtual void NotifyAnimationFinished( 857 virtual void NotifyAnimationFinished(
842 base::TimeTicks monotonic_time, 858 TimeTicks monotonic_time,
843 Animation::TargetProperty target_property) OVERRIDE { 859 Animation::TargetProperty target_property) OVERRIDE {
844 finished_ = true; 860 finished_ = true;
845 } 861 }
846 862
847 bool started() { return started_; } 863 bool started() { return started_; }
848 864
849 bool finished() { return finished_; } 865 bool finished() { return finished_; }
850 866
851 private: 867 private:
852 bool started_; 868 bool started_;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); 903 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type);
888 EXPECT_TRUE((*events)[1].is_impl_only); 904 EXPECT_TRUE((*events)[1].is_impl_only);
889 905
890 // Passing on the start event to the main thread controller should cause the 906 // Passing on the start event to the main thread controller should cause the
891 // delegate to get notified. 907 // delegate to get notified.
892 EXPECT_FALSE(delegate.started()); 908 EXPECT_FALSE(delegate.started());
893 controller->NotifyAnimationStarted((*events)[0]); 909 controller->NotifyAnimationStarted((*events)[0]);
894 EXPECT_TRUE(delegate.started()); 910 EXPECT_TRUE(delegate.started());
895 911
896 events.reset(new AnimationEventsVector); 912 events.reset(new AnimationEventsVector);
897 controller_impl->Animate(kInitialTickTime + 1.0); 913 controller_impl->Animate(kInitialTickTime +
914 TimeDelta::FromMilliseconds(1000));
898 controller_impl->UpdateState(true, events.get()); 915 controller_impl->UpdateState(true, events.get());
899 916
900 // We should receive 2 events (a finished notification and a property update). 917 // We should receive 2 events (a finished notification and a property update).
901 EXPECT_EQ(2u, events->size()); 918 EXPECT_EQ(2u, events->size());
902 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); 919 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type);
903 EXPECT_TRUE((*events)[0].is_impl_only); 920 EXPECT_TRUE((*events)[0].is_impl_only);
904 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); 921 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type);
905 EXPECT_TRUE((*events)[1].is_impl_only); 922 EXPECT_TRUE((*events)[1].is_impl_only);
906 923
907 // Passing on the finished event to the main thread controller should cause 924 // Passing on the finished event to the main thread controller should cause
(...skipping 20 matching lines...) Expand all
928 Animation::Opacity)); 945 Animation::Opacity));
929 to_add->set_needs_synchronized_start_time(true); 946 to_add->set_needs_synchronized_start_time(true);
930 947
931 // We should pause at the first keyframe indefinitely waiting for that 948 // We should pause at the first keyframe indefinitely waiting for that
932 // animation to start. 949 // animation to start.
933 controller->AddAnimation(to_add.Pass()); 950 controller->AddAnimation(to_add.Pass());
934 controller->Animate(kInitialTickTime); 951 controller->Animate(kInitialTickTime);
935 controller->UpdateState(true, events.get()); 952 controller->UpdateState(true, events.get());
936 EXPECT_TRUE(controller->HasActiveAnimation()); 953 EXPECT_TRUE(controller->HasActiveAnimation());
937 EXPECT_EQ(0.f, dummy.opacity()); 954 EXPECT_EQ(0.f, dummy.opacity());
938 controller->Animate(kInitialTickTime + 1.0); 955 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
939 controller->UpdateState(true, events.get()); 956 controller->UpdateState(true, events.get());
940 EXPECT_TRUE(controller->HasActiveAnimation()); 957 EXPECT_TRUE(controller->HasActiveAnimation());
941 EXPECT_EQ(0.f, dummy.opacity()); 958 EXPECT_EQ(0.f, dummy.opacity());
942 controller->Animate(kInitialTickTime + 2.0); 959 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
943 controller->UpdateState(true, events.get()); 960 controller->UpdateState(true, events.get());
944 EXPECT_TRUE(controller->HasActiveAnimation()); 961 EXPECT_TRUE(controller->HasActiveAnimation());
945 EXPECT_EQ(0.f, dummy.opacity()); 962 EXPECT_EQ(0.f, dummy.opacity());
946 963
947 // Send the synchronized start time. 964 // Send the synchronized start time.
948 controller->NotifyAnimationStarted(AnimationEvent( 965 controller->NotifyAnimationStarted(
949 AnimationEvent::Started, 0, 1, Animation::Opacity, kInitialTickTime + 2)); 966 AnimationEvent(AnimationEvent::Started,
950 controller->Animate(kInitialTickTime + 5.0); 967 0,
968 1,
969 Animation::Opacity,
970 kInitialTickTime + TimeDelta::FromMilliseconds(2000)));
971 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(5000));
951 controller->UpdateState(true, events.get()); 972 controller->UpdateState(true, events.get());
952 EXPECT_EQ(1.f, dummy.opacity()); 973 EXPECT_EQ(1.f, dummy.opacity());
953 EXPECT_FALSE(controller->HasActiveAnimation()); 974 EXPECT_FALSE(controller->HasActiveAnimation());
954 } 975 }
955 976
956 // Tests that two queued animations affecting the same property run in sequence. 977 // Tests that two queued animations affecting the same property run in sequence.
957 TEST(LayerAnimationControllerTest, TrivialQueuing) { 978 TEST(LayerAnimationControllerTest, TrivialQueuing) {
958 scoped_ptr<AnimationEventsVector> events( 979 scoped_ptr<AnimationEventsVector> events(
959 make_scoped_ptr(new AnimationEventsVector)); 980 make_scoped_ptr(new AnimationEventsVector));
960 FakeLayerAnimationValueObserver dummy; 981 FakeLayerAnimationValueObserver dummy;
961 scoped_refptr<LayerAnimationController> controller( 982 scoped_refptr<LayerAnimationController> controller(
962 LayerAnimationController::Create(0)); 983 LayerAnimationController::Create(0));
963 controller->AddValueObserver(&dummy); 984 controller->AddValueObserver(&dummy);
964 985
965 controller->AddAnimation(CreateAnimation( 986 controller->AddAnimation(CreateAnimation(
966 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 987 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
967 1, 988 1,
968 Animation::Opacity)); 989 Animation::Opacity));
969 controller->AddAnimation(CreateAnimation( 990 controller->AddAnimation(CreateAnimation(
970 scoped_ptr<AnimationCurve>( 991 scoped_ptr<AnimationCurve>(
971 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), 992 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(),
972 2, 993 2,
973 Animation::Opacity)); 994 Animation::Opacity));
974 995
975 controller->Animate(kInitialTickTime); 996 controller->Animate(kInitialTickTime);
976 controller->UpdateState(true, events.get()); 997 controller->UpdateState(true, events.get());
977 EXPECT_TRUE(controller->HasActiveAnimation()); 998 EXPECT_TRUE(controller->HasActiveAnimation());
978 EXPECT_EQ(0.f, dummy.opacity()); 999 EXPECT_EQ(0.f, dummy.opacity());
979 controller->Animate(kInitialTickTime + 1.0); 1000 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
980 controller->UpdateState(true, events.get()); 1001 controller->UpdateState(true, events.get());
981 EXPECT_TRUE(controller->HasActiveAnimation()); 1002 EXPECT_TRUE(controller->HasActiveAnimation());
982 EXPECT_EQ(1.f, dummy.opacity()); 1003 EXPECT_EQ(1.f, dummy.opacity());
983 controller->Animate(kInitialTickTime + 2.0); 1004 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
984 controller->UpdateState(true, events.get()); 1005 controller->UpdateState(true, events.get());
985 EXPECT_EQ(0.5f, dummy.opacity()); 1006 EXPECT_EQ(0.5f, dummy.opacity());
986 EXPECT_FALSE(controller->HasActiveAnimation()); 1007 EXPECT_FALSE(controller->HasActiveAnimation());
987 } 1008 }
988 1009
989 // Tests interrupting a transition with another transition. 1010 // Tests interrupting a transition with another transition.
990 TEST(LayerAnimationControllerTest, Interrupt) { 1011 TEST(LayerAnimationControllerTest, Interrupt) {
991 scoped_ptr<AnimationEventsVector> events( 1012 scoped_ptr<AnimationEventsVector> events(
992 make_scoped_ptr(new AnimationEventsVector)); 1013 make_scoped_ptr(new AnimationEventsVector));
993 FakeLayerAnimationValueObserver dummy; 1014 FakeLayerAnimationValueObserver dummy;
(...skipping 12 matching lines...) Expand all
1006 scoped_ptr<Animation> to_add(CreateAnimation( 1027 scoped_ptr<Animation> to_add(CreateAnimation(
1007 scoped_ptr<AnimationCurve>( 1028 scoped_ptr<AnimationCurve>(
1008 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), 1029 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(),
1009 2, 1030 2,
1010 Animation::Opacity)); 1031 Animation::Opacity));
1011 controller->AbortAnimations(Animation::Opacity); 1032 controller->AbortAnimations(Animation::Opacity);
1012 controller->AddAnimation(to_add.Pass()); 1033 controller->AddAnimation(to_add.Pass());
1013 1034
1014 // Since the previous animation was aborted, the new animation should start 1035 // Since the previous animation was aborted, the new animation should start
1015 // right in this call to animate. 1036 // right in this call to animate.
1016 controller->Animate(kInitialTickTime + 0.5); 1037 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
1017 controller->UpdateState(true, events.get()); 1038 controller->UpdateState(true, events.get());
1018 EXPECT_TRUE(controller->HasActiveAnimation()); 1039 EXPECT_TRUE(controller->HasActiveAnimation());
1019 EXPECT_EQ(1.f, dummy.opacity()); 1040 EXPECT_EQ(1.f, dummy.opacity());
1020 controller->Animate(kInitialTickTime + 1.5); 1041 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500));
1021 controller->UpdateState(true, events.get()); 1042 controller->UpdateState(true, events.get());
1022 EXPECT_EQ(0.5f, dummy.opacity()); 1043 EXPECT_EQ(0.5f, dummy.opacity());
1023 EXPECT_FALSE(controller->HasActiveAnimation()); 1044 EXPECT_FALSE(controller->HasActiveAnimation());
1024 } 1045 }
1025 1046
1026 // Tests scheduling two animations to run together when only one property is 1047 // Tests scheduling two animations to run together when only one property is
1027 // free. 1048 // free.
1028 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { 1049 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) {
1029 scoped_ptr<AnimationEventsVector> events( 1050 scoped_ptr<AnimationEventsVector> events(
1030 make_scoped_ptr(new AnimationEventsVector)); 1051 make_scoped_ptr(new AnimationEventsVector));
(...skipping 12 matching lines...) Expand all
1043 Animation::Transform)); 1064 Animation::Transform));
1044 controller->AddAnimation(CreateAnimation( 1065 controller->AddAnimation(CreateAnimation(
1045 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1066 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1046 2, 1067 2,
1047 Animation::Opacity)); 1068 Animation::Opacity));
1048 1069
1049 controller->Animate(kInitialTickTime); 1070 controller->Animate(kInitialTickTime);
1050 controller->UpdateState(true, events.get()); 1071 controller->UpdateState(true, events.get());
1051 EXPECT_EQ(0.f, dummy.opacity()); 1072 EXPECT_EQ(0.f, dummy.opacity());
1052 EXPECT_TRUE(controller->HasActiveAnimation()); 1073 EXPECT_TRUE(controller->HasActiveAnimation());
1053 controller->Animate(kInitialTickTime + 1.0); 1074 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1054 controller->UpdateState(true, events.get()); 1075 controller->UpdateState(true, events.get());
1055 // Should not have started the float transition yet. 1076 // Should not have started the float transition yet.
1056 EXPECT_TRUE(controller->HasActiveAnimation()); 1077 EXPECT_TRUE(controller->HasActiveAnimation());
1057 EXPECT_EQ(0.f, dummy.opacity()); 1078 EXPECT_EQ(0.f, dummy.opacity());
1058 // The float animation should have started at time 1 and should be done. 1079 // The float animation should have started at time 1 and should be done.
1059 controller->Animate(kInitialTickTime + 2.0); 1080 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1060 controller->UpdateState(true, events.get()); 1081 controller->UpdateState(true, events.get());
1061 EXPECT_EQ(1.f, dummy.opacity()); 1082 EXPECT_EQ(1.f, dummy.opacity());
1062 EXPECT_FALSE(controller->HasActiveAnimation()); 1083 EXPECT_FALSE(controller->HasActiveAnimation());
1063 } 1084 }
1064 1085
1065 // Tests scheduling two animations to run together with different lengths and 1086 // Tests scheduling two animations to run together with different lengths and
1066 // another animation queued to start when the shorter animation finishes (should 1087 // another animation queued to start when the shorter animation finishes (should
1067 // wait for both to finish). 1088 // wait for both to finish).
1068 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { 1089 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) {
1069 scoped_ptr<AnimationEventsVector> events( 1090 scoped_ptr<AnimationEventsVector> events(
(...skipping 18 matching lines...) Expand all
1088 Animation::Opacity)); 1109 Animation::Opacity));
1089 1110
1090 // Animations with id 1 should both start now. 1111 // Animations with id 1 should both start now.
1091 controller->Animate(kInitialTickTime); 1112 controller->Animate(kInitialTickTime);
1092 controller->UpdateState(true, events.get()); 1113 controller->UpdateState(true, events.get());
1093 EXPECT_TRUE(controller->HasActiveAnimation()); 1114 EXPECT_TRUE(controller->HasActiveAnimation());
1094 EXPECT_EQ(0.f, dummy.opacity()); 1115 EXPECT_EQ(0.f, dummy.opacity());
1095 // The opacity animation should have finished at time 1, but the group 1116 // The opacity animation should have finished at time 1, but the group
1096 // of animations with id 1 don't finish until time 2 because of the length 1117 // of animations with id 1 don't finish until time 2 because of the length
1097 // of the transform animation. 1118 // of the transform animation.
1098 controller->Animate(kInitialTickTime + 2.0); 1119 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1099 controller->UpdateState(true, events.get()); 1120 controller->UpdateState(true, events.get());
1100 // Should not have started the float transition yet. 1121 // Should not have started the float transition yet.
1101 EXPECT_TRUE(controller->HasActiveAnimation()); 1122 EXPECT_TRUE(controller->HasActiveAnimation());
1102 EXPECT_EQ(1.f, dummy.opacity()); 1123 EXPECT_EQ(1.f, dummy.opacity());
1103 1124
1104 // The second opacity animation should start at time 2 and should be done by 1125 // The second opacity animation should start at time 2 and should be done by
1105 // time 3. 1126 // time 3.
1106 controller->Animate(kInitialTickTime + 3.0); 1127 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
1107 controller->UpdateState(true, events.get()); 1128 controller->UpdateState(true, events.get());
1108 EXPECT_EQ(0.5f, dummy.opacity()); 1129 EXPECT_EQ(0.5f, dummy.opacity());
1109 EXPECT_FALSE(controller->HasActiveAnimation()); 1130 EXPECT_FALSE(controller->HasActiveAnimation());
1110 } 1131 }
1111 1132
1112 // Test that a looping animation loops and for the correct number of iterations. 1133 // Test that a looping animation loops and for the correct number of iterations.
1113 TEST(LayerAnimationControllerTest, TrivialLooping) { 1134 TEST(LayerAnimationControllerTest, TrivialLooping) {
1114 scoped_ptr<AnimationEventsVector> events( 1135 scoped_ptr<AnimationEventsVector> events(
1115 make_scoped_ptr(new AnimationEventsVector)); 1136 make_scoped_ptr(new AnimationEventsVector));
1116 FakeLayerAnimationValueObserver dummy; 1137 FakeLayerAnimationValueObserver dummy;
1117 scoped_refptr<LayerAnimationController> controller( 1138 scoped_refptr<LayerAnimationController> controller(
1118 LayerAnimationController::Create(0)); 1139 LayerAnimationController::Create(0));
1119 controller->AddValueObserver(&dummy); 1140 controller->AddValueObserver(&dummy);
1120 1141
1121 scoped_ptr<Animation> to_add(CreateAnimation( 1142 scoped_ptr<Animation> to_add(CreateAnimation(
1122 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1143 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1123 1, 1144 1,
1124 Animation::Opacity)); 1145 Animation::Opacity));
1125 to_add->set_iterations(3); 1146 to_add->set_iterations(3);
1126 controller->AddAnimation(to_add.Pass()); 1147 controller->AddAnimation(to_add.Pass());
1127 1148
1128 controller->Animate(kInitialTickTime); 1149 controller->Animate(kInitialTickTime);
1129 controller->UpdateState(true, events.get()); 1150 controller->UpdateState(true, events.get());
1130 EXPECT_TRUE(controller->HasActiveAnimation()); 1151 EXPECT_TRUE(controller->HasActiveAnimation());
1131 EXPECT_EQ(0.f, dummy.opacity()); 1152 EXPECT_EQ(0.f, dummy.opacity());
1132 controller->Animate(kInitialTickTime + 1.25); 1153 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250));
1133 controller->UpdateState(true, events.get()); 1154 controller->UpdateState(true, events.get());
1134 EXPECT_TRUE(controller->HasActiveAnimation()); 1155 EXPECT_TRUE(controller->HasActiveAnimation());
1135 EXPECT_EQ(0.25f, dummy.opacity()); 1156 EXPECT_EQ(0.25f, dummy.opacity());
1136 controller->Animate(kInitialTickTime + 1.75); 1157 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750));
1137 controller->UpdateState(true, events.get()); 1158 controller->UpdateState(true, events.get());
1138 EXPECT_TRUE(controller->HasActiveAnimation()); 1159 EXPECT_TRUE(controller->HasActiveAnimation());
1139 EXPECT_EQ(0.75f, dummy.opacity()); 1160 EXPECT_EQ(0.75f, dummy.opacity());
1140 controller->Animate(kInitialTickTime + 2.25); 1161 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2250));
1141 controller->UpdateState(true, events.get()); 1162 controller->UpdateState(true, events.get());
1142 EXPECT_TRUE(controller->HasActiveAnimation()); 1163 EXPECT_TRUE(controller->HasActiveAnimation());
1143 EXPECT_EQ(0.25f, dummy.opacity()); 1164 EXPECT_EQ(0.25f, dummy.opacity());
1144 controller->Animate(kInitialTickTime + 2.75); 1165 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2750));
1145 controller->UpdateState(true, events.get()); 1166 controller->UpdateState(true, events.get());
1146 EXPECT_TRUE(controller->HasActiveAnimation()); 1167 EXPECT_TRUE(controller->HasActiveAnimation());
1147 EXPECT_EQ(0.75f, dummy.opacity()); 1168 EXPECT_EQ(0.75f, dummy.opacity());
1148 controller->Animate(kInitialTickTime + 3.0); 1169 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
1149 controller->UpdateState(true, events.get()); 1170 controller->UpdateState(true, events.get());
1150 EXPECT_FALSE(controller->HasActiveAnimation()); 1171 EXPECT_FALSE(controller->HasActiveAnimation());
1151 EXPECT_EQ(1.f, dummy.opacity()); 1172 EXPECT_EQ(1.f, dummy.opacity());
1152 1173
1153 // Just be extra sure. 1174 // Just be extra sure.
1154 controller->Animate(kInitialTickTime + 4.0); 1175 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000));
1155 controller->UpdateState(true, events.get()); 1176 controller->UpdateState(true, events.get());
1156 EXPECT_EQ(1.f, dummy.opacity()); 1177 EXPECT_EQ(1.f, dummy.opacity());
1157 } 1178 }
1158 1179
1159 // Test that an infinitely looping animation does indeed go until aborted. 1180 // Test that an infinitely looping animation does indeed go until aborted.
1160 TEST(LayerAnimationControllerTest, InfiniteLooping) { 1181 TEST(LayerAnimationControllerTest, InfiniteLooping) {
1161 scoped_ptr<AnimationEventsVector> events( 1182 scoped_ptr<AnimationEventsVector> events(
1162 make_scoped_ptr(new AnimationEventsVector)); 1183 make_scoped_ptr(new AnimationEventsVector));
1163 FakeLayerAnimationValueObserver dummy; 1184 FakeLayerAnimationValueObserver dummy;
1164 scoped_refptr<LayerAnimationController> controller( 1185 scoped_refptr<LayerAnimationController> controller(
1165 LayerAnimationController::Create(0)); 1186 LayerAnimationController::Create(0));
1166 controller->AddValueObserver(&dummy); 1187 controller->AddValueObserver(&dummy);
1167 1188
1168 const int id = 1; 1189 const int id = 1;
1169 scoped_ptr<Animation> to_add(CreateAnimation( 1190 scoped_ptr<Animation> to_add(CreateAnimation(
1170 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1191 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1171 id, 1192 id,
1172 Animation::Opacity)); 1193 Animation::Opacity));
1173 to_add->set_iterations(-1); 1194 to_add->set_iterations(-1);
1174 controller->AddAnimation(to_add.Pass()); 1195 controller->AddAnimation(to_add.Pass());
1175 1196
1176 controller->Animate(kInitialTickTime); 1197 controller->Animate(kInitialTickTime);
1177 controller->UpdateState(true, events.get()); 1198 controller->UpdateState(true, events.get());
1178 EXPECT_TRUE(controller->HasActiveAnimation()); 1199 EXPECT_TRUE(controller->HasActiveAnimation());
1179 EXPECT_EQ(0.f, dummy.opacity()); 1200 EXPECT_EQ(0.f, dummy.opacity());
1180 controller->Animate(kInitialTickTime + 1.25); 1201 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250));
1181 controller->UpdateState(true, events.get()); 1202 controller->UpdateState(true, events.get());
1182 EXPECT_TRUE(controller->HasActiveAnimation()); 1203 EXPECT_TRUE(controller->HasActiveAnimation());
1183 EXPECT_EQ(0.25f, dummy.opacity()); 1204 EXPECT_EQ(0.25f, dummy.opacity());
1184 controller->Animate(kInitialTickTime + 1.75); 1205 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750));
1185 controller->UpdateState(true, events.get()); 1206 controller->UpdateState(true, events.get());
1186 EXPECT_TRUE(controller->HasActiveAnimation()); 1207 EXPECT_TRUE(controller->HasActiveAnimation());
1187 EXPECT_EQ(0.75f, dummy.opacity()); 1208 EXPECT_EQ(0.75f, dummy.opacity());
1188 1209
1189 controller->Animate(kInitialTickTime + 1073741824.25); 1210 controller->Animate(kInitialTickTime +
1211 TimeDelta::FromMilliseconds(1073741824250));
1190 controller->UpdateState(true, events.get()); 1212 controller->UpdateState(true, events.get());
1191 EXPECT_TRUE(controller->HasActiveAnimation()); 1213 EXPECT_TRUE(controller->HasActiveAnimation());
1192 EXPECT_EQ(0.25f, dummy.opacity()); 1214 EXPECT_EQ(0.25f, dummy.opacity());
1193 controller->Animate(kInitialTickTime + 1073741824.75); 1215 controller->Animate(kInitialTickTime +
1216 TimeDelta::FromMilliseconds(1073741824750));
1194 controller->UpdateState(true, events.get()); 1217 controller->UpdateState(true, events.get());
1195 EXPECT_TRUE(controller->HasActiveAnimation()); 1218 EXPECT_TRUE(controller->HasActiveAnimation());
1196 EXPECT_EQ(0.75f, dummy.opacity()); 1219 EXPECT_EQ(0.75f, dummy.opacity());
1197 1220
1198 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); 1221 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity));
1199 controller->GetAnimation(id, Animation::Opacity)->SetRunState( 1222 controller->GetAnimation(id, Animation::Opacity)->SetRunState(
1200 Animation::Aborted, kInitialTickTime + 0.75); 1223 Animation::Aborted, kInitialTickTime + TimeDelta::FromMilliseconds(750));
1201 EXPECT_FALSE(controller->HasActiveAnimation()); 1224 EXPECT_FALSE(controller->HasActiveAnimation());
1202 EXPECT_EQ(0.75f, dummy.opacity()); 1225 EXPECT_EQ(0.75f, dummy.opacity());
1203 } 1226 }
1204 1227
1205 // Test that pausing and resuming work as expected. 1228 // Test that pausing and resuming work as expected.
1206 TEST(LayerAnimationControllerTest, PauseResume) { 1229 TEST(LayerAnimationControllerTest, PauseResume) {
1207 scoped_ptr<AnimationEventsVector> events( 1230 scoped_ptr<AnimationEventsVector> events(
1208 make_scoped_ptr(new AnimationEventsVector)); 1231 make_scoped_ptr(new AnimationEventsVector));
1209 FakeLayerAnimationValueObserver dummy; 1232 FakeLayerAnimationValueObserver dummy;
1210 scoped_refptr<LayerAnimationController> controller( 1233 scoped_refptr<LayerAnimationController> controller(
1211 LayerAnimationController::Create(0)); 1234 LayerAnimationController::Create(0));
1212 controller->AddValueObserver(&dummy); 1235 controller->AddValueObserver(&dummy);
1213 1236
1214 const int id = 1; 1237 const int id = 1;
1215 controller->AddAnimation(CreateAnimation( 1238 controller->AddAnimation(CreateAnimation(
1216 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1239 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1217 id, 1240 id,
1218 Animation::Opacity)); 1241 Animation::Opacity));
1219 1242
1220 controller->Animate(kInitialTickTime); 1243 controller->Animate(kInitialTickTime);
1221 controller->UpdateState(true, events.get()); 1244 controller->UpdateState(true, events.get());
1222 EXPECT_TRUE(controller->HasActiveAnimation()); 1245 EXPECT_TRUE(controller->HasActiveAnimation());
1223 EXPECT_EQ(0.f, dummy.opacity()); 1246 EXPECT_EQ(0.f, dummy.opacity());
1224 controller->Animate(kInitialTickTime + 0.5); 1247 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
1225 controller->UpdateState(true, events.get()); 1248 controller->UpdateState(true, events.get());
1226 EXPECT_TRUE(controller->HasActiveAnimation()); 1249 EXPECT_TRUE(controller->HasActiveAnimation());
1227 EXPECT_EQ(0.5f, dummy.opacity()); 1250 EXPECT_EQ(0.5f, dummy.opacity());
1228 1251
1229 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); 1252 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity));
1230 controller->GetAnimation(id, Animation::Opacity)->SetRunState( 1253 controller->GetAnimation(id, Animation::Opacity)->SetRunState(
1231 Animation::Paused, kInitialTickTime + 0.5); 1254 Animation::Paused, kInitialTickTime + TimeDelta::FromMilliseconds(500));
1232 1255
1233 controller->Animate(kInitialTickTime + 1024.0); 1256 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024000));
1234 controller->UpdateState(true, events.get()); 1257 controller->UpdateState(true, events.get());
1235 EXPECT_TRUE(controller->HasActiveAnimation()); 1258 EXPECT_TRUE(controller->HasActiveAnimation());
1236 EXPECT_EQ(0.5f, dummy.opacity()); 1259 EXPECT_EQ(0.5f, dummy.opacity());
1237 1260
1238 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); 1261 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity));
1239 controller->GetAnimation(id, Animation::Opacity)->SetRunState( 1262 controller->GetAnimation(id, Animation::Opacity)
1240 Animation::Running, kInitialTickTime + 1024); 1263 ->SetRunState(Animation::Running,
1241 1264 kInitialTickTime + TimeDelta::FromMilliseconds(1024000));
1242 controller->Animate(kInitialTickTime + 1024.25); 1265 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024250));
1243 controller->UpdateState(true, events.get()); 1266 controller->UpdateState(true, events.get());
1244 EXPECT_TRUE(controller->HasActiveAnimation()); 1267 EXPECT_TRUE(controller->HasActiveAnimation());
1245 EXPECT_EQ(0.75f, dummy.opacity()); 1268 EXPECT_EQ(0.75f, dummy.opacity());
1246 controller->Animate(kInitialTickTime + 1024.5); 1269
1270 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024500));
1247 controller->UpdateState(true, events.get()); 1271 controller->UpdateState(true, events.get());
1248 EXPECT_FALSE(controller->HasActiveAnimation()); 1272 EXPECT_FALSE(controller->HasActiveAnimation());
1249 EXPECT_EQ(1.f, dummy.opacity()); 1273 EXPECT_EQ(1.f, dummy.opacity());
1250 } 1274 }
1251 1275
1252 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { 1276 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) {
1253 scoped_ptr<AnimationEventsVector> events( 1277 scoped_ptr<AnimationEventsVector> events(
1254 make_scoped_ptr(new AnimationEventsVector)); 1278 make_scoped_ptr(new AnimationEventsVector));
1255 FakeLayerAnimationValueObserver dummy; 1279 FakeLayerAnimationValueObserver dummy;
1256 scoped_refptr<LayerAnimationController> controller( 1280 scoped_refptr<LayerAnimationController> controller(
(...skipping 12 matching lines...) Expand all
1269 controller->AddAnimation(CreateAnimation( 1293 controller->AddAnimation(CreateAnimation(
1270 scoped_ptr<AnimationCurve>( 1294 scoped_ptr<AnimationCurve>(
1271 new FakeFloatTransition(1.0, 1.f, 0.75f)).Pass(), 1295 new FakeFloatTransition(1.0, 1.f, 0.75f)).Pass(),
1272 2, 1296 2,
1273 Animation::Opacity)); 1297 Animation::Opacity));
1274 1298
1275 controller->Animate(kInitialTickTime); 1299 controller->Animate(kInitialTickTime);
1276 controller->UpdateState(true, events.get()); 1300 controller->UpdateState(true, events.get());
1277 EXPECT_TRUE(controller->HasActiveAnimation()); 1301 EXPECT_TRUE(controller->HasActiveAnimation());
1278 EXPECT_EQ(0.f, dummy.opacity()); 1302 EXPECT_EQ(0.f, dummy.opacity());
1279 controller->Animate(kInitialTickTime + 1.0); 1303 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1280 controller->UpdateState(true, events.get()); 1304 controller->UpdateState(true, events.get());
1281 EXPECT_TRUE(controller->HasActiveAnimation()); 1305 EXPECT_TRUE(controller->HasActiveAnimation());
1282 EXPECT_EQ(0.5f, dummy.opacity()); 1306 EXPECT_EQ(0.5f, dummy.opacity());
1283 1307
1284 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); 1308 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity));
1285 controller->GetAnimation(id, Animation::Opacity)->SetRunState( 1309 controller->GetAnimation(id, Animation::Opacity)->SetRunState(
1286 Animation::Aborted, kInitialTickTime + 1.0); 1310 Animation::Aborted, kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1287 controller->Animate(kInitialTickTime + 1.0); 1311 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1288 controller->UpdateState(true, events.get()); 1312 controller->UpdateState(true, events.get());
1289 EXPECT_TRUE(controller->HasActiveAnimation()); 1313 EXPECT_TRUE(controller->HasActiveAnimation());
1290 EXPECT_EQ(1.f, dummy.opacity()); 1314 EXPECT_EQ(1.f, dummy.opacity());
1291 controller->Animate(kInitialTickTime + 2.0); 1315 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1292 controller->UpdateState(true, events.get()); 1316 controller->UpdateState(true, events.get());
1293 EXPECT_TRUE(!controller->HasActiveAnimation()); 1317 EXPECT_TRUE(!controller->HasActiveAnimation());
1294 EXPECT_EQ(0.75f, dummy.opacity()); 1318 EXPECT_EQ(0.75f, dummy.opacity());
1295 } 1319 }
1296 1320
1297 TEST(LayerAnimationControllerTest, PushUpdatesWhenSynchronizedStartTimeNeeded) { 1321 TEST(LayerAnimationControllerTest, PushUpdatesWhenSynchronizedStartTimeNeeded) {
1298 FakeLayerAnimationValueObserver dummy_impl; 1322 FakeLayerAnimationValueObserver dummy_impl;
1299 scoped_refptr<LayerAnimationController> controller_impl( 1323 scoped_refptr<LayerAnimationController> controller_impl(
1300 LayerAnimationController::Create(0)); 1324 LayerAnimationController::Create(0));
1301 controller_impl->AddValueObserver(&dummy_impl); 1325 controller_impl->AddValueObserver(&dummy_impl);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 1369
1346 controller->Animate(kInitialTickTime); 1370 controller->Animate(kInitialTickTime);
1347 controller->UpdateState(true, events.get()); 1371 controller->UpdateState(true, events.get());
1348 1372
1349 controller->AddAnimation(CreateAnimation( 1373 controller->AddAnimation(CreateAnimation(
1350 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1374 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1351 2, 1375 2,
1352 Animation::Opacity)); 1376 Animation::Opacity));
1353 1377
1354 // Animate but don't UpdateState. 1378 // Animate but don't UpdateState.
1355 controller->Animate(kInitialTickTime + 1.0); 1379 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1356 1380
1357 controller->Animate(kInitialTickTime + 2.0); 1381 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1358 events.reset(new AnimationEventsVector); 1382 events.reset(new AnimationEventsVector);
1359 controller->UpdateState(true, events.get()); 1383 controller->UpdateState(true, events.get());
1360 1384
1361 // Should have one Started event and one Finished event. 1385 // Should have one Started event and one Finished event.
1362 EXPECT_EQ(2u, events->size()); 1386 EXPECT_EQ(2u, events->size());
1363 EXPECT_NE((*events)[0].type, (*events)[1].type); 1387 EXPECT_NE((*events)[0].type, (*events)[1].type);
1364 1388
1365 // The float transition should still be at its starting point. 1389 // The float transition should still be at its starting point.
1366 EXPECT_TRUE(controller->HasActiveAnimation()); 1390 EXPECT_TRUE(controller->HasActiveAnimation());
1367 EXPECT_EQ(0.f, dummy.opacity()); 1391 EXPECT_EQ(0.f, dummy.opacity());
1368 1392
1369 controller->Animate(kInitialTickTime + 3.0); 1393 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
1370 controller->UpdateState(true, events.get()); 1394 controller->UpdateState(true, events.get());
1371 1395
1372 // The float tranisition should now be done. 1396 // The float tranisition should now be done.
1373 EXPECT_EQ(1.f, dummy.opacity()); 1397 EXPECT_EQ(1.f, dummy.opacity());
1374 EXPECT_FALSE(controller->HasActiveAnimation()); 1398 EXPECT_FALSE(controller->HasActiveAnimation());
1375 } 1399 }
1376 1400
1377 // Tests that an animation controller with only a pending observer gets ticked 1401 // Tests that an animation controller with only a pending observer gets ticked
1378 // but doesn't progress animations past the Starting state. 1402 // but doesn't progress animations past the Starting state.
1379 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { 1403 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) {
(...skipping 16 matching lines...) Expand all
1396 controller->UpdateState(true, events.get()); 1420 controller->UpdateState(true, events.get());
1397 EXPECT_EQ(0u, events->size()); 1421 EXPECT_EQ(0u, events->size());
1398 EXPECT_EQ(Animation::WaitingForTargetAvailability, 1422 EXPECT_EQ(Animation::WaitingForTargetAvailability,
1399 controller->GetAnimation(id, Animation::Opacity)->run_state()); 1423 controller->GetAnimation(id, Animation::Opacity)->run_state());
1400 1424
1401 controller->AddValueObserver(&pending_dummy); 1425 controller->AddValueObserver(&pending_dummy);
1402 1426
1403 // With only a pending observer, the animation should progress to the 1427 // With only a pending observer, the animation should progress to the
1404 // Starting state and get ticked at its starting point, but should not 1428 // Starting state and get ticked at its starting point, but should not
1405 // progress to Running. 1429 // progress to Running.
1406 controller->Animate(kInitialTickTime + 1.0); 1430 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1407 controller->UpdateState(true, events.get()); 1431 controller->UpdateState(true, events.get());
1408 EXPECT_EQ(0u, events->size()); 1432 EXPECT_EQ(0u, events->size());
1409 EXPECT_EQ(Animation::Starting, 1433 EXPECT_EQ(Animation::Starting,
1410 controller->GetAnimation(id, Animation::Opacity)->run_state()); 1434 controller->GetAnimation(id, Animation::Opacity)->run_state());
1411 EXPECT_EQ(0.5f, pending_dummy.opacity()); 1435 EXPECT_EQ(0.5f, pending_dummy.opacity());
1412 1436
1413 // Even when already in the Starting state, the animation should stay 1437 // Even when already in the Starting state, the animation should stay
1414 // there, and shouldn't be ticked past its starting point. 1438 // there, and shouldn't be ticked past its starting point.
1415 controller->Animate(kInitialTickTime + 2.0); 1439 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1416 controller->UpdateState(true, events.get()); 1440 controller->UpdateState(true, events.get());
1417 EXPECT_EQ(0u, events->size()); 1441 EXPECT_EQ(0u, events->size());
1418 EXPECT_EQ(Animation::Starting, 1442 EXPECT_EQ(Animation::Starting,
1419 controller->GetAnimation(id, Animation::Opacity)->run_state()); 1443 controller->GetAnimation(id, Animation::Opacity)->run_state());
1420 EXPECT_EQ(0.5f, pending_dummy.opacity()); 1444 EXPECT_EQ(0.5f, pending_dummy.opacity());
1421 1445
1422 controller->AddValueObserver(&dummy); 1446 controller->AddValueObserver(&dummy);
1423 1447
1424 // Now that an active observer has been added, the animation should still 1448 // Now that an active observer has been added, the animation should still
1425 // initially tick at its starting point, but should now progress to Running. 1449 // initially tick at its starting point, but should now progress to Running.
1426 controller->Animate(kInitialTickTime + 3.0); 1450 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
1427 controller->UpdateState(true, events.get()); 1451 controller->UpdateState(true, events.get());
1428 EXPECT_EQ(1u, events->size()); 1452 EXPECT_EQ(1u, events->size());
1429 EXPECT_EQ(Animation::Running, 1453 EXPECT_EQ(Animation::Running,
1430 controller->GetAnimation(id, Animation::Opacity)->run_state()); 1454 controller->GetAnimation(id, Animation::Opacity)->run_state());
1431 EXPECT_EQ(0.5f, pending_dummy.opacity()); 1455 EXPECT_EQ(0.5f, pending_dummy.opacity());
1432 EXPECT_EQ(0.5f, dummy.opacity()); 1456 EXPECT_EQ(0.5f, dummy.opacity());
1433 1457
1434 // The animation should now tick past its starting point. 1458 // The animation should now tick past its starting point.
1435 controller->Animate(kInitialTickTime + 3.5); 1459 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3500));
1436 EXPECT_NE(0.5f, pending_dummy.opacity()); 1460 EXPECT_NE(0.5f, pending_dummy.opacity());
1437 EXPECT_NE(0.5f, dummy.opacity()); 1461 EXPECT_NE(0.5f, dummy.opacity());
1438 } 1462 }
1439 1463
1440 TEST(LayerAnimationControllerTest, TransformAnimationBounds) { 1464 TEST(LayerAnimationControllerTest, TransformAnimationBounds) {
1441 scoped_refptr<LayerAnimationController> controller_impl( 1465 scoped_refptr<LayerAnimationController> controller_impl(
1442 LayerAnimationController::Create(0)); 1466 LayerAnimationController::Create(0));
1443 1467
1444 scoped_ptr<KeyframedTransformAnimationCurve> curve1( 1468 scoped_ptr<KeyframedTransformAnimationCurve> curve1(
1445 KeyframedTransformAnimationCurve::Create()); 1469 KeyframedTransformAnimationCurve::Create());
(...skipping 24 matching lines...) Expand all
1470 controller_impl->AddAnimation(animation.Pass()); 1494 controller_impl->AddAnimation(animation.Pass());
1471 1495
1472 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); 1496 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f);
1473 gfx::BoxF bounds; 1497 gfx::BoxF bounds;
1474 1498
1475 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); 1499 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds));
1476 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), 1500 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(),
1477 bounds.ToString()); 1501 bounds.ToString());
1478 1502
1479 controller_impl->GetAnimation(1, Animation::Transform) 1503 controller_impl->GetAnimation(1, Animation::Transform)
1480 ->SetRunState(Animation::Finished, 0.0); 1504 ->SetRunState(Animation::Finished, TimeUtil::TicksFromSecondsF(0.0));
1481 1505
1482 // Only the unfinished animation should affect the animated bounds. 1506 // Only the unfinished animation should affect the animated bounds.
1483 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); 1507 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds));
1484 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 7.f, 16.f, 20.f).ToString(), 1508 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 7.f, 16.f, 20.f).ToString(),
1485 bounds.ToString()); 1509 bounds.ToString());
1486 1510
1487 controller_impl->GetAnimation(2, Animation::Transform) 1511 controller_impl->GetAnimation(2, Animation::Transform)
1488 ->SetRunState(Animation::Finished, 0.0); 1512 ->SetRunState(Animation::Finished, TimeUtil::TicksFromSecondsF(0.0));
1489 1513
1490 // There are no longer any running animations. 1514 // There are no longer any running animations.
1491 EXPECT_FALSE(controller_impl->HasTransformAnimationThatInflatesBounds()); 1515 EXPECT_FALSE(controller_impl->HasTransformAnimationThatInflatesBounds());
1492 1516
1493 // Add an animation whose bounds we don't yet support computing. 1517 // Add an animation whose bounds we don't yet support computing.
1494 scoped_ptr<KeyframedTransformAnimationCurve> curve3( 1518 scoped_ptr<KeyframedTransformAnimationCurve> curve3(
1495 KeyframedTransformAnimationCurve::Create()); 1519 KeyframedTransformAnimationCurve::Create());
1496 TransformOperations operations3; 1520 TransformOperations operations3;
1497 gfx::Transform transform3; 1521 gfx::Transform transform3;
1498 transform3.Scale3d(1.0, 2.0, 3.0); 1522 transform3.Scale3d(1.0, 2.0, 3.0);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), 1557 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(),
1534 4, 1558 4,
1535 Animation::Transform)); 1559 Animation::Transform));
1536 controller->AddAnimation(CreateAnimation( 1560 controller->AddAnimation(CreateAnimation(
1537 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1561 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1538 5, 1562 5,
1539 Animation::Opacity)); 1563 Animation::Opacity));
1540 1564
1541 controller->Animate(kInitialTickTime); 1565 controller->Animate(kInitialTickTime);
1542 controller->UpdateState(true, NULL); 1566 controller->UpdateState(true, NULL);
1543 controller->Animate(kInitialTickTime + 1.0); 1567 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1544 controller->UpdateState(true, NULL); 1568 controller->UpdateState(true, NULL);
1545 1569
1546 EXPECT_EQ(Animation::Finished, 1570 EXPECT_EQ(Animation::Finished,
1547 controller->GetAnimation(1, Animation::Transform)->run_state()); 1571 controller->GetAnimation(1, Animation::Transform)->run_state());
1548 EXPECT_EQ(Animation::Finished, 1572 EXPECT_EQ(Animation::Finished,
1549 controller->GetAnimation(2, Animation::Opacity)->run_state()); 1573 controller->GetAnimation(2, Animation::Opacity)->run_state());
1550 EXPECT_EQ(Animation::Running, 1574 EXPECT_EQ(Animation::Running,
1551 controller->GetAnimation(3, Animation::Transform)->run_state()); 1575 controller->GetAnimation(3, Animation::Transform)->run_state());
1552 EXPECT_EQ(Animation::WaitingForTargetAvailability, 1576 EXPECT_EQ(Animation::WaitingForTargetAvailability,
1553 controller->GetAnimation(4, Animation::Transform)->run_state()); 1577 controller->GetAnimation(4, Animation::Transform)->run_state());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); 1659 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion());
1636 EXPECT_EQ(1u, events.size()); 1660 EXPECT_EQ(1u, events.size());
1637 EXPECT_EQ(AnimationEvent::Aborted, events[0].type); 1661 EXPECT_EQ(AnimationEvent::Aborted, events[0].type);
1638 EXPECT_EQ(Animation::WaitingForDeletion, 1662 EXPECT_EQ(Animation::WaitingForDeletion,
1639 controller_impl->GetAnimation(Animation::Opacity)->run_state()); 1663 controller_impl->GetAnimation(Animation::Opacity)->run_state());
1640 1664
1641 controller->NotifyAnimationAborted(events[0]); 1665 controller->NotifyAnimationAborted(events[0]);
1642 EXPECT_EQ(Animation::Aborted, 1666 EXPECT_EQ(Animation::Aborted,
1643 controller->GetAnimation(Animation::Opacity)->run_state()); 1667 controller->GetAnimation(Animation::Opacity)->run_state());
1644 1668
1645 controller->Animate(kInitialTickTime + 0.5); 1669 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
1646 controller->UpdateState(true, NULL); 1670 controller->UpdateState(true, NULL);
1647 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); 1671 EXPECT_TRUE(dummy.animation_waiting_for_deletion());
1648 EXPECT_EQ(Animation::WaitingForDeletion, 1672 EXPECT_EQ(Animation::WaitingForDeletion,
1649 controller->GetAnimation(Animation::Opacity)->run_state()); 1673 controller->GetAnimation(Animation::Opacity)->run_state());
1650 1674
1651 controller->PushAnimationUpdatesTo(controller_impl.get()); 1675 controller->PushAnimationUpdatesTo(controller_impl.get());
1652 controller_impl->ActivateAnimations(); 1676 controller_impl->ActivateAnimations();
1653 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity)); 1677 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity));
1654 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); 1678 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity));
1655 } 1679 }
(...skipping 20 matching lines...) Expand all
1676 1700
1677 controller_impl->Animate(kInitialTickTime); 1701 controller_impl->Animate(kInitialTickTime);
1678 controller_impl->UpdateState(true, events.get()); 1702 controller_impl->UpdateState(true, events.get());
1679 1703
1680 // Both animations should have started. 1704 // Both animations should have started.
1681 EXPECT_EQ(2u, events->size()); 1705 EXPECT_EQ(2u, events->size());
1682 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); 1706 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type);
1683 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); 1707 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type);
1684 1708
1685 events.reset(new AnimationEventsVector); 1709 events.reset(new AnimationEventsVector);
1686 controller_impl->Animate(kInitialTickTime + 1.0); 1710 controller_impl->Animate(kInitialTickTime +
1711 TimeDelta::FromMilliseconds(1000));
1687 controller_impl->UpdateState(true, events.get()); 1712 controller_impl->UpdateState(true, events.get());
1688 1713
1689 // The opacity animation should be finished, but should not have generated 1714 // The opacity animation should be finished, but should not have generated
1690 // a Finished event yet. 1715 // a Finished event yet.
1691 EXPECT_EQ(0u, events->size()); 1716 EXPECT_EQ(0u, events->size());
1692 EXPECT_EQ(Animation::Finished, 1717 EXPECT_EQ(Animation::Finished,
1693 controller_impl->GetAnimation(1, Animation::Opacity)->run_state()); 1718 controller_impl->GetAnimation(1, Animation::Opacity)->run_state());
1694 EXPECT_EQ(Animation::Running, 1719 EXPECT_EQ(Animation::Running,
1695 controller_impl->GetAnimation(1, 1720 controller_impl->GetAnimation(1,
1696 Animation::Transform)->run_state()); 1721 Animation::Transform)->run_state());
1697 1722
1698 controller_impl->Animate(kInitialTickTime + 2.0); 1723 controller_impl->Animate(kInitialTickTime +
1724 TimeDelta::FromMilliseconds(2000));
1699 controller_impl->UpdateState(true, events.get()); 1725 controller_impl->UpdateState(true, events.get());
1700 1726
1701 // Both animations should have generated Finished events. 1727 // Both animations should have generated Finished events.
1702 EXPECT_EQ(2u, events->size()); 1728 EXPECT_EQ(2u, events->size());
1703 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); 1729 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type);
1704 EXPECT_EQ(AnimationEvent::Finished, (*events)[1].type); 1730 EXPECT_EQ(AnimationEvent::Finished, (*events)[1].type);
1705 } 1731 }
1706 1732
1707 // Ensure that when a group has a mix of aborted and finished animations, 1733 // Ensure that when a group has a mix of aborted and finished animations,
1708 // we generate a Finished event for the finished animation and an Aborted 1734 // we generate a Finished event for the finished animation and an Aborted
(...skipping 20 matching lines...) Expand all
1729 controller_impl->UpdateState(true, events.get()); 1755 controller_impl->UpdateState(true, events.get());
1730 1756
1731 // Both animations should have started. 1757 // Both animations should have started.
1732 EXPECT_EQ(2u, events->size()); 1758 EXPECT_EQ(2u, events->size());
1733 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); 1759 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type);
1734 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); 1760 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type);
1735 1761
1736 controller_impl->AbortAnimations(Animation::Opacity); 1762 controller_impl->AbortAnimations(Animation::Opacity);
1737 1763
1738 events.reset(new AnimationEventsVector); 1764 events.reset(new AnimationEventsVector);
1739 controller_impl->Animate(kInitialTickTime + 1.0); 1765 controller_impl->Animate(kInitialTickTime +
1766 TimeDelta::FromMilliseconds(1000));
1740 controller_impl->UpdateState(true, events.get()); 1767 controller_impl->UpdateState(true, events.get());
1741 1768
1742 // We should have exactly 2 events: a Finished event for the tranform 1769 // We should have exactly 2 events: a Finished event for the tranform
1743 // animation, and an Aborted event for the opacity animation. 1770 // animation, and an Aborted event for the opacity animation.
1744 EXPECT_EQ(2u, events->size()); 1771 EXPECT_EQ(2u, events->size());
1745 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); 1772 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type);
1746 EXPECT_EQ(Animation::Transform, (*events)[0].target_property); 1773 EXPECT_EQ(Animation::Transform, (*events)[0].target_property);
1747 EXPECT_EQ(AnimationEvent::Aborted, (*events)[1].type); 1774 EXPECT_EQ(AnimationEvent::Aborted, (*events)[1].type);
1748 EXPECT_EQ(Animation::Opacity, (*events)[1].target_property); 1775 EXPECT_EQ(Animation::Opacity, (*events)[1].target_property);
1749 } 1776 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 curve2->AddKeyframe(TransformKeyframe::Create( 1816 curve2->AddKeyframe(TransformKeyframe::Create(
1790 1.0, operations2, scoped_ptr<TimingFunction>())); 1817 1.0, operations2, scoped_ptr<TimingFunction>()));
1791 1818
1792 animation = Animation::Create( 1819 animation = Animation::Create(
1793 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); 1820 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform);
1794 controller_impl->AddAnimation(animation.Pass()); 1821 controller_impl->AddAnimation(animation.Pass());
1795 1822
1796 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale()); 1823 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale());
1797 1824
1798 controller_impl->GetAnimation(3, Animation::Transform) 1825 controller_impl->GetAnimation(3, Animation::Transform)
1799 ->SetRunState(Animation::Finished, 0.0); 1826 ->SetRunState(Animation::Finished, TimeUtil::TicksFromSecondsF(0.0));
1800 1827
1801 // Only unfinished animations should be considered by 1828 // Only unfinished animations should be considered by
1802 // HasAnimationThatAffectsScale. 1829 // HasAnimationThatAffectsScale.
1803 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); 1830 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale());
1804 } 1831 }
1805 1832
1806 TEST(LayerAnimationControllerTest, HasOnlyTranslationTransforms) { 1833 TEST(LayerAnimationControllerTest, HasOnlyTranslationTransforms) {
1807 scoped_refptr<LayerAnimationController> controller_impl( 1834 scoped_refptr<LayerAnimationController> controller_impl(
1808 LayerAnimationController::Create(0)); 1835 LayerAnimationController::Create(0));
1809 1836
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 1.0, operations2, scoped_ptr<TimingFunction>())); 1872 1.0, operations2, scoped_ptr<TimingFunction>()));
1846 1873
1847 animation = Animation::Create( 1874 animation = Animation::Create(
1848 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); 1875 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform);
1849 controller_impl->AddAnimation(animation.Pass()); 1876 controller_impl->AddAnimation(animation.Pass());
1850 1877
1851 // A scale animation is not a translation. 1878 // A scale animation is not a translation.
1852 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms()); 1879 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms());
1853 1880
1854 controller_impl->GetAnimation(3, Animation::Transform) 1881 controller_impl->GetAnimation(3, Animation::Transform)
1855 ->SetRunState(Animation::Finished, 0.0); 1882 ->SetRunState(Animation::Finished, TimeUtil::TicksFromSecondsF(0.0));
1856 1883
1857 // Only unfinished animations should be considered by 1884 // Only unfinished animations should be considered by
1858 // HasOnlyTranslationTransforms. 1885 // HasOnlyTranslationTransforms.
1859 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); 1886 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms());
1860 } 1887 }
1861 1888
1862 TEST(LayerAnimationControllerTest, MaximumScale) { 1889 TEST(LayerAnimationControllerTest, MaximumScale) {
1863 scoped_refptr<LayerAnimationController> controller_impl( 1890 scoped_refptr<LayerAnimationController> controller_impl(
1864 LayerAnimationController::Create(0)); 1891 LayerAnimationController::Create(0));
1865 1892
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 curve3->AddKeyframe(TransformKeyframe::Create( 1938 curve3->AddKeyframe(TransformKeyframe::Create(
1912 1.0, operations3, scoped_ptr<TimingFunction>())); 1939 1.0, operations3, scoped_ptr<TimingFunction>()));
1913 1940
1914 animation = Animation::Create( 1941 animation = Animation::Create(
1915 curve3.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); 1942 curve3.PassAs<AnimationCurve>(), 3, 3, Animation::Transform);
1916 controller_impl->AddAnimation(animation.Pass()); 1943 controller_impl->AddAnimation(animation.Pass());
1917 1944
1918 EXPECT_FALSE(controller_impl->MaximumScale(&max_scale)); 1945 EXPECT_FALSE(controller_impl->MaximumScale(&max_scale));
1919 1946
1920 controller_impl->GetAnimation(3, Animation::Transform) 1947 controller_impl->GetAnimation(3, Animation::Transform)
1921 ->SetRunState(Animation::Finished, 0.0); 1948 ->SetRunState(Animation::Finished, TimeUtil::TicksFromSecondsF(0.0));
1922 controller_impl->GetAnimation(2, Animation::Transform) 1949 controller_impl->GetAnimation(2, Animation::Transform)
1923 ->SetRunState(Animation::Finished, 0.0); 1950 ->SetRunState(Animation::Finished, TimeUtil::TicksFromSecondsF(0.0));
1924 1951
1925 // Only unfinished animations should be considered by 1952 // Only unfinished animations should be considered by
1926 // MaximumScale. 1953 // MaximumScale.
1927 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); 1954 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale));
1928 EXPECT_EQ(4.f, max_scale); 1955 EXPECT_EQ(4.f, max_scale);
1929 } 1956 }
1930 1957
1931 TEST(LayerAnimationControllerTest, NewlyPushedAnimationWaitsForActivation) { 1958 TEST(LayerAnimationControllerTest, NewlyPushedAnimationWaitsForActivation) {
1932 scoped_ptr<AnimationEventsVector> events( 1959 scoped_ptr<AnimationEventsVector> events(
1933 make_scoped_ptr(new AnimationEventsVector)); 1960 make_scoped_ptr(new AnimationEventsVector));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 // should have been ticked. 1996 // should have been ticked.
1970 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); 1997 EXPECT_EQ(0.5f, pending_dummy_impl.opacity());
1971 EXPECT_EQ(0.f, dummy_impl.opacity()); 1998 EXPECT_EQ(0.f, dummy_impl.opacity());
1972 1999
1973 controller_impl->ActivateAnimations(); 2000 controller_impl->ActivateAnimations();
1974 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity) 2001 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)
1975 ->affects_pending_observers()); 2002 ->affects_pending_observers());
1976 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity) 2003 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)
1977 ->affects_active_observers()); 2004 ->affects_active_observers());
1978 2005
1979 controller_impl->Animate(kInitialTickTime + 1.0); 2006 controller_impl->Animate(kInitialTickTime +
2007 TimeDelta::FromMilliseconds(1000));
1980 controller_impl->UpdateState(true, events.get()); 2008 controller_impl->UpdateState(true, events.get());
1981 2009
1982 // Since the animation has been activated, it should have reached the 2010 // Since the animation has been activated, it should have reached the
1983 // Running state and the active observer should start to get ticked. 2011 // Running state and the active observer should start to get ticked.
1984 EXPECT_EQ( 2012 EXPECT_EQ(
1985 Animation::Running, 2013 Animation::Running,
1986 controller_impl->GetAnimation(group_id, Animation::Opacity)->run_state()); 2014 controller_impl->GetAnimation(group_id, Animation::Opacity)->run_state());
1987 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); 2015 EXPECT_EQ(0.5f, pending_dummy_impl.opacity());
1988 EXPECT_EQ(0.5f, dummy_impl.opacity()); 2016 EXPECT_EQ(0.5f, dummy_impl.opacity());
1989 } 2017 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 ->affects_active_observers()); 2058 ->affects_active_observers());
2031 2059
2032 controller_impl->UpdateState(true, events.get()); 2060 controller_impl->UpdateState(true, events.get());
2033 2061
2034 // Since the animation has been activated, it should have reached the 2062 // Since the animation has been activated, it should have reached the
2035 // Running state. 2063 // Running state.
2036 EXPECT_EQ( 2064 EXPECT_EQ(
2037 Animation::Running, 2065 Animation::Running,
2038 controller_impl->GetAnimation(group_id, Animation::Opacity)->run_state()); 2066 controller_impl->GetAnimation(group_id, Animation::Opacity)->run_state());
2039 2067
2040 controller_impl->Animate(kInitialTickTime + 0.5); 2068 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
2041 2069
2042 // Both observers should have been ticked. 2070 // Both observers should have been ticked.
2043 EXPECT_EQ(0.75f, pending_dummy_impl.opacity()); 2071 EXPECT_EQ(0.75f, pending_dummy_impl.opacity());
2044 EXPECT_EQ(0.75f, dummy_impl.opacity()); 2072 EXPECT_EQ(0.75f, dummy_impl.opacity());
2045 } 2073 }
2046 2074
2047 TEST(LayerAnimationControllerTest, PushedDeletedAnimationWaitsForActivation) { 2075 TEST(LayerAnimationControllerTest, PushedDeletedAnimationWaitsForActivation) {
2048 scoped_ptr<AnimationEventsVector> events( 2076 scoped_ptr<AnimationEventsVector> events(
2049 make_scoped_ptr(new AnimationEventsVector)); 2077 make_scoped_ptr(new AnimationEventsVector));
2050 FakeLayerAnimationValueObserver dummy_impl; 2078 FakeLayerAnimationValueObserver dummy_impl;
(...skipping 29 matching lines...) Expand all
2080 controller->RemoveAnimation( 2108 controller->RemoveAnimation(
2081 controller->GetAnimation(Animation::Opacity)->id()); 2109 controller->GetAnimation(Animation::Opacity)->id());
2082 controller->PushAnimationUpdatesTo(controller_impl.get()); 2110 controller->PushAnimationUpdatesTo(controller_impl.get());
2083 2111
2084 // The animation should no longer affect pending observers. 2112 // The animation should no longer affect pending observers.
2085 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity) 2113 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)
2086 ->affects_pending_observers()); 2114 ->affects_pending_observers());
2087 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity) 2115 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)
2088 ->affects_active_observers()); 2116 ->affects_active_observers());
2089 2117
2090 controller_impl->Animate(kInitialTickTime + 0.5); 2118 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
2091 controller_impl->UpdateState(true, events.get()); 2119 controller_impl->UpdateState(true, events.get());
2092 2120
2093 // Only the active observer should have been ticked. 2121 // Only the active observer should have been ticked.
2094 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); 2122 EXPECT_EQ(0.5f, pending_dummy_impl.opacity());
2095 EXPECT_EQ(0.75f, dummy_impl.opacity()); 2123 EXPECT_EQ(0.75f, dummy_impl.opacity());
2096 2124
2097 controller_impl->ActivateAnimations(); 2125 controller_impl->ActivateAnimations();
2098 2126
2099 // Activation should cause the animation to be deleted. 2127 // Activation should cause the animation to be deleted.
2100 EXPECT_FALSE(controller_impl->has_any_animation()); 2128 EXPECT_FALSE(controller_impl->has_any_animation());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 EXPECT_TRUE(controller_impl->GetAnimation(first_animation_group_id, 2170 EXPECT_TRUE(controller_impl->GetAnimation(first_animation_group_id,
2143 Animation::Opacity) 2171 Animation::Opacity)
2144 ->affects_active_observers()); 2172 ->affects_active_observers());
2145 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id, 2173 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id,
2146 Animation::Opacity) 2174 Animation::Opacity)
2147 ->affects_pending_observers()); 2175 ->affects_pending_observers());
2148 EXPECT_FALSE(controller_impl->GetAnimation(second_animation_group_id, 2176 EXPECT_FALSE(controller_impl->GetAnimation(second_animation_group_id,
2149 Animation::Opacity) 2177 Animation::Opacity)
2150 ->affects_active_observers()); 2178 ->affects_active_observers());
2151 2179
2152 controller_impl->Animate(kInitialTickTime + 0.5); 2180 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
2153 controller_impl->UpdateState(true, events.get()); 2181 controller_impl->UpdateState(true, events.get());
2154 2182
2155 // The original animation should still be running, and the new animation 2183 // The original animation should still be running, and the new animation
2156 // should be starting. 2184 // should be starting.
2157 EXPECT_EQ(Animation::Running, 2185 EXPECT_EQ(Animation::Running,
2158 controller_impl->GetAnimation(first_animation_group_id, 2186 controller_impl->GetAnimation(first_animation_group_id,
2159 Animation::Opacity)->run_state()); 2187 Animation::Opacity)->run_state());
2160 EXPECT_EQ(Animation::Starting, 2188 EXPECT_EQ(Animation::Starting,
2161 controller_impl->GetAnimation(second_animation_group_id, 2189 controller_impl->GetAnimation(second_animation_group_id,
2162 Animation::Opacity)->run_state()); 2190 Animation::Opacity)->run_state());
2163 2191
2164 // The active observer should have been ticked by the original animation, 2192 // The active observer should have been ticked by the original animation,
2165 // and the pending observer should have been ticked by the new animation. 2193 // and the pending observer should have been ticked by the new animation.
2166 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); 2194 EXPECT_EQ(1.f, pending_dummy_impl.opacity());
2167 EXPECT_EQ(0.5f, dummy_impl.opacity()); 2195 EXPECT_EQ(0.5f, dummy_impl.opacity());
2168 2196
2169 controller_impl->ActivateAnimations(); 2197 controller_impl->ActivateAnimations();
2170 2198
2171 // The original animation should have been deleted, and the new animation 2199 // The original animation should have been deleted, and the new animation
2172 // should now affect both observers. 2200 // should now affect both observers.
2173 EXPECT_FALSE(controller_impl->GetAnimation(first_animation_group_id, 2201 EXPECT_FALSE(controller_impl->GetAnimation(first_animation_group_id,
2174 Animation::Opacity)); 2202 Animation::Opacity));
2175 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id, 2203 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id,
2176 Animation::Opacity) 2204 Animation::Opacity)
2177 ->affects_pending_observers()); 2205 ->affects_pending_observers());
2178 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id, 2206 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id,
2179 Animation::Opacity) 2207 Animation::Opacity)
2180 ->affects_active_observers()); 2208 ->affects_active_observers());
2181 2209
2182 controller_impl->Animate(kInitialTickTime + 1.0); 2210 controller_impl->Animate(kInitialTickTime +
2211 TimeDelta::FromMilliseconds(1000));
2183 controller_impl->UpdateState(true, events.get()); 2212 controller_impl->UpdateState(true, events.get());
2184 2213
2185 // The new animation should be running, and the active observer should have 2214 // The new animation should be running, and the active observer should have
2186 // been ticked at the new animation's starting point. 2215 // been ticked at the new animation's starting point.
2187 EXPECT_EQ(Animation::Running, 2216 EXPECT_EQ(Animation::Running,
2188 controller_impl->GetAnimation(second_animation_group_id, 2217 controller_impl->GetAnimation(second_animation_group_id,
2189 Animation::Opacity)->run_state()); 2218 Animation::Opacity)->run_state());
2190 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); 2219 EXPECT_EQ(1.f, pending_dummy_impl.opacity());
2191 EXPECT_EQ(1.f, dummy_impl.opacity()); 2220 EXPECT_EQ(1.f, dummy_impl.opacity());
2192 } 2221 }
2193 2222
2194 } // namespace 2223 } // namespace
2195 } // namespace cc 2224 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698