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

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

Powered by Google App Engine
This is Rietveld 408576698