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

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

Issue 1700653002: CC Animation: Expose TargetProperty enum to be aliased in Blink Platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 10 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/animation/target_property.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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/animation/animation.h" 9 #include "cc/animation/animation.h"
10 #include "cc/animation/animation_curve.h" 10 #include "cc/animation/animation_curve.h"
(...skipping 20 matching lines...) Expand all
31 base::Time::kMicrosecondsPerSecond); 31 base::Time::kMicrosecondsPerSecond);
32 } 32 }
33 33
34 // A LayerAnimationController cannot be ticked at 0.0, since an animation 34 // A LayerAnimationController cannot be ticked at 0.0, since an animation
35 // with start time 0.0 is treated as an animation whose start time has 35 // with start time 0.0 is treated as an animation whose start time has
36 // not yet been set. 36 // not yet been set.
37 const TimeTicks kInitialTickTime = TicksFromSecondsF(1.0); 37 const TimeTicks kInitialTickTime = TicksFromSecondsF(1.0);
38 38
39 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve, 39 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve,
40 int group_id, 40 int group_id,
41 Animation::TargetProperty property) { 41 TargetProperty::Type property) {
42 return Animation::Create(std::move(curve), 0, group_id, property); 42 return Animation::Create(std::move(curve), 0, group_id, property);
43 } 43 }
44 44
45 TEST(LayerAnimationControllerTest, SyncNewAnimation) { 45 TEST(LayerAnimationControllerTest, SyncNewAnimation) {
46 FakeLayerAnimationValueObserver dummy_impl; 46 FakeLayerAnimationValueObserver dummy_impl;
47 scoped_refptr<LayerAnimationController> controller_impl( 47 scoped_refptr<LayerAnimationController> controller_impl(
48 LayerAnimationController::Create(0)); 48 LayerAnimationController::Create(0));
49 controller_impl->AddValueObserver(&dummy_impl); 49 controller_impl->AddValueObserver(&dummy_impl);
50 FakeLayerAnimationValueObserver dummy; 50 FakeLayerAnimationValueObserver dummy;
51 scoped_refptr<LayerAnimationController> controller( 51 scoped_refptr<LayerAnimationController> controller(
52 LayerAnimationController::Create(0)); 52 LayerAnimationController::Create(0));
53 controller->AddValueObserver(&dummy); 53 controller->AddValueObserver(&dummy);
54 54
55 EXPECT_FALSE(controller_impl->GetAnimation(Animation::OPACITY)); 55 EXPECT_FALSE(controller_impl->GetAnimation(TargetProperty::OPACITY));
56 56
57 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); 57 EXPECT_FALSE(controller->needs_to_start_animations_for_testing());
58 EXPECT_FALSE(controller_impl->needs_to_start_animations_for_testing()); 58 EXPECT_FALSE(controller_impl->needs_to_start_animations_for_testing());
59 59
60 int animation_id = 60 int animation_id =
61 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); 61 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false);
62 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); 62 EXPECT_TRUE(controller->needs_to_start_animations_for_testing());
63 63
64 controller->PushAnimationUpdatesTo(controller_impl.get()); 64 controller->PushAnimationUpdatesTo(controller_impl.get());
65 EXPECT_TRUE(controller_impl->needs_to_start_animations_for_testing()); 65 EXPECT_TRUE(controller_impl->needs_to_start_animations_for_testing());
(...skipping 12 matching lines...) Expand all
78 LayerAnimationController::Create(0)); 78 LayerAnimationController::Create(0));
79 controller_impl->AddValueObserver(&dummy_impl); 79 controller_impl->AddValueObserver(&dummy_impl);
80 controller_impl->set_value_provider(&dummy_provider_impl); 80 controller_impl->set_value_provider(&dummy_provider_impl);
81 FakeLayerAnimationValueObserver dummy; 81 FakeLayerAnimationValueObserver dummy;
82 FakeLayerAnimationValueProvider dummy_provider; 82 FakeLayerAnimationValueProvider dummy_provider;
83 scoped_refptr<LayerAnimationController> controller( 83 scoped_refptr<LayerAnimationController> controller(
84 LayerAnimationController::Create(0)); 84 LayerAnimationController::Create(0));
85 controller->AddValueObserver(&dummy); 85 controller->AddValueObserver(&dummy);
86 controller->set_value_provider(&dummy_provider); 86 controller->set_value_provider(&dummy_provider);
87 87
88 EXPECT_FALSE(controller_impl->GetAnimation(Animation::SCROLL_OFFSET)); 88 EXPECT_FALSE(controller_impl->GetAnimation(TargetProperty::SCROLL_OFFSET));
89 89
90 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); 90 EXPECT_FALSE(controller->needs_to_start_animations_for_testing());
91 EXPECT_FALSE(controller_impl->needs_to_start_animations_for_testing()); 91 EXPECT_FALSE(controller_impl->needs_to_start_animations_for_testing());
92 92
93 gfx::ScrollOffset initial_value(100.f, 300.f); 93 gfx::ScrollOffset initial_value(100.f, 300.f);
94 gfx::ScrollOffset provider_initial_value(150.f, 300.f); 94 gfx::ScrollOffset provider_initial_value(150.f, 300.f);
95 gfx::ScrollOffset target_value(300.f, 200.f); 95 gfx::ScrollOffset target_value(300.f, 200.f);
96 96
97 dummy_provider_impl.set_scroll_offset(provider_initial_value); 97 dummy_provider_impl.set_scroll_offset(provider_initial_value);
98 98
99 // Animation with initial value set. 99 // Animation with initial value set.
100 scoped_ptr<ScrollOffsetAnimationCurve> curve_fixed( 100 scoped_ptr<ScrollOffsetAnimationCurve> curve_fixed(
101 ScrollOffsetAnimationCurve::Create(target_value, 101 ScrollOffsetAnimationCurve::Create(target_value,
102 EaseInOutTimingFunction::Create())); 102 EaseInOutTimingFunction::Create()));
103 curve_fixed->SetInitialValue(initial_value); 103 curve_fixed->SetInitialValue(initial_value);
104 scoped_ptr<Animation> animation_fixed( 104 scoped_ptr<Animation> animation_fixed(
105 Animation::Create(std::move(curve_fixed), 1 /* animation_id */, 0, 105 Animation::Create(std::move(curve_fixed), 1 /* animation_id */, 0,
106 Animation::SCROLL_OFFSET)); 106 TargetProperty::SCROLL_OFFSET));
107 controller->AddAnimation(std::move(animation_fixed)); 107 controller->AddAnimation(std::move(animation_fixed));
108 controller->PushAnimationUpdatesTo(controller_impl.get()); 108 controller->PushAnimationUpdatesTo(controller_impl.get());
109 EXPECT_VECTOR2DF_EQ(initial_value, controller_impl->GetAnimationById(1) 109 EXPECT_VECTOR2DF_EQ(initial_value, controller_impl->GetAnimationById(1)
110 ->curve() 110 ->curve()
111 ->ToScrollOffsetAnimationCurve() 111 ->ToScrollOffsetAnimationCurve()
112 ->GetValue(base::TimeDelta())); 112 ->GetValue(base::TimeDelta()));
113 113
114 // Animation without initial value set. 114 // Animation without initial value set.
115 scoped_ptr<ScrollOffsetAnimationCurve> curve( 115 scoped_ptr<ScrollOffsetAnimationCurve> curve(
116 ScrollOffsetAnimationCurve::Create(target_value, 116 ScrollOffsetAnimationCurve::Create(target_value,
117 EaseInOutTimingFunction::Create())); 117 EaseInOutTimingFunction::Create()));
118 scoped_ptr<Animation> animation(Animation::Create( 118 scoped_ptr<Animation> animation(
119 std::move(curve), 2 /* animation id */, 0, Animation::SCROLL_OFFSET)); 119 Animation::Create(std::move(curve), 2 /* animation id */, 0,
120 TargetProperty::SCROLL_OFFSET));
120 controller->AddAnimation(std::move(animation)); 121 controller->AddAnimation(std::move(animation));
121 controller->PushAnimationUpdatesTo(controller_impl.get()); 122 controller->PushAnimationUpdatesTo(controller_impl.get());
122 EXPECT_VECTOR2DF_EQ(provider_initial_value, 123 EXPECT_VECTOR2DF_EQ(provider_initial_value,
123 controller_impl->GetAnimationById(2) 124 controller_impl->GetAnimationById(2)
124 ->curve() 125 ->curve()
125 ->ToScrollOffsetAnimationCurve() 126 ->ToScrollOffsetAnimationCurve()
126 ->GetValue(base::TimeDelta())); 127 ->GetValue(base::TimeDelta()));
127 } 128 }
128 129
129 // If an animation is started on the impl thread before it is ticked on the main 130 // If an animation is started on the impl thread before it is ticked on the main
130 // thread, we must be sure to respect the synchronized start time. 131 // thread, we must be sure to respect the synchronized start time.
131 TEST(LayerAnimationControllerTest, DoNotClobberStartTimes) { 132 TEST(LayerAnimationControllerTest, DoNotClobberStartTimes) {
132 FakeLayerAnimationValueObserver dummy_impl; 133 FakeLayerAnimationValueObserver dummy_impl;
133 scoped_refptr<LayerAnimationController> controller_impl( 134 scoped_refptr<LayerAnimationController> controller_impl(
134 LayerAnimationController::Create(0)); 135 LayerAnimationController::Create(0));
135 controller_impl->AddValueObserver(&dummy_impl); 136 controller_impl->AddValueObserver(&dummy_impl);
136 FakeLayerAnimationValueObserver dummy; 137 FakeLayerAnimationValueObserver dummy;
137 scoped_refptr<LayerAnimationController> controller( 138 scoped_refptr<LayerAnimationController> controller(
138 LayerAnimationController::Create(0)); 139 LayerAnimationController::Create(0));
139 controller->AddValueObserver(&dummy); 140 controller->AddValueObserver(&dummy);
140 141
141 EXPECT_FALSE(controller_impl->GetAnimation(Animation::OPACITY)); 142 EXPECT_FALSE(controller_impl->GetAnimation(TargetProperty::OPACITY));
142 143
143 int animation_id = 144 int animation_id =
144 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); 145 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false);
145 146
146 controller->PushAnimationUpdatesTo(controller_impl.get()); 147 controller->PushAnimationUpdatesTo(controller_impl.get());
147 controller_impl->ActivateAnimations(); 148 controller_impl->ActivateAnimations();
148 149
149 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); 150 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id));
150 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, 151 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY,
151 controller_impl->GetAnimationById(animation_id)->run_state()); 152 controller_impl->GetAnimationById(animation_id)->run_state());
(...skipping 22 matching lines...) Expand all
174 controller_impl->AddValueObserver(&dummy_impl); 175 controller_impl->AddValueObserver(&dummy_impl);
175 FakeLayerAnimationValueObserver dummy; 176 FakeLayerAnimationValueObserver dummy;
176 scoped_refptr<LayerAnimationController> controller( 177 scoped_refptr<LayerAnimationController> controller(
177 LayerAnimationController::Create(0)); 178 LayerAnimationController::Create(0));
178 controller->AddValueObserver(&dummy); 179 controller->AddValueObserver(&dummy);
179 180
180 int animation_id = 181 int animation_id =
181 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); 182 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false);
182 183
183 const TimeTicks start_time = TicksFromSecondsF(123); 184 const TimeTicks start_time = TicksFromSecondsF(123);
184 controller->GetAnimation(Animation::OPACITY)->set_start_time(start_time); 185 controller->GetAnimation(TargetProperty::OPACITY)->set_start_time(start_time);
185 186
186 controller->PushAnimationUpdatesTo(controller_impl.get()); 187 controller->PushAnimationUpdatesTo(controller_impl.get());
187 controller_impl->ActivateAnimations(); 188 controller_impl->ActivateAnimations();
188 189
189 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); 190 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id));
190 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, 191 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY,
191 controller_impl->GetAnimationById(animation_id)->run_state()); 192 controller_impl->GetAnimationById(animation_id)->run_state());
192 193
193 AnimationEvents events; 194 AnimationEvents events;
194 controller_impl->Animate(kInitialTickTime); 195 controller_impl->Animate(kInitialTickTime);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 EXPECT_EQ(1u, 258 EXPECT_EQ(1u,
258 registrar_impl->active_animation_controllers_for_testing().size()); 259 registrar_impl->active_animation_controllers_for_testing().size());
259 260
260 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); 261 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
261 controller->UpdateState(true, nullptr); 262 controller->UpdateState(true, nullptr);
262 EXPECT_EQ(1u, registrar->active_animation_controllers_for_testing().size()); 263 EXPECT_EQ(1u, registrar->active_animation_controllers_for_testing().size());
263 264
264 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 265 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
265 controller->UpdateState(true, nullptr); 266 controller->UpdateState(true, nullptr);
266 EXPECT_EQ(Animation::FINISHED, 267 EXPECT_EQ(Animation::FINISHED,
267 controller->GetAnimation(Animation::OPACITY)->run_state()); 268 controller->GetAnimation(TargetProperty::OPACITY)->run_state());
268 EXPECT_EQ(1u, registrar->active_animation_controllers_for_testing().size()); 269 EXPECT_EQ(1u, registrar->active_animation_controllers_for_testing().size());
269 270
270 events.reset(new AnimationEvents); 271 events.reset(new AnimationEvents);
271 controller_impl->Animate(kInitialTickTime + 272 controller_impl->Animate(kInitialTickTime +
272 TimeDelta::FromMilliseconds(1500)); 273 TimeDelta::FromMilliseconds(1500));
273 controller_impl->UpdateState(true, events.get()); 274 controller_impl->UpdateState(true, events.get());
274 275
275 EXPECT_EQ(Animation::WAITING_FOR_DELETION, 276 EXPECT_EQ(
276 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); 277 Animation::WAITING_FOR_DELETION,
278 controller_impl->GetAnimation(TargetProperty::OPACITY)->run_state());
277 // The impl thread controller should have de-activated. 279 // The impl thread controller should have de-activated.
278 EXPECT_EQ(0u, 280 EXPECT_EQ(0u,
279 registrar_impl->active_animation_controllers_for_testing().size()); 281 registrar_impl->active_animation_controllers_for_testing().size());
280 282
281 EXPECT_EQ(1u, events->events_.size()); 283 EXPECT_EQ(1u, events->events_.size());
282 controller->NotifyAnimationFinished(events->events_[0]); 284 controller->NotifyAnimationFinished(events->events_[0]);
283 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); 285 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500));
284 controller->UpdateState(true, nullptr); 286 controller->UpdateState(true, nullptr);
285 287
286 EXPECT_EQ(Animation::WAITING_FOR_DELETION, 288 EXPECT_EQ(Animation::WAITING_FOR_DELETION,
287 controller->GetAnimation(Animation::OPACITY)->run_state()); 289 controller->GetAnimation(TargetProperty::OPACITY)->run_state());
288 // The main thread controller should have de-activated. 290 // The main thread controller should have de-activated.
289 EXPECT_EQ(0u, registrar->active_animation_controllers_for_testing().size()); 291 EXPECT_EQ(0u, registrar->active_animation_controllers_for_testing().size());
290 292
291 controller->PushAnimationUpdatesTo(controller_impl.get()); 293 controller->PushAnimationUpdatesTo(controller_impl.get());
292 controller_impl->ActivateAnimations(); 294 controller_impl->ActivateAnimations();
293 EXPECT_FALSE(controller->has_any_animation()); 295 EXPECT_FALSE(controller->has_any_animation());
294 EXPECT_FALSE(controller_impl->has_any_animation()); 296 EXPECT_FALSE(controller_impl->has_any_animation());
295 EXPECT_EQ(0u, registrar->active_animation_controllers_for_testing().size()); 297 EXPECT_EQ(0u, registrar->active_animation_controllers_for_testing().size());
296 EXPECT_EQ(0u, 298 EXPECT_EQ(0u,
297 registrar_impl->active_animation_controllers_for_testing().size()); 299 registrar_impl->active_animation_controllers_for_testing().size());
298 300
299 controller->SetAnimationRegistrar(nullptr); 301 controller->SetAnimationRegistrar(nullptr);
300 controller_impl->SetAnimationRegistrar(nullptr); 302 controller_impl->SetAnimationRegistrar(nullptr);
301 } 303 }
302 304
303 TEST(LayerAnimationControllerTest, SyncPause) { 305 TEST(LayerAnimationControllerTest, SyncPause) {
304 FakeLayerAnimationValueObserver dummy_impl; 306 FakeLayerAnimationValueObserver dummy_impl;
305 scoped_refptr<LayerAnimationController> controller_impl( 307 scoped_refptr<LayerAnimationController> controller_impl(
306 LayerAnimationController::Create(0)); 308 LayerAnimationController::Create(0));
307 controller_impl->AddValueObserver(&dummy_impl); 309 controller_impl->AddValueObserver(&dummy_impl);
308 FakeLayerAnimationValueObserver dummy; 310 FakeLayerAnimationValueObserver dummy;
309 scoped_refptr<LayerAnimationController> controller( 311 scoped_refptr<LayerAnimationController> controller(
310 LayerAnimationController::Create(0)); 312 LayerAnimationController::Create(0));
311 controller->AddValueObserver(&dummy); 313 controller->AddValueObserver(&dummy);
312 314
313 EXPECT_FALSE(controller_impl->GetAnimation(Animation::OPACITY)); 315 EXPECT_FALSE(controller_impl->GetAnimation(TargetProperty::OPACITY));
314 316
315 // Two steps, three ranges: [0-1) -> 0.2, [1-2) -> 0.3, [2-3] -> 0.4. 317 // Two steps, three ranges: [0-1) -> 0.2, [1-2) -> 0.3, [2-3] -> 0.4.
316 const double duration = 3.0; 318 const double duration = 3.0;
317 const int animation_id = 319 const int animation_id =
318 AddOpacityStepsToController(controller.get(), duration, 0.2f, 0.4f, 2); 320 AddOpacityStepsToController(controller.get(), duration, 0.2f, 0.4f, 2);
319 321
320 // Set start offset to be at the beginning of the second range. 322 // Set start offset to be at the beginning of the second range.
321 controller->GetAnimationById(animation_id) 323 controller->GetAnimationById(animation_id)
322 ->set_time_offset(TimeDelta::FromSecondsD(1.01)); 324 ->set_time_offset(TimeDelta::FromSecondsD(1.01));
323 325
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 FakeLayerAnimationValueObserver dummy_impl; 382 FakeLayerAnimationValueObserver dummy_impl;
381 scoped_refptr<LayerAnimationController> controller_impl( 383 scoped_refptr<LayerAnimationController> controller_impl(
382 LayerAnimationController::Create(0)); 384 LayerAnimationController::Create(0));
383 controller_impl->AddValueObserver(&dummy_impl); 385 controller_impl->AddValueObserver(&dummy_impl);
384 FakeLayerAnimationValueObserver dummy; 386 FakeLayerAnimationValueObserver dummy;
385 scoped_refptr<LayerAnimationController> controller( 387 scoped_refptr<LayerAnimationController> controller(
386 LayerAnimationController::Create(0)); 388 LayerAnimationController::Create(0));
387 controller->AddValueObserver(&dummy); 389 controller->AddValueObserver(&dummy);
388 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 390 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
389 391
390 EXPECT_FALSE(controller_impl->GetAnimation(Animation::OPACITY)); 392 EXPECT_FALSE(controller_impl->GetAnimation(TargetProperty::OPACITY));
391 393
392 int animation_id = 394 int animation_id =
393 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); 395 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false);
394 396
395 controller->PushAnimationUpdatesTo(controller_impl.get()); 397 controller->PushAnimationUpdatesTo(controller_impl.get());
396 controller_impl->ActivateAnimations(); 398 controller_impl->ActivateAnimations();
397 399
398 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); 400 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id));
399 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, 401 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY,
400 controller_impl->GetAnimationById(animation_id)->run_state()); 402 controller_impl->GetAnimationById(animation_id)->run_state());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 TimeDelta::FromMilliseconds(2000)); 466 TimeDelta::FromMilliseconds(2000));
465 controller_impl->UpdateState(true, events.get()); 467 controller_impl->UpdateState(true, events.get());
466 468
467 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); 469 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion());
468 470
469 // There should be a FINISHED event for the animation. 471 // There should be a FINISHED event for the animation.
470 EXPECT_EQ(1u, events->events_.size()); 472 EXPECT_EQ(1u, events->events_.size());
471 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); 473 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type);
472 474
473 // Neither controller should have deleted the animation yet. 475 // Neither controller should have deleted the animation yet.
474 EXPECT_TRUE(controller->GetAnimation(Animation::OPACITY)); 476 EXPECT_TRUE(controller->GetAnimation(TargetProperty::OPACITY));
475 EXPECT_TRUE(controller_impl->GetAnimation(Animation::OPACITY)); 477 EXPECT_TRUE(controller_impl->GetAnimation(TargetProperty::OPACITY));
476 478
477 controller->NotifyAnimationFinished(events->events_[0]); 479 controller->NotifyAnimationFinished(events->events_[0]);
478 480
479 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); 481 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
480 controller->UpdateState(true, nullptr); 482 controller->UpdateState(true, nullptr);
481 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); 483 EXPECT_TRUE(dummy.animation_waiting_for_deletion());
482 484
483 controller->PushAnimationUpdatesTo(controller_impl.get()); 485 controller->PushAnimationUpdatesTo(controller_impl.get());
484 486
485 // Both controllers should now have deleted the animation. The impl controller 487 // Both controllers should now have deleted the animation. The impl controller
(...skipping 18 matching lines...) Expand all
504 506
505 TEST(LayerAnimationControllerTest, TrivialTransition) { 507 TEST(LayerAnimationControllerTest, TrivialTransition) {
506 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 508 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
507 FakeLayerAnimationValueObserver dummy; 509 FakeLayerAnimationValueObserver dummy;
508 scoped_refptr<LayerAnimationController> controller( 510 scoped_refptr<LayerAnimationController> controller(
509 LayerAnimationController::Create(0)); 511 LayerAnimationController::Create(0));
510 controller->AddValueObserver(&dummy); 512 controller->AddValueObserver(&dummy);
511 513
512 scoped_ptr<Animation> to_add(CreateAnimation( 514 scoped_ptr<Animation> to_add(CreateAnimation(
513 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, 515 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1,
514 Animation::OPACITY)); 516 TargetProperty::OPACITY));
515 517
516 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); 518 EXPECT_FALSE(controller->needs_to_start_animations_for_testing());
517 controller->AddAnimation(std::move(to_add)); 519 controller->AddAnimation(std::move(to_add));
518 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); 520 EXPECT_TRUE(controller->needs_to_start_animations_for_testing());
519 controller->Animate(kInitialTickTime); 521 controller->Animate(kInitialTickTime);
520 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); 522 EXPECT_FALSE(controller->needs_to_start_animations_for_testing());
521 controller->UpdateState(true, events.get()); 523 controller->UpdateState(true, events.get());
522 EXPECT_TRUE(controller->HasActiveAnimation()); 524 EXPECT_TRUE(controller->HasActiveAnimation());
523 EXPECT_EQ(0.f, dummy.opacity()); 525 EXPECT_EQ(0.f, dummy.opacity());
524 // A non-impl-only animation should not generate property updates. 526 // A non-impl-only animation should not generate property updates.
525 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 527 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
526 EXPECT_FALSE(event); 528 EXPECT_FALSE(event);
527 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 529 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
528 controller->UpdateState(true, events.get()); 530 controller->UpdateState(true, events.get());
529 EXPECT_EQ(1.f, dummy.opacity()); 531 EXPECT_EQ(1.f, dummy.opacity());
530 EXPECT_FALSE(controller->HasActiveAnimation()); 532 EXPECT_FALSE(controller->HasActiveAnimation());
531 event = GetMostRecentPropertyUpdateEvent(events.get()); 533 event = GetMostRecentPropertyUpdateEvent(events.get());
532 EXPECT_FALSE(event); 534 EXPECT_FALSE(event);
533 } 535 }
534 536
535 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { 537 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) {
536 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 538 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
537 FakeLayerAnimationValueObserver dummy_impl; 539 FakeLayerAnimationValueObserver dummy_impl;
538 scoped_refptr<LayerAnimationController> controller_impl( 540 scoped_refptr<LayerAnimationController> controller_impl(
539 LayerAnimationController::Create(0)); 541 LayerAnimationController::Create(0));
540 controller_impl->AddValueObserver(&dummy_impl); 542 controller_impl->AddValueObserver(&dummy_impl);
541 543
542 scoped_ptr<Animation> to_add(CreateAnimation( 544 scoped_ptr<Animation> to_add(CreateAnimation(
543 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, 545 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1,
544 Animation::OPACITY)); 546 TargetProperty::OPACITY));
545 to_add->set_is_impl_only(true); 547 to_add->set_is_impl_only(true);
546 548
547 controller_impl->AddAnimation(std::move(to_add)); 549 controller_impl->AddAnimation(std::move(to_add));
548 controller_impl->Animate(kInitialTickTime); 550 controller_impl->Animate(kInitialTickTime);
549 controller_impl->UpdateState(true, events.get()); 551 controller_impl->UpdateState(true, events.get());
550 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 552 EXPECT_TRUE(controller_impl->HasActiveAnimation());
551 EXPECT_EQ(0.f, dummy_impl.opacity()); 553 EXPECT_EQ(0.f, dummy_impl.opacity());
552 EXPECT_EQ(1u, events->events_.size()); 554 EXPECT_EQ(1u, events->events_.size());
553 const AnimationEvent* start_opacity_event = 555 const AnimationEvent* start_opacity_event =
554 GetMostRecentPropertyUpdateEvent(events.get()); 556 GetMostRecentPropertyUpdateEvent(events.get());
(...skipping 27 matching lines...) Expand all
582 584
583 // Create simple TRANSFORM animation. 585 // Create simple TRANSFORM animation.
584 TransformOperations operations; 586 TransformOperations operations;
585 curve->AddKeyframe( 587 curve->AddKeyframe(
586 TransformKeyframe::Create(base::TimeDelta(), operations, nullptr)); 588 TransformKeyframe::Create(base::TimeDelta(), operations, nullptr));
587 operations.AppendTranslate(delta_x, delta_y, 0); 589 operations.AppendTranslate(delta_x, delta_y, 0);
588 curve->AddKeyframe(TransformKeyframe::Create( 590 curve->AddKeyframe(TransformKeyframe::Create(
589 base::TimeDelta::FromSecondsD(1.0), operations, nullptr)); 591 base::TimeDelta::FromSecondsD(1.0), operations, nullptr));
590 592
591 scoped_ptr<Animation> animation( 593 scoped_ptr<Animation> animation(
592 Animation::Create(std::move(curve), 1, 0, Animation::TRANSFORM)); 594 Animation::Create(std::move(curve), 1, 0, TargetProperty::TRANSFORM));
593 animation->set_is_impl_only(true); 595 animation->set_is_impl_only(true);
594 controller_impl->AddAnimation(std::move(animation)); 596 controller_impl->AddAnimation(std::move(animation));
595 597
596 // Run animation. 598 // Run animation.
597 controller_impl->Animate(kInitialTickTime); 599 controller_impl->Animate(kInitialTickTime);
598 controller_impl->UpdateState(true, events.get()); 600 controller_impl->UpdateState(true, events.get());
599 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 601 EXPECT_TRUE(controller_impl->HasActiveAnimation());
600 EXPECT_EQ(gfx::Transform(), dummy_impl.transform()); 602 EXPECT_EQ(gfx::Transform(), dummy_impl.transform());
601 EXPECT_EQ(1u, events->events_.size()); 603 EXPECT_EQ(1u, events->events_.size());
602 const AnimationEvent* start_transform_event = 604 const AnimationEvent* start_transform_event =
(...skipping 30 matching lines...) Expand all
633 FilterOperations start_filters; 635 FilterOperations start_filters;
634 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); 636 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f));
635 curve->AddKeyframe( 637 curve->AddKeyframe(
636 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); 638 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr));
637 FilterOperations end_filters; 639 FilterOperations end_filters;
638 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); 640 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f));
639 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 641 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0),
640 end_filters, nullptr)); 642 end_filters, nullptr));
641 643
642 scoped_ptr<Animation> animation( 644 scoped_ptr<Animation> animation(
643 Animation::Create(std::move(curve), 1, 0, Animation::FILTER)); 645 Animation::Create(std::move(curve), 1, 0, TargetProperty::FILTER));
644 controller->AddAnimation(std::move(animation)); 646 controller->AddAnimation(std::move(animation));
645 647
646 controller->Animate(kInitialTickTime); 648 controller->Animate(kInitialTickTime);
647 controller->UpdateState(true, events.get()); 649 controller->UpdateState(true, events.get());
648 EXPECT_TRUE(controller->HasActiveAnimation()); 650 EXPECT_TRUE(controller->HasActiveAnimation());
649 EXPECT_EQ(start_filters, dummy.filters()); 651 EXPECT_EQ(start_filters, dummy.filters());
650 // A non-impl-only animation should not generate property updates. 652 // A non-impl-only animation should not generate property updates.
651 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 653 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
652 EXPECT_FALSE(event); 654 EXPECT_FALSE(event);
653 655
(...skipping 27 matching lines...) Expand all
681 FilterOperations start_filters; 683 FilterOperations start_filters;
682 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); 684 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f));
683 curve->AddKeyframe( 685 curve->AddKeyframe(
684 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); 686 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr));
685 FilterOperations end_filters; 687 FilterOperations end_filters;
686 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); 688 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f));
687 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 689 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0),
688 end_filters, nullptr)); 690 end_filters, nullptr));
689 691
690 scoped_ptr<Animation> animation( 692 scoped_ptr<Animation> animation(
691 Animation::Create(std::move(curve), 1, 0, Animation::FILTER)); 693 Animation::Create(std::move(curve), 1, 0, TargetProperty::FILTER));
692 animation->set_is_impl_only(true); 694 animation->set_is_impl_only(true);
693 controller_impl->AddAnimation(std::move(animation)); 695 controller_impl->AddAnimation(std::move(animation));
694 696
695 // Run animation. 697 // Run animation.
696 controller_impl->Animate(kInitialTickTime); 698 controller_impl->Animate(kInitialTickTime);
697 controller_impl->UpdateState(true, events.get()); 699 controller_impl->UpdateState(true, events.get());
698 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 700 EXPECT_TRUE(controller_impl->HasActiveAnimation());
699 EXPECT_EQ(start_filters, dummy_impl.filters()); 701 EXPECT_EQ(start_filters, dummy_impl.filters());
700 EXPECT_EQ(1u, events->events_.size()); 702 EXPECT_EQ(1u, events->events_.size());
701 const AnimationEvent* start_filter_event = 703 const AnimationEvent* start_filter_event =
(...skipping 30 matching lines...) Expand all
732 controller->AddValueObserver(&dummy); 734 controller->AddValueObserver(&dummy);
733 controller->set_value_provider(&dummy_provider); 735 controller->set_value_provider(&dummy_provider);
734 736
735 gfx::ScrollOffset initial_value(100.f, 300.f); 737 gfx::ScrollOffset initial_value(100.f, 300.f);
736 gfx::ScrollOffset target_value(300.f, 200.f); 738 gfx::ScrollOffset target_value(300.f, 200.f);
737 scoped_ptr<ScrollOffsetAnimationCurve> curve( 739 scoped_ptr<ScrollOffsetAnimationCurve> curve(
738 ScrollOffsetAnimationCurve::Create(target_value, 740 ScrollOffsetAnimationCurve::Create(target_value,
739 EaseInOutTimingFunction::Create())); 741 EaseInOutTimingFunction::Create()));
740 742
741 scoped_ptr<Animation> animation( 743 scoped_ptr<Animation> animation(
742 Animation::Create(std::move(curve), 1, 0, Animation::SCROLL_OFFSET)); 744 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET));
743 animation->set_needs_synchronized_start_time(true); 745 animation->set_needs_synchronized_start_time(true);
744 controller->AddAnimation(std::move(animation)); 746 controller->AddAnimation(std::move(animation));
745 747
746 dummy_provider_impl.set_scroll_offset(initial_value); 748 dummy_provider_impl.set_scroll_offset(initial_value);
747 controller->PushAnimationUpdatesTo(controller_impl.get()); 749 controller->PushAnimationUpdatesTo(controller_impl.get());
748 controller_impl->ActivateAnimations(); 750 controller_impl->ActivateAnimations();
749 EXPECT_TRUE(controller_impl->GetAnimation(Animation::SCROLL_OFFSET)); 751 EXPECT_TRUE(controller_impl->GetAnimation(TargetProperty::SCROLL_OFFSET));
750 TimeDelta duration = controller_impl->GetAnimation(Animation::SCROLL_OFFSET) 752 TimeDelta duration =
751 ->curve() 753 controller_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)
752 ->Duration(); 754 ->curve()
753 EXPECT_EQ( 755 ->Duration();
754 duration, 756 EXPECT_EQ(duration, controller->GetAnimation(TargetProperty::SCROLL_OFFSET)
755 controller->GetAnimation(Animation::SCROLL_OFFSET)->curve()->Duration()); 757 ->curve()
758 ->Duration());
756 759
757 controller->Animate(kInitialTickTime); 760 controller->Animate(kInitialTickTime);
758 controller->UpdateState(true, nullptr); 761 controller->UpdateState(true, nullptr);
759 EXPECT_TRUE(controller->HasActiveAnimation()); 762 EXPECT_TRUE(controller->HasActiveAnimation());
760 EXPECT_EQ(initial_value, dummy.scroll_offset()); 763 EXPECT_EQ(initial_value, dummy.scroll_offset());
761 764
762 controller_impl->Animate(kInitialTickTime); 765 controller_impl->Animate(kInitialTickTime);
763 controller_impl->UpdateState(true, events.get()); 766 controller_impl->UpdateState(true, events.get());
764 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 767 EXPECT_TRUE(controller_impl->HasActiveAnimation());
765 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); 768 EXPECT_EQ(initial_value, dummy_impl.scroll_offset());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 controller->AddValueObserver(&dummy); 812 controller->AddValueObserver(&dummy);
810 controller->set_value_provider(&dummy_provider); 813 controller->set_value_provider(&dummy_provider);
811 814
812 gfx::ScrollOffset initial_value(500.f, 100.f); 815 gfx::ScrollOffset initial_value(500.f, 100.f);
813 gfx::ScrollOffset target_value(300.f, 200.f); 816 gfx::ScrollOffset target_value(300.f, 200.f);
814 scoped_ptr<ScrollOffsetAnimationCurve> curve( 817 scoped_ptr<ScrollOffsetAnimationCurve> curve(
815 ScrollOffsetAnimationCurve::Create(target_value, 818 ScrollOffsetAnimationCurve::Create(target_value,
816 EaseInOutTimingFunction::Create())); 819 EaseInOutTimingFunction::Create()));
817 820
818 scoped_ptr<Animation> animation( 821 scoped_ptr<Animation> animation(
819 Animation::Create(std::move(curve), 1, 0, Animation::SCROLL_OFFSET)); 822 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET));
820 animation->set_needs_synchronized_start_time(true); 823 animation->set_needs_synchronized_start_time(true);
821 controller->AddAnimation(std::move(animation)); 824 controller->AddAnimation(std::move(animation));
822 825
823 dummy_provider.set_scroll_offset(initial_value); 826 dummy_provider.set_scroll_offset(initial_value);
824 controller->PushAnimationUpdatesTo(controller_impl.get()); 827 controller->PushAnimationUpdatesTo(controller_impl.get());
825 controller_impl->ActivateAnimations(); 828 controller_impl->ActivateAnimations();
826 EXPECT_TRUE(controller_impl->GetAnimation(Animation::SCROLL_OFFSET)); 829 EXPECT_TRUE(controller_impl->GetAnimation(TargetProperty::SCROLL_OFFSET));
827 TimeDelta duration = controller_impl->GetAnimation(Animation::SCROLL_OFFSET) 830 TimeDelta duration =
828 ->curve() 831 controller_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)
829 ->Duration(); 832 ->curve()
830 EXPECT_EQ( 833 ->Duration();
831 duration, 834 EXPECT_EQ(duration, controller->GetAnimation(TargetProperty::SCROLL_OFFSET)
832 controller->GetAnimation(Animation::SCROLL_OFFSET)->curve()->Duration()); 835 ->curve()
836 ->Duration());
833 837
834 controller->Animate(kInitialTickTime); 838 controller->Animate(kInitialTickTime);
835 controller->UpdateState(true, nullptr); 839 controller->UpdateState(true, nullptr);
836 EXPECT_TRUE(controller->HasActiveAnimation()); 840 EXPECT_TRUE(controller->HasActiveAnimation());
837 EXPECT_EQ(initial_value, dummy.scroll_offset()); 841 EXPECT_EQ(initial_value, dummy.scroll_offset());
838 842
839 controller_impl->Animate(kInitialTickTime); 843 controller_impl->Animate(kInitialTickTime);
840 controller_impl->UpdateState(true, events.get()); 844 controller_impl->UpdateState(true, events.get());
841 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 845 EXPECT_TRUE(controller_impl->HasActiveAnimation());
842 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); 846 EXPECT_EQ(initial_value, dummy_impl.scroll_offset());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 883
880 gfx::ScrollOffset initial_value(100.f, 300.f); 884 gfx::ScrollOffset initial_value(100.f, 300.f);
881 gfx::ScrollOffset target_value(300.f, 200.f); 885 gfx::ScrollOffset target_value(300.f, 200.f);
882 scoped_ptr<ScrollOffsetAnimationCurve> curve( 886 scoped_ptr<ScrollOffsetAnimationCurve> curve(
883 ScrollOffsetAnimationCurve::Create(target_value, 887 ScrollOffsetAnimationCurve::Create(target_value,
884 EaseInOutTimingFunction::Create())); 888 EaseInOutTimingFunction::Create()));
885 curve->SetInitialValue(initial_value); 889 curve->SetInitialValue(initial_value);
886 double duration_in_seconds = curve->Duration().InSecondsF(); 890 double duration_in_seconds = curve->Duration().InSecondsF();
887 891
888 scoped_ptr<Animation> animation( 892 scoped_ptr<Animation> animation(
889 Animation::Create(std::move(curve), 1, 0, Animation::SCROLL_OFFSET)); 893 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET));
890 animation->set_is_impl_only(true); 894 animation->set_is_impl_only(true);
891 controller_impl->AddAnimation(std::move(animation)); 895 controller_impl->AddAnimation(std::move(animation));
892 896
893 controller_impl->Animate(kInitialTickTime); 897 controller_impl->Animate(kInitialTickTime);
894 controller_impl->UpdateState(true, events.get()); 898 controller_impl->UpdateState(true, events.get());
895 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 899 EXPECT_TRUE(controller_impl->HasActiveAnimation());
896 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); 900 EXPECT_EQ(initial_value, dummy_impl.scroll_offset());
897 // Scroll offset animations should not generate property updates. 901 // Scroll offset animations should not generate property updates.
898 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 902 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
899 EXPECT_FALSE(event); 903 EXPECT_FALSE(event);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 controller->set_value_provider(&dummy_provider); 936 controller->set_value_provider(&dummy_provider);
933 937
934 // First test the 1-argument version of RemoveAnimation. 938 // First test the 1-argument version of RemoveAnimation.
935 gfx::ScrollOffset target_value(300.f, 200.f); 939 gfx::ScrollOffset target_value(300.f, 200.f);
936 scoped_ptr<ScrollOffsetAnimationCurve> curve( 940 scoped_ptr<ScrollOffsetAnimationCurve> curve(
937 ScrollOffsetAnimationCurve::Create(target_value, 941 ScrollOffsetAnimationCurve::Create(target_value,
938 EaseInOutTimingFunction::Create())); 942 EaseInOutTimingFunction::Create()));
939 943
940 int animation_id = 1; 944 int animation_id = 1;
941 scoped_ptr<Animation> animation(Animation::Create( 945 scoped_ptr<Animation> animation(Animation::Create(
942 std::move(curve), animation_id, 0, Animation::SCROLL_OFFSET)); 946 std::move(curve), animation_id, 0, TargetProperty::SCROLL_OFFSET));
943 animation->set_needs_synchronized_start_time(true); 947 animation->set_needs_synchronized_start_time(true);
944 controller->AddAnimation(std::move(animation)); 948 controller->AddAnimation(std::move(animation));
945 controller->PushAnimationUpdatesTo(controller_impl.get()); 949 controller->PushAnimationUpdatesTo(controller_impl.get());
946 controller_impl->ActivateAnimations(); 950 controller_impl->ActivateAnimations();
947 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); 951 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted());
948 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); 952 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted());
949 953
950 controller->RemoveAnimation(animation_id); 954 controller->RemoveAnimation(animation_id);
951 EXPECT_TRUE(controller->scroll_offset_animation_was_interrupted()); 955 EXPECT_TRUE(controller->scroll_offset_animation_was_interrupted());
952 956
953 controller->PushAnimationUpdatesTo(controller_impl.get()); 957 controller->PushAnimationUpdatesTo(controller_impl.get());
954 EXPECT_TRUE(controller_impl->scroll_offset_animation_was_interrupted()); 958 EXPECT_TRUE(controller_impl->scroll_offset_animation_was_interrupted());
955 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); 959 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted());
956 960
957 controller_impl->ActivateAnimations(); 961 controller_impl->ActivateAnimations();
958 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); 962 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted());
959 963
960 // Now, test the 2-argument version of RemoveAnimation. 964 // Now, test the 2-argument version of RemoveAnimation.
961 curve = ScrollOffsetAnimationCurve::Create(target_value, 965 curve = ScrollOffsetAnimationCurve::Create(target_value,
962 EaseInOutTimingFunction::Create()); 966 EaseInOutTimingFunction::Create());
963 animation = Animation::Create(std::move(curve), animation_id, 0, 967 animation = Animation::Create(std::move(curve), animation_id, 0,
964 Animation::SCROLL_OFFSET); 968 TargetProperty::SCROLL_OFFSET);
965 animation->set_needs_synchronized_start_time(true); 969 animation->set_needs_synchronized_start_time(true);
966 controller->AddAnimation(std::move(animation)); 970 controller->AddAnimation(std::move(animation));
967 controller->PushAnimationUpdatesTo(controller_impl.get()); 971 controller->PushAnimationUpdatesTo(controller_impl.get());
968 controller_impl->ActivateAnimations(); 972 controller_impl->ActivateAnimations();
969 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); 973 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted());
970 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); 974 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted());
971 975
972 controller->RemoveAnimation(animation_id); 976 controller->RemoveAnimation(animation_id);
973 EXPECT_TRUE(controller->scroll_offset_animation_was_interrupted()); 977 EXPECT_TRUE(controller->scroll_offset_animation_was_interrupted());
974 978
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 1021
1018 class FakeAnimationDelegate : public AnimationDelegate { 1022 class FakeAnimationDelegate : public AnimationDelegate {
1019 public: 1023 public:
1020 FakeAnimationDelegate() 1024 FakeAnimationDelegate()
1021 : started_(false), 1025 : started_(false),
1022 finished_(false), 1026 finished_(false),
1023 aborted_(false), 1027 aborted_(false),
1024 start_time_(base::TimeTicks()) {} 1028 start_time_(base::TimeTicks()) {}
1025 1029
1026 void NotifyAnimationStarted(TimeTicks monotonic_time, 1030 void NotifyAnimationStarted(TimeTicks monotonic_time,
1027 Animation::TargetProperty target_property, 1031 TargetProperty::Type target_property,
1028 int group) override { 1032 int group) override {
1029 started_ = true; 1033 started_ = true;
1030 start_time_ = monotonic_time; 1034 start_time_ = monotonic_time;
1031 } 1035 }
1032 1036
1033 void NotifyAnimationFinished(TimeTicks monotonic_time, 1037 void NotifyAnimationFinished(TimeTicks monotonic_time,
1034 Animation::TargetProperty target_property, 1038 TargetProperty::Type target_property,
1035 int group) override { 1039 int group) override {
1036 finished_ = true; 1040 finished_ = true;
1037 } 1041 }
1038 1042
1039 void NotifyAnimationAborted(TimeTicks monotonic_time, 1043 void NotifyAnimationAborted(TimeTicks monotonic_time,
1040 Animation::TargetProperty target_property, 1044 TargetProperty::Type target_property,
1041 int group) override { 1045 int group) override {
1042 aborted_ = true; 1046 aborted_ = true;
1043 } 1047 }
1044 1048
1045 bool started() { return started_; } 1049 bool started() { return started_; }
1046 1050
1047 bool finished() { return finished_; } 1051 bool finished() { return finished_; }
1048 1052
1049 bool aborted() { return aborted_; } 1053 bool aborted() { return aborted_; }
1050 1054
(...skipping 13 matching lines...) Expand all
1064 FakeLayerAnimationValueObserver dummy_impl; 1068 FakeLayerAnimationValueObserver dummy_impl;
1065 scoped_refptr<LayerAnimationController> controller_impl( 1069 scoped_refptr<LayerAnimationController> controller_impl(
1066 LayerAnimationController::Create(0)); 1070 LayerAnimationController::Create(0));
1067 controller_impl->AddValueObserver(&dummy_impl); 1071 controller_impl->AddValueObserver(&dummy_impl);
1068 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 1072 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
1069 FakeAnimationDelegate delegate; 1073 FakeAnimationDelegate delegate;
1070 controller_impl->set_layer_animation_delegate(&delegate); 1074 controller_impl->set_layer_animation_delegate(&delegate);
1071 1075
1072 scoped_ptr<Animation> to_add(CreateAnimation( 1076 scoped_ptr<Animation> to_add(CreateAnimation(
1073 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, 1077 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1,
1074 Animation::OPACITY)); 1078 TargetProperty::OPACITY));
1075 to_add->set_is_impl_only(true); 1079 to_add->set_is_impl_only(true);
1076 controller_impl->AddAnimation(std::move(to_add)); 1080 controller_impl->AddAnimation(std::move(to_add));
1077 1081
1078 EXPECT_FALSE(delegate.started()); 1082 EXPECT_FALSE(delegate.started());
1079 EXPECT_FALSE(delegate.finished()); 1083 EXPECT_FALSE(delegate.finished());
1080 1084
1081 controller_impl->Animate(kInitialTickTime); 1085 controller_impl->Animate(kInitialTickTime);
1082 controller_impl->UpdateState(true, events.get()); 1086 controller_impl->UpdateState(true, events.get());
1083 1087
1084 EXPECT_TRUE(delegate.started()); 1088 EXPECT_TRUE(delegate.started());
(...skipping 19 matching lines...) Expand all
1104 scoped_refptr<LayerAnimationController> controller( 1108 scoped_refptr<LayerAnimationController> controller(
1105 LayerAnimationController::Create(0)); 1109 LayerAnimationController::Create(0));
1106 controller->AddValueObserver(&dummy); 1110 controller->AddValueObserver(&dummy);
1107 FakeAnimationDelegate delegate; 1111 FakeAnimationDelegate delegate;
1108 controller->set_layer_animation_delegate(&delegate); 1112 controller->set_layer_animation_delegate(&delegate);
1109 1113
1110 int animation_id = 1114 int animation_id =
1111 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); 1115 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false);
1112 1116
1113 const TimeTicks start_time = TicksFromSecondsF(123); 1117 const TimeTicks start_time = TicksFromSecondsF(123);
1114 controller->GetAnimation(Animation::OPACITY)->set_start_time(start_time); 1118 controller->GetAnimation(TargetProperty::OPACITY)->set_start_time(start_time);
1115 1119
1116 controller->PushAnimationUpdatesTo(controller_impl.get()); 1120 controller->PushAnimationUpdatesTo(controller_impl.get());
1117 controller_impl->ActivateAnimations(); 1121 controller_impl->ActivateAnimations();
1118 1122
1119 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); 1123 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id));
1120 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, 1124 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY,
1121 controller_impl->GetAnimationById(animation_id)->run_state()); 1125 controller_impl->GetAnimationById(animation_id)->run_state());
1122 1126
1123 AnimationEvents events; 1127 AnimationEvents events;
1124 controller_impl->Animate(kInitialTickTime); 1128 controller_impl->Animate(kInitialTickTime);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 scoped_refptr<LayerAnimationController> controller( 1160 scoped_refptr<LayerAnimationController> controller(
1157 LayerAnimationController::Create(0)); 1161 LayerAnimationController::Create(0));
1158 controller->AddValueObserver(&dummy); 1162 controller->AddValueObserver(&dummy);
1159 FakeLayerAnimationEventObserver observer; 1163 FakeLayerAnimationEventObserver observer;
1160 controller->AddEventObserver(&observer); 1164 controller->AddEventObserver(&observer);
1161 1165
1162 int animation_id = 1166 int animation_id =
1163 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); 1167 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false);
1164 1168
1165 const TimeTicks start_time = TicksFromSecondsF(123); 1169 const TimeTicks start_time = TicksFromSecondsF(123);
1166 controller->GetAnimation(Animation::OPACITY)->set_start_time(start_time); 1170 controller->GetAnimation(TargetProperty::OPACITY)->set_start_time(start_time);
1167 1171
1168 controller->PushAnimationUpdatesTo(controller_impl.get()); 1172 controller->PushAnimationUpdatesTo(controller_impl.get());
1169 controller_impl->ActivateAnimations(); 1173 controller_impl->ActivateAnimations();
1170 1174
1171 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); 1175 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id));
1172 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, 1176 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY,
1173 controller_impl->GetAnimationById(animation_id)->run_state()); 1177 controller_impl->GetAnimationById(animation_id)->run_state());
1174 1178
1175 AnimationEvents events; 1179 AnimationEvents events;
1176 controller_impl->Animate(kInitialTickTime); 1180 controller_impl->Animate(kInitialTickTime);
(...skipping 12 matching lines...) Expand all
1189 TEST(LayerAnimationControllerTest, 1193 TEST(LayerAnimationControllerTest,
1190 AnimationsWaitingForStartTimeDoNotFinishIfTheyOutwaitTheirFinish) { 1194 AnimationsWaitingForStartTimeDoNotFinishIfTheyOutwaitTheirFinish) {
1191 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 1195 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
1192 FakeLayerAnimationValueObserver dummy; 1196 FakeLayerAnimationValueObserver dummy;
1193 scoped_refptr<LayerAnimationController> controller( 1197 scoped_refptr<LayerAnimationController> controller(
1194 LayerAnimationController::Create(0)); 1198 LayerAnimationController::Create(0));
1195 controller->AddValueObserver(&dummy); 1199 controller->AddValueObserver(&dummy);
1196 1200
1197 scoped_ptr<Animation> to_add(CreateAnimation( 1201 scoped_ptr<Animation> to_add(CreateAnimation(
1198 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, 1202 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1,
1199 Animation::OPACITY)); 1203 TargetProperty::OPACITY));
1200 to_add->set_needs_synchronized_start_time(true); 1204 to_add->set_needs_synchronized_start_time(true);
1201 1205
1202 // We should pause at the first keyframe indefinitely waiting for that 1206 // We should pause at the first keyframe indefinitely waiting for that
1203 // animation to start. 1207 // animation to start.
1204 controller->AddAnimation(std::move(to_add)); 1208 controller->AddAnimation(std::move(to_add));
1205 controller->Animate(kInitialTickTime); 1209 controller->Animate(kInitialTickTime);
1206 controller->UpdateState(true, events.get()); 1210 controller->UpdateState(true, events.get());
1207 EXPECT_TRUE(controller->HasActiveAnimation()); 1211 EXPECT_TRUE(controller->HasActiveAnimation());
1208 EXPECT_EQ(0.f, dummy.opacity()); 1212 EXPECT_EQ(0.f, dummy.opacity());
1209 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 1213 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1210 controller->UpdateState(true, events.get()); 1214 controller->UpdateState(true, events.get());
1211 EXPECT_TRUE(controller->HasActiveAnimation()); 1215 EXPECT_TRUE(controller->HasActiveAnimation());
1212 EXPECT_EQ(0.f, dummy.opacity()); 1216 EXPECT_EQ(0.f, dummy.opacity());
1213 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 1217 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1214 controller->UpdateState(true, events.get()); 1218 controller->UpdateState(true, events.get());
1215 EXPECT_TRUE(controller->HasActiveAnimation()); 1219 EXPECT_TRUE(controller->HasActiveAnimation());
1216 EXPECT_EQ(0.f, dummy.opacity()); 1220 EXPECT_EQ(0.f, dummy.opacity());
1217 1221
1218 // Send the synchronized start time. 1222 // Send the synchronized start time.
1219 controller->NotifyAnimationStarted( 1223 controller->NotifyAnimationStarted(
1220 AnimationEvent(AnimationEvent::STARTED, 0, 1, Animation::OPACITY, 1224 AnimationEvent(AnimationEvent::STARTED, 0, 1, TargetProperty::OPACITY,
1221 kInitialTickTime + TimeDelta::FromMilliseconds(2000))); 1225 kInitialTickTime + TimeDelta::FromMilliseconds(2000)));
1222 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(5000)); 1226 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(5000));
1223 controller->UpdateState(true, events.get()); 1227 controller->UpdateState(true, events.get());
1224 EXPECT_EQ(1.f, dummy.opacity()); 1228 EXPECT_EQ(1.f, dummy.opacity());
1225 EXPECT_FALSE(controller->HasActiveAnimation()); 1229 EXPECT_FALSE(controller->HasActiveAnimation());
1226 } 1230 }
1227 1231
1228 // Tests that two queued animations affecting the same property run in sequence. 1232 // Tests that two queued animations affecting the same property run in sequence.
1229 TEST(LayerAnimationControllerTest, TrivialQueuing) { 1233 TEST(LayerAnimationControllerTest, TrivialQueuing) {
1230 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 1234 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
1231 FakeLayerAnimationValueObserver dummy; 1235 FakeLayerAnimationValueObserver dummy;
1232 scoped_refptr<LayerAnimationController> controller( 1236 scoped_refptr<LayerAnimationController> controller(
1233 LayerAnimationController::Create(0)); 1237 LayerAnimationController::Create(0));
1234 controller->AddValueObserver(&dummy); 1238 controller->AddValueObserver(&dummy);
1235 1239
1236 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); 1240 EXPECT_FALSE(controller->needs_to_start_animations_for_testing());
1237 1241
1238 controller->AddAnimation(CreateAnimation( 1242 controller->AddAnimation(CreateAnimation(
1239 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, 1243 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1,
1240 Animation::OPACITY)); 1244 TargetProperty::OPACITY));
1241 controller->AddAnimation(CreateAnimation( 1245 controller->AddAnimation(CreateAnimation(
1242 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), 2, 1246 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), 2,
1243 Animation::OPACITY)); 1247 TargetProperty::OPACITY));
1244 1248
1245 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); 1249 EXPECT_TRUE(controller->needs_to_start_animations_for_testing());
1246 1250
1247 controller->Animate(kInitialTickTime); 1251 controller->Animate(kInitialTickTime);
1248 1252
1249 // The second animation still needs to be started. 1253 // The second animation still needs to be started.
1250 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); 1254 EXPECT_TRUE(controller->needs_to_start_animations_for_testing());
1251 1255
1252 controller->UpdateState(true, events.get()); 1256 controller->UpdateState(true, events.get());
1253 EXPECT_TRUE(controller->HasActiveAnimation()); 1257 EXPECT_TRUE(controller->HasActiveAnimation());
(...skipping 14 matching lines...) Expand all
1268 1272
1269 // Tests interrupting a transition with another transition. 1273 // Tests interrupting a transition with another transition.
1270 TEST(LayerAnimationControllerTest, Interrupt) { 1274 TEST(LayerAnimationControllerTest, Interrupt) {
1271 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 1275 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
1272 FakeLayerAnimationValueObserver dummy; 1276 FakeLayerAnimationValueObserver dummy;
1273 scoped_refptr<LayerAnimationController> controller( 1277 scoped_refptr<LayerAnimationController> controller(
1274 LayerAnimationController::Create(0)); 1278 LayerAnimationController::Create(0));
1275 controller->AddValueObserver(&dummy); 1279 controller->AddValueObserver(&dummy);
1276 controller->AddAnimation(CreateAnimation( 1280 controller->AddAnimation(CreateAnimation(
1277 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, 1281 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1,
1278 Animation::OPACITY)); 1282 TargetProperty::OPACITY));
1279 controller->Animate(kInitialTickTime); 1283 controller->Animate(kInitialTickTime);
1280 controller->UpdateState(true, events.get()); 1284 controller->UpdateState(true, events.get());
1281 EXPECT_TRUE(controller->HasActiveAnimation()); 1285 EXPECT_TRUE(controller->HasActiveAnimation());
1282 EXPECT_EQ(0.f, dummy.opacity()); 1286 EXPECT_EQ(0.f, dummy.opacity());
1283 1287
1284 scoped_ptr<Animation> to_add(CreateAnimation( 1288 scoped_ptr<Animation> to_add(CreateAnimation(
1285 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), 2, 1289 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), 2,
1286 Animation::OPACITY)); 1290 TargetProperty::OPACITY));
1287 controller->AbortAnimations(Animation::OPACITY); 1291 controller->AbortAnimations(TargetProperty::OPACITY);
1288 controller->AddAnimation(std::move(to_add)); 1292 controller->AddAnimation(std::move(to_add));
1289 1293
1290 // Since the previous animation was aborted, the new animation should start 1294 // Since the previous animation was aborted, the new animation should start
1291 // right in this call to animate. 1295 // right in this call to animate.
1292 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); 1296 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
1293 controller->UpdateState(true, events.get()); 1297 controller->UpdateState(true, events.get());
1294 EXPECT_TRUE(controller->HasActiveAnimation()); 1298 EXPECT_TRUE(controller->HasActiveAnimation());
1295 EXPECT_EQ(1.f, dummy.opacity()); 1299 EXPECT_EQ(1.f, dummy.opacity());
1296 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); 1300 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500));
1297 controller->UpdateState(true, events.get()); 1301 controller->UpdateState(true, events.get());
1298 EXPECT_EQ(0.5f, dummy.opacity()); 1302 EXPECT_EQ(0.5f, dummy.opacity());
1299 EXPECT_FALSE(controller->HasActiveAnimation()); 1303 EXPECT_FALSE(controller->HasActiveAnimation());
1300 } 1304 }
1301 1305
1302 // Tests scheduling two animations to run together when only one property is 1306 // Tests scheduling two animations to run together when only one property is
1303 // free. 1307 // free.
1304 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { 1308 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) {
1305 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 1309 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
1306 FakeLayerAnimationValueObserver dummy; 1310 FakeLayerAnimationValueObserver dummy;
1307 scoped_refptr<LayerAnimationController> controller( 1311 scoped_refptr<LayerAnimationController> controller(
1308 LayerAnimationController::Create(0)); 1312 LayerAnimationController::Create(0));
1309 controller->AddValueObserver(&dummy); 1313 controller->AddValueObserver(&dummy);
1310 1314
1311 controller->AddAnimation(CreateAnimation( 1315 controller->AddAnimation(CreateAnimation(
1312 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, 1316 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1,
1313 Animation::TRANSFORM)); 1317 TargetProperty::TRANSFORM));
1314 controller->AddAnimation(CreateAnimation( 1318 controller->AddAnimation(CreateAnimation(
1315 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 2, 1319 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 2,
1316 Animation::TRANSFORM)); 1320 TargetProperty::TRANSFORM));
1317 controller->AddAnimation(CreateAnimation( 1321 controller->AddAnimation(CreateAnimation(
1318 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2, 1322 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2,
1319 Animation::OPACITY)); 1323 TargetProperty::OPACITY));
1320 1324
1321 controller->Animate(kInitialTickTime); 1325 controller->Animate(kInitialTickTime);
1322 controller->UpdateState(true, events.get()); 1326 controller->UpdateState(true, events.get());
1323 EXPECT_EQ(0.f, dummy.opacity()); 1327 EXPECT_EQ(0.f, dummy.opacity());
1324 EXPECT_TRUE(controller->HasActiveAnimation()); 1328 EXPECT_TRUE(controller->HasActiveAnimation());
1325 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 1329 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1326 controller->UpdateState(true, events.get()); 1330 controller->UpdateState(true, events.get());
1327 // Should not have started the float transition yet. 1331 // Should not have started the float transition yet.
1328 EXPECT_TRUE(controller->HasActiveAnimation()); 1332 EXPECT_TRUE(controller->HasActiveAnimation());
1329 EXPECT_EQ(0.f, dummy.opacity()); 1333 EXPECT_EQ(0.f, dummy.opacity());
1330 // The float animation should have started at time 1 and should be done. 1334 // The float animation should have started at time 1 and should be done.
1331 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 1335 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1332 controller->UpdateState(true, events.get()); 1336 controller->UpdateState(true, events.get());
1333 EXPECT_EQ(1.f, dummy.opacity()); 1337 EXPECT_EQ(1.f, dummy.opacity());
1334 EXPECT_FALSE(controller->HasActiveAnimation()); 1338 EXPECT_FALSE(controller->HasActiveAnimation());
1335 } 1339 }
1336 1340
1337 // Tests scheduling two animations to run together with different lengths and 1341 // Tests scheduling two animations to run together with different lengths and
1338 // another animation queued to start when the shorter animation finishes (should 1342 // another animation queued to start when the shorter animation finishes (should
1339 // wait for both to finish). 1343 // wait for both to finish).
1340 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { 1344 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) {
1341 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 1345 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
1342 FakeLayerAnimationValueObserver dummy; 1346 FakeLayerAnimationValueObserver dummy;
1343 scoped_refptr<LayerAnimationController> controller( 1347 scoped_refptr<LayerAnimationController> controller(
1344 LayerAnimationController::Create(0)); 1348 LayerAnimationController::Create(0));
1345 controller->AddValueObserver(&dummy); 1349 controller->AddValueObserver(&dummy);
1346 1350
1347 controller->AddAnimation(CreateAnimation( 1351 controller->AddAnimation(CreateAnimation(
1348 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2)), 1, 1352 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2)), 1,
1349 Animation::TRANSFORM)); 1353 TargetProperty::TRANSFORM));
1350 controller->AddAnimation(CreateAnimation( 1354 controller->AddAnimation(CreateAnimation(
1351 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, 1355 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1,
1352 Animation::OPACITY)); 1356 TargetProperty::OPACITY));
1353 controller->AddAnimation(CreateAnimation( 1357 controller->AddAnimation(CreateAnimation(
1354 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), 2, 1358 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), 2,
1355 Animation::OPACITY)); 1359 TargetProperty::OPACITY));
1356 1360
1357 // Animations with id 1 should both start now. 1361 // Animations with id 1 should both start now.
1358 controller->Animate(kInitialTickTime); 1362 controller->Animate(kInitialTickTime);
1359 controller->UpdateState(true, events.get()); 1363 controller->UpdateState(true, events.get());
1360 EXPECT_TRUE(controller->HasActiveAnimation()); 1364 EXPECT_TRUE(controller->HasActiveAnimation());
1361 EXPECT_EQ(0.f, dummy.opacity()); 1365 EXPECT_EQ(0.f, dummy.opacity());
1362 // The opacity animation should have finished at time 1, but the group 1366 // The opacity animation should have finished at time 1, but the group
1363 // of animations with id 1 don't finish until time 2 because of the length 1367 // of animations with id 1 don't finish until time 2 because of the length
1364 // of the transform animation. 1368 // of the transform animation.
1365 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 1369 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
(...skipping 13 matching lines...) Expand all
1379 // Test that a looping animation loops and for the correct number of iterations. 1383 // Test that a looping animation loops and for the correct number of iterations.
1380 TEST(LayerAnimationControllerTest, TrivialLooping) { 1384 TEST(LayerAnimationControllerTest, TrivialLooping) {
1381 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 1385 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
1382 FakeLayerAnimationValueObserver dummy; 1386 FakeLayerAnimationValueObserver dummy;
1383 scoped_refptr<LayerAnimationController> controller( 1387 scoped_refptr<LayerAnimationController> controller(
1384 LayerAnimationController::Create(0)); 1388 LayerAnimationController::Create(0));
1385 controller->AddValueObserver(&dummy); 1389 controller->AddValueObserver(&dummy);
1386 1390
1387 scoped_ptr<Animation> to_add(CreateAnimation( 1391 scoped_ptr<Animation> to_add(CreateAnimation(
1388 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, 1392 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1,
1389 Animation::OPACITY)); 1393 TargetProperty::OPACITY));
1390 to_add->set_iterations(3); 1394 to_add->set_iterations(3);
1391 controller->AddAnimation(std::move(to_add)); 1395 controller->AddAnimation(std::move(to_add));
1392 1396
1393 controller->Animate(kInitialTickTime); 1397 controller->Animate(kInitialTickTime);
1394 controller->UpdateState(true, events.get()); 1398 controller->UpdateState(true, events.get());
1395 EXPECT_TRUE(controller->HasActiveAnimation()); 1399 EXPECT_TRUE(controller->HasActiveAnimation());
1396 EXPECT_EQ(0.f, dummy.opacity()); 1400 EXPECT_EQ(0.f, dummy.opacity());
1397 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); 1401 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250));
1398 controller->UpdateState(true, events.get()); 1402 controller->UpdateState(true, events.get());
1399 EXPECT_TRUE(controller->HasActiveAnimation()); 1403 EXPECT_TRUE(controller->HasActiveAnimation());
(...skipping 24 matching lines...) Expand all
1424 // Test that an infinitely looping animation does indeed go until aborted. 1428 // Test that an infinitely looping animation does indeed go until aborted.
1425 TEST(LayerAnimationControllerTest, InfiniteLooping) { 1429 TEST(LayerAnimationControllerTest, InfiniteLooping) {
1426 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 1430 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
1427 FakeLayerAnimationValueObserver dummy; 1431 FakeLayerAnimationValueObserver dummy;
1428 scoped_refptr<LayerAnimationController> controller( 1432 scoped_refptr<LayerAnimationController> controller(
1429 LayerAnimationController::Create(0)); 1433 LayerAnimationController::Create(0));
1430 controller->AddValueObserver(&dummy); 1434 controller->AddValueObserver(&dummy);
1431 1435
1432 scoped_ptr<Animation> to_add(CreateAnimation( 1436 scoped_ptr<Animation> to_add(CreateAnimation(
1433 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, 1437 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1,
1434 Animation::OPACITY)); 1438 TargetProperty::OPACITY));
1435 to_add->set_iterations(-1); 1439 to_add->set_iterations(-1);
1436 controller->AddAnimation(std::move(to_add)); 1440 controller->AddAnimation(std::move(to_add));
1437 1441
1438 controller->Animate(kInitialTickTime); 1442 controller->Animate(kInitialTickTime);
1439 controller->UpdateState(true, events.get()); 1443 controller->UpdateState(true, events.get());
1440 EXPECT_TRUE(controller->HasActiveAnimation()); 1444 EXPECT_TRUE(controller->HasActiveAnimation());
1441 EXPECT_EQ(0.f, dummy.opacity()); 1445 EXPECT_EQ(0.f, dummy.opacity());
1442 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); 1446 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250));
1443 controller->UpdateState(true, events.get()); 1447 controller->UpdateState(true, events.get());
1444 EXPECT_TRUE(controller->HasActiveAnimation()); 1448 EXPECT_TRUE(controller->HasActiveAnimation());
1445 EXPECT_EQ(0.25f, dummy.opacity()); 1449 EXPECT_EQ(0.25f, dummy.opacity());
1446 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); 1450 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750));
1447 controller->UpdateState(true, events.get()); 1451 controller->UpdateState(true, events.get());
1448 EXPECT_TRUE(controller->HasActiveAnimation()); 1452 EXPECT_TRUE(controller->HasActiveAnimation());
1449 EXPECT_EQ(0.75f, dummy.opacity()); 1453 EXPECT_EQ(0.75f, dummy.opacity());
1450 1454
1451 controller->Animate(kInitialTickTime + 1455 controller->Animate(kInitialTickTime +
1452 TimeDelta::FromMilliseconds(1073741824250)); 1456 TimeDelta::FromMilliseconds(1073741824250));
1453 controller->UpdateState(true, events.get()); 1457 controller->UpdateState(true, events.get());
1454 EXPECT_TRUE(controller->HasActiveAnimation()); 1458 EXPECT_TRUE(controller->HasActiveAnimation());
1455 EXPECT_EQ(0.25f, dummy.opacity()); 1459 EXPECT_EQ(0.25f, dummy.opacity());
1456 controller->Animate(kInitialTickTime + 1460 controller->Animate(kInitialTickTime +
1457 TimeDelta::FromMilliseconds(1073741824750)); 1461 TimeDelta::FromMilliseconds(1073741824750));
1458 controller->UpdateState(true, events.get()); 1462 controller->UpdateState(true, events.get());
1459 EXPECT_TRUE(controller->HasActiveAnimation()); 1463 EXPECT_TRUE(controller->HasActiveAnimation());
1460 EXPECT_EQ(0.75f, dummy.opacity()); 1464 EXPECT_EQ(0.75f, dummy.opacity());
1461 1465
1462 EXPECT_TRUE(controller->GetAnimation(Animation::OPACITY)); 1466 EXPECT_TRUE(controller->GetAnimation(TargetProperty::OPACITY));
1463 controller->GetAnimation(Animation::OPACITY) 1467 controller->GetAnimation(TargetProperty::OPACITY)
1464 ->SetRunState(Animation::ABORTED, 1468 ->SetRunState(Animation::ABORTED,
1465 kInitialTickTime + TimeDelta::FromMilliseconds(750)); 1469 kInitialTickTime + TimeDelta::FromMilliseconds(750));
1466 EXPECT_FALSE(controller->HasActiveAnimation()); 1470 EXPECT_FALSE(controller->HasActiveAnimation());
1467 EXPECT_EQ(0.75f, dummy.opacity()); 1471 EXPECT_EQ(0.75f, dummy.opacity());
1468 } 1472 }
1469 1473
1470 // Test that pausing and resuming work as expected. 1474 // Test that pausing and resuming work as expected.
1471 TEST(LayerAnimationControllerTest, PauseResume) { 1475 TEST(LayerAnimationControllerTest, PauseResume) {
1472 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 1476 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
1473 FakeLayerAnimationValueObserver dummy; 1477 FakeLayerAnimationValueObserver dummy;
1474 scoped_refptr<LayerAnimationController> controller( 1478 scoped_refptr<LayerAnimationController> controller(
1475 LayerAnimationController::Create(0)); 1479 LayerAnimationController::Create(0));
1476 controller->AddValueObserver(&dummy); 1480 controller->AddValueObserver(&dummy);
1477 1481
1478 controller->AddAnimation(CreateAnimation( 1482 controller->AddAnimation(CreateAnimation(
1479 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, 1483 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1,
1480 Animation::OPACITY)); 1484 TargetProperty::OPACITY));
1481 1485
1482 controller->Animate(kInitialTickTime); 1486 controller->Animate(kInitialTickTime);
1483 controller->UpdateState(true, events.get()); 1487 controller->UpdateState(true, events.get());
1484 EXPECT_TRUE(controller->HasActiveAnimation()); 1488 EXPECT_TRUE(controller->HasActiveAnimation());
1485 EXPECT_EQ(0.f, dummy.opacity()); 1489 EXPECT_EQ(0.f, dummy.opacity());
1486 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); 1490 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
1487 controller->UpdateState(true, events.get()); 1491 controller->UpdateState(true, events.get());
1488 EXPECT_TRUE(controller->HasActiveAnimation()); 1492 EXPECT_TRUE(controller->HasActiveAnimation());
1489 EXPECT_EQ(0.5f, dummy.opacity()); 1493 EXPECT_EQ(0.5f, dummy.opacity());
1490 1494
1491 EXPECT_TRUE(controller->GetAnimation(Animation::OPACITY)); 1495 EXPECT_TRUE(controller->GetAnimation(TargetProperty::OPACITY));
1492 controller->GetAnimation(Animation::OPACITY) 1496 controller->GetAnimation(TargetProperty::OPACITY)
1493 ->SetRunState(Animation::PAUSED, 1497 ->SetRunState(Animation::PAUSED,
1494 kInitialTickTime + TimeDelta::FromMilliseconds(500)); 1498 kInitialTickTime + TimeDelta::FromMilliseconds(500));
1495 1499
1496 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); 1500 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024000));
1497 controller->UpdateState(true, events.get()); 1501 controller->UpdateState(true, events.get());
1498 EXPECT_TRUE(controller->HasActiveAnimation()); 1502 EXPECT_TRUE(controller->HasActiveAnimation());
1499 EXPECT_EQ(0.5f, dummy.opacity()); 1503 EXPECT_EQ(0.5f, dummy.opacity());
1500 1504
1501 EXPECT_TRUE(controller->GetAnimation(Animation::OPACITY)); 1505 EXPECT_TRUE(controller->GetAnimation(TargetProperty::OPACITY));
1502 controller->GetAnimation(Animation::OPACITY) 1506 controller->GetAnimation(TargetProperty::OPACITY)
1503 ->SetRunState(Animation::RUNNING, 1507 ->SetRunState(Animation::RUNNING,
1504 kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); 1508 kInitialTickTime + TimeDelta::FromMilliseconds(1024000));
1505 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024250)); 1509 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024250));
1506 controller->UpdateState(true, events.get()); 1510 controller->UpdateState(true, events.get());
1507 EXPECT_TRUE(controller->HasActiveAnimation()); 1511 EXPECT_TRUE(controller->HasActiveAnimation());
1508 EXPECT_EQ(0.75f, dummy.opacity()); 1512 EXPECT_EQ(0.75f, dummy.opacity());
1509 1513
1510 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024500)); 1514 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024500));
1511 controller->UpdateState(true, events.get()); 1515 controller->UpdateState(true, events.get());
1512 EXPECT_FALSE(controller->HasActiveAnimation()); 1516 EXPECT_FALSE(controller->HasActiveAnimation());
1513 EXPECT_EQ(1.f, dummy.opacity()); 1517 EXPECT_EQ(1.f, dummy.opacity());
1514 } 1518 }
1515 1519
1516 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { 1520 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) {
1517 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 1521 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
1518 FakeLayerAnimationValueObserver dummy; 1522 FakeLayerAnimationValueObserver dummy;
1519 scoped_refptr<LayerAnimationController> controller( 1523 scoped_refptr<LayerAnimationController> controller(
1520 LayerAnimationController::Create(0)); 1524 LayerAnimationController::Create(0));
1521 controller->AddValueObserver(&dummy); 1525 controller->AddValueObserver(&dummy);
1522 1526
1523 const int animation_id = 2; 1527 const int animation_id = 2;
1524 controller->AddAnimation(Animation::Create( 1528 controller->AddAnimation(Animation::Create(
1525 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, 1, 1529 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, 1,
1526 Animation::TRANSFORM)); 1530 TargetProperty::TRANSFORM));
1527 controller->AddAnimation(Animation::Create( 1531 controller->AddAnimation(Animation::Create(
1528 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)), 1532 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)),
1529 animation_id, 1, Animation::OPACITY)); 1533 animation_id, 1, TargetProperty::OPACITY));
1530 controller->AddAnimation(Animation::Create( 1534 controller->AddAnimation(Animation::Create(
1531 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.75f)), 3, 1535 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.75f)), 3,
1532 2, Animation::OPACITY)); 1536 2, TargetProperty::OPACITY));
1533 1537
1534 controller->Animate(kInitialTickTime); 1538 controller->Animate(kInitialTickTime);
1535 controller->UpdateState(true, events.get()); 1539 controller->UpdateState(true, events.get());
1536 EXPECT_TRUE(controller->HasActiveAnimation()); 1540 EXPECT_TRUE(controller->HasActiveAnimation());
1537 EXPECT_EQ(0.f, dummy.opacity()); 1541 EXPECT_EQ(0.f, dummy.opacity());
1538 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 1542 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1539 controller->UpdateState(true, events.get()); 1543 controller->UpdateState(true, events.get());
1540 EXPECT_TRUE(controller->HasActiveAnimation()); 1544 EXPECT_TRUE(controller->HasActiveAnimation());
1541 EXPECT_EQ(0.5f, dummy.opacity()); 1545 EXPECT_EQ(0.5f, dummy.opacity());
1542 1546
(...skipping 17 matching lines...) Expand all
1560 LayerAnimationController::Create(0)); 1564 LayerAnimationController::Create(0));
1561 controller_impl->AddValueObserver(&dummy_impl); 1565 controller_impl->AddValueObserver(&dummy_impl);
1562 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 1566 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
1563 FakeLayerAnimationValueObserver dummy; 1567 FakeLayerAnimationValueObserver dummy;
1564 scoped_refptr<LayerAnimationController> controller( 1568 scoped_refptr<LayerAnimationController> controller(
1565 LayerAnimationController::Create(0)); 1569 LayerAnimationController::Create(0));
1566 controller->AddValueObserver(&dummy); 1570 controller->AddValueObserver(&dummy);
1567 1571
1568 scoped_ptr<Animation> to_add(CreateAnimation( 1572 scoped_ptr<Animation> to_add(CreateAnimation(
1569 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)), 0, 1573 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)), 0,
1570 Animation::OPACITY)); 1574 TargetProperty::OPACITY));
1571 to_add->set_needs_synchronized_start_time(true); 1575 to_add->set_needs_synchronized_start_time(true);
1572 controller->AddAnimation(std::move(to_add)); 1576 controller->AddAnimation(std::move(to_add));
1573 1577
1574 controller->Animate(kInitialTickTime); 1578 controller->Animate(kInitialTickTime);
1575 controller->UpdateState(true, events.get()); 1579 controller->UpdateState(true, events.get());
1576 EXPECT_TRUE(controller->HasActiveAnimation()); 1580 EXPECT_TRUE(controller->HasActiveAnimation());
1577 Animation* active_animation = controller->GetAnimation(Animation::OPACITY); 1581 Animation* active_animation =
1582 controller->GetAnimation(TargetProperty::OPACITY);
1578 EXPECT_TRUE(active_animation); 1583 EXPECT_TRUE(active_animation);
1579 EXPECT_TRUE(active_animation->needs_synchronized_start_time()); 1584 EXPECT_TRUE(active_animation->needs_synchronized_start_time());
1580 1585
1581 controller->PushAnimationUpdatesTo(controller_impl.get()); 1586 controller->PushAnimationUpdatesTo(controller_impl.get());
1582 controller_impl->ActivateAnimations(); 1587 controller_impl->ActivateAnimations();
1583 1588
1584 active_animation = controller_impl->GetAnimation(Animation::OPACITY); 1589 active_animation = controller_impl->GetAnimation(TargetProperty::OPACITY);
1585 EXPECT_TRUE(active_animation); 1590 EXPECT_TRUE(active_animation);
1586 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, 1591 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY,
1587 active_animation->run_state()); 1592 active_animation->run_state());
1588 } 1593 }
1589 1594
1590 // Tests that skipping a call to UpdateState works as expected. 1595 // Tests that skipping a call to UpdateState works as expected.
1591 TEST(LayerAnimationControllerTest, SkipUpdateState) { 1596 TEST(LayerAnimationControllerTest, SkipUpdateState) {
1592 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 1597 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
1593 FakeLayerAnimationValueObserver dummy; 1598 FakeLayerAnimationValueObserver dummy;
1594 scoped_refptr<LayerAnimationController> controller( 1599 scoped_refptr<LayerAnimationController> controller(
1595 LayerAnimationController::Create(0)); 1600 LayerAnimationController::Create(0));
1596 controller->AddValueObserver(&dummy); 1601 controller->AddValueObserver(&dummy);
1597 1602
1598 scoped_ptr<Animation> first_animation(CreateAnimation( 1603 scoped_ptr<Animation> first_animation(CreateAnimation(
1599 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, 1604 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1,
1600 Animation::TRANSFORM)); 1605 TargetProperty::TRANSFORM));
1601 first_animation->set_is_controlling_instance_for_test(true); 1606 first_animation->set_is_controlling_instance_for_test(true);
1602 controller->AddAnimation(std::move(first_animation)); 1607 controller->AddAnimation(std::move(first_animation));
1603 1608
1604 controller->Animate(kInitialTickTime); 1609 controller->Animate(kInitialTickTime);
1605 controller->UpdateState(true, events.get()); 1610 controller->UpdateState(true, events.get());
1606 1611
1607 scoped_ptr<Animation> second_animation(CreateAnimation( 1612 scoped_ptr<Animation> second_animation(CreateAnimation(
1608 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2, 1613 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2,
1609 Animation::OPACITY)); 1614 TargetProperty::OPACITY));
1610 second_animation->set_is_controlling_instance_for_test(true); 1615 second_animation->set_is_controlling_instance_for_test(true);
1611 controller->AddAnimation(std::move(second_animation)); 1616 controller->AddAnimation(std::move(second_animation));
1612 1617
1613 // Animate but don't UpdateState. 1618 // Animate but don't UpdateState.
1614 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 1619 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1615 1620
1616 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 1621 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1617 events.reset(new AnimationEvents); 1622 events.reset(new AnimationEvents);
1618 controller->UpdateState(true, events.get()); 1623 controller->UpdateState(true, events.get());
1619 1624
(...skipping 18 matching lines...) Expand all
1638 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { 1643 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) {
1639 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 1644 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
1640 FakeLayerAnimationValueObserver dummy; 1645 FakeLayerAnimationValueObserver dummy;
1641 FakeInactiveLayerAnimationValueObserver pending_dummy; 1646 FakeInactiveLayerAnimationValueObserver pending_dummy;
1642 scoped_refptr<LayerAnimationController> controller( 1647 scoped_refptr<LayerAnimationController> controller(
1643 LayerAnimationController::Create(0)); 1648 LayerAnimationController::Create(0));
1644 1649
1645 const int id = 1; 1650 const int id = 1;
1646 controller->AddAnimation(CreateAnimation( 1651 controller->AddAnimation(CreateAnimation(
1647 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.5f, 1.f)), id, 1652 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.5f, 1.f)), id,
1648 Animation::OPACITY)); 1653 TargetProperty::OPACITY));
1649 1654
1650 // Without an observer, the animation shouldn't progress to the STARTING 1655 // Without an observer, the animation shouldn't progress to the STARTING
1651 // state. 1656 // state.
1652 controller->Animate(kInitialTickTime); 1657 controller->Animate(kInitialTickTime);
1653 controller->UpdateState(true, events.get()); 1658 controller->UpdateState(true, events.get());
1654 EXPECT_EQ(0u, events->events_.size()); 1659 EXPECT_EQ(0u, events->events_.size());
1655 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, 1660 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY,
1656 controller->GetAnimation(Animation::OPACITY)->run_state()); 1661 controller->GetAnimation(TargetProperty::OPACITY)->run_state());
1657 1662
1658 controller->AddValueObserver(&pending_dummy); 1663 controller->AddValueObserver(&pending_dummy);
1659 1664
1660 // With only a pending observer, the animation should progress to the 1665 // With only a pending observer, the animation should progress to the
1661 // STARTING state and get ticked at its starting point, but should not 1666 // STARTING state and get ticked at its starting point, but should not
1662 // progress to RUNNING. 1667 // progress to RUNNING.
1663 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 1668 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1664 controller->UpdateState(true, events.get()); 1669 controller->UpdateState(true, events.get());
1665 EXPECT_EQ(0u, events->events_.size()); 1670 EXPECT_EQ(0u, events->events_.size());
1666 EXPECT_EQ(Animation::STARTING, 1671 EXPECT_EQ(Animation::STARTING,
1667 controller->GetAnimation(Animation::OPACITY)->run_state()); 1672 controller->GetAnimation(TargetProperty::OPACITY)->run_state());
1668 EXPECT_EQ(0.5f, pending_dummy.opacity()); 1673 EXPECT_EQ(0.5f, pending_dummy.opacity());
1669 1674
1670 // Even when already in the STARTING state, the animation should stay 1675 // Even when already in the STARTING state, the animation should stay
1671 // there, and shouldn't be ticked past its starting point. 1676 // there, and shouldn't be ticked past its starting point.
1672 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 1677 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
1673 controller->UpdateState(true, events.get()); 1678 controller->UpdateState(true, events.get());
1674 EXPECT_EQ(0u, events->events_.size()); 1679 EXPECT_EQ(0u, events->events_.size());
1675 EXPECT_EQ(Animation::STARTING, 1680 EXPECT_EQ(Animation::STARTING,
1676 controller->GetAnimation(Animation::OPACITY)->run_state()); 1681 controller->GetAnimation(TargetProperty::OPACITY)->run_state());
1677 EXPECT_EQ(0.5f, pending_dummy.opacity()); 1682 EXPECT_EQ(0.5f, pending_dummy.opacity());
1678 1683
1679 controller->AddValueObserver(&dummy); 1684 controller->AddValueObserver(&dummy);
1680 1685
1681 // Now that an active observer has been added, the animation should still 1686 // Now that an active observer has been added, the animation should still
1682 // initially tick at its starting point, but should now progress to RUNNING. 1687 // initially tick at its starting point, but should now progress to RUNNING.
1683 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); 1688 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000));
1684 controller->UpdateState(true, events.get()); 1689 controller->UpdateState(true, events.get());
1685 EXPECT_EQ(1u, events->events_.size()); 1690 EXPECT_EQ(1u, events->events_.size());
1686 EXPECT_EQ(Animation::RUNNING, 1691 EXPECT_EQ(Animation::RUNNING,
1687 controller->GetAnimation(Animation::OPACITY)->run_state()); 1692 controller->GetAnimation(TargetProperty::OPACITY)->run_state());
1688 EXPECT_EQ(0.5f, pending_dummy.opacity()); 1693 EXPECT_EQ(0.5f, pending_dummy.opacity());
1689 EXPECT_EQ(0.5f, dummy.opacity()); 1694 EXPECT_EQ(0.5f, dummy.opacity());
1690 1695
1691 // The animation should now tick past its starting point. 1696 // The animation should now tick past its starting point.
1692 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3500)); 1697 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3500));
1693 EXPECT_NE(0.5f, pending_dummy.opacity()); 1698 EXPECT_NE(0.5f, pending_dummy.opacity());
1694 EXPECT_NE(0.5f, dummy.opacity()); 1699 EXPECT_NE(0.5f, dummy.opacity());
1695 } 1700 }
1696 1701
1697 TEST(LayerAnimationControllerTest, TransformAnimationBounds) { 1702 TEST(LayerAnimationControllerTest, TransformAnimationBounds) {
1698 scoped_refptr<LayerAnimationController> controller_impl( 1703 scoped_refptr<LayerAnimationController> controller_impl(
1699 LayerAnimationController::Create(0)); 1704 LayerAnimationController::Create(0));
1700 1705
1701 scoped_ptr<KeyframedTransformAnimationCurve> curve1( 1706 scoped_ptr<KeyframedTransformAnimationCurve> curve1(
1702 KeyframedTransformAnimationCurve::Create()); 1707 KeyframedTransformAnimationCurve::Create());
1703 1708
1704 TransformOperations operations1; 1709 TransformOperations operations1;
1705 curve1->AddKeyframe( 1710 curve1->AddKeyframe(
1706 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); 1711 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr));
1707 operations1.AppendTranslate(10.0, 15.0, 0.0); 1712 operations1.AppendTranslate(10.0, 15.0, 0.0);
1708 curve1->AddKeyframe(TransformKeyframe::Create( 1713 curve1->AddKeyframe(TransformKeyframe::Create(
1709 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); 1714 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr));
1710 1715
1711 scoped_ptr<Animation> animation( 1716 scoped_ptr<Animation> animation(
1712 Animation::Create(std::move(curve1), 1, 1, Animation::TRANSFORM)); 1717 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM));
1713 controller_impl->AddAnimation(std::move(animation)); 1718 controller_impl->AddAnimation(std::move(animation));
1714 1719
1715 scoped_ptr<KeyframedTransformAnimationCurve> curve2( 1720 scoped_ptr<KeyframedTransformAnimationCurve> curve2(
1716 KeyframedTransformAnimationCurve::Create()); 1721 KeyframedTransformAnimationCurve::Create());
1717 1722
1718 TransformOperations operations2; 1723 TransformOperations operations2;
1719 curve2->AddKeyframe( 1724 curve2->AddKeyframe(
1720 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); 1725 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr));
1721 operations2.AppendScale(2.0, 3.0, 4.0); 1726 operations2.AppendScale(2.0, 3.0, 4.0);
1722 curve2->AddKeyframe(TransformKeyframe::Create( 1727 curve2->AddKeyframe(TransformKeyframe::Create(
1723 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); 1728 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr));
1724 1729
1725 animation = Animation::Create(std::move(curve2), 2, 2, Animation::TRANSFORM); 1730 animation =
1731 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM);
1726 controller_impl->AddAnimation(std::move(animation)); 1732 controller_impl->AddAnimation(std::move(animation));
1727 1733
1728 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); 1734 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f);
1729 gfx::BoxF bounds; 1735 gfx::BoxF bounds;
1730 1736
1731 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); 1737 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds));
1732 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), 1738 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(),
1733 bounds.ToString()); 1739 bounds.ToString());
1734 1740
1735 controller_impl->GetAnimationById(1) 1741 controller_impl->GetAnimationById(1)
(...skipping 14 matching lines...) Expand all
1750 scoped_ptr<KeyframedTransformAnimationCurve> curve3( 1756 scoped_ptr<KeyframedTransformAnimationCurve> curve3(
1751 KeyframedTransformAnimationCurve::Create()); 1757 KeyframedTransformAnimationCurve::Create());
1752 TransformOperations operations3; 1758 TransformOperations operations3;
1753 gfx::Transform transform3; 1759 gfx::Transform transform3;
1754 transform3.Scale3d(1.0, 2.0, 3.0); 1760 transform3.Scale3d(1.0, 2.0, 3.0);
1755 curve3->AddKeyframe( 1761 curve3->AddKeyframe(
1756 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); 1762 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr));
1757 operations3.AppendMatrix(transform3); 1763 operations3.AppendMatrix(transform3);
1758 curve3->AddKeyframe(TransformKeyframe::Create( 1764 curve3->AddKeyframe(TransformKeyframe::Create(
1759 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); 1765 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr));
1760 animation = Animation::Create(std::move(curve3), 3, 3, Animation::TRANSFORM); 1766 animation =
1767 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM);
1761 controller_impl->AddAnimation(std::move(animation)); 1768 controller_impl->AddAnimation(std::move(animation));
1762 EXPECT_FALSE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); 1769 EXPECT_FALSE(controller_impl->TransformAnimationBoundsForBox(box, &bounds));
1763 } 1770 }
1764 1771
1765 // Tests that AbortAnimations aborts all animations targeting the specified 1772 // Tests that AbortAnimations aborts all animations targeting the specified
1766 // property. 1773 // property.
1767 TEST(LayerAnimationControllerTest, AbortAnimations) { 1774 TEST(LayerAnimationControllerTest, AbortAnimations) {
1768 FakeLayerAnimationValueObserver dummy; 1775 FakeLayerAnimationValueObserver dummy;
1769 scoped_refptr<LayerAnimationController> controller( 1776 scoped_refptr<LayerAnimationController> controller(
1770 LayerAnimationController::Create(0)); 1777 LayerAnimationController::Create(0));
1771 controller->AddValueObserver(&dummy); 1778 controller->AddValueObserver(&dummy);
1772 1779
1773 // Start with several animations, and allow some of them to reach the finished 1780 // Start with several animations, and allow some of them to reach the finished
1774 // state. 1781 // state.
1775 controller->AddAnimation(Animation::Create( 1782 controller->AddAnimation(Animation::Create(
1776 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 1, 1, 1783 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 1, 1,
1777 Animation::TRANSFORM)); 1784 TargetProperty::TRANSFORM));
1778 controller->AddAnimation(Animation::Create( 1785 controller->AddAnimation(Animation::Create(
1779 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2, 2, 1786 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2, 2,
1780 Animation::OPACITY)); 1787 TargetProperty::OPACITY));
1781 controller->AddAnimation(Animation::Create( 1788 controller->AddAnimation(Animation::Create(
1782 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 3, 3, 1789 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 3, 3,
1783 Animation::TRANSFORM)); 1790 TargetProperty::TRANSFORM));
1784 controller->AddAnimation(Animation::Create( 1791 controller->AddAnimation(Animation::Create(
1785 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)), 4, 4, 1792 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)), 4, 4,
1786 Animation::TRANSFORM)); 1793 TargetProperty::TRANSFORM));
1787 controller->AddAnimation(Animation::Create( 1794 controller->AddAnimation(Animation::Create(
1788 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 5, 5, 1795 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 5, 5,
1789 Animation::OPACITY)); 1796 TargetProperty::OPACITY));
1790 1797
1791 controller->Animate(kInitialTickTime); 1798 controller->Animate(kInitialTickTime);
1792 controller->UpdateState(true, nullptr); 1799 controller->UpdateState(true, nullptr);
1793 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); 1800 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000));
1794 controller->UpdateState(true, nullptr); 1801 controller->UpdateState(true, nullptr);
1795 1802
1796 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(1)->run_state()); 1803 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(1)->run_state());
1797 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(2)->run_state()); 1804 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(2)->run_state());
1798 EXPECT_EQ(Animation::RUNNING, controller->GetAnimationById(3)->run_state()); 1805 EXPECT_EQ(Animation::RUNNING, controller->GetAnimationById(3)->run_state());
1799 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, 1806 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY,
1800 controller->GetAnimationById(4)->run_state()); 1807 controller->GetAnimationById(4)->run_state());
1801 EXPECT_EQ(Animation::RUNNING, controller->GetAnimationById(5)->run_state()); 1808 EXPECT_EQ(Animation::RUNNING, controller->GetAnimationById(5)->run_state());
1802 1809
1803 controller->AbortAnimations(Animation::TRANSFORM); 1810 controller->AbortAnimations(TargetProperty::TRANSFORM);
1804 1811
1805 // Only un-finished TRANSFORM animations should have been aborted. 1812 // Only un-finished TRANSFORM animations should have been aborted.
1806 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(1)->run_state()); 1813 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(1)->run_state());
1807 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(2)->run_state()); 1814 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(2)->run_state());
1808 EXPECT_EQ(Animation::ABORTED, controller->GetAnimationById(3)->run_state()); 1815 EXPECT_EQ(Animation::ABORTED, controller->GetAnimationById(3)->run_state());
1809 EXPECT_EQ(Animation::ABORTED, controller->GetAnimationById(4)->run_state()); 1816 EXPECT_EQ(Animation::ABORTED, controller->GetAnimationById(4)->run_state());
1810 EXPECT_EQ(Animation::RUNNING, controller->GetAnimationById(5)->run_state()); 1817 EXPECT_EQ(Animation::RUNNING, controller->GetAnimationById(5)->run_state());
1811 } 1818 }
1812 1819
1813 // An animation aborted on the main thread should get deleted on both threads. 1820 // An animation aborted on the main thread should get deleted on both threads.
1814 TEST(LayerAnimationControllerTest, MainThreadAbortedAnimationGetsDeleted) { 1821 TEST(LayerAnimationControllerTest, MainThreadAbortedAnimationGetsDeleted) {
1815 FakeLayerAnimationValueObserver dummy_impl; 1822 FakeLayerAnimationValueObserver dummy_impl;
1816 scoped_refptr<LayerAnimationController> controller_impl( 1823 scoped_refptr<LayerAnimationController> controller_impl(
1817 LayerAnimationController::Create(0)); 1824 LayerAnimationController::Create(0));
1818 controller_impl->AddValueObserver(&dummy_impl); 1825 controller_impl->AddValueObserver(&dummy_impl);
1819 FakeLayerAnimationValueObserver dummy; 1826 FakeLayerAnimationValueObserver dummy;
1820 scoped_refptr<LayerAnimationController> controller( 1827 scoped_refptr<LayerAnimationController> controller(
1821 LayerAnimationController::Create(0)); 1828 LayerAnimationController::Create(0));
1822 controller->AddValueObserver(&dummy); 1829 controller->AddValueObserver(&dummy);
1823 1830
1824 int animation_id = 1831 int animation_id =
1825 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false); 1832 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false);
1826 1833
1827 controller->PushAnimationUpdatesTo(controller_impl.get()); 1834 controller->PushAnimationUpdatesTo(controller_impl.get());
1828 controller_impl->ActivateAnimations(); 1835 controller_impl->ActivateAnimations();
1829 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); 1836 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id));
1830 1837
1831 controller->AbortAnimations(Animation::OPACITY); 1838 controller->AbortAnimations(TargetProperty::OPACITY);
1832 EXPECT_EQ(Animation::ABORTED, 1839 EXPECT_EQ(Animation::ABORTED,
1833 controller->GetAnimation(Animation::OPACITY)->run_state()); 1840 controller->GetAnimation(TargetProperty::OPACITY)->run_state());
1834 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); 1841 EXPECT_FALSE(dummy.animation_waiting_for_deletion());
1835 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); 1842 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion());
1836 1843
1837 controller->Animate(kInitialTickTime); 1844 controller->Animate(kInitialTickTime);
1838 controller->UpdateState(true, nullptr); 1845 controller->UpdateState(true, nullptr);
1839 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); 1846 EXPECT_FALSE(dummy.animation_waiting_for_deletion());
1840 EXPECT_EQ(Animation::ABORTED, 1847 EXPECT_EQ(Animation::ABORTED,
1841 controller->GetAnimation(Animation::OPACITY)->run_state()); 1848 controller->GetAnimation(TargetProperty::OPACITY)->run_state());
1842 1849
1843 controller->PushAnimationUpdatesTo(controller_impl.get()); 1850 controller->PushAnimationUpdatesTo(controller_impl.get());
1844 EXPECT_FALSE(controller->GetAnimationById(animation_id)); 1851 EXPECT_FALSE(controller->GetAnimationById(animation_id));
1845 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id)); 1852 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id));
1846 } 1853 }
1847 1854
1848 // An animation aborted on the impl thread should get deleted on both threads. 1855 // An animation aborted on the impl thread should get deleted on both threads.
1849 TEST(LayerAnimationControllerTest, ImplThreadAbortedAnimationGetsDeleted) { 1856 TEST(LayerAnimationControllerTest, ImplThreadAbortedAnimationGetsDeleted) {
1850 FakeLayerAnimationValueObserver dummy_impl; 1857 FakeLayerAnimationValueObserver dummy_impl;
1851 scoped_refptr<LayerAnimationController> controller_impl( 1858 scoped_refptr<LayerAnimationController> controller_impl(
1852 LayerAnimationController::Create(0)); 1859 LayerAnimationController::Create(0));
1853 controller_impl->AddValueObserver(&dummy_impl); 1860 controller_impl->AddValueObserver(&dummy_impl);
1854 FakeLayerAnimationValueObserver dummy; 1861 FakeLayerAnimationValueObserver dummy;
1855 scoped_refptr<LayerAnimationController> controller( 1862 scoped_refptr<LayerAnimationController> controller(
1856 LayerAnimationController::Create(0)); 1863 LayerAnimationController::Create(0));
1857 controller->AddValueObserver(&dummy); 1864 controller->AddValueObserver(&dummy);
1858 FakeAnimationDelegate delegate; 1865 FakeAnimationDelegate delegate;
1859 controller->set_layer_animation_delegate(&delegate); 1866 controller->set_layer_animation_delegate(&delegate);
1860 1867
1861 int animation_id = 1868 int animation_id =
1862 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false); 1869 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false);
1863 1870
1864 controller->PushAnimationUpdatesTo(controller_impl.get()); 1871 controller->PushAnimationUpdatesTo(controller_impl.get());
1865 controller_impl->ActivateAnimations(); 1872 controller_impl->ActivateAnimations();
1866 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); 1873 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id));
1867 1874
1868 controller_impl->AbortAnimations(Animation::OPACITY); 1875 controller_impl->AbortAnimations(TargetProperty::OPACITY);
1869 EXPECT_EQ(Animation::ABORTED, 1876 EXPECT_EQ(
1870 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); 1877 Animation::ABORTED,
1878 controller_impl->GetAnimation(TargetProperty::OPACITY)->run_state());
1871 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); 1879 EXPECT_FALSE(dummy.animation_waiting_for_deletion());
1872 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); 1880 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion());
1873 1881
1874 AnimationEvents events; 1882 AnimationEvents events;
1875 controller_impl->Animate(kInitialTickTime); 1883 controller_impl->Animate(kInitialTickTime);
1876 controller_impl->UpdateState(true, &events); 1884 controller_impl->UpdateState(true, &events);
1877 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); 1885 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion());
1878 EXPECT_EQ(1u, events.events_.size()); 1886 EXPECT_EQ(1u, events.events_.size());
1879 EXPECT_EQ(AnimationEvent::ABORTED, events.events_[0].type); 1887 EXPECT_EQ(AnimationEvent::ABORTED, events.events_[0].type);
1880 EXPECT_EQ(Animation::WAITING_FOR_DELETION, 1888 EXPECT_EQ(
1881 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); 1889 Animation::WAITING_FOR_DELETION,
1890 controller_impl->GetAnimation(TargetProperty::OPACITY)->run_state());
1882 1891
1883 controller->NotifyAnimationAborted(events.events_[0]); 1892 controller->NotifyAnimationAborted(events.events_[0]);
1884 EXPECT_EQ(Animation::ABORTED, 1893 EXPECT_EQ(Animation::ABORTED,
1885 controller->GetAnimation(Animation::OPACITY)->run_state()); 1894 controller->GetAnimation(TargetProperty::OPACITY)->run_state());
1886 EXPECT_TRUE(delegate.aborted()); 1895 EXPECT_TRUE(delegate.aborted());
1887 1896
1888 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); 1897 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
1889 controller->UpdateState(true, nullptr); 1898 controller->UpdateState(true, nullptr);
1890 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); 1899 EXPECT_TRUE(dummy.animation_waiting_for_deletion());
1891 EXPECT_EQ(Animation::WAITING_FOR_DELETION, 1900 EXPECT_EQ(Animation::WAITING_FOR_DELETION,
1892 controller->GetAnimation(Animation::OPACITY)->run_state()); 1901 controller->GetAnimation(TargetProperty::OPACITY)->run_state());
1893 1902
1894 controller->PushAnimationUpdatesTo(controller_impl.get()); 1903 controller->PushAnimationUpdatesTo(controller_impl.get());
1895 controller_impl->ActivateAnimations(); 1904 controller_impl->ActivateAnimations();
1896 EXPECT_FALSE(controller->GetAnimationById(animation_id)); 1905 EXPECT_FALSE(controller->GetAnimationById(animation_id));
1897 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id)); 1906 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id));
1898 } 1907 }
1899 1908
1900 // Ensure that we only generate FINISHED events for animations in a group 1909 // Ensure that we only generate FINISHED events for animations in a group
1901 // once all animations in that group are finished. 1910 // once all animations in that group are finished.
1902 TEST(LayerAnimationControllerTest, FinishedEventsForGroup) { 1911 TEST(LayerAnimationControllerTest, FinishedEventsForGroup) {
1903 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 1912 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
1904 FakeLayerAnimationValueObserver dummy_impl; 1913 FakeLayerAnimationValueObserver dummy_impl;
1905 scoped_refptr<LayerAnimationController> controller_impl( 1914 scoped_refptr<LayerAnimationController> controller_impl(
1906 LayerAnimationController::Create(0)); 1915 LayerAnimationController::Create(0));
1907 controller_impl->AddValueObserver(&dummy_impl); 1916 controller_impl->AddValueObserver(&dummy_impl);
1908 1917
1909 const int group_id = 1; 1918 const int group_id = 1;
1910 1919
1911 // Add two animations with the same group id but different durations. 1920 // Add two animations with the same group id but different durations.
1912 scoped_ptr<Animation> first_animation(Animation::Create( 1921 scoped_ptr<Animation> first_animation(Animation::Create(
1913 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)), 1, group_id, 1922 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)), 1, group_id,
1914 Animation::TRANSFORM)); 1923 TargetProperty::TRANSFORM));
1915 first_animation->set_is_controlling_instance_for_test(true); 1924 first_animation->set_is_controlling_instance_for_test(true);
1916 controller_impl->AddAnimation(std::move(first_animation)); 1925 controller_impl->AddAnimation(std::move(first_animation));
1917 1926
1918 scoped_ptr<Animation> second_animation(Animation::Create( 1927 scoped_ptr<Animation> second_animation(Animation::Create(
1919 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2, 1928 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2,
1920 group_id, Animation::OPACITY)); 1929 group_id, TargetProperty::OPACITY));
1921 second_animation->set_is_controlling_instance_for_test(true); 1930 second_animation->set_is_controlling_instance_for_test(true);
1922 controller_impl->AddAnimation(std::move(second_animation)); 1931 controller_impl->AddAnimation(std::move(second_animation));
1923 1932
1924 controller_impl->Animate(kInitialTickTime); 1933 controller_impl->Animate(kInitialTickTime);
1925 controller_impl->UpdateState(true, events.get()); 1934 controller_impl->UpdateState(true, events.get());
1926 1935
1927 // Both animations should have started. 1936 // Both animations should have started.
1928 EXPECT_EQ(2u, events->events_.size()); 1937 EXPECT_EQ(2u, events->events_.size());
1929 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); 1938 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type);
1930 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); 1939 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type);
(...skipping 27 matching lines...) Expand all
1958 TEST(LayerAnimationControllerTest, FinishedAndAbortedEventsForGroup) { 1967 TEST(LayerAnimationControllerTest, FinishedAndAbortedEventsForGroup) {
1959 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); 1968 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents));
1960 FakeLayerAnimationValueObserver dummy_impl; 1969 FakeLayerAnimationValueObserver dummy_impl;
1961 scoped_refptr<LayerAnimationController> controller_impl( 1970 scoped_refptr<LayerAnimationController> controller_impl(
1962 LayerAnimationController::Create(0)); 1971 LayerAnimationController::Create(0));
1963 controller_impl->AddValueObserver(&dummy_impl); 1972 controller_impl->AddValueObserver(&dummy_impl);
1964 1973
1965 // Add two animations with the same group id. 1974 // Add two animations with the same group id.
1966 scoped_ptr<Animation> first_animation(CreateAnimation( 1975 scoped_ptr<Animation> first_animation(CreateAnimation(
1967 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 1, 1976 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 1,
1968 Animation::TRANSFORM)); 1977 TargetProperty::TRANSFORM));
1969 first_animation->set_is_controlling_instance_for_test(true); 1978 first_animation->set_is_controlling_instance_for_test(true);
1970 controller_impl->AddAnimation(std::move(first_animation)); 1979 controller_impl->AddAnimation(std::move(first_animation));
1971 1980
1972 scoped_ptr<Animation> second_animation(CreateAnimation( 1981 scoped_ptr<Animation> second_animation(CreateAnimation(
1973 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, 1982 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1,
1974 Animation::OPACITY)); 1983 TargetProperty::OPACITY));
1975 second_animation->set_is_controlling_instance_for_test(true); 1984 second_animation->set_is_controlling_instance_for_test(true);
1976 controller_impl->AddAnimation(std::move(second_animation)); 1985 controller_impl->AddAnimation(std::move(second_animation));
1977 1986
1978 controller_impl->Animate(kInitialTickTime); 1987 controller_impl->Animate(kInitialTickTime);
1979 controller_impl->UpdateState(true, events.get()); 1988 controller_impl->UpdateState(true, events.get());
1980 1989
1981 // Both animations should have started. 1990 // Both animations should have started.
1982 EXPECT_EQ(2u, events->events_.size()); 1991 EXPECT_EQ(2u, events->events_.size());
1983 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); 1992 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type);
1984 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); 1993 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type);
1985 1994
1986 controller_impl->AbortAnimations(Animation::OPACITY); 1995 controller_impl->AbortAnimations(TargetProperty::OPACITY);
1987 1996
1988 events.reset(new AnimationEvents); 1997 events.reset(new AnimationEvents);
1989 controller_impl->Animate(kInitialTickTime + 1998 controller_impl->Animate(kInitialTickTime +
1990 TimeDelta::FromMilliseconds(1000)); 1999 TimeDelta::FromMilliseconds(1000));
1991 controller_impl->UpdateState(true, events.get()); 2000 controller_impl->UpdateState(true, events.get());
1992 2001
1993 // We should have exactly 2 events: a FINISHED event for the tranform 2002 // We should have exactly 2 events: a FINISHED event for the tranform
1994 // animation, and an ABORTED event for the opacity animation. 2003 // animation, and an ABORTED event for the opacity animation.
1995 EXPECT_EQ(2u, events->events_.size()); 2004 EXPECT_EQ(2u, events->events_.size());
1996 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); 2005 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type);
1997 EXPECT_EQ(Animation::TRANSFORM, events->events_[0].target_property); 2006 EXPECT_EQ(TargetProperty::TRANSFORM, events->events_[0].target_property);
1998 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[1].type); 2007 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[1].type);
1999 EXPECT_EQ(Animation::OPACITY, events->events_[1].target_property); 2008 EXPECT_EQ(TargetProperty::OPACITY, events->events_[1].target_property);
2000 } 2009 }
2001 2010
2002 TEST(LayerAnimationControllerTest, HasAnimationThatAffectsScale) { 2011 TEST(LayerAnimationControllerTest, HasAnimationThatAffectsScale) {
2003 scoped_refptr<LayerAnimationController> controller_impl( 2012 scoped_refptr<LayerAnimationController> controller_impl(
2004 LayerAnimationController::Create(0)); 2013 LayerAnimationController::Create(0));
2005 2014
2006 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); 2015 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale());
2007 2016
2008 controller_impl->AddAnimation(CreateAnimation( 2017 controller_impl->AddAnimation(CreateAnimation(
2009 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, 2018 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1,
2010 Animation::OPACITY)); 2019 TargetProperty::OPACITY));
2011 2020
2012 // Opacity animations don't affect scale. 2021 // Opacity animations don't affect scale.
2013 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); 2022 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale());
2014 2023
2015 scoped_ptr<KeyframedTransformAnimationCurve> curve1( 2024 scoped_ptr<KeyframedTransformAnimationCurve> curve1(
2016 KeyframedTransformAnimationCurve::Create()); 2025 KeyframedTransformAnimationCurve::Create());
2017 2026
2018 TransformOperations operations1; 2027 TransformOperations operations1;
2019 curve1->AddKeyframe( 2028 curve1->AddKeyframe(
2020 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); 2029 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr));
2021 operations1.AppendTranslate(10.0, 15.0, 0.0); 2030 operations1.AppendTranslate(10.0, 15.0, 0.0);
2022 curve1->AddKeyframe(TransformKeyframe::Create( 2031 curve1->AddKeyframe(TransformKeyframe::Create(
2023 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); 2032 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr));
2024 2033
2025 scoped_ptr<Animation> animation( 2034 scoped_ptr<Animation> animation(
2026 Animation::Create(std::move(curve1), 2, 2, Animation::TRANSFORM)); 2035 Animation::Create(std::move(curve1), 2, 2, TargetProperty::TRANSFORM));
2027 controller_impl->AddAnimation(std::move(animation)); 2036 controller_impl->AddAnimation(std::move(animation));
2028 2037
2029 // Translations don't affect scale. 2038 // Translations don't affect scale.
2030 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); 2039 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale());
2031 2040
2032 scoped_ptr<KeyframedTransformAnimationCurve> curve2( 2041 scoped_ptr<KeyframedTransformAnimationCurve> curve2(
2033 KeyframedTransformAnimationCurve::Create()); 2042 KeyframedTransformAnimationCurve::Create());
2034 2043
2035 TransformOperations operations2; 2044 TransformOperations operations2;
2036 curve2->AddKeyframe( 2045 curve2->AddKeyframe(
2037 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); 2046 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr));
2038 operations2.AppendScale(2.0, 3.0, 4.0); 2047 operations2.AppendScale(2.0, 3.0, 4.0);
2039 curve2->AddKeyframe(TransformKeyframe::Create( 2048 curve2->AddKeyframe(TransformKeyframe::Create(
2040 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); 2049 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr));
2041 2050
2042 animation = Animation::Create(std::move(curve2), 3, 3, Animation::TRANSFORM); 2051 animation =
2052 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM);
2043 controller_impl->AddAnimation(std::move(animation)); 2053 controller_impl->AddAnimation(std::move(animation));
2044 2054
2045 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale()); 2055 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale());
2046 2056
2047 controller_impl->GetAnimationById(3) 2057 controller_impl->GetAnimationById(3)
2048 ->SetRunState(Animation::FINISHED, TicksFromSecondsF(0.0)); 2058 ->SetRunState(Animation::FINISHED, TicksFromSecondsF(0.0));
2049 2059
2050 // Only unfinished animations should be considered by 2060 // Only unfinished animations should be considered by
2051 // HasAnimationThatAffectsScale. 2061 // HasAnimationThatAffectsScale.
2052 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); 2062 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale());
2053 } 2063 }
2054 2064
2055 TEST(LayerAnimationControllerTest, HasOnlyTranslationTransforms) { 2065 TEST(LayerAnimationControllerTest, HasOnlyTranslationTransforms) {
2056 scoped_refptr<LayerAnimationController> controller_impl( 2066 scoped_refptr<LayerAnimationController> controller_impl(
2057 LayerAnimationController::Create(0)); 2067 LayerAnimationController::Create(0));
2058 2068
2059 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( 2069 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms(
2060 LayerAnimationController::ObserverType::ACTIVE)); 2070 LayerAnimationController::ObserverType::ACTIVE));
2061 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( 2071 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms(
2062 LayerAnimationController::ObserverType::PENDING)); 2072 LayerAnimationController::ObserverType::PENDING));
2063 2073
2064 controller_impl->AddAnimation(CreateAnimation( 2074 controller_impl->AddAnimation(CreateAnimation(
2065 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, 2075 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1,
2066 Animation::OPACITY)); 2076 TargetProperty::OPACITY));
2067 2077
2068 // Opacity animations aren't non-translation transforms. 2078 // Opacity animations aren't non-translation transforms.
2069 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( 2079 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms(
2070 LayerAnimationController::ObserverType::ACTIVE)); 2080 LayerAnimationController::ObserverType::ACTIVE));
2071 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( 2081 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms(
2072 LayerAnimationController::ObserverType::PENDING)); 2082 LayerAnimationController::ObserverType::PENDING));
2073 2083
2074 scoped_ptr<KeyframedTransformAnimationCurve> curve1( 2084 scoped_ptr<KeyframedTransformAnimationCurve> curve1(
2075 KeyframedTransformAnimationCurve::Create()); 2085 KeyframedTransformAnimationCurve::Create());
2076 2086
2077 TransformOperations operations1; 2087 TransformOperations operations1;
2078 curve1->AddKeyframe( 2088 curve1->AddKeyframe(
2079 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); 2089 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr));
2080 operations1.AppendTranslate(10.0, 15.0, 0.0); 2090 operations1.AppendTranslate(10.0, 15.0, 0.0);
2081 curve1->AddKeyframe(TransformKeyframe::Create( 2091 curve1->AddKeyframe(TransformKeyframe::Create(
2082 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); 2092 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr));
2083 2093
2084 scoped_ptr<Animation> animation( 2094 scoped_ptr<Animation> animation(
2085 Animation::Create(std::move(curve1), 2, 2, Animation::TRANSFORM)); 2095 Animation::Create(std::move(curve1), 2, 2, TargetProperty::TRANSFORM));
2086 controller_impl->AddAnimation(std::move(animation)); 2096 controller_impl->AddAnimation(std::move(animation));
2087 2097
2088 // The only transform animation we've added is a translation. 2098 // The only transform animation we've added is a translation.
2089 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( 2099 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms(
2090 LayerAnimationController::ObserverType::ACTIVE)); 2100 LayerAnimationController::ObserverType::ACTIVE));
2091 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( 2101 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms(
2092 LayerAnimationController::ObserverType::PENDING)); 2102 LayerAnimationController::ObserverType::PENDING));
2093 2103
2094 scoped_ptr<KeyframedTransformAnimationCurve> curve2( 2104 scoped_ptr<KeyframedTransformAnimationCurve> curve2(
2095 KeyframedTransformAnimationCurve::Create()); 2105 KeyframedTransformAnimationCurve::Create());
2096 2106
2097 TransformOperations operations2; 2107 TransformOperations operations2;
2098 curve2->AddKeyframe( 2108 curve2->AddKeyframe(
2099 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); 2109 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr));
2100 operations2.AppendScale(2.0, 3.0, 4.0); 2110 operations2.AppendScale(2.0, 3.0, 4.0);
2101 curve2->AddKeyframe(TransformKeyframe::Create( 2111 curve2->AddKeyframe(TransformKeyframe::Create(
2102 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); 2112 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr));
2103 2113
2104 animation = Animation::Create(std::move(curve2), 3, 3, Animation::TRANSFORM); 2114 animation =
2115 Animation::Create(std::move(curve2), 3, 3, TargetProperty::TRANSFORM);
2105 animation->set_affects_active_observers(false); 2116 animation->set_affects_active_observers(false);
2106 controller_impl->AddAnimation(std::move(animation)); 2117 controller_impl->AddAnimation(std::move(animation));
2107 2118
2108 // A scale animation is not a translation. 2119 // A scale animation is not a translation.
2109 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms( 2120 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms(
2110 LayerAnimationController::ObserverType::PENDING)); 2121 LayerAnimationController::ObserverType::PENDING));
2111 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( 2122 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms(
2112 LayerAnimationController::ObserverType::ACTIVE)); 2123 LayerAnimationController::ObserverType::ACTIVE));
2113 2124
2114 controller_impl->ActivateAnimations(); 2125 controller_impl->ActivateAnimations();
(...skipping 26 matching lines...) Expand all
2141 KeyframedTransformAnimationCurve::Create()); 2152 KeyframedTransformAnimationCurve::Create());
2142 2153
2143 TransformOperations operations1; 2154 TransformOperations operations1;
2144 operations1.AppendScale(2.0, 3.0, 4.0); 2155 operations1.AppendScale(2.0, 3.0, 4.0);
2145 curve1->AddKeyframe( 2156 curve1->AddKeyframe(
2146 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); 2157 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr));
2147 TransformOperations operations2; 2158 TransformOperations operations2;
2148 curve1->AddKeyframe(TransformKeyframe::Create( 2159 curve1->AddKeyframe(TransformKeyframe::Create(
2149 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); 2160 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr));
2150 scoped_ptr<Animation> animation( 2161 scoped_ptr<Animation> animation(
2151 Animation::Create(std::move(curve1), 1, 1, Animation::TRANSFORM)); 2162 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM));
2152 animation->set_affects_active_observers(false); 2163 animation->set_affects_active_observers(false);
2153 controller_impl->AddAnimation(std::move(animation)); 2164 controller_impl->AddAnimation(std::move(animation));
2154 2165
2155 float start_scale = 0.f; 2166 float start_scale = 0.f;
2156 EXPECT_TRUE(controller_impl->AnimationStartScale( 2167 EXPECT_TRUE(controller_impl->AnimationStartScale(
2157 LayerAnimationController::ObserverType::PENDING, &start_scale)); 2168 LayerAnimationController::ObserverType::PENDING, &start_scale));
2158 EXPECT_EQ(4.f, start_scale); 2169 EXPECT_EQ(4.f, start_scale);
2159 EXPECT_TRUE(controller_impl->AnimationStartScale( 2170 EXPECT_TRUE(controller_impl->AnimationStartScale(
2160 LayerAnimationController::ObserverType::ACTIVE, &start_scale)); 2171 LayerAnimationController::ObserverType::ACTIVE, &start_scale));
2161 EXPECT_EQ(0.f, start_scale); 2172 EXPECT_EQ(0.f, start_scale);
(...skipping 10 matching lines...) Expand all
2172 KeyframedTransformAnimationCurve::Create()); 2183 KeyframedTransformAnimationCurve::Create());
2173 2184
2174 TransformOperations operations3; 2185 TransformOperations operations3;
2175 curve2->AddKeyframe( 2186 curve2->AddKeyframe(
2176 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); 2187 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr));
2177 operations3.AppendScale(6.0, 5.0, 4.0); 2188 operations3.AppendScale(6.0, 5.0, 4.0);
2178 curve2->AddKeyframe(TransformKeyframe::Create( 2189 curve2->AddKeyframe(TransformKeyframe::Create(
2179 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); 2190 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr));
2180 2191
2181 controller_impl->RemoveAnimation(1); 2192 controller_impl->RemoveAnimation(1);
2182 animation = Animation::Create(std::move(curve2), 2, 2, Animation::TRANSFORM); 2193 animation =
2194 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM);
2183 2195
2184 // Reverse Direction 2196 // Reverse Direction
2185 animation->set_direction(Animation::DIRECTION_REVERSE); 2197 animation->set_direction(Animation::DIRECTION_REVERSE);
2186 animation->set_affects_active_observers(false); 2198 animation->set_affects_active_observers(false);
2187 controller_impl->AddAnimation(std::move(animation)); 2199 controller_impl->AddAnimation(std::move(animation));
2188 2200
2189 scoped_ptr<KeyframedTransformAnimationCurve> curve3( 2201 scoped_ptr<KeyframedTransformAnimationCurve> curve3(
2190 KeyframedTransformAnimationCurve::Create()); 2202 KeyframedTransformAnimationCurve::Create());
2191 2203
2192 TransformOperations operations4; 2204 TransformOperations operations4;
2193 operations4.AppendScale(5.0, 3.0, 1.0); 2205 operations4.AppendScale(5.0, 3.0, 1.0);
2194 curve3->AddKeyframe( 2206 curve3->AddKeyframe(
2195 TransformKeyframe::Create(base::TimeDelta(), operations4, nullptr)); 2207 TransformKeyframe::Create(base::TimeDelta(), operations4, nullptr));
2196 TransformOperations operations5; 2208 TransformOperations operations5;
2197 curve3->AddKeyframe(TransformKeyframe::Create( 2209 curve3->AddKeyframe(TransformKeyframe::Create(
2198 base::TimeDelta::FromSecondsD(1.0), operations5, nullptr)); 2210 base::TimeDelta::FromSecondsD(1.0), operations5, nullptr));
2199 2211
2200 animation = Animation::Create(std::move(curve3), 3, 3, Animation::TRANSFORM); 2212 animation =
2213 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM);
2201 animation->set_affects_active_observers(false); 2214 animation->set_affects_active_observers(false);
2202 controller_impl->AddAnimation(std::move(animation)); 2215 controller_impl->AddAnimation(std::move(animation));
2203 2216
2204 EXPECT_TRUE(controller_impl->AnimationStartScale( 2217 EXPECT_TRUE(controller_impl->AnimationStartScale(
2205 LayerAnimationController::ObserverType::PENDING, &start_scale)); 2218 LayerAnimationController::ObserverType::PENDING, &start_scale));
2206 EXPECT_EQ(6.f, start_scale); 2219 EXPECT_EQ(6.f, start_scale);
2207 EXPECT_TRUE(controller_impl->AnimationStartScale( 2220 EXPECT_TRUE(controller_impl->AnimationStartScale(
2208 LayerAnimationController::ObserverType::ACTIVE, &start_scale)); 2221 LayerAnimationController::ObserverType::ACTIVE, &start_scale));
2209 EXPECT_EQ(0.f, start_scale); 2222 EXPECT_EQ(0.f, start_scale);
2210 2223
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 KeyframedTransformAnimationCurve::Create()); 2258 KeyframedTransformAnimationCurve::Create());
2246 2259
2247 TransformOperations operations1; 2260 TransformOperations operations1;
2248 curve1->AddKeyframe( 2261 curve1->AddKeyframe(
2249 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); 2262 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr));
2250 operations1.AppendScale(2.0, 3.0, 4.0); 2263 operations1.AppendScale(2.0, 3.0, 4.0);
2251 curve1->AddKeyframe(TransformKeyframe::Create( 2264 curve1->AddKeyframe(TransformKeyframe::Create(
2252 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); 2265 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr));
2253 2266
2254 scoped_ptr<Animation> animation( 2267 scoped_ptr<Animation> animation(
2255 Animation::Create(std::move(curve1), 1, 1, Animation::TRANSFORM)); 2268 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM));
2256 animation->set_affects_active_observers(false); 2269 animation->set_affects_active_observers(false);
2257 controller_impl->AddAnimation(std::move(animation)); 2270 controller_impl->AddAnimation(std::move(animation));
2258 2271
2259 EXPECT_TRUE(controller_impl->MaximumTargetScale( 2272 EXPECT_TRUE(controller_impl->MaximumTargetScale(
2260 LayerAnimationController::ObserverType::PENDING, &max_scale)); 2273 LayerAnimationController::ObserverType::PENDING, &max_scale));
2261 EXPECT_EQ(4.f, max_scale); 2274 EXPECT_EQ(4.f, max_scale);
2262 EXPECT_TRUE(controller_impl->MaximumTargetScale( 2275 EXPECT_TRUE(controller_impl->MaximumTargetScale(
2263 LayerAnimationController::ObserverType::ACTIVE, &max_scale)); 2276 LayerAnimationController::ObserverType::ACTIVE, &max_scale));
2264 EXPECT_EQ(0.f, max_scale); 2277 EXPECT_EQ(0.f, max_scale);
2265 2278
2266 controller_impl->ActivateAnimations(); 2279 controller_impl->ActivateAnimations();
2267 EXPECT_TRUE(controller_impl->MaximumTargetScale( 2280 EXPECT_TRUE(controller_impl->MaximumTargetScale(
2268 LayerAnimationController::ObserverType::PENDING, &max_scale)); 2281 LayerAnimationController::ObserverType::PENDING, &max_scale));
2269 EXPECT_EQ(4.f, max_scale); 2282 EXPECT_EQ(4.f, max_scale);
2270 EXPECT_TRUE(controller_impl->MaximumTargetScale( 2283 EXPECT_TRUE(controller_impl->MaximumTargetScale(
2271 LayerAnimationController::ObserverType::ACTIVE, &max_scale)); 2284 LayerAnimationController::ObserverType::ACTIVE, &max_scale));
2272 EXPECT_EQ(4.f, max_scale); 2285 EXPECT_EQ(4.f, max_scale);
2273 2286
2274 scoped_ptr<KeyframedTransformAnimationCurve> curve2( 2287 scoped_ptr<KeyframedTransformAnimationCurve> curve2(
2275 KeyframedTransformAnimationCurve::Create()); 2288 KeyframedTransformAnimationCurve::Create());
2276 2289
2277 TransformOperations operations2; 2290 TransformOperations operations2;
2278 curve2->AddKeyframe( 2291 curve2->AddKeyframe(
2279 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); 2292 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr));
2280 operations2.AppendScale(6.0, 5.0, 4.0); 2293 operations2.AppendScale(6.0, 5.0, 4.0);
2281 curve2->AddKeyframe(TransformKeyframe::Create( 2294 curve2->AddKeyframe(TransformKeyframe::Create(
2282 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); 2295 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr));
2283 2296
2284 animation = Animation::Create(std::move(curve2), 2, 2, Animation::TRANSFORM); 2297 animation =
2298 Animation::Create(std::move(curve2), 2, 2, TargetProperty::TRANSFORM);
2285 animation->set_affects_active_observers(false); 2299 animation->set_affects_active_observers(false);
2286 controller_impl->AddAnimation(std::move(animation)); 2300 controller_impl->AddAnimation(std::move(animation));
2287 2301
2288 EXPECT_TRUE(controller_impl->MaximumTargetScale( 2302 EXPECT_TRUE(controller_impl->MaximumTargetScale(
2289 LayerAnimationController::ObserverType::PENDING, &max_scale)); 2303 LayerAnimationController::ObserverType::PENDING, &max_scale));
2290 EXPECT_EQ(6.f, max_scale); 2304 EXPECT_EQ(6.f, max_scale);
2291 EXPECT_TRUE(controller_impl->MaximumTargetScale( 2305 EXPECT_TRUE(controller_impl->MaximumTargetScale(
2292 LayerAnimationController::ObserverType::ACTIVE, &max_scale)); 2306 LayerAnimationController::ObserverType::ACTIVE, &max_scale));
2293 EXPECT_EQ(4.f, max_scale); 2307 EXPECT_EQ(4.f, max_scale);
2294 2308
2295 controller_impl->ActivateAnimations(); 2309 controller_impl->ActivateAnimations();
2296 EXPECT_TRUE(controller_impl->MaximumTargetScale( 2310 EXPECT_TRUE(controller_impl->MaximumTargetScale(
2297 LayerAnimationController::ObserverType::PENDING, &max_scale)); 2311 LayerAnimationController::ObserverType::PENDING, &max_scale));
2298 EXPECT_EQ(6.f, max_scale); 2312 EXPECT_EQ(6.f, max_scale);
2299 EXPECT_TRUE(controller_impl->MaximumTargetScale( 2313 EXPECT_TRUE(controller_impl->MaximumTargetScale(
2300 LayerAnimationController::ObserverType::ACTIVE, &max_scale)); 2314 LayerAnimationController::ObserverType::ACTIVE, &max_scale));
2301 EXPECT_EQ(6.f, max_scale); 2315 EXPECT_EQ(6.f, max_scale);
2302 2316
2303 scoped_ptr<KeyframedTransformAnimationCurve> curve3( 2317 scoped_ptr<KeyframedTransformAnimationCurve> curve3(
2304 KeyframedTransformAnimationCurve::Create()); 2318 KeyframedTransformAnimationCurve::Create());
2305 2319
2306 TransformOperations operations3; 2320 TransformOperations operations3;
2307 curve3->AddKeyframe( 2321 curve3->AddKeyframe(
2308 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); 2322 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr));
2309 operations3.AppendPerspective(6.0); 2323 operations3.AppendPerspective(6.0);
2310 curve3->AddKeyframe(TransformKeyframe::Create( 2324 curve3->AddKeyframe(TransformKeyframe::Create(
2311 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); 2325 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr));
2312 2326
2313 animation = Animation::Create(std::move(curve3), 3, 3, Animation::TRANSFORM); 2327 animation =
2328 Animation::Create(std::move(curve3), 3, 3, TargetProperty::TRANSFORM);
2314 animation->set_affects_active_observers(false); 2329 animation->set_affects_active_observers(false);
2315 controller_impl->AddAnimation(std::move(animation)); 2330 controller_impl->AddAnimation(std::move(animation));
2316 2331
2317 EXPECT_FALSE(controller_impl->MaximumTargetScale( 2332 EXPECT_FALSE(controller_impl->MaximumTargetScale(
2318 LayerAnimationController::ObserverType::PENDING, &max_scale)); 2333 LayerAnimationController::ObserverType::PENDING, &max_scale));
2319 EXPECT_TRUE(controller_impl->MaximumTargetScale( 2334 EXPECT_TRUE(controller_impl->MaximumTargetScale(
2320 LayerAnimationController::ObserverType::ACTIVE, &max_scale)); 2335 LayerAnimationController::ObserverType::ACTIVE, &max_scale));
2321 EXPECT_EQ(6.f, max_scale); 2336 EXPECT_EQ(6.f, max_scale);
2322 2337
2323 controller_impl->ActivateAnimations(); 2338 controller_impl->ActivateAnimations();
(...skipping 26 matching lines...) Expand all
2350 TransformOperations operations1; 2365 TransformOperations operations1;
2351 operations1.AppendScale(1.0, 2.0, 3.0); 2366 operations1.AppendScale(1.0, 2.0, 3.0);
2352 curve1->AddKeyframe( 2367 curve1->AddKeyframe(
2353 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); 2368 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr));
2354 TransformOperations operations2; 2369 TransformOperations operations2;
2355 operations2.AppendScale(4.0, 5.0, 6.0); 2370 operations2.AppendScale(4.0, 5.0, 6.0);
2356 curve1->AddKeyframe(TransformKeyframe::Create( 2371 curve1->AddKeyframe(TransformKeyframe::Create(
2357 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); 2372 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr));
2358 2373
2359 scoped_ptr<Animation> animation_owned( 2374 scoped_ptr<Animation> animation_owned(
2360 Animation::Create(std::move(curve1), 1, 1, Animation::TRANSFORM)); 2375 Animation::Create(std::move(curve1), 1, 1, TargetProperty::TRANSFORM));
2361 Animation* animation = animation_owned.get(); 2376 Animation* animation = animation_owned.get();
2362 controller_impl->AddAnimation(std::move(animation_owned)); 2377 controller_impl->AddAnimation(std::move(animation_owned));
2363 2378
2364 float max_scale = 0.f; 2379 float max_scale = 0.f;
2365 2380
2366 EXPECT_GT(animation->playback_rate(), 0.0); 2381 EXPECT_GT(animation->playback_rate(), 0.0);
2367 2382
2368 // NORMAL direction with positive playback rate. 2383 // NORMAL direction with positive playback rate.
2369 animation->set_direction(Animation::DIRECTION_NORMAL); 2384 animation->set_direction(Animation::DIRECTION_NORMAL);
2370 EXPECT_TRUE(controller_impl->MaximumTargetScale( 2385 EXPECT_TRUE(controller_impl->MaximumTargetScale(
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2654 EXPECT_TRUE(pending_dummy_impl.transform_is_animating()); 2669 EXPECT_TRUE(pending_dummy_impl.transform_is_animating());
2655 EXPECT_TRUE(active_dummy_impl.transform_is_animating()); 2670 EXPECT_TRUE(active_dummy_impl.transform_is_animating());
2656 2671
2657 controller_impl->Animate(kInitialTickTime + 2672 controller_impl->Animate(kInitialTickTime +
2658 TimeDelta::FromMilliseconds(3000)); 2673 TimeDelta::FromMilliseconds(3000));
2659 controller_impl->UpdateState(true, &events); 2674 controller_impl->UpdateState(true, &events);
2660 2675
2661 controller->NotifyAnimationStarted(events.events_[0]); 2676 controller->NotifyAnimationStarted(events.events_[0]);
2662 events.events_.clear(); 2677 events.events_.clear();
2663 2678
2664 controller_impl->AbortAnimations(Animation::TRANSFORM); 2679 controller_impl->AbortAnimations(TargetProperty::TRANSFORM);
2665 EXPECT_FALSE(pending_dummy_impl.transform_is_animating()); 2680 EXPECT_FALSE(pending_dummy_impl.transform_is_animating());
2666 EXPECT_FALSE(active_dummy_impl.transform_is_animating()); 2681 EXPECT_FALSE(active_dummy_impl.transform_is_animating());
2667 2682
2668 controller_impl->Animate(kInitialTickTime + 2683 controller_impl->Animate(kInitialTickTime +
2669 TimeDelta::FromMilliseconds(4000)); 2684 TimeDelta::FromMilliseconds(4000));
2670 controller_impl->UpdateState(true, &events); 2685 controller_impl->UpdateState(true, &events);
2671 2686
2672 controller->NotifyAnimationAborted(events.events_[0]); 2687 controller->NotifyAnimationAborted(events.events_[0]);
2673 EXPECT_FALSE(dummy.transform_is_animating()); 2688 EXPECT_FALSE(dummy.transform_is_animating());
2674 } 2689 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2730 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); 2745 EXPECT_EQ(0.5f, pending_dummy_impl.opacity());
2731 EXPECT_EQ(0.5f, dummy_impl.opacity()); 2746 EXPECT_EQ(0.5f, dummy_impl.opacity());
2732 2747
2733 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) 2748 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)
2734 ->affects_pending_observers()); 2749 ->affects_pending_observers());
2735 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) 2750 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)
2736 ->affects_active_observers()); 2751 ->affects_active_observers());
2737 2752
2738 // Delete the animation on the main-thread controller. 2753 // Delete the animation on the main-thread controller.
2739 controller->RemoveAnimation( 2754 controller->RemoveAnimation(
2740 controller->GetAnimation(Animation::OPACITY)->id()); 2755 controller->GetAnimation(TargetProperty::OPACITY)->id());
2741 controller->PushAnimationUpdatesTo(controller_impl.get()); 2756 controller->PushAnimationUpdatesTo(controller_impl.get());
2742 2757
2743 // The animation should no longer affect pending observers. 2758 // The animation should no longer affect pending observers.
2744 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id) 2759 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id)
2745 ->affects_pending_observers()); 2760 ->affects_pending_observers());
2746 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) 2761 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)
2747 ->affects_active_observers()); 2762 ->affects_active_observers());
2748 2763
2749 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); 2764 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500));
2750 controller_impl->UpdateState(true, events.get()); 2765 controller_impl->UpdateState(true, events.get());
(...skipping 27 matching lines...) Expand all
2778 AddOpacityTransitionToController(controller.get(), 1, 0.f, 1.f, true); 2793 AddOpacityTransitionToController(controller.get(), 1, 0.f, 1.f, true);
2779 2794
2780 controller->PushAnimationUpdatesTo(controller_impl.get()); 2795 controller->PushAnimationUpdatesTo(controller_impl.get());
2781 controller_impl->ActivateAnimations(); 2796 controller_impl->ActivateAnimations();
2782 controller_impl->Animate(kInitialTickTime); 2797 controller_impl->Animate(kInitialTickTime);
2783 controller_impl->UpdateState(true, events.get()); 2798 controller_impl->UpdateState(true, events.get());
2784 2799
2785 // Remove the first animation from the main-thread controller, and add a 2800 // Remove the first animation from the main-thread controller, and add a
2786 // new animation affecting the same property. 2801 // new animation affecting the same property.
2787 controller->RemoveAnimation( 2802 controller->RemoveAnimation(
2788 controller->GetAnimation(Animation::OPACITY)->id()); 2803 controller->GetAnimation(TargetProperty::OPACITY)->id());
2789 int second_animation_id = 2804 int second_animation_id =
2790 AddOpacityTransitionToController(controller.get(), 1, 1.f, 0.5f, true); 2805 AddOpacityTransitionToController(controller.get(), 1, 1.f, 0.5f, true);
2791 controller->PushAnimationUpdatesTo(controller_impl.get()); 2806 controller->PushAnimationUpdatesTo(controller_impl.get());
2792 2807
2793 // The original animation should only affect active observers, and the new 2808 // The original animation should only affect active observers, and the new
2794 // animation should only affect pending observers. 2809 // animation should only affect pending observers.
2795 EXPECT_FALSE(controller_impl->GetAnimationById(first_animation_id) 2810 EXPECT_FALSE(controller_impl->GetAnimationById(first_animation_id)
2796 ->affects_pending_observers()); 2811 ->affects_pending_observers());
2797 EXPECT_TRUE(controller_impl->GetAnimationById(first_animation_id) 2812 EXPECT_TRUE(controller_impl->GetAnimationById(first_animation_id)
2798 ->affects_active_observers()); 2813 ->affects_active_observers());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2842 2857
2843 TEST(LayerAnimationControllerTest, TestIsCurrentlyAnimatingProperty) { 2858 TEST(LayerAnimationControllerTest, TestIsCurrentlyAnimatingProperty) {
2844 FakeLayerAnimationValueObserver dummy; 2859 FakeLayerAnimationValueObserver dummy;
2845 scoped_refptr<LayerAnimationController> controller( 2860 scoped_refptr<LayerAnimationController> controller(
2846 LayerAnimationController::Create(0)); 2861 LayerAnimationController::Create(0));
2847 controller->AddValueObserver(&dummy); 2862 controller->AddValueObserver(&dummy);
2848 2863
2849 // Create an animation that initially affects only pending observers. 2864 // Create an animation that initially affects only pending observers.
2850 scoped_ptr<Animation> animation(CreateAnimation( 2865 scoped_ptr<Animation> animation(CreateAnimation(
2851 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, 2866 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1,
2852 Animation::OPACITY)); 2867 TargetProperty::OPACITY));
2853 animation->set_affects_active_observers(false); 2868 animation->set_affects_active_observers(false);
2854 2869
2855 controller->AddAnimation(std::move(animation)); 2870 controller->AddAnimation(std::move(animation));
2856 controller->Animate(kInitialTickTime); 2871 controller->Animate(kInitialTickTime);
2857 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( 2872 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty(
2858 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); 2873 TargetProperty::OPACITY,
2874 LayerAnimationController::ObserverType::PENDING));
2859 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2875 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2860 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); 2876 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE));
2861 controller->UpdateState(true, nullptr); 2877 controller->UpdateState(true, nullptr);
2862 EXPECT_TRUE(controller->HasActiveAnimation()); 2878 EXPECT_TRUE(controller->HasActiveAnimation());
2863 2879
2864 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( 2880 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty(
2865 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); 2881 TargetProperty::OPACITY,
2882 LayerAnimationController::ObserverType::PENDING));
2866 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2883 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2867 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); 2884 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE));
2868 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2885 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2869 Animation::FILTER, LayerAnimationController::ObserverType::PENDING)); 2886 TargetProperty::FILTER, LayerAnimationController::ObserverType::PENDING));
2870 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2887 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2871 Animation::FILTER, LayerAnimationController::ObserverType::ACTIVE)); 2888 TargetProperty::FILTER, LayerAnimationController::ObserverType::ACTIVE));
2872 2889
2873 controller->ActivateAnimations(); 2890 controller->ActivateAnimations();
2874 2891
2875 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( 2892 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty(
2876 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); 2893 TargetProperty::OPACITY,
2894 LayerAnimationController::ObserverType::PENDING));
2877 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( 2895 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty(
2878 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); 2896 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE));
2879 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2897 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2880 Animation::FILTER, LayerAnimationController::ObserverType::PENDING)); 2898 TargetProperty::FILTER, LayerAnimationController::ObserverType::PENDING));
2881 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2899 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2882 Animation::FILTER, LayerAnimationController::ObserverType::ACTIVE)); 2900 TargetProperty::FILTER, LayerAnimationController::ObserverType::ACTIVE));
2883 2901
2884 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(10)); 2902 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(10));
2885 controller->UpdateState(true, nullptr); 2903 controller->UpdateState(true, nullptr);
2886 2904
2887 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( 2905 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty(
2888 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); 2906 TargetProperty::OPACITY,
2907 LayerAnimationController::ObserverType::PENDING));
2889 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( 2908 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty(
2890 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); 2909 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE));
2891 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2910 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2892 Animation::FILTER, LayerAnimationController::ObserverType::PENDING)); 2911 TargetProperty::FILTER, LayerAnimationController::ObserverType::PENDING));
2893 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2912 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2894 Animation::FILTER, LayerAnimationController::ObserverType::ACTIVE)); 2913 TargetProperty::FILTER, LayerAnimationController::ObserverType::ACTIVE));
2895 2914
2896 EXPECT_EQ(0.f, dummy.opacity()); 2915 EXPECT_EQ(0.f, dummy.opacity());
2897 2916
2898 // Tick past the end of the animation. 2917 // Tick past the end of the animation.
2899 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1100)); 2918 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1100));
2900 controller->UpdateState(true, nullptr); 2919 controller->UpdateState(true, nullptr);
2901 2920
2902 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2921 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2903 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); 2922 TargetProperty::OPACITY,
2923 LayerAnimationController::ObserverType::PENDING));
2904 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2924 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2905 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); 2925 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE));
2906 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2926 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2907 Animation::FILTER, LayerAnimationController::ObserverType::PENDING)); 2927 TargetProperty::FILTER, LayerAnimationController::ObserverType::PENDING));
2908 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2928 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2909 Animation::FILTER, LayerAnimationController::ObserverType::ACTIVE)); 2929 TargetProperty::FILTER, LayerAnimationController::ObserverType::ACTIVE));
2910 2930
2911 EXPECT_EQ(1.f, dummy.opacity()); 2931 EXPECT_EQ(1.f, dummy.opacity());
2912 } 2932 }
2913 2933
2914 TEST(LayerAnimationControllerTest, TestIsAnimatingPropertyTimeOffsetFillMode) { 2934 TEST(LayerAnimationControllerTest, TestIsAnimatingPropertyTimeOffsetFillMode) {
2915 FakeLayerAnimationValueObserver dummy; 2935 FakeLayerAnimationValueObserver dummy;
2916 scoped_refptr<LayerAnimationController> controller( 2936 scoped_refptr<LayerAnimationController> controller(
2917 LayerAnimationController::Create(0)); 2937 LayerAnimationController::Create(0));
2918 controller->AddValueObserver(&dummy); 2938 controller->AddValueObserver(&dummy);
2919 2939
2920 // Create an animation that initially affects only pending observers, and has 2940 // Create an animation that initially affects only pending observers, and has
2921 // a start delay of 2 seconds. 2941 // a start delay of 2 seconds.
2922 scoped_ptr<Animation> animation(CreateAnimation( 2942 scoped_ptr<Animation> animation(CreateAnimation(
2923 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, 2943 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1,
2924 Animation::OPACITY)); 2944 TargetProperty::OPACITY));
2925 animation->set_fill_mode(Animation::FILL_MODE_NONE); 2945 animation->set_fill_mode(Animation::FILL_MODE_NONE);
2926 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000)); 2946 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000));
2927 animation->set_affects_active_observers(false); 2947 animation->set_affects_active_observers(false);
2928 2948
2929 controller->AddAnimation(std::move(animation)); 2949 controller->AddAnimation(std::move(animation));
2930 2950
2931 controller->Animate(kInitialTickTime); 2951 controller->Animate(kInitialTickTime);
2932 2952
2933 // Since the animation has a start delay, the observers it affects have a 2953 // Since the animation has a start delay, the observers it affects have a
2934 // potentially running transform animation but aren't currently animating 2954 // potentially running transform animation but aren't currently animating
2935 // transform. 2955 // transform.
2936 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty( 2956 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty(
2937 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); 2957 TargetProperty::OPACITY,
2958 LayerAnimationController::ObserverType::PENDING));
2938 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( 2959 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty(
2939 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); 2960 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE));
2940 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2961 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2941 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); 2962 TargetProperty::OPACITY,
2963 LayerAnimationController::ObserverType::PENDING));
2942 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2964 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2943 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); 2965 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE));
2944 EXPECT_TRUE(controller->HasActiveAnimation()); 2966 EXPECT_TRUE(controller->HasActiveAnimation());
2945 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( 2967 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty(
2946 Animation::FILTER, LayerAnimationController::ObserverType::PENDING)); 2968 TargetProperty::FILTER, LayerAnimationController::ObserverType::PENDING));
2947 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( 2969 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty(
2948 Animation::FILTER, LayerAnimationController::ObserverType::ACTIVE)); 2970 TargetProperty::FILTER, LayerAnimationController::ObserverType::ACTIVE));
2949 2971
2950 controller->ActivateAnimations(); 2972 controller->ActivateAnimations();
2951 2973
2952 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty( 2974 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty(
2953 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); 2975 TargetProperty::OPACITY,
2976 LayerAnimationController::ObserverType::PENDING));
2954 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty( 2977 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty(
2955 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); 2978 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE));
2956 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2979 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2957 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); 2980 TargetProperty::OPACITY,
2981 LayerAnimationController::ObserverType::PENDING));
2958 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 2982 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2959 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); 2983 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE));
2960 EXPECT_TRUE(controller->HasActiveAnimation()); 2984 EXPECT_TRUE(controller->HasActiveAnimation());
2961 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( 2985 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty(
2962 Animation::FILTER, LayerAnimationController::ObserverType::PENDING)); 2986 TargetProperty::FILTER, LayerAnimationController::ObserverType::PENDING));
2963 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( 2987 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty(
2964 Animation::FILTER, LayerAnimationController::ObserverType::ACTIVE)); 2988 TargetProperty::FILTER, LayerAnimationController::ObserverType::ACTIVE));
2965 2989
2966 controller->UpdateState(true, nullptr); 2990 controller->UpdateState(true, nullptr);
2967 2991
2968 // Tick past the start delay. 2992 // Tick past the start delay.
2969 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 2993 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
2970 controller->UpdateState(true, nullptr); 2994 controller->UpdateState(true, nullptr);
2971 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty( 2995 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty(
2972 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); 2996 TargetProperty::OPACITY,
2997 LayerAnimationController::ObserverType::PENDING));
2973 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty( 2998 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty(
2974 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); 2999 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE));
2975 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( 3000 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty(
2976 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); 3001 TargetProperty::OPACITY,
3002 LayerAnimationController::ObserverType::PENDING));
2977 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( 3003 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty(
2978 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); 3004 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE));
2979 3005
2980 // After the animaton finishes, the observers it affects have neither a 3006 // After the animaton finishes, the observers it affects have neither a
2981 // potentially running transform animation nor a currently running transform 3007 // potentially running transform animation nor a currently running transform
2982 // animation. 3008 // animation.
2983 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); 3009 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000));
2984 controller->UpdateState(true, nullptr); 3010 controller->UpdateState(true, nullptr);
2985 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( 3011 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty(
2986 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); 3012 TargetProperty::OPACITY,
3013 LayerAnimationController::ObserverType::PENDING));
2987 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( 3014 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty(
2988 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); 3015 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE));
2989 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 3016 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2990 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); 3017 TargetProperty::OPACITY,
3018 LayerAnimationController::ObserverType::PENDING));
2991 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( 3019 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty(
2992 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); 3020 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE));
2993 } 3021 }
2994 3022
2995 } // namespace 3023 } // namespace
2996 } // namespace cc 3024 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/layer_animation_controller.cc ('k') | cc/animation/target_property.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698