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

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: Code changed as per review comments 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/test/animation_test_common.h" 14 #include "cc/test/animation_test_common.h"
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "ui/gfx/box_f.h" 17 #include "ui/gfx/box_f.h"
18 #include "ui/gfx/transform.h" 18 #include "ui/gfx/transform.h"
19 19
20 namespace cc { 20 namespace cc {
21 namespace { 21 namespace {
22 22
23 using base::TimeDelta;
24 using base::TimeTicks;
25
26 static base::TimeTicks TicksFromSecondsF(double seconds) {
27 return base::TimeTicks::FromInternalValue(seconds *
28 base::Time::kMicrosecondsPerSecond);
29 }
30
23 // A LayerAnimationController cannot be ticked at 0.0, since an animation 31 // 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 32 // with start time 0.0 is treated as an animation whose start time has
25 // not yet been set. 33 // not yet been set.
26 const double kInitialTickTime = 1.0; 34 const TimeTicks kInitialTickTime = TicksFromSecondsF(1.0);
27 35
28 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve, 36 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve,
29 int id, 37 int id,
30 Animation::TargetProperty property) { 38 Animation::TargetProperty property) {
31 return Animation::Create(curve.Pass(), 0, id, property); 39 return Animation::Create(curve.Pass(), 0, id, property);
32 } 40 }
33 41
34 TEST(LayerAnimationControllerTest, SyncNewAnimation) { 42 TEST(LayerAnimationControllerTest, SyncNewAnimation) {
35 FakeLayerAnimationValueObserver dummy_impl; 43 FakeLayerAnimationValueObserver dummy_impl;
36 scoped_refptr<LayerAnimationController> controller_impl( 44 scoped_refptr<LayerAnimationController> controller_impl(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 99
92 // Synchronize the start times. 100 // Synchronize the start times.
93 EXPECT_EQ(1u, events.size()); 101 EXPECT_EQ(1u, events.size());
94 controller->NotifyAnimationStarted(events[0]); 102 controller->NotifyAnimationStarted(events[0]);
95 EXPECT_EQ(controller->GetAnimation(group_id, 103 EXPECT_EQ(controller->GetAnimation(group_id,
96 Animation::Opacity)->start_time(), 104 Animation::Opacity)->start_time(),
97 controller_impl->GetAnimation(group_id, 105 controller_impl->GetAnimation(group_id,
98 Animation::Opacity)->start_time()); 106 Animation::Opacity)->start_time());
99 107
100 // Start the animation on the main thread. Should not affect the start time. 108 // Start the animation on the main thread. Should not affect the start time.
101 controller->Animate(kInitialTickTime + 0.5); 109 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
102 controller->UpdateState(true, NULL); 110 controller->UpdateState(true, NULL);
103 EXPECT_EQ(controller->GetAnimation(group_id, 111 EXPECT_EQ(controller->GetAnimation(group_id,
104 Animation::Opacity)->start_time(), 112 Animation::Opacity)->start_time(),
105 controller_impl->GetAnimation(group_id, 113 controller_impl->GetAnimation(group_id,
106 Animation::Opacity)->start_time()); 114 Animation::Opacity)->start_time());
107 } 115 }
108 116
109 TEST(LayerAnimationControllerTest, UseSpecifiedStartTimes) { 117 TEST(LayerAnimationControllerTest, UseSpecifiedStartTimes) {
110 FakeLayerAnimationValueObserver dummy_impl; 118 FakeLayerAnimationValueObserver dummy_impl;
111 scoped_refptr<LayerAnimationController> controller_impl( 119 scoped_refptr<LayerAnimationController> controller_impl(
112 LayerAnimationController::Create(0)); 120 LayerAnimationController::Create(0));
113 controller_impl->AddValueObserver(&dummy_impl); 121 controller_impl->AddValueObserver(&dummy_impl);
114 FakeLayerAnimationValueObserver dummy; 122 FakeLayerAnimationValueObserver dummy;
115 scoped_refptr<LayerAnimationController> controller( 123 scoped_refptr<LayerAnimationController> controller(
116 LayerAnimationController::Create(0)); 124 LayerAnimationController::Create(0));
117 controller->AddValueObserver(&dummy); 125 controller->AddValueObserver(&dummy);
118 126
119 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); 127 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false);
120 int group_id = controller->GetAnimation(Animation::Opacity)->group(); 128 int group_id = controller->GetAnimation(Animation::Opacity)->group();
121 129
122 const double start_time = 123; 130 const TimeTicks start_time = TicksFromSecondsF(123);
123 controller->GetAnimation(Animation::Opacity)->set_start_time(start_time); 131 controller->GetAnimation(Animation::Opacity)->set_start_time(start_time);
124 132
125 controller->PushAnimationUpdatesTo(controller_impl.get()); 133 controller->PushAnimationUpdatesTo(controller_impl.get());
126 controller_impl->ActivateAnimations(); 134 controller_impl->ActivateAnimations();
127 135
128 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); 136 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity));
129 EXPECT_EQ(Animation::WaitingForTargetAvailability, 137 EXPECT_EQ(Animation::WaitingForTargetAvailability,
130 controller_impl->GetAnimation(group_id, 138 controller_impl->GetAnimation(group_id,
131 Animation::Opacity)->run_state()); 139 Animation::Opacity)->run_state());
132 140
133 AnimationEventsVector events; 141 AnimationEventsVector events;
134 controller_impl->Animate(kInitialTickTime); 142 controller_impl->Animate(kInitialTickTime);
135 controller_impl->UpdateState(true, &events); 143 controller_impl->UpdateState(true, &events);
136 144
137 // Synchronize the start times. 145 // Synchronize the start times.
138 EXPECT_EQ(1u, events.size()); 146 EXPECT_EQ(1u, events.size());
139 controller->NotifyAnimationStarted(events[0]); 147 controller->NotifyAnimationStarted(events[0]);
140 148
141 EXPECT_EQ(start_time, 149 EXPECT_EQ(start_time,
142 controller->GetAnimation(group_id, 150 controller->GetAnimation(group_id,
143 Animation::Opacity)->start_time()); 151 Animation::Opacity)->start_time());
144 EXPECT_EQ(controller->GetAnimation(group_id, 152 EXPECT_EQ(controller->GetAnimation(group_id,
145 Animation::Opacity)->start_time(), 153 Animation::Opacity)->start_time(),
146 controller_impl->GetAnimation(group_id, 154 controller_impl->GetAnimation(group_id,
147 Animation::Opacity)->start_time()); 155 Animation::Opacity)->start_time());
148 156
149 // Start the animation on the main thread. Should not affect the start time. 157 // Start the animation on the main thread. Should not affect the start time.
150 controller->Animate(kInitialTickTime + 0.5); 158 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
151 controller->UpdateState(true, NULL); 159 controller->UpdateState(true, NULL);
152 EXPECT_EQ(start_time, 160 EXPECT_EQ(start_time,
153 controller->GetAnimation(group_id, 161 controller->GetAnimation(group_id,
154 Animation::Opacity)->start_time()); 162 Animation::Opacity)->start_time());
155 EXPECT_EQ(controller->GetAnimation(group_id, 163 EXPECT_EQ(controller->GetAnimation(group_id,
156 Animation::Opacity)->start_time(), 164 Animation::Opacity)->start_time(),
157 controller_impl->GetAnimation(group_id, 165 controller_impl->GetAnimation(group_id,
158 Animation::Opacity)->start_time()); 166 Animation::Opacity)->start_time());
159 } 167 }
160 168
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); 202 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size());
195 203
196 controller_impl->Animate(kInitialTickTime); 204 controller_impl->Animate(kInitialTickTime);
197 controller_impl->UpdateState(true, events.get()); 205 controller_impl->UpdateState(true, events.get());
198 EXPECT_EQ(1u, events->size()); 206 EXPECT_EQ(1u, events->size());
199 controller->NotifyAnimationStarted((*events)[0]); 207 controller->NotifyAnimationStarted((*events)[0]);
200 208
201 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); 209 EXPECT_EQ(1u, registrar->active_animation_controllers().size());
202 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); 210 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size());
203 211
204 controller->Animate(kInitialTickTime + 0.5); 212 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
205 controller->UpdateState(true, NULL); 213 controller->UpdateState(true, NULL);
206 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); 214 EXPECT_EQ(1u, registrar->active_animation_controllers().size());
207 215
208 controller->Animate(kInitialTickTime + 1.0); 216 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
209 controller->UpdateState(true, NULL); 217 controller->UpdateState(true, NULL);
210 EXPECT_EQ(Animation::Finished, 218 EXPECT_EQ(Animation::Finished,
211 controller->GetAnimation(Animation::Opacity)->run_state()); 219 controller->GetAnimation(Animation::Opacity)->run_state());
212 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); 220 EXPECT_EQ(1u, registrar->active_animation_controllers().size());
213 221
214 events.reset(new AnimationEventsVector); 222 events.reset(new AnimationEventsVector);
215 controller_impl->Animate(kInitialTickTime + 1.5); 223 controller_impl->Animate(kInitialTickTime +
224 TimeDelta::FromMilliseconds(1500));
216 controller_impl->UpdateState(true, events.get()); 225 controller_impl->UpdateState(true, events.get());
217 226
218 EXPECT_EQ(Animation::WaitingForDeletion, 227 EXPECT_EQ(Animation::WaitingForDeletion,
219 controller_impl->GetAnimation(Animation::Opacity)->run_state()); 228 controller_impl->GetAnimation(Animation::Opacity)->run_state());
220 // The impl thread controller should have de-activated. 229 // The impl thread controller should have de-activated.
221 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); 230 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size());
222 231
223 EXPECT_EQ(1u, events->size()); 232 EXPECT_EQ(1u, events->size());
224 controller->NotifyAnimationFinished((*events)[0]); 233 controller->NotifyAnimationFinished((*events)[0]);
225 controller->Animate(kInitialTickTime + 1.5); 234 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500));
226 controller->UpdateState(true, NULL); 235 controller->UpdateState(true, NULL);
227 236
228 EXPECT_EQ(Animation::WaitingForDeletion, 237 EXPECT_EQ(Animation::WaitingForDeletion,
229 controller->GetAnimation(Animation::Opacity)->run_state()); 238 controller->GetAnimation(Animation::Opacity)->run_state());
230 // The main thread controller should have de-activated. 239 // The main thread controller should have de-activated.
231 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); 240 EXPECT_EQ(0u, registrar->active_animation_controllers().size());
232 241
233 controller->PushAnimationUpdatesTo(controller_impl.get()); 242 controller->PushAnimationUpdatesTo(controller_impl.get());
234 controller_impl->ActivateAnimations(); 243 controller_impl->ActivateAnimations();
235 EXPECT_FALSE(controller->has_any_animation()); 244 EXPECT_FALSE(controller->has_any_animation());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 controller->Animate(kInitialTickTime); 281 controller->Animate(kInitialTickTime);
273 controller->UpdateState(true, NULL); 282 controller->UpdateState(true, NULL);
274 EXPECT_EQ(Animation::Running, 283 EXPECT_EQ(Animation::Running,
275 controller_impl->GetAnimation(group_id, 284 controller_impl->GetAnimation(group_id,
276 Animation::Opacity)->run_state()); 285 Animation::Opacity)->run_state());
277 EXPECT_EQ(Animation::Running, 286 EXPECT_EQ(Animation::Running,
278 controller->GetAnimation(group_id, 287 controller->GetAnimation(group_id,
279 Animation::Opacity)->run_state()); 288 Animation::Opacity)->run_state());
280 289
281 // Pause the main-thread animation. 290 // Pause the main-thread animation.
282 controller->PauseAnimation(animation_id, kInitialTickTime + 1.0); 291 controller->PauseAnimation(
292 animation_id,
293 TimeDelta::FromMilliseconds(1000) + TimeDelta::FromMilliseconds(1000));
283 EXPECT_EQ(Animation::Paused, 294 EXPECT_EQ(Animation::Paused,
284 controller->GetAnimation(group_id, 295 controller->GetAnimation(group_id,
285 Animation::Opacity)->run_state()); 296 Animation::Opacity)->run_state());
286 297
287 // The pause run state change should make it to the impl thread controller. 298 // The pause run state change should make it to the impl thread controller.
288 controller->PushAnimationUpdatesTo(controller_impl.get()); 299 controller->PushAnimationUpdatesTo(controller_impl.get());
289 controller_impl->ActivateAnimations(); 300 controller_impl->ActivateAnimations();
290 EXPECT_EQ(Animation::Paused, 301 EXPECT_EQ(Animation::Paused,
291 controller_impl->GetAnimation(group_id, 302 controller_impl->GetAnimation(group_id,
292 Animation::Opacity)->run_state()); 303 Animation::Opacity)->run_state());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 LayerAnimationController::Create(0)); 361 LayerAnimationController::Create(0));
351 controller->AddValueObserver(&dummy); 362 controller->AddValueObserver(&dummy);
352 controller_impl->AddValueObserver(&dummy_impl); 363 controller_impl->AddValueObserver(&dummy_impl);
353 364
354 AddOpacityTransitionToController(controller.get(), 1.0, 0.0f, 1.0f, false); 365 AddOpacityTransitionToController(controller.get(), 1.0, 0.0f, 1.0f, false);
355 controller->Animate(kInitialTickTime); 366 controller->Animate(kInitialTickTime);
356 controller->UpdateState(true, NULL); 367 controller->UpdateState(true, NULL);
357 controller->PushAnimationUpdatesTo(controller_impl.get()); 368 controller->PushAnimationUpdatesTo(controller_impl.get());
358 controller_impl->ActivateAnimations(); 369 controller_impl->ActivateAnimations();
359 370
360 controller_impl->Animate(kInitialTickTime + 0.5); 371 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
361 controller_impl->UpdateState(true, events.get()); 372 controller_impl->UpdateState(true, events.get());
362 373
363 // There should be a Started event for the animation. 374 // There should be a Started event for the animation.
364 EXPECT_EQ(1u, events->size()); 375 EXPECT_EQ(1u, events->size());
365 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); 376 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type);
366 controller->NotifyAnimationStarted((*events)[0]); 377 controller->NotifyAnimationStarted((*events)[0]);
367 378
368 controller->Animate(kInitialTickTime + 1.0); 379 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
369 controller->UpdateState(true, NULL); 380 controller->UpdateState(true, NULL);
370 381
371 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); 382 EXPECT_FALSE(dummy.animation_waiting_for_deletion());
372 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); 383 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion());
373 384
374 events.reset(new AnimationEventsVector); 385 events.reset(new AnimationEventsVector);
375 controller_impl->Animate(kInitialTickTime + 2.0); 386 controller_impl->Animate(kInitialTickTime +
387 TimeDelta::FromMilliseconds(2000));
376 controller_impl->UpdateState(true, events.get()); 388 controller_impl->UpdateState(true, events.get());
377 389
378 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); 390 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion());
379 391
380 // There should be a Finished event for the animation. 392 // There should be a Finished event for the animation.
381 EXPECT_EQ(1u, events->size()); 393 EXPECT_EQ(1u, events->size());
382 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); 394 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type);
383 395
384 // Neither controller should have deleted the animation yet. 396 // Neither controller should have deleted the animation yet.
385 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); 397 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity));
386 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity)); 398 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity));
387 399
388 controller->NotifyAnimationFinished((*events)[0]); 400 controller->NotifyAnimationFinished((*events)[0]);
389 401
390 controller->Animate(kInitialTickTime + 3.0); 402 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
391 controller->UpdateState(true, NULL); 403 controller->UpdateState(true, NULL);
392 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); 404 EXPECT_TRUE(dummy.animation_waiting_for_deletion());
393 405
394 controller->PushAnimationUpdatesTo(controller_impl.get()); 406 controller->PushAnimationUpdatesTo(controller_impl.get());
395 407
396 // Both controllers should now have deleted the animation. The impl controller 408 // Both controllers should now have deleted the animation. The impl controller
397 // should have deleted the animation even though activation has not occurred, 409 // should have deleted the animation even though activation has not occurred,
398 // since the animation was already waiting for deletion when 410 // since the animation was already waiting for deletion when
399 // PushAnimationUpdatesTo was called. 411 // PushAnimationUpdatesTo was called.
400 EXPECT_FALSE(controller->has_any_animation()); 412 EXPECT_FALSE(controller->has_any_animation());
(...skipping 29 matching lines...) Expand all
430 controller->AddAnimation(to_add.Pass()); 442 controller->AddAnimation(to_add.Pass());
431 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); 443 EXPECT_TRUE(controller->needs_to_start_animations_for_testing());
432 controller->Animate(kInitialTickTime); 444 controller->Animate(kInitialTickTime);
433 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); 445 EXPECT_FALSE(controller->needs_to_start_animations_for_testing());
434 controller->UpdateState(true, events.get()); 446 controller->UpdateState(true, events.get());
435 EXPECT_TRUE(controller->HasActiveAnimation()); 447 EXPECT_TRUE(controller->HasActiveAnimation());
436 EXPECT_EQ(0.f, dummy.opacity()); 448 EXPECT_EQ(0.f, dummy.opacity());
437 // A non-impl-only animation should not generate property updates. 449 // A non-impl-only animation should not generate property updates.
438 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 450 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
439 EXPECT_FALSE(event); 451 EXPECT_FALSE(event);
440 controller->Animate(kInitialTickTime + 1.0); 452 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
441 controller->UpdateState(true, events.get()); 453 controller->UpdateState(true, events.get());
442 EXPECT_EQ(1.f, dummy.opacity()); 454 EXPECT_EQ(1.f, dummy.opacity());
443 EXPECT_FALSE(controller->HasActiveAnimation()); 455 EXPECT_FALSE(controller->HasActiveAnimation());
444 event = GetMostRecentPropertyUpdateEvent(events.get()); 456 event = GetMostRecentPropertyUpdateEvent(events.get());
445 EXPECT_FALSE(event); 457 EXPECT_FALSE(event);
446 } 458 }
447 459
448 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { 460 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) {
449 scoped_ptr<AnimationEventsVector> events( 461 scoped_ptr<AnimationEventsVector> events(
450 make_scoped_ptr(new AnimationEventsVector)); 462 make_scoped_ptr(new AnimationEventsVector));
(...skipping 11 matching lines...) Expand all
462 controller_impl->AddAnimation(to_add.Pass()); 474 controller_impl->AddAnimation(to_add.Pass());
463 controller_impl->Animate(kInitialTickTime); 475 controller_impl->Animate(kInitialTickTime);
464 controller_impl->UpdateState(true, events.get()); 476 controller_impl->UpdateState(true, events.get());
465 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 477 EXPECT_TRUE(controller_impl->HasActiveAnimation());
466 EXPECT_EQ(0.f, dummy_impl.opacity()); 478 EXPECT_EQ(0.f, dummy_impl.opacity());
467 EXPECT_EQ(2u, events->size()); 479 EXPECT_EQ(2u, events->size());
468 const AnimationEvent* start_opacity_event = 480 const AnimationEvent* start_opacity_event =
469 GetMostRecentPropertyUpdateEvent(events.get()); 481 GetMostRecentPropertyUpdateEvent(events.get());
470 EXPECT_EQ(0.f, start_opacity_event->opacity); 482 EXPECT_EQ(0.f, start_opacity_event->opacity);
471 483
472 controller_impl->Animate(kInitialTickTime + 1.0); 484 controller_impl->Animate(kInitialTickTime +
485 TimeDelta::FromMilliseconds(1000));
473 controller_impl->UpdateState(true, events.get()); 486 controller_impl->UpdateState(true, events.get());
474 EXPECT_EQ(1.f, dummy_impl.opacity()); 487 EXPECT_EQ(1.f, dummy_impl.opacity());
475 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 488 EXPECT_FALSE(controller_impl->HasActiveAnimation());
476 EXPECT_EQ(4u, events->size()); 489 EXPECT_EQ(4u, events->size());
477 const AnimationEvent* end_opacity_event = 490 const AnimationEvent* end_opacity_event =
478 GetMostRecentPropertyUpdateEvent(events.get()); 491 GetMostRecentPropertyUpdateEvent(events.get());
479 EXPECT_EQ(1.f, end_opacity_event->opacity); 492 EXPECT_EQ(1.f, end_opacity_event->opacity);
480 } 493 }
481 494
482 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) { 495 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 EXPECT_EQ(2u, events->size()); 529 EXPECT_EQ(2u, events->size());
517 const AnimationEvent* start_transform_event = 530 const AnimationEvent* start_transform_event =
518 GetMostRecentPropertyUpdateEvent(events.get()); 531 GetMostRecentPropertyUpdateEvent(events.get());
519 ASSERT_TRUE(start_transform_event); 532 ASSERT_TRUE(start_transform_event);
520 EXPECT_EQ(gfx::Transform(), start_transform_event->transform); 533 EXPECT_EQ(gfx::Transform(), start_transform_event->transform);
521 EXPECT_TRUE(start_transform_event->is_impl_only); 534 EXPECT_TRUE(start_transform_event->is_impl_only);
522 535
523 gfx::Transform expected_transform; 536 gfx::Transform expected_transform;
524 expected_transform.Translate(delta_x, delta_y); 537 expected_transform.Translate(delta_x, delta_y);
525 538
526 controller_impl->Animate(kInitialTickTime + 1.0); 539 controller_impl->Animate(kInitialTickTime +
540 TimeDelta::FromMilliseconds(1000));
527 controller_impl->UpdateState(true, events.get()); 541 controller_impl->UpdateState(true, events.get());
528 EXPECT_EQ(expected_transform, dummy_impl.transform()); 542 EXPECT_EQ(expected_transform, dummy_impl.transform());
529 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 543 EXPECT_FALSE(controller_impl->HasActiveAnimation());
530 EXPECT_EQ(4u, events->size()); 544 EXPECT_EQ(4u, events->size());
531 const AnimationEvent* end_transform_event = 545 const AnimationEvent* end_transform_event =
532 GetMostRecentPropertyUpdateEvent(events.get()); 546 GetMostRecentPropertyUpdateEvent(events.get());
533 EXPECT_EQ(expected_transform, end_transform_event->transform); 547 EXPECT_EQ(expected_transform, end_transform_event->transform);
534 EXPECT_TRUE(end_transform_event->is_impl_only); 548 EXPECT_TRUE(end_transform_event->is_impl_only);
535 } 549 }
536 550
(...skipping 22 matching lines...) Expand all
559 controller->AddAnimation(animation.Pass()); 573 controller->AddAnimation(animation.Pass());
560 574
561 controller->Animate(kInitialTickTime); 575 controller->Animate(kInitialTickTime);
562 controller->UpdateState(true, events.get()); 576 controller->UpdateState(true, events.get());
563 EXPECT_TRUE(controller->HasActiveAnimation()); 577 EXPECT_TRUE(controller->HasActiveAnimation());
564 EXPECT_EQ(start_filters, dummy.filters()); 578 EXPECT_EQ(start_filters, dummy.filters());
565 // A non-impl-only animation should not generate property updates. 579 // A non-impl-only animation should not generate property updates.
566 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 580 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
567 EXPECT_FALSE(event); 581 EXPECT_FALSE(event);
568 582
569 controller->Animate(kInitialTickTime + 0.5); 583 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
570 controller->UpdateState(true, events.get()); 584 controller->UpdateState(true, events.get());
571 EXPECT_EQ(1u, dummy.filters().size()); 585 EXPECT_EQ(1u, dummy.filters().size());
572 EXPECT_EQ(FilterOperation::CreateBrightnessFilter(1.5f), 586 EXPECT_EQ(FilterOperation::CreateBrightnessFilter(1.5f),
573 dummy.filters().at(0)); 587 dummy.filters().at(0));
574 event = GetMostRecentPropertyUpdateEvent(events.get()); 588 event = GetMostRecentPropertyUpdateEvent(events.get());
575 EXPECT_FALSE(event); 589 EXPECT_FALSE(event);
576 590
577 controller->Animate(kInitialTickTime + 1.0); 591 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
578 controller->UpdateState(true, events.get()); 592 controller->UpdateState(true, events.get());
579 EXPECT_EQ(end_filters, dummy.filters()); 593 EXPECT_EQ(end_filters, dummy.filters());
580 EXPECT_FALSE(controller->HasActiveAnimation()); 594 EXPECT_FALSE(controller->HasActiveAnimation());
581 event = GetMostRecentPropertyUpdateEvent(events.get()); 595 event = GetMostRecentPropertyUpdateEvent(events.get());
582 EXPECT_FALSE(event); 596 EXPECT_FALSE(event);
583 } 597 }
584 598
585 TEST(LayerAnimationControllerTest, FilterTransitionOnImplOnly) { 599 TEST(LayerAnimationControllerTest, FilterTransitionOnImplOnly) {
586 scoped_ptr<AnimationEventsVector> events( 600 scoped_ptr<AnimationEventsVector> events(
587 make_scoped_ptr(new AnimationEventsVector)); 601 make_scoped_ptr(new AnimationEventsVector));
(...skipping 25 matching lines...) Expand all
613 controller_impl->UpdateState(true, events.get()); 627 controller_impl->UpdateState(true, events.get());
614 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 628 EXPECT_TRUE(controller_impl->HasActiveAnimation());
615 EXPECT_EQ(start_filters, dummy_impl.filters()); 629 EXPECT_EQ(start_filters, dummy_impl.filters());
616 EXPECT_EQ(2u, events->size()); 630 EXPECT_EQ(2u, events->size());
617 const AnimationEvent* start_filter_event = 631 const AnimationEvent* start_filter_event =
618 GetMostRecentPropertyUpdateEvent(events.get()); 632 GetMostRecentPropertyUpdateEvent(events.get());
619 EXPECT_TRUE(start_filter_event); 633 EXPECT_TRUE(start_filter_event);
620 EXPECT_EQ(start_filters, start_filter_event->filters); 634 EXPECT_EQ(start_filters, start_filter_event->filters);
621 EXPECT_TRUE(start_filter_event->is_impl_only); 635 EXPECT_TRUE(start_filter_event->is_impl_only);
622 636
623 controller_impl->Animate(kInitialTickTime + 1.0); 637 controller_impl->Animate(kInitialTickTime +
638 TimeDelta::FromMilliseconds(1000));
624 controller_impl->UpdateState(true, events.get()); 639 controller_impl->UpdateState(true, events.get());
625 EXPECT_EQ(end_filters, dummy_impl.filters()); 640 EXPECT_EQ(end_filters, dummy_impl.filters());
626 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 641 EXPECT_FALSE(controller_impl->HasActiveAnimation());
627 EXPECT_EQ(4u, events->size()); 642 EXPECT_EQ(4u, events->size());
628 const AnimationEvent* end_filter_event = 643 const AnimationEvent* end_filter_event =
629 GetMostRecentPropertyUpdateEvent(events.get()); 644 GetMostRecentPropertyUpdateEvent(events.get());
630 EXPECT_TRUE(end_filter_event); 645 EXPECT_TRUE(end_filter_event);
631 EXPECT_EQ(end_filters, end_filter_event->filters); 646 EXPECT_EQ(end_filters, end_filter_event->filters);
632 EXPECT_TRUE(end_filter_event->is_impl_only); 647 EXPECT_TRUE(end_filter_event->is_impl_only);
633 } 648 }
(...skipping 23 matching lines...) Expand all
657 672
658 scoped_ptr<Animation> animation(Animation::Create( 673 scoped_ptr<Animation> animation(Animation::Create(
659 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); 674 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset));
660 animation->set_needs_synchronized_start_time(true); 675 animation->set_needs_synchronized_start_time(true);
661 controller->AddAnimation(animation.Pass()); 676 controller->AddAnimation(animation.Pass());
662 677
663 dummy_provider_impl.set_scroll_offset(initial_value); 678 dummy_provider_impl.set_scroll_offset(initial_value);
664 controller->PushAnimationUpdatesTo(controller_impl.get()); 679 controller->PushAnimationUpdatesTo(controller_impl.get());
665 controller_impl->ActivateAnimations(); 680 controller_impl->ActivateAnimations();
666 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); 681 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset));
667 double duration = controller_impl->GetAnimation( 682 double duration_in_seconds =
668 Animation::ScrollOffset)->curve()->Duration(); 683 controller_impl->GetAnimation(Animation::ScrollOffset)
669 684 ->curve()
685 ->Duration();
686 TimeDelta duration = TimeDelta::FromMicroseconds(
687 duration_in_seconds * base::Time::kMicrosecondsPerSecond);
670 EXPECT_EQ( 688 EXPECT_EQ(
671 duration, 689 duration_in_seconds,
672 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); 690 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration());
673 691
674 controller->Animate(kInitialTickTime); 692 controller->Animate(kInitialTickTime);
675 controller->UpdateState(true, NULL); 693 controller->UpdateState(true, NULL);
676 EXPECT_TRUE(controller->HasActiveAnimation()); 694 EXPECT_TRUE(controller->HasActiveAnimation());
677 EXPECT_EQ(initial_value, dummy.scroll_offset()); 695 EXPECT_EQ(initial_value, dummy.scroll_offset());
678 696
679 controller_impl->Animate(kInitialTickTime); 697 controller_impl->Animate(kInitialTickTime);
680 controller_impl->UpdateState(true, events.get()); 698 controller_impl->UpdateState(true, events.get());
681 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 699 EXPECT_TRUE(controller_impl->HasActiveAnimation());
682 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); 700 EXPECT_EQ(initial_value, dummy_impl.scroll_offset());
683 // Scroll offset animations should not generate property updates. 701 // Scroll offset animations should not generate property updates.
684 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 702 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
685 EXPECT_FALSE(event); 703 EXPECT_FALSE(event);
686 704
687 controller->NotifyAnimationStarted((*events)[0]); 705 controller->NotifyAnimationStarted((*events)[0]);
688 controller->Animate(kInitialTickTime + duration/2.0); 706 controller->Animate(kInitialTickTime + duration / 2);
689 controller->UpdateState(true, NULL); 707 controller->UpdateState(true, NULL);
690 EXPECT_TRUE(controller->HasActiveAnimation()); 708 EXPECT_TRUE(controller->HasActiveAnimation());
691 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), dummy.scroll_offset()); 709 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), dummy.scroll_offset());
692 710
693 controller_impl->Animate(kInitialTickTime + duration/2.0); 711 controller_impl->Animate(kInitialTickTime + duration / 2);
694 controller_impl->UpdateState(true, events.get()); 712 controller_impl->UpdateState(true, events.get());
695 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), 713 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f),
696 dummy_impl.scroll_offset()); 714 dummy_impl.scroll_offset());
697 event = GetMostRecentPropertyUpdateEvent(events.get()); 715 event = GetMostRecentPropertyUpdateEvent(events.get());
698 EXPECT_FALSE(event); 716 EXPECT_FALSE(event);
699 717
700 controller_impl->Animate(kInitialTickTime + duration); 718 controller_impl->Animate(kInitialTickTime + duration);
701 controller_impl->UpdateState(true, events.get()); 719 controller_impl->UpdateState(true, events.get());
702 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); 720 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset());
703 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 721 EXPECT_FALSE(controller_impl->HasActiveAnimation());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 754
737 scoped_ptr<Animation> animation(Animation::Create( 755 scoped_ptr<Animation> animation(Animation::Create(
738 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); 756 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset));
739 animation->set_needs_synchronized_start_time(true); 757 animation->set_needs_synchronized_start_time(true);
740 controller->AddAnimation(animation.Pass()); 758 controller->AddAnimation(animation.Pass());
741 759
742 dummy_provider.set_scroll_offset(initial_value); 760 dummy_provider.set_scroll_offset(initial_value);
743 controller->PushAnimationUpdatesTo(controller_impl.get()); 761 controller->PushAnimationUpdatesTo(controller_impl.get());
744 controller_impl->ActivateAnimations(); 762 controller_impl->ActivateAnimations();
745 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); 763 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset));
746 double duration = controller_impl->GetAnimation( 764 double duration_in_seconds =
747 Animation::ScrollOffset)->curve()->Duration(); 765 controller_impl->GetAnimation(Animation::ScrollOffset)
748 766 ->curve()
767 ->Duration();
749 EXPECT_EQ( 768 EXPECT_EQ(
750 duration, 769 duration_in_seconds,
751 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); 770 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration());
752 771
753 controller->Animate(kInitialTickTime); 772 controller->Animate(kInitialTickTime);
754 controller->UpdateState(true, NULL); 773 controller->UpdateState(true, NULL);
755 EXPECT_TRUE(controller->HasActiveAnimation()); 774 EXPECT_TRUE(controller->HasActiveAnimation());
756 EXPECT_EQ(initial_value, dummy.scroll_offset()); 775 EXPECT_EQ(initial_value, dummy.scroll_offset());
757 776
758 controller_impl->Animate(kInitialTickTime); 777 controller_impl->Animate(kInitialTickTime);
759 controller_impl->UpdateState(true, events.get()); 778 controller_impl->UpdateState(true, events.get());
760 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 779 EXPECT_TRUE(controller_impl->HasActiveAnimation());
761 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); 780 EXPECT_EQ(initial_value, dummy_impl.scroll_offset());
762 // Scroll offset animations should not generate property updates. 781 // Scroll offset animations should not generate property updates.
763 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 782 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
764 EXPECT_FALSE(event); 783 EXPECT_FALSE(event);
765 784
785 TimeDelta duration = TimeDelta::FromMicroseconds(
786 duration_in_seconds * base::Time::kMicrosecondsPerSecond);
787
766 controller->NotifyAnimationStarted((*events)[0]); 788 controller->NotifyAnimationStarted((*events)[0]);
767 controller->Animate(kInitialTickTime + duration/2.0); 789 controller->Animate(kInitialTickTime + duration / 2);
768 controller->UpdateState(true, NULL); 790 controller->UpdateState(true, NULL);
769 EXPECT_TRUE(controller->HasActiveAnimation()); 791 EXPECT_TRUE(controller->HasActiveAnimation());
770 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), dummy.scroll_offset()); 792 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), dummy.scroll_offset());
771 793
772 controller_impl->Animate(kInitialTickTime + duration/2.0); 794 controller_impl->Animate(kInitialTickTime + duration / 2);
773 controller_impl->UpdateState(true, events.get()); 795 controller_impl->UpdateState(true, events.get());
774 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), 796 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f),
775 dummy_impl.scroll_offset()); 797 dummy_impl.scroll_offset());
776 event = GetMostRecentPropertyUpdateEvent(events.get()); 798 event = GetMostRecentPropertyUpdateEvent(events.get());
777 EXPECT_FALSE(event); 799 EXPECT_FALSE(event);
778 800
779 controller_impl->Animate(kInitialTickTime + duration); 801 controller_impl->Animate(kInitialTickTime + duration);
780 controller_impl->UpdateState(true, events.get()); 802 controller_impl->UpdateState(true, events.get());
781 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); 803 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset());
782 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 804 EXPECT_FALSE(controller_impl->HasActiveAnimation());
(...skipping 14 matching lines...) Expand all
797 scoped_ptr<AnimationEventsVector> events( 819 scoped_ptr<AnimationEventsVector> events(
798 make_scoped_ptr(new AnimationEventsVector)); 820 make_scoped_ptr(new AnimationEventsVector));
799 821
800 gfx::Vector2dF initial_value(100.f, 300.f); 822 gfx::Vector2dF initial_value(100.f, 300.f);
801 gfx::Vector2dF target_value(300.f, 200.f); 823 gfx::Vector2dF target_value(300.f, 200.f);
802 scoped_ptr<ScrollOffsetAnimationCurve> curve( 824 scoped_ptr<ScrollOffsetAnimationCurve> curve(
803 ScrollOffsetAnimationCurve::Create( 825 ScrollOffsetAnimationCurve::Create(
804 target_value, 826 target_value,
805 EaseInOutTimingFunction::Create().Pass())); 827 EaseInOutTimingFunction::Create().Pass()));
806 curve->SetInitialValue(initial_value); 828 curve->SetInitialValue(initial_value);
807 double duration = curve->Duration(); 829 double duration_in_seconds = curve->Duration();
808 830
809 scoped_ptr<Animation> animation(Animation::Create( 831 scoped_ptr<Animation> animation(Animation::Create(
810 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); 832 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset));
811 animation->set_is_impl_only(true); 833 animation->set_is_impl_only(true);
812 controller_impl->AddAnimation(animation.Pass()); 834 controller_impl->AddAnimation(animation.Pass());
813 835
814 controller_impl->Animate(kInitialTickTime); 836 controller_impl->Animate(kInitialTickTime);
815 controller_impl->UpdateState(true, events.get()); 837 controller_impl->UpdateState(true, events.get());
816 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 838 EXPECT_TRUE(controller_impl->HasActiveAnimation());
817 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); 839 EXPECT_EQ(initial_value, dummy_impl.scroll_offset());
818 // Scroll offset animations should not generate property updates. 840 // Scroll offset animations should not generate property updates.
819 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 841 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
820 EXPECT_FALSE(event); 842 EXPECT_FALSE(event);
821 843
822 controller_impl->Animate(kInitialTickTime + duration/2.0); 844 TimeDelta duration = TimeDelta::FromMicroseconds(
845 duration_in_seconds * base::Time::kMicrosecondsPerSecond);
846
847 controller_impl->Animate(kInitialTickTime + duration / 2);
823 controller_impl->UpdateState(true, events.get()); 848 controller_impl->UpdateState(true, events.get());
824 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), 849 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f),
825 dummy_impl.scroll_offset()); 850 dummy_impl.scroll_offset());
826 event = GetMostRecentPropertyUpdateEvent(events.get()); 851 event = GetMostRecentPropertyUpdateEvent(events.get());
827 EXPECT_FALSE(event); 852 EXPECT_FALSE(event);
828 853
829 controller_impl->Animate(kInitialTickTime + duration); 854 controller_impl->Animate(kInitialTickTime + duration);
830 controller_impl->UpdateState(true, events.get()); 855 controller_impl->UpdateState(true, events.get());
831 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); 856 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset());
832 EXPECT_FALSE(controller_impl->HasActiveAnimation()); 857 EXPECT_FALSE(controller_impl->HasActiveAnimation());
833 event = GetMostRecentPropertyUpdateEvent(events.get()); 858 event = GetMostRecentPropertyUpdateEvent(events.get());
834 EXPECT_FALSE(event); 859 EXPECT_FALSE(event);
835 } 860 }
836 861
837 class FakeAnimationDelegate : public AnimationDelegate { 862 class FakeAnimationDelegate : public AnimationDelegate {
838 public: 863 public:
839 FakeAnimationDelegate() 864 FakeAnimationDelegate()
840 : started_(false), 865 : started_(false),
841 finished_(false) {} 866 finished_(false) {}
842 867
843 virtual void NotifyAnimationStarted( 868 virtual void NotifyAnimationStarted(
844 base::TimeTicks monotonic_time, 869 TimeTicks monotonic_time,
845 Animation::TargetProperty target_property) OVERRIDE { 870 Animation::TargetProperty target_property) OVERRIDE {
846 started_ = true; 871 started_ = true;
847 } 872 }
848 873
849 virtual void NotifyAnimationFinished( 874 virtual void NotifyAnimationFinished(
850 base::TimeTicks monotonic_time, 875 TimeTicks monotonic_time,
851 Animation::TargetProperty target_property) OVERRIDE { 876 Animation::TargetProperty target_property) OVERRIDE {
852 finished_ = true; 877 finished_ = true;
853 } 878 }
854 879
855 bool started() { return started_; } 880 bool started() { return started_; }
856 881
857 bool finished() { return finished_; } 882 bool finished() { return finished_; }
858 883
859 private: 884 private:
860 bool started_; 885 bool started_;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); 920 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type);
896 EXPECT_TRUE((*events)[1].is_impl_only); 921 EXPECT_TRUE((*events)[1].is_impl_only);
897 922
898 // Passing on the start event to the main thread controller should cause the 923 // Passing on the start event to the main thread controller should cause the
899 // delegate to get notified. 924 // delegate to get notified.
900 EXPECT_FALSE(delegate.started()); 925 EXPECT_FALSE(delegate.started());
901 controller->NotifyAnimationStarted((*events)[0]); 926 controller->NotifyAnimationStarted((*events)[0]);
902 EXPECT_TRUE(delegate.started()); 927 EXPECT_TRUE(delegate.started());
903 928
904 events.reset(new AnimationEventsVector); 929 events.reset(new AnimationEventsVector);
905 controller_impl->Animate(kInitialTickTime + 1.0); 930 controller_impl->Animate(kInitialTickTime +
931 TimeDelta::FromMilliseconds(1000));
906 controller_impl->UpdateState(true, events.get()); 932 controller_impl->UpdateState(true, events.get());
907 933
908 // We should receive 2 events (a finished notification and a property update). 934 // We should receive 2 events (a finished notification and a property update).
909 EXPECT_EQ(2u, events->size()); 935 EXPECT_EQ(2u, events->size());
910 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); 936 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type);
911 EXPECT_TRUE((*events)[0].is_impl_only); 937 EXPECT_TRUE((*events)[0].is_impl_only);
912 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); 938 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type);
913 EXPECT_TRUE((*events)[1].is_impl_only); 939 EXPECT_TRUE((*events)[1].is_impl_only);
914 940
915 // Passing on the finished event to the main thread controller should cause 941 // Passing on the finished event to the main thread controller should cause
(...skipping 20 matching lines...) Expand all
936 Animation::Opacity)); 962 Animation::Opacity));
937 to_add->set_needs_synchronized_start_time(true); 963 to_add->set_needs_synchronized_start_time(true);
938 964
939 // We should pause at the first keyframe indefinitely waiting for that 965 // We should pause at the first keyframe indefinitely waiting for that
940 // animation to start. 966 // animation to start.
941 controller->AddAnimation(to_add.Pass()); 967 controller->AddAnimation(to_add.Pass());
942 controller->Animate(kInitialTickTime); 968 controller->Animate(kInitialTickTime);
943 controller->UpdateState(true, events.get()); 969 controller->UpdateState(true, events.get());
944 EXPECT_TRUE(controller->HasActiveAnimation()); 970 EXPECT_TRUE(controller->HasActiveAnimation());
945 EXPECT_EQ(0.f, dummy.opacity()); 971 EXPECT_EQ(0.f, dummy.opacity());
946 controller->Animate(kInitialTickTime + 1.0); 972 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
947 controller->UpdateState(true, events.get()); 973 controller->UpdateState(true, events.get());
948 EXPECT_TRUE(controller->HasActiveAnimation()); 974 EXPECT_TRUE(controller->HasActiveAnimation());
949 EXPECT_EQ(0.f, dummy.opacity()); 975 EXPECT_EQ(0.f, dummy.opacity());
950 controller->Animate(kInitialTickTime + 2.0); 976 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
951 controller->UpdateState(true, events.get()); 977 controller->UpdateState(true, events.get());
952 EXPECT_TRUE(controller->HasActiveAnimation()); 978 EXPECT_TRUE(controller->HasActiveAnimation());
953 EXPECT_EQ(0.f, dummy.opacity()); 979 EXPECT_EQ(0.f, dummy.opacity());
954 980
955 // Send the synchronized start time. 981 // Send the synchronized start time.
956 controller->NotifyAnimationStarted(AnimationEvent( 982 controller->NotifyAnimationStarted(
957 AnimationEvent::Started, 0, 1, Animation::Opacity, kInitialTickTime + 2)); 983 AnimationEvent(AnimationEvent::Started,
958 controller->Animate(kInitialTickTime + 5.0); 984 0,
985 1,
986 Animation::Opacity,
987 kInitialTickTime + TimeDelta::FromMilliseconds(2000)));
988 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(5000));
959 controller->UpdateState(true, events.get()); 989 controller->UpdateState(true, events.get());
960 EXPECT_EQ(1.f, dummy.opacity()); 990 EXPECT_EQ(1.f, dummy.opacity());
961 EXPECT_FALSE(controller->HasActiveAnimation()); 991 EXPECT_FALSE(controller->HasActiveAnimation());
962 } 992 }
963 993
964 // Tests that two queued animations affecting the same property run in sequence. 994 // Tests that two queued animations affecting the same property run in sequence.
965 TEST(LayerAnimationControllerTest, TrivialQueuing) { 995 TEST(LayerAnimationControllerTest, TrivialQueuing) {
966 scoped_ptr<AnimationEventsVector> events( 996 scoped_ptr<AnimationEventsVector> events(
967 make_scoped_ptr(new AnimationEventsVector)); 997 make_scoped_ptr(new AnimationEventsVector));
968 FakeLayerAnimationValueObserver dummy; 998 FakeLayerAnimationValueObserver dummy;
(...skipping 16 matching lines...) Expand all
985 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); 1015 EXPECT_TRUE(controller->needs_to_start_animations_for_testing());
986 1016
987 controller->Animate(kInitialTickTime); 1017 controller->Animate(kInitialTickTime);
988 1018
989 // The second animation still needs to be started. 1019 // The second animation still needs to be started.
990 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); 1020 EXPECT_TRUE(controller->needs_to_start_animations_for_testing());
991 1021
992 controller->UpdateState(true, events.get()); 1022 controller->UpdateState(true, events.get());
993 EXPECT_TRUE(controller->HasActiveAnimation()); 1023 EXPECT_TRUE(controller->HasActiveAnimation());
994 EXPECT_EQ(0.f, dummy.opacity()); 1024 EXPECT_EQ(0.f, dummy.opacity());
995 controller->Animate(kInitialTickTime + 1.0);
996 1025
1026 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
997 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); 1027 EXPECT_TRUE(controller->needs_to_start_animations_for_testing());
998 controller->UpdateState(true, events.get()); 1028 controller->UpdateState(true, events.get());
999 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); 1029 EXPECT_FALSE(controller->needs_to_start_animations_for_testing());
1000 1030
1001 EXPECT_TRUE(controller->HasActiveAnimation()); 1031 EXPECT_TRUE(controller->HasActiveAnimation());
1002 EXPECT_EQ(1.f, dummy.opacity()); 1032 EXPECT_EQ(1.f, dummy.opacity());
1003 controller->Animate(kInitialTickTime + 2.0); 1033 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1004 controller->UpdateState(true, events.get()); 1034 controller->UpdateState(true, events.get());
1005 EXPECT_EQ(0.5f, dummy.opacity()); 1035 EXPECT_EQ(0.5f, dummy.opacity());
1006 EXPECT_FALSE(controller->HasActiveAnimation()); 1036 EXPECT_FALSE(controller->HasActiveAnimation());
1007 } 1037 }
1008 1038
1009 // Tests interrupting a transition with another transition. 1039 // Tests interrupting a transition with another transition.
1010 TEST(LayerAnimationControllerTest, Interrupt) { 1040 TEST(LayerAnimationControllerTest, Interrupt) {
1011 scoped_ptr<AnimationEventsVector> events( 1041 scoped_ptr<AnimationEventsVector> events(
1012 make_scoped_ptr(new AnimationEventsVector)); 1042 make_scoped_ptr(new AnimationEventsVector));
1013 FakeLayerAnimationValueObserver dummy; 1043 FakeLayerAnimationValueObserver dummy;
(...skipping 12 matching lines...) Expand all
1026 scoped_ptr<Animation> to_add(CreateAnimation( 1056 scoped_ptr<Animation> to_add(CreateAnimation(
1027 scoped_ptr<AnimationCurve>( 1057 scoped_ptr<AnimationCurve>(
1028 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), 1058 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(),
1029 2, 1059 2,
1030 Animation::Opacity)); 1060 Animation::Opacity));
1031 controller->AbortAnimations(Animation::Opacity); 1061 controller->AbortAnimations(Animation::Opacity);
1032 controller->AddAnimation(to_add.Pass()); 1062 controller->AddAnimation(to_add.Pass());
1033 1063
1034 // Since the previous animation was aborted, the new animation should start 1064 // Since the previous animation was aborted, the new animation should start
1035 // right in this call to animate. 1065 // right in this call to animate.
1036 controller->Animate(kInitialTickTime + 0.5); 1066 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
1037 controller->UpdateState(true, events.get()); 1067 controller->UpdateState(true, events.get());
1038 EXPECT_TRUE(controller->HasActiveAnimation()); 1068 EXPECT_TRUE(controller->HasActiveAnimation());
1039 EXPECT_EQ(1.f, dummy.opacity()); 1069 EXPECT_EQ(1.f, dummy.opacity());
1040 controller->Animate(kInitialTickTime + 1.5); 1070 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500));
1041 controller->UpdateState(true, events.get()); 1071 controller->UpdateState(true, events.get());
1042 EXPECT_EQ(0.5f, dummy.opacity()); 1072 EXPECT_EQ(0.5f, dummy.opacity());
1043 EXPECT_FALSE(controller->HasActiveAnimation()); 1073 EXPECT_FALSE(controller->HasActiveAnimation());
1044 } 1074 }
1045 1075
1046 // Tests scheduling two animations to run together when only one property is 1076 // Tests scheduling two animations to run together when only one property is
1047 // free. 1077 // free.
1048 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { 1078 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) {
1049 scoped_ptr<AnimationEventsVector> events( 1079 scoped_ptr<AnimationEventsVector> events(
1050 make_scoped_ptr(new AnimationEventsVector)); 1080 make_scoped_ptr(new AnimationEventsVector));
(...skipping 12 matching lines...) Expand all
1063 Animation::Transform)); 1093 Animation::Transform));
1064 controller->AddAnimation(CreateAnimation( 1094 controller->AddAnimation(CreateAnimation(
1065 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1095 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1066 2, 1096 2,
1067 Animation::Opacity)); 1097 Animation::Opacity));
1068 1098
1069 controller->Animate(kInitialTickTime); 1099 controller->Animate(kInitialTickTime);
1070 controller->UpdateState(true, events.get()); 1100 controller->UpdateState(true, events.get());
1071 EXPECT_EQ(0.f, dummy.opacity()); 1101 EXPECT_EQ(0.f, dummy.opacity());
1072 EXPECT_TRUE(controller->HasActiveAnimation()); 1102 EXPECT_TRUE(controller->HasActiveAnimation());
1073 controller->Animate(kInitialTickTime + 1.0); 1103 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1074 controller->UpdateState(true, events.get()); 1104 controller->UpdateState(true, events.get());
1075 // Should not have started the float transition yet. 1105 // Should not have started the float transition yet.
1076 EXPECT_TRUE(controller->HasActiveAnimation()); 1106 EXPECT_TRUE(controller->HasActiveAnimation());
1077 EXPECT_EQ(0.f, dummy.opacity()); 1107 EXPECT_EQ(0.f, dummy.opacity());
1078 // The float animation should have started at time 1 and should be done. 1108 // The float animation should have started at time 1 and should be done.
1079 controller->Animate(kInitialTickTime + 2.0); 1109 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1080 controller->UpdateState(true, events.get()); 1110 controller->UpdateState(true, events.get());
1081 EXPECT_EQ(1.f, dummy.opacity()); 1111 EXPECT_EQ(1.f, dummy.opacity());
1082 EXPECT_FALSE(controller->HasActiveAnimation()); 1112 EXPECT_FALSE(controller->HasActiveAnimation());
1083 } 1113 }
1084 1114
1085 // Tests scheduling two animations to run together with different lengths and 1115 // Tests scheduling two animations to run together with different lengths and
1086 // another animation queued to start when the shorter animation finishes (should 1116 // another animation queued to start when the shorter animation finishes (should
1087 // wait for both to finish). 1117 // wait for both to finish).
1088 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { 1118 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) {
1089 scoped_ptr<AnimationEventsVector> events( 1119 scoped_ptr<AnimationEventsVector> events(
(...skipping 18 matching lines...) Expand all
1108 Animation::Opacity)); 1138 Animation::Opacity));
1109 1139
1110 // Animations with id 1 should both start now. 1140 // Animations with id 1 should both start now.
1111 controller->Animate(kInitialTickTime); 1141 controller->Animate(kInitialTickTime);
1112 controller->UpdateState(true, events.get()); 1142 controller->UpdateState(true, events.get());
1113 EXPECT_TRUE(controller->HasActiveAnimation()); 1143 EXPECT_TRUE(controller->HasActiveAnimation());
1114 EXPECT_EQ(0.f, dummy.opacity()); 1144 EXPECT_EQ(0.f, dummy.opacity());
1115 // The opacity animation should have finished at time 1, but the group 1145 // The opacity animation should have finished at time 1, but the group
1116 // of animations with id 1 don't finish until time 2 because of the length 1146 // of animations with id 1 don't finish until time 2 because of the length
1117 // of the transform animation. 1147 // of the transform animation.
1118 controller->Animate(kInitialTickTime + 2.0); 1148 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1119 controller->UpdateState(true, events.get()); 1149 controller->UpdateState(true, events.get());
1120 // Should not have started the float transition yet. 1150 // Should not have started the float transition yet.
1121 EXPECT_TRUE(controller->HasActiveAnimation()); 1151 EXPECT_TRUE(controller->HasActiveAnimation());
1122 EXPECT_EQ(1.f, dummy.opacity()); 1152 EXPECT_EQ(1.f, dummy.opacity());
1123 1153
1124 // The second opacity animation should start at time 2 and should be done by 1154 // The second opacity animation should start at time 2 and should be done by
1125 // time 3. 1155 // time 3.
1126 controller->Animate(kInitialTickTime + 3.0); 1156 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
1127 controller->UpdateState(true, events.get()); 1157 controller->UpdateState(true, events.get());
1128 EXPECT_EQ(0.5f, dummy.opacity()); 1158 EXPECT_EQ(0.5f, dummy.opacity());
1129 EXPECT_FALSE(controller->HasActiveAnimation()); 1159 EXPECT_FALSE(controller->HasActiveAnimation());
1130 } 1160 }
1131 1161
1132 // Test that a looping animation loops and for the correct number of iterations. 1162 // Test that a looping animation loops and for the correct number of iterations.
1133 TEST(LayerAnimationControllerTest, TrivialLooping) { 1163 TEST(LayerAnimationControllerTest, TrivialLooping) {
1134 scoped_ptr<AnimationEventsVector> events( 1164 scoped_ptr<AnimationEventsVector> events(
1135 make_scoped_ptr(new AnimationEventsVector)); 1165 make_scoped_ptr(new AnimationEventsVector));
1136 FakeLayerAnimationValueObserver dummy; 1166 FakeLayerAnimationValueObserver dummy;
1137 scoped_refptr<LayerAnimationController> controller( 1167 scoped_refptr<LayerAnimationController> controller(
1138 LayerAnimationController::Create(0)); 1168 LayerAnimationController::Create(0));
1139 controller->AddValueObserver(&dummy); 1169 controller->AddValueObserver(&dummy);
1140 1170
1141 scoped_ptr<Animation> to_add(CreateAnimation( 1171 scoped_ptr<Animation> to_add(CreateAnimation(
1142 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1172 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1143 1, 1173 1,
1144 Animation::Opacity)); 1174 Animation::Opacity));
1145 to_add->set_iterations(3); 1175 to_add->set_iterations(3);
1146 controller->AddAnimation(to_add.Pass()); 1176 controller->AddAnimation(to_add.Pass());
1147 1177
1148 controller->Animate(kInitialTickTime); 1178 controller->Animate(kInitialTickTime);
1149 controller->UpdateState(true, events.get()); 1179 controller->UpdateState(true, events.get());
1150 EXPECT_TRUE(controller->HasActiveAnimation()); 1180 EXPECT_TRUE(controller->HasActiveAnimation());
1151 EXPECT_EQ(0.f, dummy.opacity()); 1181 EXPECT_EQ(0.f, dummy.opacity());
1152 controller->Animate(kInitialTickTime + 1.25); 1182 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250));
1153 controller->UpdateState(true, events.get()); 1183 controller->UpdateState(true, events.get());
1154 EXPECT_TRUE(controller->HasActiveAnimation()); 1184 EXPECT_TRUE(controller->HasActiveAnimation());
1155 EXPECT_EQ(0.25f, dummy.opacity()); 1185 EXPECT_EQ(0.25f, dummy.opacity());
1156 controller->Animate(kInitialTickTime + 1.75); 1186 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750));
1157 controller->UpdateState(true, events.get()); 1187 controller->UpdateState(true, events.get());
1158 EXPECT_TRUE(controller->HasActiveAnimation()); 1188 EXPECT_TRUE(controller->HasActiveAnimation());
1159 EXPECT_EQ(0.75f, dummy.opacity()); 1189 EXPECT_EQ(0.75f, dummy.opacity());
1160 controller->Animate(kInitialTickTime + 2.25); 1190 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2250));
1161 controller->UpdateState(true, events.get()); 1191 controller->UpdateState(true, events.get());
1162 EXPECT_TRUE(controller->HasActiveAnimation()); 1192 EXPECT_TRUE(controller->HasActiveAnimation());
1163 EXPECT_EQ(0.25f, dummy.opacity()); 1193 EXPECT_EQ(0.25f, dummy.opacity());
1164 controller->Animate(kInitialTickTime + 2.75); 1194 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2750));
1165 controller->UpdateState(true, events.get()); 1195 controller->UpdateState(true, events.get());
1166 EXPECT_TRUE(controller->HasActiveAnimation()); 1196 EXPECT_TRUE(controller->HasActiveAnimation());
1167 EXPECT_EQ(0.75f, dummy.opacity()); 1197 EXPECT_EQ(0.75f, dummy.opacity());
1168 controller->Animate(kInitialTickTime + 3.0); 1198 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
1169 controller->UpdateState(true, events.get()); 1199 controller->UpdateState(true, events.get());
1170 EXPECT_FALSE(controller->HasActiveAnimation()); 1200 EXPECT_FALSE(controller->HasActiveAnimation());
1171 EXPECT_EQ(1.f, dummy.opacity()); 1201 EXPECT_EQ(1.f, dummy.opacity());
1172 1202
1173 // Just be extra sure. 1203 // Just be extra sure.
1174 controller->Animate(kInitialTickTime + 4.0); 1204 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000));
1175 controller->UpdateState(true, events.get()); 1205 controller->UpdateState(true, events.get());
1176 EXPECT_EQ(1.f, dummy.opacity()); 1206 EXPECT_EQ(1.f, dummy.opacity());
1177 } 1207 }
1178 1208
1179 // Test that an infinitely looping animation does indeed go until aborted. 1209 // Test that an infinitely looping animation does indeed go until aborted.
1180 TEST(LayerAnimationControllerTest, InfiniteLooping) { 1210 TEST(LayerAnimationControllerTest, InfiniteLooping) {
1181 scoped_ptr<AnimationEventsVector> events( 1211 scoped_ptr<AnimationEventsVector> events(
1182 make_scoped_ptr(new AnimationEventsVector)); 1212 make_scoped_ptr(new AnimationEventsVector));
1183 FakeLayerAnimationValueObserver dummy; 1213 FakeLayerAnimationValueObserver dummy;
1184 scoped_refptr<LayerAnimationController> controller( 1214 scoped_refptr<LayerAnimationController> controller(
1185 LayerAnimationController::Create(0)); 1215 LayerAnimationController::Create(0));
1186 controller->AddValueObserver(&dummy); 1216 controller->AddValueObserver(&dummy);
1187 1217
1188 const int id = 1; 1218 const int id = 1;
1189 scoped_ptr<Animation> to_add(CreateAnimation( 1219 scoped_ptr<Animation> to_add(CreateAnimation(
1190 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1220 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1191 id, 1221 id,
1192 Animation::Opacity)); 1222 Animation::Opacity));
1193 to_add->set_iterations(-1); 1223 to_add->set_iterations(-1);
1194 controller->AddAnimation(to_add.Pass()); 1224 controller->AddAnimation(to_add.Pass());
1195 1225
1196 controller->Animate(kInitialTickTime); 1226 controller->Animate(kInitialTickTime);
1197 controller->UpdateState(true, events.get()); 1227 controller->UpdateState(true, events.get());
1198 EXPECT_TRUE(controller->HasActiveAnimation()); 1228 EXPECT_TRUE(controller->HasActiveAnimation());
1199 EXPECT_EQ(0.f, dummy.opacity()); 1229 EXPECT_EQ(0.f, dummy.opacity());
1200 controller->Animate(kInitialTickTime + 1.25); 1230 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250));
1201 controller->UpdateState(true, events.get()); 1231 controller->UpdateState(true, events.get());
1202 EXPECT_TRUE(controller->HasActiveAnimation()); 1232 EXPECT_TRUE(controller->HasActiveAnimation());
1203 EXPECT_EQ(0.25f, dummy.opacity()); 1233 EXPECT_EQ(0.25f, dummy.opacity());
1204 controller->Animate(kInitialTickTime + 1.75); 1234 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750));
1205 controller->UpdateState(true, events.get()); 1235 controller->UpdateState(true, events.get());
1206 EXPECT_TRUE(controller->HasActiveAnimation()); 1236 EXPECT_TRUE(controller->HasActiveAnimation());
1207 EXPECT_EQ(0.75f, dummy.opacity()); 1237 EXPECT_EQ(0.75f, dummy.opacity());
1208 1238
1209 controller->Animate(kInitialTickTime + 1073741824.25); 1239 controller->Animate(kInitialTickTime +
1240 TimeDelta::FromMilliseconds(1073741824250));
1210 controller->UpdateState(true, events.get()); 1241 controller->UpdateState(true, events.get());
1211 EXPECT_TRUE(controller->HasActiveAnimation()); 1242 EXPECT_TRUE(controller->HasActiveAnimation());
1212 EXPECT_EQ(0.25f, dummy.opacity()); 1243 EXPECT_EQ(0.25f, dummy.opacity());
1213 controller->Animate(kInitialTickTime + 1073741824.75); 1244 controller->Animate(kInitialTickTime +
1245 TimeDelta::FromMilliseconds(1073741824750));
1214 controller->UpdateState(true, events.get()); 1246 controller->UpdateState(true, events.get());
1215 EXPECT_TRUE(controller->HasActiveAnimation()); 1247 EXPECT_TRUE(controller->HasActiveAnimation());
1216 EXPECT_EQ(0.75f, dummy.opacity()); 1248 EXPECT_EQ(0.75f, dummy.opacity());
1217 1249
1218 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); 1250 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity));
1219 controller->GetAnimation(id, Animation::Opacity)->SetRunState( 1251 controller->GetAnimation(id, Animation::Opacity)->SetRunState(
1220 Animation::Aborted, kInitialTickTime + 0.75); 1252 Animation::Aborted, kInitialTickTime + TimeDelta::FromMilliseconds(750));
1221 EXPECT_FALSE(controller->HasActiveAnimation()); 1253 EXPECT_FALSE(controller->HasActiveAnimation());
1222 EXPECT_EQ(0.75f, dummy.opacity()); 1254 EXPECT_EQ(0.75f, dummy.opacity());
1223 } 1255 }
1224 1256
1225 // Test that pausing and resuming work as expected. 1257 // Test that pausing and resuming work as expected.
1226 TEST(LayerAnimationControllerTest, PauseResume) { 1258 TEST(LayerAnimationControllerTest, PauseResume) {
1227 scoped_ptr<AnimationEventsVector> events( 1259 scoped_ptr<AnimationEventsVector> events(
1228 make_scoped_ptr(new AnimationEventsVector)); 1260 make_scoped_ptr(new AnimationEventsVector));
1229 FakeLayerAnimationValueObserver dummy; 1261 FakeLayerAnimationValueObserver dummy;
1230 scoped_refptr<LayerAnimationController> controller( 1262 scoped_refptr<LayerAnimationController> controller(
1231 LayerAnimationController::Create(0)); 1263 LayerAnimationController::Create(0));
1232 controller->AddValueObserver(&dummy); 1264 controller->AddValueObserver(&dummy);
1233 1265
1234 const int id = 1; 1266 const int id = 1;
1235 controller->AddAnimation(CreateAnimation( 1267 controller->AddAnimation(CreateAnimation(
1236 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1268 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1237 id, 1269 id,
1238 Animation::Opacity)); 1270 Animation::Opacity));
1239 1271
1240 controller->Animate(kInitialTickTime); 1272 controller->Animate(kInitialTickTime);
1241 controller->UpdateState(true, events.get()); 1273 controller->UpdateState(true, events.get());
1242 EXPECT_TRUE(controller->HasActiveAnimation()); 1274 EXPECT_TRUE(controller->HasActiveAnimation());
1243 EXPECT_EQ(0.f, dummy.opacity()); 1275 EXPECT_EQ(0.f, dummy.opacity());
1244 controller->Animate(kInitialTickTime + 0.5); 1276 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
1245 controller->UpdateState(true, events.get()); 1277 controller->UpdateState(true, events.get());
1246 EXPECT_TRUE(controller->HasActiveAnimation()); 1278 EXPECT_TRUE(controller->HasActiveAnimation());
1247 EXPECT_EQ(0.5f, dummy.opacity()); 1279 EXPECT_EQ(0.5f, dummy.opacity());
1248 1280
1249 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); 1281 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity));
1250 controller->GetAnimation(id, Animation::Opacity)->SetRunState( 1282 controller->GetAnimation(id, Animation::Opacity)->SetRunState(
1251 Animation::Paused, kInitialTickTime + 0.5); 1283 Animation::Paused, kInitialTickTime + TimeDelta::FromMilliseconds(500));
1252 1284
1253 controller->Animate(kInitialTickTime + 1024.0); 1285 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024000));
1254 controller->UpdateState(true, events.get()); 1286 controller->UpdateState(true, events.get());
1255 EXPECT_TRUE(controller->HasActiveAnimation()); 1287 EXPECT_TRUE(controller->HasActiveAnimation());
1256 EXPECT_EQ(0.5f, dummy.opacity()); 1288 EXPECT_EQ(0.5f, dummy.opacity());
1257 1289
1258 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); 1290 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity));
1259 controller->GetAnimation(id, Animation::Opacity)->SetRunState( 1291 controller->GetAnimation(id, Animation::Opacity)
1260 Animation::Running, kInitialTickTime + 1024); 1292 ->SetRunState(Animation::Running,
1261 1293 kInitialTickTime + TimeDelta::FromMilliseconds(1024000));
1262 controller->Animate(kInitialTickTime + 1024.25); 1294 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024250));
1263 controller->UpdateState(true, events.get()); 1295 controller->UpdateState(true, events.get());
1264 EXPECT_TRUE(controller->HasActiveAnimation()); 1296 EXPECT_TRUE(controller->HasActiveAnimation());
1265 EXPECT_EQ(0.75f, dummy.opacity()); 1297 EXPECT_EQ(0.75f, dummy.opacity());
1266 controller->Animate(kInitialTickTime + 1024.5); 1298
1299 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024500));
1267 controller->UpdateState(true, events.get()); 1300 controller->UpdateState(true, events.get());
1268 EXPECT_FALSE(controller->HasActiveAnimation()); 1301 EXPECT_FALSE(controller->HasActiveAnimation());
1269 EXPECT_EQ(1.f, dummy.opacity()); 1302 EXPECT_EQ(1.f, dummy.opacity());
1270 } 1303 }
1271 1304
1272 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { 1305 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) {
1273 scoped_ptr<AnimationEventsVector> events( 1306 scoped_ptr<AnimationEventsVector> events(
1274 make_scoped_ptr(new AnimationEventsVector)); 1307 make_scoped_ptr(new AnimationEventsVector));
1275 FakeLayerAnimationValueObserver dummy; 1308 FakeLayerAnimationValueObserver dummy;
1276 scoped_refptr<LayerAnimationController> controller( 1309 scoped_refptr<LayerAnimationController> controller(
(...skipping 12 matching lines...) Expand all
1289 controller->AddAnimation(CreateAnimation( 1322 controller->AddAnimation(CreateAnimation(
1290 scoped_ptr<AnimationCurve>( 1323 scoped_ptr<AnimationCurve>(
1291 new FakeFloatTransition(1.0, 1.f, 0.75f)).Pass(), 1324 new FakeFloatTransition(1.0, 1.f, 0.75f)).Pass(),
1292 2, 1325 2,
1293 Animation::Opacity)); 1326 Animation::Opacity));
1294 1327
1295 controller->Animate(kInitialTickTime); 1328 controller->Animate(kInitialTickTime);
1296 controller->UpdateState(true, events.get()); 1329 controller->UpdateState(true, events.get());
1297 EXPECT_TRUE(controller->HasActiveAnimation()); 1330 EXPECT_TRUE(controller->HasActiveAnimation());
1298 EXPECT_EQ(0.f, dummy.opacity()); 1331 EXPECT_EQ(0.f, dummy.opacity());
1299 controller->Animate(kInitialTickTime + 1.0); 1332 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1300 controller->UpdateState(true, events.get()); 1333 controller->UpdateState(true, events.get());
1301 EXPECT_TRUE(controller->HasActiveAnimation()); 1334 EXPECT_TRUE(controller->HasActiveAnimation());
1302 EXPECT_EQ(0.5f, dummy.opacity()); 1335 EXPECT_EQ(0.5f, dummy.opacity());
1303 1336
1304 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); 1337 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity));
1305 controller->GetAnimation(id, Animation::Opacity)->SetRunState( 1338 controller->GetAnimation(id, Animation::Opacity)->SetRunState(
1306 Animation::Aborted, kInitialTickTime + 1.0); 1339 Animation::Aborted, kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1307 controller->Animate(kInitialTickTime + 1.0); 1340 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1308 controller->UpdateState(true, events.get()); 1341 controller->UpdateState(true, events.get());
1309 EXPECT_TRUE(controller->HasActiveAnimation()); 1342 EXPECT_TRUE(controller->HasActiveAnimation());
1310 EXPECT_EQ(1.f, dummy.opacity()); 1343 EXPECT_EQ(1.f, dummy.opacity());
1311 controller->Animate(kInitialTickTime + 2.0); 1344 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1312 controller->UpdateState(true, events.get()); 1345 controller->UpdateState(true, events.get());
1313 EXPECT_TRUE(!controller->HasActiveAnimation()); 1346 EXPECT_TRUE(!controller->HasActiveAnimation());
1314 EXPECT_EQ(0.75f, dummy.opacity()); 1347 EXPECT_EQ(0.75f, dummy.opacity());
1315 } 1348 }
1316 1349
1317 TEST(LayerAnimationControllerTest, PushUpdatesWhenSynchronizedStartTimeNeeded) { 1350 TEST(LayerAnimationControllerTest, PushUpdatesWhenSynchronizedStartTimeNeeded) {
1318 FakeLayerAnimationValueObserver dummy_impl; 1351 FakeLayerAnimationValueObserver dummy_impl;
1319 scoped_refptr<LayerAnimationController> controller_impl( 1352 scoped_refptr<LayerAnimationController> controller_impl(
1320 LayerAnimationController::Create(0)); 1353 LayerAnimationController::Create(0));
1321 controller_impl->AddValueObserver(&dummy_impl); 1354 controller_impl->AddValueObserver(&dummy_impl);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 1398
1366 controller->Animate(kInitialTickTime); 1399 controller->Animate(kInitialTickTime);
1367 controller->UpdateState(true, events.get()); 1400 controller->UpdateState(true, events.get());
1368 1401
1369 controller->AddAnimation(CreateAnimation( 1402 controller->AddAnimation(CreateAnimation(
1370 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1403 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1371 2, 1404 2,
1372 Animation::Opacity)); 1405 Animation::Opacity));
1373 1406
1374 // Animate but don't UpdateState. 1407 // Animate but don't UpdateState.
1375 controller->Animate(kInitialTickTime + 1.0); 1408 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1376 1409
1377 controller->Animate(kInitialTickTime + 2.0); 1410 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1378 events.reset(new AnimationEventsVector); 1411 events.reset(new AnimationEventsVector);
1379 controller->UpdateState(true, events.get()); 1412 controller->UpdateState(true, events.get());
1380 1413
1381 // Should have one Started event and one Finished event. 1414 // Should have one Started event and one Finished event.
1382 EXPECT_EQ(2u, events->size()); 1415 EXPECT_EQ(2u, events->size());
1383 EXPECT_NE((*events)[0].type, (*events)[1].type); 1416 EXPECT_NE((*events)[0].type, (*events)[1].type);
1384 1417
1385 // The float transition should still be at its starting point. 1418 // The float transition should still be at its starting point.
1386 EXPECT_TRUE(controller->HasActiveAnimation()); 1419 EXPECT_TRUE(controller->HasActiveAnimation());
1387 EXPECT_EQ(0.f, dummy.opacity()); 1420 EXPECT_EQ(0.f, dummy.opacity());
1388 1421
1389 controller->Animate(kInitialTickTime + 3.0); 1422 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
1390 controller->UpdateState(true, events.get()); 1423 controller->UpdateState(true, events.get());
1391 1424
1392 // The float tranisition should now be done. 1425 // The float tranisition should now be done.
1393 EXPECT_EQ(1.f, dummy.opacity()); 1426 EXPECT_EQ(1.f, dummy.opacity());
1394 EXPECT_FALSE(controller->HasActiveAnimation()); 1427 EXPECT_FALSE(controller->HasActiveAnimation());
1395 } 1428 }
1396 1429
1397 // Tests that an animation controller with only a pending observer gets ticked 1430 // Tests that an animation controller with only a pending observer gets ticked
1398 // but doesn't progress animations past the Starting state. 1431 // but doesn't progress animations past the Starting state.
1399 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { 1432 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) {
(...skipping 16 matching lines...) Expand all
1416 controller->UpdateState(true, events.get()); 1449 controller->UpdateState(true, events.get());
1417 EXPECT_EQ(0u, events->size()); 1450 EXPECT_EQ(0u, events->size());
1418 EXPECT_EQ(Animation::WaitingForTargetAvailability, 1451 EXPECT_EQ(Animation::WaitingForTargetAvailability,
1419 controller->GetAnimation(id, Animation::Opacity)->run_state()); 1452 controller->GetAnimation(id, Animation::Opacity)->run_state());
1420 1453
1421 controller->AddValueObserver(&pending_dummy); 1454 controller->AddValueObserver(&pending_dummy);
1422 1455
1423 // With only a pending observer, the animation should progress to the 1456 // With only a pending observer, the animation should progress to the
1424 // Starting state and get ticked at its starting point, but should not 1457 // Starting state and get ticked at its starting point, but should not
1425 // progress to Running. 1458 // progress to Running.
1426 controller->Animate(kInitialTickTime + 1.0); 1459 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1427 controller->UpdateState(true, events.get()); 1460 controller->UpdateState(true, events.get());
1428 EXPECT_EQ(0u, events->size()); 1461 EXPECT_EQ(0u, events->size());
1429 EXPECT_EQ(Animation::Starting, 1462 EXPECT_EQ(Animation::Starting,
1430 controller->GetAnimation(id, Animation::Opacity)->run_state()); 1463 controller->GetAnimation(id, Animation::Opacity)->run_state());
1431 EXPECT_EQ(0.5f, pending_dummy.opacity()); 1464 EXPECT_EQ(0.5f, pending_dummy.opacity());
1432 1465
1433 // Even when already in the Starting state, the animation should stay 1466 // Even when already in the Starting state, the animation should stay
1434 // there, and shouldn't be ticked past its starting point. 1467 // there, and shouldn't be ticked past its starting point.
1435 controller->Animate(kInitialTickTime + 2.0); 1468 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1436 controller->UpdateState(true, events.get()); 1469 controller->UpdateState(true, events.get());
1437 EXPECT_EQ(0u, events->size()); 1470 EXPECT_EQ(0u, events->size());
1438 EXPECT_EQ(Animation::Starting, 1471 EXPECT_EQ(Animation::Starting,
1439 controller->GetAnimation(id, Animation::Opacity)->run_state()); 1472 controller->GetAnimation(id, Animation::Opacity)->run_state());
1440 EXPECT_EQ(0.5f, pending_dummy.opacity()); 1473 EXPECT_EQ(0.5f, pending_dummy.opacity());
1441 1474
1442 controller->AddValueObserver(&dummy); 1475 controller->AddValueObserver(&dummy);
1443 1476
1444 // Now that an active observer has been added, the animation should still 1477 // Now that an active observer has been added, the animation should still
1445 // initially tick at its starting point, but should now progress to Running. 1478 // initially tick at its starting point, but should now progress to Running.
1446 controller->Animate(kInitialTickTime + 3.0); 1479 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
1447 controller->UpdateState(true, events.get()); 1480 controller->UpdateState(true, events.get());
1448 EXPECT_EQ(1u, events->size()); 1481 EXPECT_EQ(1u, events->size());
1449 EXPECT_EQ(Animation::Running, 1482 EXPECT_EQ(Animation::Running,
1450 controller->GetAnimation(id, Animation::Opacity)->run_state()); 1483 controller->GetAnimation(id, Animation::Opacity)->run_state());
1451 EXPECT_EQ(0.5f, pending_dummy.opacity()); 1484 EXPECT_EQ(0.5f, pending_dummy.opacity());
1452 EXPECT_EQ(0.5f, dummy.opacity()); 1485 EXPECT_EQ(0.5f, dummy.opacity());
1453 1486
1454 // The animation should now tick past its starting point. 1487 // The animation should now tick past its starting point.
1455 controller->Animate(kInitialTickTime + 3.5); 1488 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3500));
1456 EXPECT_NE(0.5f, pending_dummy.opacity()); 1489 EXPECT_NE(0.5f, pending_dummy.opacity());
1457 EXPECT_NE(0.5f, dummy.opacity()); 1490 EXPECT_NE(0.5f, dummy.opacity());
1458 } 1491 }
1459 1492
1460 TEST(LayerAnimationControllerTest, TransformAnimationBounds) { 1493 TEST(LayerAnimationControllerTest, TransformAnimationBounds) {
1461 scoped_refptr<LayerAnimationController> controller_impl( 1494 scoped_refptr<LayerAnimationController> controller_impl(
1462 LayerAnimationController::Create(0)); 1495 LayerAnimationController::Create(0));
1463 1496
1464 scoped_ptr<KeyframedTransformAnimationCurve> curve1( 1497 scoped_ptr<KeyframedTransformAnimationCurve> curve1(
1465 KeyframedTransformAnimationCurve::Create()); 1498 KeyframedTransformAnimationCurve::Create());
(...skipping 24 matching lines...) Expand all
1490 controller_impl->AddAnimation(animation.Pass()); 1523 controller_impl->AddAnimation(animation.Pass());
1491 1524
1492 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); 1525 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f);
1493 gfx::BoxF bounds; 1526 gfx::BoxF bounds;
1494 1527
1495 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); 1528 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds));
1496 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), 1529 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(),
1497 bounds.ToString()); 1530 bounds.ToString());
1498 1531
1499 controller_impl->GetAnimation(1, Animation::Transform) 1532 controller_impl->GetAnimation(1, Animation::Transform)
1500 ->SetRunState(Animation::Finished, 0.0); 1533 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0));
1501 1534
1502 // Only the unfinished animation should affect the animated bounds. 1535 // Only the unfinished animation should affect the animated bounds.
1503 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); 1536 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds));
1504 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 7.f, 16.f, 20.f).ToString(), 1537 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 7.f, 16.f, 20.f).ToString(),
1505 bounds.ToString()); 1538 bounds.ToString());
1506 1539
1507 controller_impl->GetAnimation(2, Animation::Transform) 1540 controller_impl->GetAnimation(2, Animation::Transform)
1508 ->SetRunState(Animation::Finished, 0.0); 1541 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0));
1509 1542
1510 // There are no longer any running animations. 1543 // There are no longer any running animations.
1511 EXPECT_FALSE(controller_impl->HasTransformAnimationThatInflatesBounds()); 1544 EXPECT_FALSE(controller_impl->HasTransformAnimationThatInflatesBounds());
1512 1545
1513 // Add an animation whose bounds we don't yet support computing. 1546 // Add an animation whose bounds we don't yet support computing.
1514 scoped_ptr<KeyframedTransformAnimationCurve> curve3( 1547 scoped_ptr<KeyframedTransformAnimationCurve> curve3(
1515 KeyframedTransformAnimationCurve::Create()); 1548 KeyframedTransformAnimationCurve::Create());
1516 TransformOperations operations3; 1549 TransformOperations operations3;
1517 gfx::Transform transform3; 1550 gfx::Transform transform3;
1518 transform3.Scale3d(1.0, 2.0, 3.0); 1551 transform3.Scale3d(1.0, 2.0, 3.0);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), 1586 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(),
1554 4, 1587 4,
1555 Animation::Transform)); 1588 Animation::Transform));
1556 controller->AddAnimation(CreateAnimation( 1589 controller->AddAnimation(CreateAnimation(
1557 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 1590 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
1558 5, 1591 5,
1559 Animation::Opacity)); 1592 Animation::Opacity));
1560 1593
1561 controller->Animate(kInitialTickTime); 1594 controller->Animate(kInitialTickTime);
1562 controller->UpdateState(true, NULL); 1595 controller->UpdateState(true, NULL);
1563 controller->Animate(kInitialTickTime + 1.0); 1596 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1564 controller->UpdateState(true, NULL); 1597 controller->UpdateState(true, NULL);
1565 1598
1566 EXPECT_EQ(Animation::Finished, 1599 EXPECT_EQ(Animation::Finished,
1567 controller->GetAnimation(1, Animation::Transform)->run_state()); 1600 controller->GetAnimation(1, Animation::Transform)->run_state());
1568 EXPECT_EQ(Animation::Finished, 1601 EXPECT_EQ(Animation::Finished,
1569 controller->GetAnimation(2, Animation::Opacity)->run_state()); 1602 controller->GetAnimation(2, Animation::Opacity)->run_state());
1570 EXPECT_EQ(Animation::Running, 1603 EXPECT_EQ(Animation::Running,
1571 controller->GetAnimation(3, Animation::Transform)->run_state()); 1604 controller->GetAnimation(3, Animation::Transform)->run_state());
1572 EXPECT_EQ(Animation::WaitingForTargetAvailability, 1605 EXPECT_EQ(Animation::WaitingForTargetAvailability,
1573 controller->GetAnimation(4, Animation::Transform)->run_state()); 1606 controller->GetAnimation(4, Animation::Transform)->run_state());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); 1688 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion());
1656 EXPECT_EQ(1u, events.size()); 1689 EXPECT_EQ(1u, events.size());
1657 EXPECT_EQ(AnimationEvent::Aborted, events[0].type); 1690 EXPECT_EQ(AnimationEvent::Aborted, events[0].type);
1658 EXPECT_EQ(Animation::WaitingForDeletion, 1691 EXPECT_EQ(Animation::WaitingForDeletion,
1659 controller_impl->GetAnimation(Animation::Opacity)->run_state()); 1692 controller_impl->GetAnimation(Animation::Opacity)->run_state());
1660 1693
1661 controller->NotifyAnimationAborted(events[0]); 1694 controller->NotifyAnimationAborted(events[0]);
1662 EXPECT_EQ(Animation::Aborted, 1695 EXPECT_EQ(Animation::Aborted,
1663 controller->GetAnimation(Animation::Opacity)->run_state()); 1696 controller->GetAnimation(Animation::Opacity)->run_state());
1664 1697
1665 controller->Animate(kInitialTickTime + 0.5); 1698 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
1666 controller->UpdateState(true, NULL); 1699 controller->UpdateState(true, NULL);
1667 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); 1700 EXPECT_TRUE(dummy.animation_waiting_for_deletion());
1668 EXPECT_EQ(Animation::WaitingForDeletion, 1701 EXPECT_EQ(Animation::WaitingForDeletion,
1669 controller->GetAnimation(Animation::Opacity)->run_state()); 1702 controller->GetAnimation(Animation::Opacity)->run_state());
1670 1703
1671 controller->PushAnimationUpdatesTo(controller_impl.get()); 1704 controller->PushAnimationUpdatesTo(controller_impl.get());
1672 controller_impl->ActivateAnimations(); 1705 controller_impl->ActivateAnimations();
1673 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity)); 1706 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity));
1674 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); 1707 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity));
1675 } 1708 }
(...skipping 20 matching lines...) Expand all
1696 1729
1697 controller_impl->Animate(kInitialTickTime); 1730 controller_impl->Animate(kInitialTickTime);
1698 controller_impl->UpdateState(true, events.get()); 1731 controller_impl->UpdateState(true, events.get());
1699 1732
1700 // Both animations should have started. 1733 // Both animations should have started.
1701 EXPECT_EQ(2u, events->size()); 1734 EXPECT_EQ(2u, events->size());
1702 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); 1735 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type);
1703 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); 1736 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type);
1704 1737
1705 events.reset(new AnimationEventsVector); 1738 events.reset(new AnimationEventsVector);
1706 controller_impl->Animate(kInitialTickTime + 1.0); 1739 controller_impl->Animate(kInitialTickTime +
1740 TimeDelta::FromMilliseconds(1000));
1707 controller_impl->UpdateState(true, events.get()); 1741 controller_impl->UpdateState(true, events.get());
1708 1742
1709 // The opacity animation should be finished, but should not have generated 1743 // The opacity animation should be finished, but should not have generated
1710 // a Finished event yet. 1744 // a Finished event yet.
1711 EXPECT_EQ(0u, events->size()); 1745 EXPECT_EQ(0u, events->size());
1712 EXPECT_EQ(Animation::Finished, 1746 EXPECT_EQ(Animation::Finished,
1713 controller_impl->GetAnimation(1, Animation::Opacity)->run_state()); 1747 controller_impl->GetAnimation(1, Animation::Opacity)->run_state());
1714 EXPECT_EQ(Animation::Running, 1748 EXPECT_EQ(Animation::Running,
1715 controller_impl->GetAnimation(1, 1749 controller_impl->GetAnimation(1,
1716 Animation::Transform)->run_state()); 1750 Animation::Transform)->run_state());
1717 1751
1718 controller_impl->Animate(kInitialTickTime + 2.0); 1752 controller_impl->Animate(kInitialTickTime +
1753 TimeDelta::FromMilliseconds(2000));
1719 controller_impl->UpdateState(true, events.get()); 1754 controller_impl->UpdateState(true, events.get());
1720 1755
1721 // Both animations should have generated Finished events. 1756 // Both animations should have generated Finished events.
1722 EXPECT_EQ(2u, events->size()); 1757 EXPECT_EQ(2u, events->size());
1723 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); 1758 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type);
1724 EXPECT_EQ(AnimationEvent::Finished, (*events)[1].type); 1759 EXPECT_EQ(AnimationEvent::Finished, (*events)[1].type);
1725 } 1760 }
1726 1761
1727 // Ensure that when a group has a mix of aborted and finished animations, 1762 // Ensure that when a group has a mix of aborted and finished animations,
1728 // we generate a Finished event for the finished animation and an Aborted 1763 // we generate a Finished event for the finished animation and an Aborted
(...skipping 20 matching lines...) Expand all
1749 controller_impl->UpdateState(true, events.get()); 1784 controller_impl->UpdateState(true, events.get());
1750 1785
1751 // Both animations should have started. 1786 // Both animations should have started.
1752 EXPECT_EQ(2u, events->size()); 1787 EXPECT_EQ(2u, events->size());
1753 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); 1788 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type);
1754 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); 1789 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type);
1755 1790
1756 controller_impl->AbortAnimations(Animation::Opacity); 1791 controller_impl->AbortAnimations(Animation::Opacity);
1757 1792
1758 events.reset(new AnimationEventsVector); 1793 events.reset(new AnimationEventsVector);
1759 controller_impl->Animate(kInitialTickTime + 1.0); 1794 controller_impl->Animate(kInitialTickTime +
1795 TimeDelta::FromMilliseconds(1000));
1760 controller_impl->UpdateState(true, events.get()); 1796 controller_impl->UpdateState(true, events.get());
1761 1797
1762 // We should have exactly 2 events: a Finished event for the tranform 1798 // We should have exactly 2 events: a Finished event for the tranform
1763 // animation, and an Aborted event for the opacity animation. 1799 // animation, and an Aborted event for the opacity animation.
1764 EXPECT_EQ(2u, events->size()); 1800 EXPECT_EQ(2u, events->size());
1765 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); 1801 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type);
1766 EXPECT_EQ(Animation::Transform, (*events)[0].target_property); 1802 EXPECT_EQ(Animation::Transform, (*events)[0].target_property);
1767 EXPECT_EQ(AnimationEvent::Aborted, (*events)[1].type); 1803 EXPECT_EQ(AnimationEvent::Aborted, (*events)[1].type);
1768 EXPECT_EQ(Animation::Opacity, (*events)[1].target_property); 1804 EXPECT_EQ(Animation::Opacity, (*events)[1].target_property);
1769 } 1805 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1809 curve2->AddKeyframe(TransformKeyframe::Create( 1845 curve2->AddKeyframe(TransformKeyframe::Create(
1810 1.0, operations2, scoped_ptr<TimingFunction>())); 1846 1.0, operations2, scoped_ptr<TimingFunction>()));
1811 1847
1812 animation = Animation::Create( 1848 animation = Animation::Create(
1813 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); 1849 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform);
1814 controller_impl->AddAnimation(animation.Pass()); 1850 controller_impl->AddAnimation(animation.Pass());
1815 1851
1816 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale()); 1852 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale());
1817 1853
1818 controller_impl->GetAnimation(3, Animation::Transform) 1854 controller_impl->GetAnimation(3, Animation::Transform)
1819 ->SetRunState(Animation::Finished, 0.0); 1855 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0));
1820 1856
1821 // Only unfinished animations should be considered by 1857 // Only unfinished animations should be considered by
1822 // HasAnimationThatAffectsScale. 1858 // HasAnimationThatAffectsScale.
1823 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); 1859 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale());
1824 } 1860 }
1825 1861
1826 TEST(LayerAnimationControllerTest, HasOnlyTranslationTransforms) { 1862 TEST(LayerAnimationControllerTest, HasOnlyTranslationTransforms) {
1827 scoped_refptr<LayerAnimationController> controller_impl( 1863 scoped_refptr<LayerAnimationController> controller_impl(
1828 LayerAnimationController::Create(0)); 1864 LayerAnimationController::Create(0));
1829 1865
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 1.0, operations2, scoped_ptr<TimingFunction>())); 1901 1.0, operations2, scoped_ptr<TimingFunction>()));
1866 1902
1867 animation = Animation::Create( 1903 animation = Animation::Create(
1868 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); 1904 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform);
1869 controller_impl->AddAnimation(animation.Pass()); 1905 controller_impl->AddAnimation(animation.Pass());
1870 1906
1871 // A scale animation is not a translation. 1907 // A scale animation is not a translation.
1872 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms()); 1908 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms());
1873 1909
1874 controller_impl->GetAnimation(3, Animation::Transform) 1910 controller_impl->GetAnimation(3, Animation::Transform)
1875 ->SetRunState(Animation::Finished, 0.0); 1911 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0));
1876 1912
1877 // Only unfinished animations should be considered by 1913 // Only unfinished animations should be considered by
1878 // HasOnlyTranslationTransforms. 1914 // HasOnlyTranslationTransforms.
1879 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); 1915 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms());
1880 } 1916 }
1881 1917
1882 TEST(LayerAnimationControllerTest, MaximumScale) { 1918 TEST(LayerAnimationControllerTest, MaximumScale) {
1883 scoped_refptr<LayerAnimationController> controller_impl( 1919 scoped_refptr<LayerAnimationController> controller_impl(
1884 LayerAnimationController::Create(0)); 1920 LayerAnimationController::Create(0));
1885 1921
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 curve3->AddKeyframe(TransformKeyframe::Create( 1967 curve3->AddKeyframe(TransformKeyframe::Create(
1932 1.0, operations3, scoped_ptr<TimingFunction>())); 1968 1.0, operations3, scoped_ptr<TimingFunction>()));
1933 1969
1934 animation = Animation::Create( 1970 animation = Animation::Create(
1935 curve3.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); 1971 curve3.PassAs<AnimationCurve>(), 3, 3, Animation::Transform);
1936 controller_impl->AddAnimation(animation.Pass()); 1972 controller_impl->AddAnimation(animation.Pass());
1937 1973
1938 EXPECT_FALSE(controller_impl->MaximumScale(&max_scale)); 1974 EXPECT_FALSE(controller_impl->MaximumScale(&max_scale));
1939 1975
1940 controller_impl->GetAnimation(3, Animation::Transform) 1976 controller_impl->GetAnimation(3, Animation::Transform)
1941 ->SetRunState(Animation::Finished, 0.0); 1977 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0));
1942 controller_impl->GetAnimation(2, Animation::Transform) 1978 controller_impl->GetAnimation(2, Animation::Transform)
1943 ->SetRunState(Animation::Finished, 0.0); 1979 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0));
1944 1980
1945 // Only unfinished animations should be considered by 1981 // Only unfinished animations should be considered by
1946 // MaximumScale. 1982 // MaximumScale.
1947 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); 1983 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale));
1948 EXPECT_EQ(4.f, max_scale); 1984 EXPECT_EQ(4.f, max_scale);
1949 } 1985 }
1950 1986
1951 TEST(LayerAnimationControllerTest, NewlyPushedAnimationWaitsForActivation) { 1987 TEST(LayerAnimationControllerTest, NewlyPushedAnimationWaitsForActivation) {
1952 scoped_ptr<AnimationEventsVector> events( 1988 scoped_ptr<AnimationEventsVector> events(
1953 make_scoped_ptr(new AnimationEventsVector)); 1989 make_scoped_ptr(new AnimationEventsVector));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 // should have been ticked. 2030 // should have been ticked.
1995 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); 2031 EXPECT_EQ(0.5f, pending_dummy_impl.opacity());
1996 EXPECT_EQ(0.f, dummy_impl.opacity()); 2032 EXPECT_EQ(0.f, dummy_impl.opacity());
1997 2033
1998 controller_impl->ActivateAnimations(); 2034 controller_impl->ActivateAnimations();
1999 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity) 2035 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)
2000 ->affects_pending_observers()); 2036 ->affects_pending_observers());
2001 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity) 2037 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)
2002 ->affects_active_observers()); 2038 ->affects_active_observers());
2003 2039
2004 controller_impl->Animate(kInitialTickTime + 1.0); 2040 controller_impl->Animate(kInitialTickTime +
2041 TimeDelta::FromMilliseconds(1000));
2005 controller_impl->UpdateState(true, events.get()); 2042 controller_impl->UpdateState(true, events.get());
2006 2043
2007 // Since the animation has been activated, it should have reached the 2044 // Since the animation has been activated, it should have reached the
2008 // Running state and the active observer should start to get ticked. 2045 // Running state and the active observer should start to get ticked.
2009 EXPECT_EQ( 2046 EXPECT_EQ(
2010 Animation::Running, 2047 Animation::Running,
2011 controller_impl->GetAnimation(group_id, Animation::Opacity)->run_state()); 2048 controller_impl->GetAnimation(group_id, Animation::Opacity)->run_state());
2012 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); 2049 EXPECT_EQ(0.5f, pending_dummy_impl.opacity());
2013 EXPECT_EQ(0.5f, dummy_impl.opacity()); 2050 EXPECT_EQ(0.5f, dummy_impl.opacity());
2014 } 2051 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 ->affects_active_observers()); 2092 ->affects_active_observers());
2056 2093
2057 controller_impl->UpdateState(true, events.get()); 2094 controller_impl->UpdateState(true, events.get());
2058 2095
2059 // Since the animation has been activated, it should have reached the 2096 // Since the animation has been activated, it should have reached the
2060 // Running state. 2097 // Running state.
2061 EXPECT_EQ( 2098 EXPECT_EQ(
2062 Animation::Running, 2099 Animation::Running,
2063 controller_impl->GetAnimation(group_id, Animation::Opacity)->run_state()); 2100 controller_impl->GetAnimation(group_id, Animation::Opacity)->run_state());
2064 2101
2065 controller_impl->Animate(kInitialTickTime + 0.5); 2102 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
2066 2103
2067 // Both observers should have been ticked. 2104 // Both observers should have been ticked.
2068 EXPECT_EQ(0.75f, pending_dummy_impl.opacity()); 2105 EXPECT_EQ(0.75f, pending_dummy_impl.opacity());
2069 EXPECT_EQ(0.75f, dummy_impl.opacity()); 2106 EXPECT_EQ(0.75f, dummy_impl.opacity());
2070 } 2107 }
2071 2108
2072 TEST(LayerAnimationControllerTest, PushedDeletedAnimationWaitsForActivation) { 2109 TEST(LayerAnimationControllerTest, PushedDeletedAnimationWaitsForActivation) {
2073 scoped_ptr<AnimationEventsVector> events( 2110 scoped_ptr<AnimationEventsVector> events(
2074 make_scoped_ptr(new AnimationEventsVector)); 2111 make_scoped_ptr(new AnimationEventsVector));
2075 FakeLayerAnimationValueObserver dummy_impl; 2112 FakeLayerAnimationValueObserver dummy_impl;
(...skipping 29 matching lines...) Expand all
2105 controller->RemoveAnimation( 2142 controller->RemoveAnimation(
2106 controller->GetAnimation(Animation::Opacity)->id()); 2143 controller->GetAnimation(Animation::Opacity)->id());
2107 controller->PushAnimationUpdatesTo(controller_impl.get()); 2144 controller->PushAnimationUpdatesTo(controller_impl.get());
2108 2145
2109 // The animation should no longer affect pending observers. 2146 // The animation should no longer affect pending observers.
2110 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity) 2147 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)
2111 ->affects_pending_observers()); 2148 ->affects_pending_observers());
2112 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity) 2149 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)
2113 ->affects_active_observers()); 2150 ->affects_active_observers());
2114 2151
2115 controller_impl->Animate(kInitialTickTime + 0.5); 2152 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
2116 controller_impl->UpdateState(true, events.get()); 2153 controller_impl->UpdateState(true, events.get());
2117 2154
2118 // Only the active observer should have been ticked. 2155 // Only the active observer should have been ticked.
2119 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); 2156 EXPECT_EQ(0.5f, pending_dummy_impl.opacity());
2120 EXPECT_EQ(0.75f, dummy_impl.opacity()); 2157 EXPECT_EQ(0.75f, dummy_impl.opacity());
2121 2158
2122 controller_impl->ActivateAnimations(); 2159 controller_impl->ActivateAnimations();
2123 2160
2124 // Activation should cause the animation to be deleted. 2161 // Activation should cause the animation to be deleted.
2125 EXPECT_FALSE(controller_impl->has_any_animation()); 2162 EXPECT_FALSE(controller_impl->has_any_animation());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2167 EXPECT_TRUE(controller_impl->GetAnimation(first_animation_group_id, 2204 EXPECT_TRUE(controller_impl->GetAnimation(first_animation_group_id,
2168 Animation::Opacity) 2205 Animation::Opacity)
2169 ->affects_active_observers()); 2206 ->affects_active_observers());
2170 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id, 2207 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id,
2171 Animation::Opacity) 2208 Animation::Opacity)
2172 ->affects_pending_observers()); 2209 ->affects_pending_observers());
2173 EXPECT_FALSE(controller_impl->GetAnimation(second_animation_group_id, 2210 EXPECT_FALSE(controller_impl->GetAnimation(second_animation_group_id,
2174 Animation::Opacity) 2211 Animation::Opacity)
2175 ->affects_active_observers()); 2212 ->affects_active_observers());
2176 2213
2177 controller_impl->Animate(kInitialTickTime + 0.5); 2214 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
2178 controller_impl->UpdateState(true, events.get()); 2215 controller_impl->UpdateState(true, events.get());
2179 2216
2180 // The original animation should still be running, and the new animation 2217 // The original animation should still be running, and the new animation
2181 // should be starting. 2218 // should be starting.
2182 EXPECT_EQ(Animation::Running, 2219 EXPECT_EQ(Animation::Running,
2183 controller_impl->GetAnimation(first_animation_group_id, 2220 controller_impl->GetAnimation(first_animation_group_id,
2184 Animation::Opacity)->run_state()); 2221 Animation::Opacity)->run_state());
2185 EXPECT_EQ(Animation::Starting, 2222 EXPECT_EQ(Animation::Starting,
2186 controller_impl->GetAnimation(second_animation_group_id, 2223 controller_impl->GetAnimation(second_animation_group_id,
2187 Animation::Opacity)->run_state()); 2224 Animation::Opacity)->run_state());
2188 2225
2189 // The active observer should have been ticked by the original animation, 2226 // The active observer should have been ticked by the original animation,
2190 // and the pending observer should have been ticked by the new animation. 2227 // and the pending observer should have been ticked by the new animation.
2191 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); 2228 EXPECT_EQ(1.f, pending_dummy_impl.opacity());
2192 EXPECT_EQ(0.5f, dummy_impl.opacity()); 2229 EXPECT_EQ(0.5f, dummy_impl.opacity());
2193 2230
2194 controller_impl->ActivateAnimations(); 2231 controller_impl->ActivateAnimations();
2195 2232
2196 // The original animation should have been deleted, and the new animation 2233 // The original animation should have been deleted, and the new animation
2197 // should now affect both observers. 2234 // should now affect both observers.
2198 EXPECT_FALSE(controller_impl->GetAnimation(first_animation_group_id, 2235 EXPECT_FALSE(controller_impl->GetAnimation(first_animation_group_id,
2199 Animation::Opacity)); 2236 Animation::Opacity));
2200 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id, 2237 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id,
2201 Animation::Opacity) 2238 Animation::Opacity)
2202 ->affects_pending_observers()); 2239 ->affects_pending_observers());
2203 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id, 2240 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id,
2204 Animation::Opacity) 2241 Animation::Opacity)
2205 ->affects_active_observers()); 2242 ->affects_active_observers());
2206 2243
2207 controller_impl->Animate(kInitialTickTime + 1.0); 2244 controller_impl->Animate(kInitialTickTime +
2245 TimeDelta::FromMilliseconds(1000));
2208 controller_impl->UpdateState(true, events.get()); 2246 controller_impl->UpdateState(true, events.get());
2209 2247
2210 // The new animation should be running, and the active observer should have 2248 // The new animation should be running, and the active observer should have
2211 // been ticked at the new animation's starting point. 2249 // been ticked at the new animation's starting point.
2212 EXPECT_EQ(Animation::Running, 2250 EXPECT_EQ(Animation::Running,
2213 controller_impl->GetAnimation(second_animation_group_id, 2251 controller_impl->GetAnimation(second_animation_group_id,
2214 Animation::Opacity)->run_state()); 2252 Animation::Opacity)->run_state());
2215 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); 2253 EXPECT_EQ(1.f, pending_dummy_impl.opacity());
2216 EXPECT_EQ(1.f, dummy_impl.opacity()); 2254 EXPECT_EQ(1.f, dummy_impl.opacity());
2217 } 2255 }
2218 2256
2219 } // namespace 2257 } // namespace
2220 } // namespace cc 2258 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/layer_animation_controller.cc ('k') | cc/animation/scroll_offset_animation_curve.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698