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

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

Issue 13465014: LayerTreeHost::SetAnimationEvents should use AnimationRegistrar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/animation/layer_animation_controller.h" 5 #include "cc/animation/layer_animation_controller.h"
6 6
7 #include "cc/animation/animation.h" 7 #include "cc/animation/animation.h"
8 #include "cc/animation/animation_curve.h" 8 #include "cc/animation/animation_curve.h"
9 #include "cc/animation/keyframed_animation_curve.h" 9 #include "cc/animation/keyframed_animation_curve.h"
10 #include "cc/animation/transform_operations.h" 10 #include "cc/animation/transform_operations.h"
(...skipping 11 matching lines...) Expand all
22 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve, 22 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve,
23 int id, 23 int id,
24 Animation::TargetProperty property) { 24 Animation::TargetProperty property) {
25 return Animation::Create(curve.Pass(), 0, id, property); 25 return Animation::Create(curve.Pass(), 0, id, property);
26 } 26 }
27 27
28 TEST(LayerAnimationControllerTest, SyncNewAnimation) { 28 TEST(LayerAnimationControllerTest, SyncNewAnimation) {
29 FakeLayerAnimationValueObserver dummy_impl; 29 FakeLayerAnimationValueObserver dummy_impl;
30 scoped_refptr<LayerAnimationController> controller_impl( 30 scoped_refptr<LayerAnimationController> controller_impl(
31 LayerAnimationController::Create(0)); 31 LayerAnimationController::Create(0));
32 controller_impl->AddObserver(&dummy_impl); 32 controller_impl->AddValueObserver(&dummy_impl);
33 FakeLayerAnimationValueObserver dummy; 33 FakeLayerAnimationValueObserver dummy;
34 scoped_refptr<LayerAnimationController> controller( 34 scoped_refptr<LayerAnimationController> controller(
35 LayerAnimationController::Create(0)); 35 LayerAnimationController::Create(0));
36 controller->AddObserver(&dummy); 36 controller->AddValueObserver(&dummy);
37 37
38 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); 38 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity));
39 39
40 AddOpacityTransitionToController(controller, 1, 0, 1, false); 40 AddOpacityTransitionToController(controller, 1, 0, 1, false);
41 41
42 controller->PushAnimationUpdatesTo(controller_impl.get()); 42 controller->PushAnimationUpdatesTo(controller_impl.get());
43 43
44 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); 44 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity));
45 EXPECT_EQ(Animation::WaitingForTargetAvailability, 45 EXPECT_EQ(Animation::WaitingForTargetAvailability,
46 controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); 46 controller_impl->GetAnimation(0, Animation::Opacity)->run_state());
47 } 47 }
48 48
49 // If an animation is started on the impl thread before it is ticked on the main 49 // If an animation is started on the impl thread before it is ticked on the main
50 // thread, we must be sure to respect the synchronized start time. 50 // thread, we must be sure to respect the synchronized start time.
51 TEST(LayerAnimationControllerTest, DoNotClobberStartTimes) { 51 TEST(LayerAnimationControllerTest, DoNotClobberStartTimes) {
52 FakeLayerAnimationValueObserver dummy_impl; 52 FakeLayerAnimationValueObserver dummy_impl;
53 scoped_refptr<LayerAnimationController> controller_impl( 53 scoped_refptr<LayerAnimationController> controller_impl(
54 LayerAnimationController::Create(0)); 54 LayerAnimationController::Create(0));
55 controller_impl->AddObserver(&dummy_impl); 55 controller_impl->AddValueObserver(&dummy_impl);
56 FakeLayerAnimationValueObserver dummy; 56 FakeLayerAnimationValueObserver dummy;
57 scoped_refptr<LayerAnimationController> controller( 57 scoped_refptr<LayerAnimationController> controller(
58 LayerAnimationController::Create(0)); 58 LayerAnimationController::Create(0));
59 controller->AddObserver(&dummy); 59 controller->AddValueObserver(&dummy);
60 60
61 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); 61 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity));
62 62
63 AddOpacityTransitionToController(controller, 1, 0, 1, false); 63 AddOpacityTransitionToController(controller, 1, 0, 1, false);
64 64
65 controller->PushAnimationUpdatesTo(controller_impl.get()); 65 controller->PushAnimationUpdatesTo(controller_impl.get());
66 66
67 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); 67 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity));
68 EXPECT_EQ(Animation::WaitingForTargetAvailability, 68 EXPECT_EQ(Animation::WaitingForTargetAvailability,
69 controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); 69 controller_impl->GetAnimation(0, Animation::Opacity)->run_state());
70 70
71 AnimationEventsVector events; 71 AnimationEventsVector events;
72 controller_impl->Animate(1.0); 72 controller_impl->Animate(1.0);
73 controller_impl->UpdateState(&events); 73 controller_impl->UpdateState(&events);
74 74
75 // Synchronize the start times. 75 // Synchronize the start times.
76 EXPECT_EQ(1u, events.size()); 76 EXPECT_EQ(1u, events.size());
77 controller->OnAnimationStarted(events[0]); 77 controller->NotifyAnimationStarted(events[0], 0.0);
78 EXPECT_EQ(controller->GetAnimation(0, Animation::Opacity)->start_time(), 78 EXPECT_EQ(controller->GetAnimation(0, Animation::Opacity)->start_time(),
79 controller_impl->GetAnimation(0, Animation::Opacity)->start_time()); 79 controller_impl->GetAnimation(0, Animation::Opacity)->start_time());
80 80
81 // Start the animation on the main thread. Should not affect the start time. 81 // Start the animation on the main thread. Should not affect the start time.
82 controller->Animate(1.5); 82 controller->Animate(1.5);
83 controller->UpdateState(NULL); 83 controller->UpdateState(NULL);
84 EXPECT_EQ(controller->GetAnimation(0, Animation::Opacity)->start_time(), 84 EXPECT_EQ(controller->GetAnimation(0, Animation::Opacity)->start_time(),
85 controller_impl->GetAnimation(0, Animation::Opacity)->start_time()); 85 controller_impl->GetAnimation(0, Animation::Opacity)->start_time());
86 } 86 }
87 87
88 TEST(LayerAnimationControllerTest, SyncPauseAndResume) { 88 TEST(LayerAnimationControllerTest, SyncPauseAndResume) {
89 FakeLayerAnimationValueObserver dummy_impl; 89 FakeLayerAnimationValueObserver dummy_impl;
90 scoped_refptr<LayerAnimationController> controller_impl( 90 scoped_refptr<LayerAnimationController> controller_impl(
91 LayerAnimationController::Create(0)); 91 LayerAnimationController::Create(0));
92 controller_impl->AddObserver(&dummy_impl); 92 controller_impl->AddValueObserver(&dummy_impl);
93 FakeLayerAnimationValueObserver dummy; 93 FakeLayerAnimationValueObserver dummy;
94 scoped_refptr<LayerAnimationController> controller( 94 scoped_refptr<LayerAnimationController> controller(
95 LayerAnimationController::Create(0)); 95 LayerAnimationController::Create(0));
96 controller->AddObserver(&dummy); 96 controller->AddValueObserver(&dummy);
97 97
98 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); 98 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity));
99 99
100 AddOpacityTransitionToController(controller, 1, 0, 1, false); 100 AddOpacityTransitionToController(controller, 1, 0, 1, false);
101 101
102 controller->PushAnimationUpdatesTo(controller_impl.get()); 102 controller->PushAnimationUpdatesTo(controller_impl.get());
103 103
104 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); 104 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity));
105 EXPECT_EQ(Animation::WaitingForTargetAvailability, 105 EXPECT_EQ(Animation::WaitingForTargetAvailability,
106 controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); 106 controller_impl->GetAnimation(0, Animation::Opacity)->run_state());
(...skipping 27 matching lines...) Expand all
134 // The pause run state change should make it to the impl thread controller. 134 // The pause run state change should make it to the impl thread controller.
135 controller->PushAnimationUpdatesTo(controller_impl.get()); 135 controller->PushAnimationUpdatesTo(controller_impl.get());
136 EXPECT_EQ(Animation::Running, 136 EXPECT_EQ(Animation::Running,
137 controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); 137 controller_impl->GetAnimation(0, Animation::Opacity)->run_state());
138 } 138 }
139 139
140 TEST(LayerAnimationControllerTest, DoNotSyncFinishedAnimation) { 140 TEST(LayerAnimationControllerTest, DoNotSyncFinishedAnimation) {
141 FakeLayerAnimationValueObserver dummy_impl; 141 FakeLayerAnimationValueObserver dummy_impl;
142 scoped_refptr<LayerAnimationController> controller_impl( 142 scoped_refptr<LayerAnimationController> controller_impl(
143 LayerAnimationController::Create(0)); 143 LayerAnimationController::Create(0));
144 controller_impl->AddObserver(&dummy_impl); 144 controller_impl->AddValueObserver(&dummy_impl);
145 FakeLayerAnimationValueObserver dummy; 145 FakeLayerAnimationValueObserver dummy;
146 scoped_refptr<LayerAnimationController> controller( 146 scoped_refptr<LayerAnimationController> controller(
147 LayerAnimationController::Create(0)); 147 LayerAnimationController::Create(0));
148 controller->AddObserver(&dummy); 148 controller->AddValueObserver(&dummy);
149 149
150 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); 150 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity));
151 151
152 int animation_id = 152 int animation_id =
153 AddOpacityTransitionToController(controller, 1, 0, 1, false); 153 AddOpacityTransitionToController(controller, 1, 0, 1, false);
154 154
155 controller->PushAnimationUpdatesTo(controller_impl.get()); 155 controller->PushAnimationUpdatesTo(controller_impl.get());
156 156
157 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); 157 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity));
158 EXPECT_EQ(Animation::WaitingForTargetAvailability, 158 EXPECT_EQ(Animation::WaitingForTargetAvailability,
159 controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); 159 controller_impl->GetAnimation(0, Animation::Opacity)->run_state());
160 160
161 // Notify main thread controller that the animation has started. 161 // Notify main thread controller that the animation has started.
162 AnimationEvent animation_started_event( 162 AnimationEvent animation_started_event(
163 AnimationEvent::Started, 0, 0, Animation::Opacity, 0); 163 AnimationEvent::Started, 0, 0, Animation::Opacity, 0);
164 controller->OnAnimationStarted(animation_started_event); 164 controller->NotifyAnimationStarted(animation_started_event, 0.0);
165 165
166 // Force animation to complete on impl thread. 166 // Force animation to complete on impl thread.
167 controller_impl->RemoveAnimation(animation_id); 167 controller_impl->RemoveAnimation(animation_id);
168 168
169 EXPECT_FALSE(controller_impl->GetAnimation(animation_id, Animation::Opacity)); 169 EXPECT_FALSE(controller_impl->GetAnimation(animation_id, Animation::Opacity));
170 170
171 controller->PushAnimationUpdatesTo(controller_impl.get()); 171 controller->PushAnimationUpdatesTo(controller_impl.get());
172 172
173 // Even though the main thread has a 'new' animation, it should not be pushed 173 // Even though the main thread has a 'new' animation, it should not be pushed
174 // because the animation has already completed on the impl thread. 174 // because the animation has already completed on the impl thread.
175 EXPECT_FALSE(controller_impl->GetAnimation(animation_id, Animation::Opacity)); 175 EXPECT_FALSE(controller_impl->GetAnimation(animation_id, Animation::Opacity));
176 } 176 }
177 177
178 // Ensure that a finished animation is eventually deleted by both the
179 // main-thread and the impl-thread controllers.
180 TEST(LayerAnimationControllerTest, AnimationsAreDeleted) {
181 FakeLayerAnimationValueObserver dummy;
182 FakeLayerAnimationValueObserver dummy_impl;
183 scoped_ptr<AnimationEventsVector> events(
184 make_scoped_ptr(new AnimationEventsVector));
185 scoped_refptr<LayerAnimationController> controller(
186 LayerAnimationController::Create(0));
187 scoped_refptr<LayerAnimationController> controller_impl(
188 LayerAnimationController::Create(0));
189 controller->AddValueObserver(&dummy);
190 controller_impl->AddValueObserver(&dummy_impl);
191
192 AddOpacityTransitionToController(controller, 1.0, 0.0f, 1.0f, false);
193 controller->Animate(0.0);
194 controller->UpdateState(NULL);
195 controller->PushAnimationUpdatesTo(controller_impl.get());
196
197 controller_impl->Animate(0.5);
198 controller_impl->UpdateState(events.get());
199
200 // There should be a Started event for the animation.
201 EXPECT_EQ(1u, events->size());
202 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type);
203 controller->NotifyAnimationStarted((*events)[0], 0.0);
204
205 controller->Animate(1.0);
206 controller->UpdateState(NULL);
207
208 events.reset(new AnimationEventsVector);
209 controller_impl->Animate(2.0);
210 controller_impl->UpdateState(events.get());
211
212 // There should be a Finished event for the animation.
213 EXPECT_EQ(1u, events->size());
214 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type);
215
216 // Neither controller should have deleted the animation yet.
217 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity));
218 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity));
219
220 controller->NotifyAnimationFinished((*events)[0], 0.0);
221
222 controller->Animate(3.0);
223 controller->UpdateState(NULL);
224
225 controller->PushAnimationUpdatesTo(controller_impl.get());
226
227 // Both controllers should now have deleted the animation.
228 EXPECT_FALSE(controller->has_any_animation());
229 EXPECT_FALSE(controller_impl->has_any_animation());
230 }
Ian Vollick 2013/04/04 18:38:58 Great test!
231
232 TEST(LayerAnimationControllerTest, TransferAnimationsTo) {
233 scoped_refptr<LayerAnimationController> controller(
234 LayerAnimationController::Create(0));
235 scoped_refptr<LayerAnimationController> other_controller(
236 LayerAnimationController::Create(1));
237
238 int opacity_animation_id =
239 AddOpacityTransitionToController(controller, 1.0, 0.0f, 1.0f, false);
240
241 int transform_animation_id =
242 AddAnimatedTransformToController(controller, 1.0, 10, 10);
243
244 controller->TransferAnimationsTo(other_controller);
245
246 // Ensure both animations have been transfered.
Ian Vollick 2013/04/04 18:38:58 Can you also confirm that the run states are ident
ajuma 2013/04/05 14:38:18 Done.
247 EXPECT_FALSE(controller->has_any_animation());
248 EXPECT_EQ(other_controller->GetAnimation(Animation::Opacity)->id(),
249 opacity_animation_id);
250 EXPECT_EQ(other_controller->GetAnimation(Animation::Transform)->id(),
251 transform_animation_id);
252 }
253
178 // Tests that transitioning opacity from 0 to 1 works as expected. 254 // Tests that transitioning opacity from 0 to 1 works as expected.
179 255
180 static const AnimationEvent* GetMostRecentPropertyUpdateEvent( 256 static const AnimationEvent* GetMostRecentPropertyUpdateEvent(
181 const AnimationEventsVector* events) { 257 const AnimationEventsVector* events) {
182 const AnimationEvent* event = 0; 258 const AnimationEvent* event = 0;
183 for (size_t i = 0; i < events->size(); ++i) 259 for (size_t i = 0; i < events->size(); ++i)
184 if ((*events)[i].type == AnimationEvent::PropertyUpdate) 260 if ((*events)[i].type == AnimationEvent::PropertyUpdate)
185 event = &(*events)[i]; 261 event = &(*events)[i];
186 262
187 return event; 263 return event;
188 } 264 }
189 265
190 TEST(LayerAnimationControllerTest, TrivialTransition) { 266 TEST(LayerAnimationControllerTest, TrivialTransition) {
191 scoped_ptr<AnimationEventsVector> events( 267 scoped_ptr<AnimationEventsVector> events(
192 make_scoped_ptr(new AnimationEventsVector)); 268 make_scoped_ptr(new AnimationEventsVector));
193 FakeLayerAnimationValueObserver dummy; 269 FakeLayerAnimationValueObserver dummy;
194 scoped_refptr<LayerAnimationController> controller( 270 scoped_refptr<LayerAnimationController> controller(
195 LayerAnimationController::Create(0)); 271 LayerAnimationController::Create(0));
196 controller->AddObserver(&dummy); 272 controller->AddValueObserver(&dummy);
197 273
198 scoped_ptr<Animation> to_add(CreateAnimation( 274 scoped_ptr<Animation> to_add(CreateAnimation(
199 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 275 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
200 1, 276 1,
201 Animation::Opacity)); 277 Animation::Opacity));
202 278
203 controller->AddAnimation(to_add.Pass()); 279 controller->AddAnimation(to_add.Pass());
204 controller->Animate(0.0); 280 controller->Animate(0.0);
205 controller->UpdateState(events.get()); 281 controller->UpdateState(events.get());
206 EXPECT_TRUE(controller->HasActiveAnimation()); 282 EXPECT_TRUE(controller->HasActiveAnimation());
207 EXPECT_EQ(0.f, dummy.opacity()); 283 EXPECT_EQ(0.f, dummy.opacity());
208 // A non-impl-only animation should not generate property updates. 284 // A non-impl-only animation should not generate property updates.
209 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 285 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
210 EXPECT_FALSE(event); 286 EXPECT_FALSE(event);
211 controller->Animate(1.0); 287 controller->Animate(1.0);
212 controller->UpdateState(events.get()); 288 controller->UpdateState(events.get());
213 EXPECT_EQ(1.f, dummy.opacity()); 289 EXPECT_EQ(1.f, dummy.opacity());
214 EXPECT_FALSE(controller->HasActiveAnimation()); 290 EXPECT_FALSE(controller->HasActiveAnimation());
215 event = GetMostRecentPropertyUpdateEvent(events.get()); 291 event = GetMostRecentPropertyUpdateEvent(events.get());
216 EXPECT_FALSE(event); 292 EXPECT_FALSE(event);
217 } 293 }
218 294
219 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { 295 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) {
220 scoped_ptr<AnimationEventsVector> events( 296 scoped_ptr<AnimationEventsVector> events(
221 make_scoped_ptr(new AnimationEventsVector)); 297 make_scoped_ptr(new AnimationEventsVector));
222 FakeLayerAnimationValueObserver dummy_impl; 298 FakeLayerAnimationValueObserver dummy_impl;
223 scoped_refptr<LayerAnimationController> controller_impl( 299 scoped_refptr<LayerAnimationController> controller_impl(
224 LayerAnimationController::Create(0)); 300 LayerAnimationController::Create(0));
225 controller_impl->AddObserver(&dummy_impl); 301 controller_impl->AddValueObserver(&dummy_impl);
226 302
227 scoped_ptr<Animation> to_add(CreateAnimation( 303 scoped_ptr<Animation> to_add(CreateAnimation(
228 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 304 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
229 1, 305 1,
230 Animation::Opacity)); 306 Animation::Opacity));
231 to_add->set_is_impl_only(true); 307 to_add->set_is_impl_only(true);
232 308
233 controller_impl->AddAnimation(to_add.Pass()); 309 controller_impl->AddAnimation(to_add.Pass());
234 controller_impl->Animate(0.0); 310 controller_impl->Animate(0.0);
235 controller_impl->UpdateState(events.get()); 311 controller_impl->UpdateState(events.get());
(...skipping 13 matching lines...) Expand all
249 GetMostRecentPropertyUpdateEvent(events.get()); 325 GetMostRecentPropertyUpdateEvent(events.get());
250 EXPECT_EQ(1.f, end_opacity_event->opacity); 326 EXPECT_EQ(1.f, end_opacity_event->opacity);
251 } 327 }
252 328
253 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) { 329 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) {
254 scoped_ptr<AnimationEventsVector> events( 330 scoped_ptr<AnimationEventsVector> events(
255 make_scoped_ptr(new AnimationEventsVector)); 331 make_scoped_ptr(new AnimationEventsVector));
256 FakeLayerAnimationValueObserver dummy_impl; 332 FakeLayerAnimationValueObserver dummy_impl;
257 scoped_refptr<LayerAnimationController> controller_impl( 333 scoped_refptr<LayerAnimationController> controller_impl(
258 LayerAnimationController::Create(0)); 334 LayerAnimationController::Create(0));
259 controller_impl->AddObserver(&dummy_impl); 335 controller_impl->AddValueObserver(&dummy_impl);
260 336
261 // Choose different values for x and y to avoid coincidental values in the 337 // Choose different values for x and y to avoid coincidental values in the
262 // observed transforms. 338 // observed transforms.
263 const float delta_x = 3; 339 const float delta_x = 3;
264 const float delta_y = 4; 340 const float delta_y = 4;
265 341
266 scoped_ptr<KeyframedTransformAnimationCurve> curve( 342 scoped_ptr<KeyframedTransformAnimationCurve> curve(
267 KeyframedTransformAnimationCurve::Create()); 343 KeyframedTransformAnimationCurve::Create());
268 344
269 // Create simple Transform animation. 345 // Create simple Transform animation.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 381
306 // Tests animations that are waiting for a synchronized start time do not 382 // Tests animations that are waiting for a synchronized start time do not
307 // finish. 383 // finish.
308 TEST(LayerAnimationControllerTest, 384 TEST(LayerAnimationControllerTest,
309 AnimationsWaitingForStartTimeDoNotFinishIfTheyWaitLongerToStartThanTheirDur ation) { 385 AnimationsWaitingForStartTimeDoNotFinishIfTheyWaitLongerToStartThanTheirDur ation) {
310 scoped_ptr<AnimationEventsVector> events( 386 scoped_ptr<AnimationEventsVector> events(
311 make_scoped_ptr(new AnimationEventsVector)); 387 make_scoped_ptr(new AnimationEventsVector));
312 FakeLayerAnimationValueObserver dummy; 388 FakeLayerAnimationValueObserver dummy;
313 scoped_refptr<LayerAnimationController> controller( 389 scoped_refptr<LayerAnimationController> controller(
314 LayerAnimationController::Create(0)); 390 LayerAnimationController::Create(0));
315 controller->AddObserver(&dummy); 391 controller->AddValueObserver(&dummy);
316 392
317 scoped_ptr<Animation> to_add(CreateAnimation( 393 scoped_ptr<Animation> to_add(CreateAnimation(
318 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 394 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
319 1, 395 1,
320 Animation::Opacity)); 396 Animation::Opacity));
321 to_add->set_needs_synchronized_start_time(true); 397 to_add->set_needs_synchronized_start_time(true);
322 398
323 // We should pause at the first keyframe indefinitely waiting for that 399 // We should pause at the first keyframe indefinitely waiting for that
324 // animation to start. 400 // animation to start.
325 controller->AddAnimation(to_add.Pass()); 401 controller->AddAnimation(to_add.Pass());
326 controller->Animate(0.0); 402 controller->Animate(0.0);
327 controller->UpdateState(events.get()); 403 controller->UpdateState(events.get());
328 EXPECT_TRUE(controller->HasActiveAnimation()); 404 EXPECT_TRUE(controller->HasActiveAnimation());
329 EXPECT_EQ(0.f, dummy.opacity()); 405 EXPECT_EQ(0.f, dummy.opacity());
330 controller->Animate(1.0); 406 controller->Animate(1.0);
331 controller->UpdateState(events.get()); 407 controller->UpdateState(events.get());
332 EXPECT_TRUE(controller->HasActiveAnimation()); 408 EXPECT_TRUE(controller->HasActiveAnimation());
333 EXPECT_EQ(0.f, dummy.opacity()); 409 EXPECT_EQ(0.f, dummy.opacity());
334 controller->Animate(2.0); 410 controller->Animate(2.0);
335 controller->UpdateState(events.get()); 411 controller->UpdateState(events.get());
336 EXPECT_TRUE(controller->HasActiveAnimation()); 412 EXPECT_TRUE(controller->HasActiveAnimation());
337 EXPECT_EQ(0.f, dummy.opacity()); 413 EXPECT_EQ(0.f, dummy.opacity());
338 414
339 // Send the synchronized start time. 415 // Send the synchronized start time.
340 controller->OnAnimationStarted(AnimationEvent( 416 controller->NotifyAnimationStarted(
341 AnimationEvent::Started, 0, 1, Animation::Opacity, 2)); 417 AnimationEvent(AnimationEvent::Started, 0, 1, Animation::Opacity, 2),
418 0.0);
342 controller->Animate(5.0); 419 controller->Animate(5.0);
343 controller->UpdateState(events.get()); 420 controller->UpdateState(events.get());
344 EXPECT_EQ(1.f, dummy.opacity()); 421 EXPECT_EQ(1.f, dummy.opacity());
345 EXPECT_FALSE(controller->HasActiveAnimation()); 422 EXPECT_FALSE(controller->HasActiveAnimation());
346 } 423 }
347 424
348 // Tests that two queued animations affecting the same property run in sequence. 425 // Tests that two queued animations affecting the same property run in sequence.
349 TEST(LayerAnimationControllerTest, TrivialQueuing) { 426 TEST(LayerAnimationControllerTest, TrivialQueuing) {
350 scoped_ptr<AnimationEventsVector> events( 427 scoped_ptr<AnimationEventsVector> events(
351 make_scoped_ptr(new AnimationEventsVector)); 428 make_scoped_ptr(new AnimationEventsVector));
352 FakeLayerAnimationValueObserver dummy; 429 FakeLayerAnimationValueObserver dummy;
353 scoped_refptr<LayerAnimationController> controller( 430 scoped_refptr<LayerAnimationController> controller(
354 LayerAnimationController::Create(0)); 431 LayerAnimationController::Create(0));
355 controller->AddObserver(&dummy); 432 controller->AddValueObserver(&dummy);
356 433
357 controller->AddAnimation(CreateAnimation( 434 controller->AddAnimation(CreateAnimation(
358 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 435 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
359 1, 436 1,
360 Animation::Opacity)); 437 Animation::Opacity));
361 controller->AddAnimation(CreateAnimation( 438 controller->AddAnimation(CreateAnimation(
362 scoped_ptr<AnimationCurve>( 439 scoped_ptr<AnimationCurve>(
363 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), 440 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(),
364 2, 441 2,
365 Animation::Opacity)); 442 Animation::Opacity));
(...skipping 12 matching lines...) Expand all
378 EXPECT_FALSE(controller->HasActiveAnimation()); 455 EXPECT_FALSE(controller->HasActiveAnimation());
379 } 456 }
380 457
381 // Tests interrupting a transition with another transition. 458 // Tests interrupting a transition with another transition.
382 TEST(LayerAnimationControllerTest, Interrupt) { 459 TEST(LayerAnimationControllerTest, Interrupt) {
383 scoped_ptr<AnimationEventsVector> events( 460 scoped_ptr<AnimationEventsVector> events(
384 make_scoped_ptr(new AnimationEventsVector)); 461 make_scoped_ptr(new AnimationEventsVector));
385 FakeLayerAnimationValueObserver dummy; 462 FakeLayerAnimationValueObserver dummy;
386 scoped_refptr<LayerAnimationController> controller( 463 scoped_refptr<LayerAnimationController> controller(
387 LayerAnimationController::Create(0)); 464 LayerAnimationController::Create(0));
388 controller->AddObserver(&dummy); 465 controller->AddValueObserver(&dummy);
389 controller->AddAnimation(CreateAnimation( 466 controller->AddAnimation(CreateAnimation(
390 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 467 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
391 1, 468 1,
392 Animation::Opacity)); 469 Animation::Opacity));
393 controller->Animate(0.0); 470 controller->Animate(0.0);
394 controller->UpdateState(events.get()); 471 controller->UpdateState(events.get());
395 EXPECT_TRUE(controller->HasActiveAnimation()); 472 EXPECT_TRUE(controller->HasActiveAnimation());
396 EXPECT_EQ(0.f, dummy.opacity()); 473 EXPECT_EQ(0.f, dummy.opacity());
397 474
398 scoped_ptr<Animation> to_add(CreateAnimation( 475 scoped_ptr<Animation> to_add(CreateAnimation(
(...skipping 17 matching lines...) Expand all
416 } 493 }
417 494
418 // Tests scheduling two animations to run together when only one property is 495 // Tests scheduling two animations to run together when only one property is
419 // free. 496 // free.
420 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { 497 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) {
421 scoped_ptr<AnimationEventsVector> events( 498 scoped_ptr<AnimationEventsVector> events(
422 make_scoped_ptr(new AnimationEventsVector)); 499 make_scoped_ptr(new AnimationEventsVector));
423 FakeLayerAnimationValueObserver dummy; 500 FakeLayerAnimationValueObserver dummy;
424 scoped_refptr<LayerAnimationController> controller( 501 scoped_refptr<LayerAnimationController> controller(
425 LayerAnimationController::Create(0)); 502 LayerAnimationController::Create(0));
426 controller->AddObserver(&dummy); 503 controller->AddValueObserver(&dummy);
427 504
428 controller->AddAnimation(CreateAnimation( 505 controller->AddAnimation(CreateAnimation(
429 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), 506 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(),
430 1, 507 1,
431 Animation::Transform)); 508 Animation::Transform));
432 controller->AddAnimation(CreateAnimation( 509 controller->AddAnimation(CreateAnimation(
433 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), 510 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(),
434 2, 511 2,
435 Animation::Transform)); 512 Animation::Transform));
436 controller->AddAnimation(CreateAnimation( 513 controller->AddAnimation(CreateAnimation(
(...skipping 19 matching lines...) Expand all
456 533
457 // Tests scheduling two animations to run together with different lengths and 534 // Tests scheduling two animations to run together with different lengths and
458 // another animation queued to start when the shorter animation finishes (should 535 // another animation queued to start when the shorter animation finishes (should
459 // wait for both to finish). 536 // wait for both to finish).
460 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { 537 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) {
461 scoped_ptr<AnimationEventsVector> events( 538 scoped_ptr<AnimationEventsVector> events(
462 make_scoped_ptr(new AnimationEventsVector)); 539 make_scoped_ptr(new AnimationEventsVector));
463 FakeLayerAnimationValueObserver dummy; 540 FakeLayerAnimationValueObserver dummy;
464 scoped_refptr<LayerAnimationController> controller( 541 scoped_refptr<LayerAnimationController> controller(
465 LayerAnimationController::Create(0)); 542 LayerAnimationController::Create(0));
466 controller->AddObserver(&dummy); 543 controller->AddValueObserver(&dummy);
467 544
468 controller->AddAnimation(CreateAnimation( 545 controller->AddAnimation(CreateAnimation(
469 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2)).Pass(), 546 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2)).Pass(),
470 1, 547 1,
471 Animation::Transform)); 548 Animation::Transform));
472 controller->AddAnimation(CreateAnimation( 549 controller->AddAnimation(CreateAnimation(
473 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 550 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
474 1, 551 1,
475 Animation::Opacity)); 552 Animation::Opacity));
476 controller->AddAnimation(CreateAnimation( 553 controller->AddAnimation(CreateAnimation(
(...skipping 24 matching lines...) Expand all
501 EXPECT_FALSE(controller->HasActiveAnimation()); 578 EXPECT_FALSE(controller->HasActiveAnimation());
502 } 579 }
503 580
504 // Tests scheduling an animation to start in the future. 581 // Tests scheduling an animation to start in the future.
505 TEST(LayerAnimationControllerTest, ScheduleAnimation) { 582 TEST(LayerAnimationControllerTest, ScheduleAnimation) {
506 scoped_ptr<AnimationEventsVector> events( 583 scoped_ptr<AnimationEventsVector> events(
507 make_scoped_ptr(new AnimationEventsVector)); 584 make_scoped_ptr(new AnimationEventsVector));
508 FakeLayerAnimationValueObserver dummy; 585 FakeLayerAnimationValueObserver dummy;
509 scoped_refptr<LayerAnimationController> controller( 586 scoped_refptr<LayerAnimationController> controller(
510 LayerAnimationController::Create(0)); 587 LayerAnimationController::Create(0));
511 controller->AddObserver(&dummy); 588 controller->AddValueObserver(&dummy);
512 589
513 scoped_ptr<Animation> to_add(CreateAnimation( 590 scoped_ptr<Animation> to_add(CreateAnimation(
514 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 591 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
515 1, 592 1,
516 Animation::Opacity)); 593 Animation::Opacity));
517 to_add->SetRunState(Animation::WaitingForStartTime, 0); 594 to_add->SetRunState(Animation::WaitingForStartTime, 0);
518 to_add->set_start_time(1.f); 595 to_add->set_start_time(1.f);
519 controller->AddAnimation(to_add.Pass()); 596 controller->AddAnimation(to_add.Pass());
520 597
521 controller->Animate(0.0); 598 controller->Animate(0.0);
(...skipping 12 matching lines...) Expand all
534 611
535 // Tests scheduling an animation to start in the future that's interrupting a 612 // Tests scheduling an animation to start in the future that's interrupting a
536 // running animation. 613 // running animation.
537 TEST(LayerAnimationControllerTest, 614 TEST(LayerAnimationControllerTest,
538 ScheduledAnimationInterruptsRunningAnimation) { 615 ScheduledAnimationInterruptsRunningAnimation) {
539 scoped_ptr<AnimationEventsVector> events( 616 scoped_ptr<AnimationEventsVector> events(
540 make_scoped_ptr(new AnimationEventsVector)); 617 make_scoped_ptr(new AnimationEventsVector));
541 FakeLayerAnimationValueObserver dummy; 618 FakeLayerAnimationValueObserver dummy;
542 scoped_refptr<LayerAnimationController> controller( 619 scoped_refptr<LayerAnimationController> controller(
543 LayerAnimationController::Create(0)); 620 LayerAnimationController::Create(0));
544 controller->AddObserver(&dummy); 621 controller->AddValueObserver(&dummy);
545 622
546 controller->AddAnimation(CreateAnimation( 623 controller->AddAnimation(CreateAnimation(
547 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), 624 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(),
548 1, 625 1,
549 Animation::Opacity)); 626 Animation::Opacity));
550 627
551 scoped_ptr<Animation> to_add(CreateAnimation( 628 scoped_ptr<Animation> to_add(CreateAnimation(
552 scoped_ptr<AnimationCurve>( 629 scoped_ptr<AnimationCurve>(
553 new FakeFloatTransition(1.0, 0.5f, 0.f)).Pass(), 630 new FakeFloatTransition(1.0, 0.5f, 0.f)).Pass(),
554 2, 631 2,
(...skipping 23 matching lines...) Expand all
578 655
579 // Tests scheduling an animation to start in the future that interrupts a 656 // Tests scheduling an animation to start in the future that interrupts a
580 // running animation and there is yet another animation queued to start later. 657 // running animation and there is yet another animation queued to start later.
581 TEST(LayerAnimationControllerTest, 658 TEST(LayerAnimationControllerTest,
582 ScheduledAnimationInterruptsRunningAnimationWithAnimInQueue) { 659 ScheduledAnimationInterruptsRunningAnimationWithAnimInQueue) {
583 scoped_ptr<AnimationEventsVector> events( 660 scoped_ptr<AnimationEventsVector> events(
584 make_scoped_ptr(new AnimationEventsVector)); 661 make_scoped_ptr(new AnimationEventsVector));
585 FakeLayerAnimationValueObserver dummy; 662 FakeLayerAnimationValueObserver dummy;
586 scoped_refptr<LayerAnimationController> controller( 663 scoped_refptr<LayerAnimationController> controller(
587 LayerAnimationController::Create(0)); 664 LayerAnimationController::Create(0));
588 controller->AddObserver(&dummy); 665 controller->AddValueObserver(&dummy);
589 666
590 controller->AddAnimation(CreateAnimation( 667 controller->AddAnimation(CreateAnimation(
591 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), 668 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(),
592 1, 669 1,
593 Animation::Opacity)); 670 Animation::Opacity));
594 671
595 scoped_ptr<Animation> to_add(CreateAnimation( 672 scoped_ptr<Animation> to_add(CreateAnimation(
596 scoped_ptr<AnimationCurve>( 673 scoped_ptr<AnimationCurve>(
597 new FakeFloatTransition(2.0, 0.5f, 0.f)).Pass(), 674 new FakeFloatTransition(2.0, 0.5f, 0.f)).Pass(),
598 2, 675 2,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 EXPECT_FALSE(controller->HasActiveAnimation()); 708 EXPECT_FALSE(controller->HasActiveAnimation());
632 } 709 }
633 710
634 // Test that a looping animation loops and for the correct number of iterations. 711 // Test that a looping animation loops and for the correct number of iterations.
635 TEST(LayerAnimationControllerTest, TrivialLooping) { 712 TEST(LayerAnimationControllerTest, TrivialLooping) {
636 scoped_ptr<AnimationEventsVector> events( 713 scoped_ptr<AnimationEventsVector> events(
637 make_scoped_ptr(new AnimationEventsVector)); 714 make_scoped_ptr(new AnimationEventsVector));
638 FakeLayerAnimationValueObserver dummy; 715 FakeLayerAnimationValueObserver dummy;
639 scoped_refptr<LayerAnimationController> controller( 716 scoped_refptr<LayerAnimationController> controller(
640 LayerAnimationController::Create(0)); 717 LayerAnimationController::Create(0));
641 controller->AddObserver(&dummy); 718 controller->AddValueObserver(&dummy);
642 719
643 scoped_ptr<Animation> to_add(CreateAnimation( 720 scoped_ptr<Animation> to_add(CreateAnimation(
644 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 721 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
645 1, 722 1,
646 Animation::Opacity)); 723 Animation::Opacity));
647 to_add->set_iterations(3); 724 to_add->set_iterations(3);
648 controller->AddAnimation(to_add.Pass()); 725 controller->AddAnimation(to_add.Pass());
649 726
650 controller->Animate(0.0); 727 controller->Animate(0.0);
651 controller->UpdateState(events.get()); 728 controller->UpdateState(events.get());
(...skipping 26 matching lines...) Expand all
678 EXPECT_EQ(1.f, dummy.opacity()); 755 EXPECT_EQ(1.f, dummy.opacity());
679 } 756 }
680 757
681 // Test that an infinitely looping animation does indeed go until aborted. 758 // Test that an infinitely looping animation does indeed go until aborted.
682 TEST(LayerAnimationControllerTest, InfiniteLooping) { 759 TEST(LayerAnimationControllerTest, InfiniteLooping) {
683 scoped_ptr<AnimationEventsVector> events( 760 scoped_ptr<AnimationEventsVector> events(
684 make_scoped_ptr(new AnimationEventsVector)); 761 make_scoped_ptr(new AnimationEventsVector));
685 FakeLayerAnimationValueObserver dummy; 762 FakeLayerAnimationValueObserver dummy;
686 scoped_refptr<LayerAnimationController> controller( 763 scoped_refptr<LayerAnimationController> controller(
687 LayerAnimationController::Create(0)); 764 LayerAnimationController::Create(0));
688 controller->AddObserver(&dummy); 765 controller->AddValueObserver(&dummy);
689 766
690 const int id = 1; 767 const int id = 1;
691 scoped_ptr<Animation> to_add(CreateAnimation( 768 scoped_ptr<Animation> to_add(CreateAnimation(
692 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 769 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
693 id, 770 id,
694 Animation::Opacity)); 771 Animation::Opacity));
695 to_add->set_iterations(-1); 772 to_add->set_iterations(-1);
696 controller->AddAnimation(to_add.Pass()); 773 controller->AddAnimation(to_add.Pass());
697 774
698 controller->Animate(0.0); 775 controller->Animate(0.0);
(...skipping 25 matching lines...) Expand all
724 EXPECT_EQ(0.75f, dummy.opacity()); 801 EXPECT_EQ(0.75f, dummy.opacity());
725 } 802 }
726 803
727 // Test that pausing and resuming work as expected. 804 // Test that pausing and resuming work as expected.
728 TEST(LayerAnimationControllerTest, PauseResume) { 805 TEST(LayerAnimationControllerTest, PauseResume) {
729 scoped_ptr<AnimationEventsVector> events( 806 scoped_ptr<AnimationEventsVector> events(
730 make_scoped_ptr(new AnimationEventsVector)); 807 make_scoped_ptr(new AnimationEventsVector));
731 FakeLayerAnimationValueObserver dummy; 808 FakeLayerAnimationValueObserver dummy;
732 scoped_refptr<LayerAnimationController> controller( 809 scoped_refptr<LayerAnimationController> controller(
733 LayerAnimationController::Create(0)); 810 LayerAnimationController::Create(0));
734 controller->AddObserver(&dummy); 811 controller->AddValueObserver(&dummy);
735 812
736 const int id = 1; 813 const int id = 1;
737 controller->AddAnimation(CreateAnimation( 814 controller->AddAnimation(CreateAnimation(
738 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), 815 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(),
739 id, 816 id,
740 Animation::Opacity)); 817 Animation::Opacity));
741 818
742 controller->Animate(0.0); 819 controller->Animate(0.0);
743 controller->UpdateState(events.get()); 820 controller->UpdateState(events.get());
744 EXPECT_TRUE(controller->HasActiveAnimation()); 821 EXPECT_TRUE(controller->HasActiveAnimation());
(...skipping 25 matching lines...) Expand all
770 EXPECT_FALSE(controller->HasActiveAnimation()); 847 EXPECT_FALSE(controller->HasActiveAnimation());
771 EXPECT_EQ(1.f, dummy.opacity()); 848 EXPECT_EQ(1.f, dummy.opacity());
772 } 849 }
773 850
774 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { 851 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) {
775 scoped_ptr<AnimationEventsVector> events( 852 scoped_ptr<AnimationEventsVector> events(
776 make_scoped_ptr(new AnimationEventsVector)); 853 make_scoped_ptr(new AnimationEventsVector));
777 FakeLayerAnimationValueObserver dummy; 854 FakeLayerAnimationValueObserver dummy;
778 scoped_refptr<LayerAnimationController> controller( 855 scoped_refptr<LayerAnimationController> controller(
779 LayerAnimationController::Create(0)); 856 LayerAnimationController::Create(0));
780 controller->AddObserver(&dummy); 857 controller->AddValueObserver(&dummy);
781 858
782 const int id = 1; 859 const int id = 1;
783 controller->AddAnimation(CreateAnimation( 860 controller->AddAnimation(CreateAnimation(
784 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), 861 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(),
785 id, 862 id,
786 Animation::Transform)); 863 Animation::Transform));
787 controller->AddAnimation(CreateAnimation( 864 controller->AddAnimation(CreateAnimation(
788 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), 865 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(),
789 id, 866 id,
790 Animation::Opacity)); 867 Animation::Opacity));
(...skipping 22 matching lines...) Expand all
813 controller->Animate(2.0); 890 controller->Animate(2.0);
814 controller->UpdateState(events.get()); 891 controller->UpdateState(events.get());
815 EXPECT_TRUE(!controller->HasActiveAnimation()); 892 EXPECT_TRUE(!controller->HasActiveAnimation());
816 EXPECT_EQ(0.75f, dummy.opacity()); 893 EXPECT_EQ(0.75f, dummy.opacity());
817 } 894 }
818 895
819 TEST(LayerAnimationControllerTest, ForceSyncWhenSynchronizedStartTimeNeeded) { 896 TEST(LayerAnimationControllerTest, ForceSyncWhenSynchronizedStartTimeNeeded) {
820 FakeLayerAnimationValueObserver dummy_impl; 897 FakeLayerAnimationValueObserver dummy_impl;
821 scoped_refptr<LayerAnimationController> controller_impl( 898 scoped_refptr<LayerAnimationController> controller_impl(
822 LayerAnimationController::Create(0)); 899 LayerAnimationController::Create(0));
823 controller_impl->AddObserver(&dummy_impl); 900 controller_impl->AddValueObserver(&dummy_impl);
824 scoped_ptr<AnimationEventsVector> events( 901 scoped_ptr<AnimationEventsVector> events(
825 make_scoped_ptr(new AnimationEventsVector)); 902 make_scoped_ptr(new AnimationEventsVector));
826 FakeLayerAnimationValueObserver dummy; 903 FakeLayerAnimationValueObserver dummy;
827 scoped_refptr<LayerAnimationController> controller( 904 scoped_refptr<LayerAnimationController> controller(
828 LayerAnimationController::Create(0)); 905 LayerAnimationController::Create(0));
829 controller->AddObserver(&dummy); 906 controller->AddValueObserver(&dummy);
830 907
831 scoped_ptr<Animation> to_add(CreateAnimation( 908 scoped_ptr<Animation> to_add(CreateAnimation(
832 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), 909 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(),
833 0, 910 0,
834 Animation::Opacity)); 911 Animation::Opacity));
835 to_add->set_needs_synchronized_start_time(true); 912 to_add->set_needs_synchronized_start_time(true);
836 controller->AddAnimation(to_add.Pass()); 913 controller->AddAnimation(to_add.Pass());
837 914
838 controller->Animate(0.0); 915 controller->Animate(0.0);
839 controller->UpdateState(events.get()); 916 controller->UpdateState(events.get());
(...skipping 12 matching lines...) Expand all
852 active_animation->run_state()); 929 active_animation->run_state());
853 } 930 }
854 931
855 // Tests that skipping a call to UpdateState works as expected. 932 // Tests that skipping a call to UpdateState works as expected.
856 TEST(LayerAnimationControllerTest, SkipUpdateState) { 933 TEST(LayerAnimationControllerTest, SkipUpdateState) {
857 scoped_ptr<AnimationEventsVector> events( 934 scoped_ptr<AnimationEventsVector> events(
858 make_scoped_ptr(new AnimationEventsVector)); 935 make_scoped_ptr(new AnimationEventsVector));
859 FakeLayerAnimationValueObserver dummy; 936 FakeLayerAnimationValueObserver dummy;
860 scoped_refptr<LayerAnimationController> controller( 937 scoped_refptr<LayerAnimationController> controller(
861 LayerAnimationController::Create(0)); 938 LayerAnimationController::Create(0));
862 controller->AddObserver(&dummy); 939 controller->AddValueObserver(&dummy);
863 940
864 controller->AddAnimation(CreateAnimation( 941 controller->AddAnimation(CreateAnimation(
865 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), 942 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(),
866 1, 943 1,
867 Animation::Transform)); 944 Animation::Transform));
868 945
869 controller->Animate(0.0); 946 controller->Animate(0.0);
870 controller->UpdateState(events.get()); 947 controller->UpdateState(events.get());
871 948
872 controller->AddAnimation(CreateAnimation( 949 controller->AddAnimation(CreateAnimation(
(...skipping 19 matching lines...) Expand all
892 controller->Animate(3.0); 969 controller->Animate(3.0);
893 controller->UpdateState(events.get()); 970 controller->UpdateState(events.get());
894 971
895 // The float tranisition should now be done. 972 // The float tranisition should now be done.
896 EXPECT_EQ(1.f, dummy.opacity()); 973 EXPECT_EQ(1.f, dummy.opacity());
897 EXPECT_FALSE(controller->HasActiveAnimation()); 974 EXPECT_FALSE(controller->HasActiveAnimation());
898 } 975 }
899 976
900 } // namespace 977 } // namespace
901 } // namespace cc 978 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698