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

Side by Side Diff: ui/compositor/layer_animator_unittest.cc

Issue 10942034: Revert 156318 - I had originally tried to build upon http://codereview.chromium.org/10869066/, but … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « ui/compositor/layer_animator.cc ('k') | ui/views/view_unittest.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ui/compositor/layer_animator.h" 5 #include "ui/compositor/layer_animator.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 private: 71 private:
72 LayerAnimator* animator_; 72 LayerAnimator* animator_;
73 LayerAnimationSequence* sequence_; 73 LayerAnimationSequence* sequence_;
74 74
75 DISALLOW_COPY_AND_ASSIGN(DeletingLayerAnimationObserver); 75 DISALLOW_COPY_AND_ASSIGN(DeletingLayerAnimationObserver);
76 }; 76 };
77 77
78 class TestLayerAnimator : public LayerAnimator { 78 class TestLayerAnimator : public LayerAnimator {
79 public: 79 public:
80 TestLayerAnimator() : LayerAnimator(base::TimeDelta::FromSeconds(0)) {} 80 TestLayerAnimator() : LayerAnimator(base::TimeDelta::FromSeconds(0)) {}
81 virtual ~TestLayerAnimator() {}
81 82
82 protected: 83 protected:
83 virtual ~TestLayerAnimator() {} 84 virtual bool ProgressAnimation(LayerAnimationSequence* sequence,
84
85 virtual void ProgressAnimation(LayerAnimationSequence* sequence,
86 base::TimeDelta delta) OVERRIDE { 85 base::TimeDelta delta) OVERRIDE {
87 EXPECT_TRUE(HasAnimation(sequence)); 86 EXPECT_TRUE(HasAnimation(sequence));
88 LayerAnimator::ProgressAnimation(sequence, delta); 87 return LayerAnimator::ProgressAnimation(sequence, delta);
89 } 88 }
90 89
91 private: 90 private:
92 DISALLOW_COPY_AND_ASSIGN(TestLayerAnimator); 91 DISALLOW_COPY_AND_ASSIGN(TestLayerAnimator);
93 }; 92 };
94 93
95 // The test layer animation sequence updates a live instances count when it is 94 // The test layer animation sequence updates a live instances count when it is
96 // created and destroyed. 95 // created and destroyed.
97 class TestLayerAnimationSequence : public LayerAnimationSequence { 96 class TestLayerAnimationSequence : public LayerAnimationSequence {
98 public: 97 public:
(...skipping 12 matching lines...) Expand all
111 int* num_live_instances_; 110 int* num_live_instances_;
112 111
113 DISALLOW_COPY_AND_ASSIGN(TestLayerAnimationSequence); 112 DISALLOW_COPY_AND_ASSIGN(TestLayerAnimationSequence);
114 }; 113 };
115 114
116 } // namespace 115 } // namespace
117 116
118 // Checks that setting a property on an implicit animator causes an animation to 117 // Checks that setting a property on an implicit animator causes an animation to
119 // happen. 118 // happen.
120 TEST(LayerAnimatorTest, ImplicitAnimation) { 119 TEST(LayerAnimatorTest, ImplicitAnimation) {
121 scoped_refptr<LayerAnimator> animator( 120 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateImplicitAnimator());
122 LayerAnimator::CreateImplicitAnimator());
123 AnimationContainerElement* element = animator.get(); 121 AnimationContainerElement* element = animator.get();
124 animator->set_disable_timer_for_test(true); 122 animator->set_disable_timer_for_test(true);
125 TestLayerAnimationDelegate delegate; 123 TestLayerAnimationDelegate delegate;
126 animator->SetDelegate(&delegate); 124 animator->SetDelegate(&delegate);
127 base::TimeTicks now = base::TimeTicks::Now(); 125 base::TimeTicks now = base::TimeTicks::Now();
128 animator->SetOpacity(0.5); 126 animator->SetOpacity(0.5);
129 EXPECT_TRUE(animator->is_animating()); 127 EXPECT_TRUE(animator->is_animating());
130 element->Step(now + base::TimeDelta::FromSeconds(1)); 128 element->Step(now + base::TimeDelta::FromSeconds(1));
131 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), 0.5); 129 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), 0.5);
132 } 130 }
133 131
134 // Checks that if the animator is a default animator, that implicit animations 132 // Checks that if the animator is a default animator, that implicit animations
135 // are not started. 133 // are not started.
136 TEST(LayerAnimatorTest, NoImplicitAnimation) { 134 TEST(LayerAnimatorTest, NoImplicitAnimation) {
137 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 135 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
138 animator->set_disable_timer_for_test(true); 136 animator->set_disable_timer_for_test(true);
139 TestLayerAnimationDelegate delegate; 137 TestLayerAnimationDelegate delegate;
140 animator->SetDelegate(&delegate); 138 animator->SetDelegate(&delegate);
141 animator->SetOpacity(0.5); 139 animator->SetOpacity(0.5);
142 EXPECT_FALSE(animator->is_animating()); 140 EXPECT_FALSE(animator->is_animating());
143 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), 0.5); 141 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), 0.5);
144 } 142 }
145 143
146 // Checks that StopAnimatingProperty stops animation for that property, and also 144 // Checks that StopAnimatingProperty stops animation for that property, and also
147 // skips the stopped animation to the end. 145 // skips the stopped animation to the end.
148 TEST(LayerAnimatorTest, StopAnimatingProperty) { 146 TEST(LayerAnimatorTest, StopAnimatingProperty) {
149 scoped_refptr<LayerAnimator> animator( 147 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateImplicitAnimator());
150 LayerAnimator::CreateImplicitAnimator());
151 animator->set_disable_timer_for_test(true); 148 animator->set_disable_timer_for_test(true);
152 TestLayerAnimationDelegate delegate; 149 TestLayerAnimationDelegate delegate;
153 animator->SetDelegate(&delegate); 150 animator->SetDelegate(&delegate);
154 double target_opacity(0.5); 151 double target_opacity(0.5);
155 gfx::Rect target_bounds(0, 0, 50, 50); 152 gfx::Rect target_bounds(0, 0, 50, 50);
156 animator->SetOpacity(target_opacity); 153 animator->SetOpacity(target_opacity);
157 animator->SetBounds(target_bounds); 154 animator->SetBounds(target_bounds);
158 animator->StopAnimatingProperty(LayerAnimationElement::OPACITY); 155 animator->StopAnimatingProperty(LayerAnimationElement::OPACITY);
159 EXPECT_TRUE(animator->is_animating()); 156 EXPECT_TRUE(animator->is_animating());
160 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), 0.5); 157 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), 0.5);
161 animator->StopAnimatingProperty(LayerAnimationElement::BOUNDS); 158 animator->StopAnimatingProperty(LayerAnimationElement::BOUNDS);
162 EXPECT_FALSE(animator->is_animating()); 159 EXPECT_FALSE(animator->is_animating());
163 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds); 160 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds);
164 } 161 }
165 162
166 // Checks that multiple running animation for separate properties can be stopped 163 // Checks that multiple running animation for separate properties can be stopped
167 // simultaneously and that all animations are advanced to their target values. 164 // simultaneously and that all animations are advanced to their target values.
168 TEST(LayerAnimatorTest, StopAnimating) { 165 TEST(LayerAnimatorTest, StopAnimating) {
169 scoped_refptr<LayerAnimator> animator( 166 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateImplicitAnimator());
170 LayerAnimator::CreateImplicitAnimator());
171 animator->set_disable_timer_for_test(true); 167 animator->set_disable_timer_for_test(true);
172 TestLayerAnimationDelegate delegate; 168 TestLayerAnimationDelegate delegate;
173 animator->SetDelegate(&delegate); 169 animator->SetDelegate(&delegate);
174 double target_opacity(0.5); 170 double target_opacity(0.5);
175 gfx::Rect target_bounds(0, 0, 50, 50); 171 gfx::Rect target_bounds(0, 0, 50, 50);
176 animator->SetOpacity(target_opacity); 172 animator->SetOpacity(target_opacity);
177 animator->SetBounds(target_bounds); 173 animator->SetBounds(target_bounds);
178 EXPECT_TRUE(animator->is_animating()); 174 EXPECT_TRUE(animator->is_animating());
179 animator->StopAnimating(); 175 animator->StopAnimating();
180 EXPECT_FALSE(animator->is_animating()); 176 EXPECT_FALSE(animator->is_animating());
181 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), 0.5); 177 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), 0.5);
182 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds); 178 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds);
183 } 179 }
184 180
185 // Schedule an animation that can run immediately. This is the trivial case and 181 // Schedule an animation that can run immediately. This is the trivial case and
186 // should result in the animation being started immediately. 182 // should result in the animation being started immediately.
187 TEST(LayerAnimatorTest, ScheduleAnimationThatCanRunImmediately) { 183 TEST(LayerAnimatorTest, ScheduleAnimationThatCanRunImmediately) {
188 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 184 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
189 AnimationContainerElement* element = animator.get(); 185 AnimationContainerElement* element = animator.get();
190 animator->set_disable_timer_for_test(true); 186 animator->set_disable_timer_for_test(true);
191 TestLayerAnimationDelegate delegate; 187 TestLayerAnimationDelegate delegate;
192 animator->SetDelegate(&delegate); 188 animator->SetDelegate(&delegate);
193 189
194 double start_opacity(0.0); 190 double start_opacity(0.0);
195 double middle_opacity(0.5); 191 double middle_opacity(0.5);
196 double target_opacity(1.0); 192 double target_opacity(1.0);
197 193
198 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 194 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
(...skipping 16 matching lines...) Expand all
215 211
216 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); 212 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
217 213
218 EXPECT_FALSE(animator->is_animating()); 214 EXPECT_FALSE(animator->is_animating());
219 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); 215 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity);
220 } 216 }
221 217
222 // Schedule two animations on separate properties. Both animations should 218 // Schedule two animations on separate properties. Both animations should
223 // start immediately and should progress in lock step. 219 // start immediately and should progress in lock step.
224 TEST(LayerAnimatorTest, ScheduleTwoAnimationsThatCanRunImmediately) { 220 TEST(LayerAnimatorTest, ScheduleTwoAnimationsThatCanRunImmediately) {
225 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 221 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
226 AnimationContainerElement* element = animator.get(); 222 AnimationContainerElement* element = animator.get();
227 animator->set_disable_timer_for_test(true); 223 animator->set_disable_timer_for_test(true);
228 TestLayerAnimationDelegate delegate; 224 TestLayerAnimationDelegate delegate;
229 animator->SetDelegate(&delegate); 225 animator->SetDelegate(&delegate);
230 226
231 double start_opacity(0.0); 227 double start_opacity(0.0);
232 double middle_opacity(0.5); 228 double middle_opacity(0.5);
233 double target_opacity(1.0); 229 double target_opacity(1.0);
234 230
235 gfx::Rect start_bounds, target_bounds, middle_bounds; 231 gfx::Rect start_bounds, target_bounds, middle_bounds;
(...skipping 29 matching lines...) Expand all
265 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); 261 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
266 262
267 EXPECT_FALSE(animator->is_animating()); 263 EXPECT_FALSE(animator->is_animating());
268 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); 264 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity);
269 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds); 265 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds);
270 } 266 }
271 267
272 // Schedule two animations on the same property. In this case, the two 268 // Schedule two animations on the same property. In this case, the two
273 // animations should run one after another. 269 // animations should run one after another.
274 TEST(LayerAnimatorTest, ScheduleTwoAnimationsOnSameProperty) { 270 TEST(LayerAnimatorTest, ScheduleTwoAnimationsOnSameProperty) {
275 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 271 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
276 AnimationContainerElement* element = animator.get(); 272 AnimationContainerElement* element = animator.get();
277 animator->set_disable_timer_for_test(true); 273 animator->set_disable_timer_for_test(true);
278 TestLayerAnimationDelegate delegate; 274 TestLayerAnimationDelegate delegate;
279 animator->SetDelegate(&delegate); 275 animator->SetDelegate(&delegate);
280 276
281 double start_opacity(0.0); 277 double start_opacity(0.0);
282 double middle_opacity(0.5); 278 double middle_opacity(0.5);
283 double target_opacity(1.0); 279 double target_opacity(1.0);
284 280
285 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 281 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); 313 element->Step(start_time + base::TimeDelta::FromMilliseconds(2000));
318 314
319 EXPECT_FALSE(animator->is_animating()); 315 EXPECT_FALSE(animator->is_animating());
320 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); 316 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity);
321 } 317 }
322 318
323 // Schedule [{o}, {o,b}, {b}] and ensure that {b} doesn't run right away. That 319 // Schedule [{o}, {o,b}, {b}] and ensure that {b} doesn't run right away. That
324 // is, ensure that all animations targetting a particular property are run in 320 // is, ensure that all animations targetting a particular property are run in
325 // order. 321 // order.
326 TEST(LayerAnimatorTest, ScheduleBlockedAnimation) { 322 TEST(LayerAnimatorTest, ScheduleBlockedAnimation) {
327 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 323 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
328 AnimationContainerElement* element = animator.get(); 324 AnimationContainerElement* element = animator.get();
329 animator->set_disable_timer_for_test(true); 325 animator->set_disable_timer_for_test(true);
330 TestLayerAnimationDelegate delegate; 326 TestLayerAnimationDelegate delegate;
331 animator->SetDelegate(&delegate); 327 animator->SetDelegate(&delegate);
332 328
333 double start_opacity(0.0); 329 double start_opacity(0.0);
334 double middle_opacity(0.5); 330 double middle_opacity(0.5);
335 double target_opacity(1.0); 331 double target_opacity(1.0);
336 332
337 gfx::Rect start_bounds, target_bounds, middle_bounds; 333 gfx::Rect start_bounds, target_bounds, middle_bounds;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 391
396 EXPECT_FALSE(animator->is_animating()); 392 EXPECT_FALSE(animator->is_animating());
397 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); 393 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity);
398 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds); 394 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds);
399 } 395 }
400 396
401 // Schedule {o} and then schedule {o} and {b} together. In this case, since 397 // Schedule {o} and then schedule {o} and {b} together. In this case, since
402 // ScheduleTogether is being used, the bounds animation should not start until 398 // ScheduleTogether is being used, the bounds animation should not start until
403 // the second opacity animation starts. 399 // the second opacity animation starts.
404 TEST(LayerAnimatorTest, ScheduleTogether) { 400 TEST(LayerAnimatorTest, ScheduleTogether) {
405 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 401 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
406 AnimationContainerElement* element = animator.get(); 402 AnimationContainerElement* element = animator.get();
407 animator->set_disable_timer_for_test(true); 403 animator->set_disable_timer_for_test(true);
408 TestLayerAnimationDelegate delegate; 404 TestLayerAnimationDelegate delegate;
409 animator->SetDelegate(&delegate); 405 animator->SetDelegate(&delegate);
410 406
411 double start_opacity(0.0); 407 double start_opacity(0.0);
412 double target_opacity(1.0); 408 double target_opacity(1.0);
413 409
414 gfx::Rect start_bounds, target_bounds, middle_bounds; 410 gfx::Rect start_bounds, target_bounds, middle_bounds;
415 start_bounds = target_bounds = gfx::Rect(0, 0, 50, 50); 411 start_bounds = target_bounds = gfx::Rect(0, 0, 50, 50);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); 444 element->Step(start_time + base::TimeDelta::FromMilliseconds(2000));
449 445
450 EXPECT_FALSE(animator->is_animating()); 446 EXPECT_FALSE(animator->is_animating());
451 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); 447 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity);
452 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds); 448 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds);
453 } 449 }
454 450
455 // Start animation (that can run immediately). This is the trivial case (see 451 // Start animation (that can run immediately). This is the trivial case (see
456 // the trival case for ScheduleAnimation). 452 // the trival case for ScheduleAnimation).
457 TEST(LayerAnimatorTest, StartAnimationThatCanRunImmediately) { 453 TEST(LayerAnimatorTest, StartAnimationThatCanRunImmediately) {
458 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 454 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
459 AnimationContainerElement* element = animator.get(); 455 AnimationContainerElement* element = animator.get();
460 animator->set_disable_timer_for_test(true); 456 animator->set_disable_timer_for_test(true);
461 TestLayerAnimationDelegate delegate; 457 TestLayerAnimationDelegate delegate;
462 animator->SetDelegate(&delegate); 458 animator->SetDelegate(&delegate);
463 459
464 double start_opacity(0.0); 460 double start_opacity(0.0);
465 double middle_opacity(0.5); 461 double middle_opacity(0.5);
466 double target_opacity(1.0); 462 double target_opacity(1.0);
467 463
468 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 464 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
(...skipping 15 matching lines...) Expand all
484 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); 480 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity);
485 481
486 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); 482 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
487 483
488 EXPECT_FALSE(animator->is_animating()); 484 EXPECT_FALSE(animator->is_animating());
489 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); 485 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity);
490 } 486 }
491 487
492 // Preempt by immediately setting new target. 488 // Preempt by immediately setting new target.
493 TEST(LayerAnimatorTest, PreemptBySettingNewTarget) { 489 TEST(LayerAnimatorTest, PreemptBySettingNewTarget) {
494 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 490 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
495 animator->set_disable_timer_for_test(true); 491 animator->set_disable_timer_for_test(true);
496 TestLayerAnimationDelegate delegate; 492 TestLayerAnimationDelegate delegate;
497 animator->SetDelegate(&delegate); 493 animator->SetDelegate(&delegate);
498 494
499 double start_opacity(0.0); 495 double start_opacity(0.0);
500 double target_opacity(1.0); 496 double target_opacity(1.0);
501 497
502 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 498 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
503 499
504 delegate.SetOpacityFromAnimation(start_opacity); 500 delegate.SetOpacityFromAnimation(start_opacity);
505 501
506 animator->set_preemption_strategy(LayerAnimator::IMMEDIATELY_SET_NEW_TARGET); 502 animator->set_preemption_strategy(LayerAnimator::IMMEDIATELY_SET_NEW_TARGET);
507 503
508 animator->StartAnimation( 504 animator->StartAnimation(
509 new LayerAnimationSequence( 505 new LayerAnimationSequence(
510 LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); 506 LayerAnimationElement::CreateOpacityElement(target_opacity, delta)));
511 507
512 animator->StartAnimation( 508 animator->StartAnimation(
513 new LayerAnimationSequence( 509 new LayerAnimationSequence(
514 LayerAnimationElement::CreateOpacityElement(start_opacity, delta))); 510 LayerAnimationElement::CreateOpacityElement(start_opacity, delta)));
515 511
516 EXPECT_FALSE(animator->is_animating()); 512 EXPECT_FALSE(animator->is_animating());
517 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); 513 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity);
518 } 514 }
519 515
520 // Preempt by animating to new target. 516 // Preempt by animating to new target.
521 TEST(LayerAnimatorTest, PreemptByImmediatelyAnimatingToNewTarget) { 517 TEST(LayerAnimatorTest, PreemptByImmediatelyAnimatingToNewTarget) {
522 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 518 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
523 AnimationContainerElement* element = animator.get(); 519 AnimationContainerElement* element = animator.get();
524 animator->set_disable_timer_for_test(true); 520 animator->set_disable_timer_for_test(true);
525 TestLayerAnimationDelegate delegate; 521 TestLayerAnimationDelegate delegate;
526 animator->SetDelegate(&delegate); 522 animator->SetDelegate(&delegate);
527 523
528 double start_opacity(0.0); 524 double start_opacity(0.0);
529 double middle_opacity(0.5); 525 double middle_opacity(0.5);
530 double target_opacity(1.0); 526 double target_opacity(1.0);
531 527
532 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 528 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 0.5 * (start_opacity + middle_opacity)); 560 0.5 * (start_opacity + middle_opacity));
565 561
566 element->Step(start_time + base::TimeDelta::FromMilliseconds(1500)); 562 element->Step(start_time + base::TimeDelta::FromMilliseconds(1500));
567 563
568 EXPECT_FALSE(animator->is_animating()); 564 EXPECT_FALSE(animator->is_animating());
569 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); 565 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity);
570 } 566 }
571 567
572 // Preempt by enqueuing the new animation. 568 // Preempt by enqueuing the new animation.
573 TEST(LayerAnimatorTest, PreemptEnqueueNewAnimation) { 569 TEST(LayerAnimatorTest, PreemptEnqueueNewAnimation) {
574 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 570 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
575 AnimationContainerElement* element = animator.get(); 571 AnimationContainerElement* element = animator.get();
576 animator->set_disable_timer_for_test(true); 572 animator->set_disable_timer_for_test(true);
577 TestLayerAnimationDelegate delegate; 573 TestLayerAnimationDelegate delegate;
578 animator->SetDelegate(&delegate); 574 animator->SetDelegate(&delegate);
579 575
580 double start_opacity(0.0); 576 double start_opacity(0.0);
581 double middle_opacity(0.5); 577 double middle_opacity(0.5);
582 double target_opacity(1.0); 578 double target_opacity(1.0);
583 579
584 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 580 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); 613 element->Step(start_time + base::TimeDelta::FromMilliseconds(2000));
618 614
619 EXPECT_FALSE(animator->is_animating()); 615 EXPECT_FALSE(animator->is_animating());
620 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); 616 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity);
621 } 617 }
622 618
623 // Start an animation when there are sequences waiting in the queue. In this 619 // Start an animation when there are sequences waiting in the queue. In this
624 // case, all pending and running animations should be finished, and the new 620 // case, all pending and running animations should be finished, and the new
625 // animation started. 621 // animation started.
626 TEST(LayerAnimatorTest, PreemptyByReplacingQueuedAnimations) { 622 TEST(LayerAnimatorTest, PreemptyByReplacingQueuedAnimations) {
627 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 623 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
628 AnimationContainerElement* element = animator.get(); 624 AnimationContainerElement* element = animator.get();
629 animator->set_disable_timer_for_test(true); 625 animator->set_disable_timer_for_test(true);
630 TestLayerAnimationDelegate delegate; 626 TestLayerAnimationDelegate delegate;
631 animator->SetDelegate(&delegate); 627 animator->SetDelegate(&delegate);
632 628
633 double start_opacity(0.0); 629 double start_opacity(0.0);
634 double middle_opacity(0.5); 630 double middle_opacity(0.5);
635 double target_opacity(1.0); 631 double target_opacity(1.0);
636 632
637 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 633 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity); 668 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), middle_opacity);
673 669
674 element->Step(start_time + base::TimeDelta::FromMilliseconds(2000)); 670 element->Step(start_time + base::TimeDelta::FromMilliseconds(2000));
675 671
676 EXPECT_FALSE(animator->is_animating()); 672 EXPECT_FALSE(animator->is_animating());
677 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity); 673 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity);
678 } 674 }
679 675
680 // Test that cyclic sequences continue to animate. 676 // Test that cyclic sequences continue to animate.
681 TEST(LayerAnimatorTest, CyclicSequences) { 677 TEST(LayerAnimatorTest, CyclicSequences) {
682 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 678 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
683 AnimationContainerElement* element = animator.get(); 679 AnimationContainerElement* element = animator.get();
684 animator->set_disable_timer_for_test(true); 680 animator->set_disable_timer_for_test(true);
685 TestLayerAnimationDelegate delegate; 681 TestLayerAnimationDelegate delegate;
686 animator->SetDelegate(&delegate); 682 animator->SetDelegate(&delegate);
687 683
688 double start_opacity(0.0); 684 double start_opacity(0.0);
689 double target_opacity(1.0); 685 double target_opacity(1.0);
690 686
691 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 687 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
692 688
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 727
732 EXPECT_TRUE(animator->is_animating()); 728 EXPECT_TRUE(animator->is_animating());
733 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity); 729 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), target_opacity);
734 730
735 animator->StopAnimatingProperty(LayerAnimationElement::OPACITY); 731 animator->StopAnimatingProperty(LayerAnimationElement::OPACITY);
736 732
737 EXPECT_FALSE(animator->is_animating()); 733 EXPECT_FALSE(animator->is_animating());
738 } 734 }
739 735
740 TEST(LayerAnimatorTest, AddObserverExplicit) { 736 TEST(LayerAnimatorTest, AddObserverExplicit) {
741 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 737 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
742 AnimationContainerElement* element = animator.get(); 738 AnimationContainerElement* element = animator.get();
743 animator->set_disable_timer_for_test(true); 739 animator->set_disable_timer_for_test(true);
744 TestLayerAnimationObserver observer; 740 TestLayerAnimationObserver observer;
745 TestLayerAnimationDelegate delegate; 741 TestLayerAnimationDelegate delegate;
746 animator->SetDelegate(&delegate); 742 animator->SetDelegate(&delegate);
747 animator->AddObserver(&observer); 743 animator->AddObserver(&observer);
748 observer.set_requires_notification_when_animator_destroyed(true); 744 observer.set_requires_notification_when_animator_destroyed(true);
749 745
750 EXPECT_TRUE(!observer.last_ended_sequence()); 746 EXPECT_TRUE(!observer.last_ended_sequence());
751 747
(...skipping 13 matching lines...) Expand all
765 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); 761 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
766 762
767 EXPECT_EQ(observer.last_ended_sequence(), sequence); 763 EXPECT_EQ(observer.last_ended_sequence(), sequence);
768 764
769 // |sequence| has been destroyed. Recreate it to test abort. 765 // |sequence| has been destroyed. Recreate it to test abort.
770 sequence = new LayerAnimationSequence( 766 sequence = new LayerAnimationSequence(
771 LayerAnimationElement::CreateOpacityElement(1.0f, delta)); 767 LayerAnimationElement::CreateOpacityElement(1.0f, delta));
772 768
773 animator->StartAnimation(sequence); 769 animator->StartAnimation(sequence);
774 770
775 animator = NULL; 771 animator.reset();
776 772
777 EXPECT_EQ(observer.last_aborted_sequence(), sequence); 773 EXPECT_EQ(observer.last_aborted_sequence(), sequence);
778 } 774 }
779 775
780 // Tests that an observer added to a scoped settings object is still notified 776 // Tests that an observer added to a scoped settings object is still notified
781 // when the object goes out of scope. 777 // when the object goes out of scope.
782 TEST(LayerAnimatorTest, ImplicitAnimationObservers) { 778 TEST(LayerAnimatorTest, ImplicitAnimationObservers) {
783 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 779 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
784 AnimationContainerElement* element = animator.get(); 780 AnimationContainerElement* element = animator.get();
785 animator->set_disable_timer_for_test(true); 781 animator->set_disable_timer_for_test(true);
786 TestImplicitAnimationObserver observer(false); 782 TestImplicitAnimationObserver observer(false);
787 TestLayerAnimationDelegate delegate; 783 TestLayerAnimationDelegate delegate;
788 animator->SetDelegate(&delegate); 784 animator->SetDelegate(&delegate);
789 785
790 EXPECT_FALSE(observer.animations_completed()); 786 EXPECT_FALSE(observer.animations_completed());
791 animator->SetOpacity(1.0f); 787 animator->SetOpacity(1.0f);
792 788
793 { 789 {
794 ScopedLayerAnimationSettings settings(animator.get()); 790 ScopedLayerAnimationSettings settings(animator.get());
795 settings.AddObserver(&observer); 791 settings.AddObserver(&observer);
796 animator->SetOpacity(0.0f); 792 animator->SetOpacity(0.0f);
797 } 793 }
798 794
799 EXPECT_FALSE(observer.animations_completed()); 795 EXPECT_FALSE(observer.animations_completed());
800 base::TimeTicks start_time = animator->last_step_time(); 796 base::TimeTicks start_time = animator->last_step_time();
801 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); 797 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
802 EXPECT_TRUE(observer.animations_completed()); 798 EXPECT_TRUE(observer.animations_completed());
803 EXPECT_FLOAT_EQ(0.0f, delegate.GetOpacityForAnimation()); 799 EXPECT_FLOAT_EQ(0.0f, delegate.GetOpacityForAnimation());
804 } 800 }
805 801
806 // Tests that an observer added to a scoped settings object is still notified 802 // Tests that an observer added to a scoped settings object is still notified
807 // when the object goes out of scope due to the animation being interrupted. 803 // when the object goes out of scope due to the animation being interrupted.
808 TEST(LayerAnimatorTest, InterruptedImplicitAnimationObservers) { 804 TEST(LayerAnimatorTest, InterruptedImplicitAnimationObservers) {
809 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 805 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
810 animator->set_disable_timer_for_test(true); 806 animator->set_disable_timer_for_test(true);
811 TestImplicitAnimationObserver observer(false); 807 TestImplicitAnimationObserver observer(false);
812 TestLayerAnimationDelegate delegate; 808 TestLayerAnimationDelegate delegate;
813 animator->SetDelegate(&delegate); 809 animator->SetDelegate(&delegate);
814 810
815 EXPECT_FALSE(observer.animations_completed()); 811 EXPECT_FALSE(observer.animations_completed());
816 animator->SetOpacity(1.0f); 812 animator->SetOpacity(1.0f);
817 813
818 { 814 {
819 ScopedLayerAnimationSettings settings(animator.get()); 815 ScopedLayerAnimationSettings settings(animator.get());
820 settings.AddObserver(&observer); 816 settings.AddObserver(&observer);
821 animator->SetOpacity(0.0f); 817 animator->SetOpacity(0.0f);
822 } 818 }
823 819
824 EXPECT_FALSE(observer.animations_completed()); 820 EXPECT_FALSE(observer.animations_completed());
825 // This should interrupt the implicit animation causing the observer to be 821 // This should interrupt the implicit animation causing the observer to be
826 // notified immediately. 822 // notified immediately.
827 animator->SetOpacity(1.0f); 823 animator->SetOpacity(1.0f);
828 EXPECT_TRUE(observer.animations_completed()); 824 EXPECT_TRUE(observer.animations_completed());
829 EXPECT_FLOAT_EQ(1.0f, delegate.GetOpacityForAnimation()); 825 EXPECT_FLOAT_EQ(1.0f, delegate.GetOpacityForAnimation());
830 } 826 }
831 827
832 // Tests that an observer added to a scoped settings object is not notified 828 // Tests that an observer added to a scoped settings object is not notified
833 // when the animator is destroyed unless explicitly requested. 829 // when the animator is destroyed unless explicitly requested.
834 TEST(LayerAnimatorTest, ImplicitObserversAtAnimatorDestruction) { 830 TEST(LayerAnimatorTest, ImplicitObserversAtAnimatorDestruction) {
835 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 831 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
836 animator->set_disable_timer_for_test(true); 832 animator->set_disable_timer_for_test(true);
837 TestImplicitAnimationObserver observer_notify(true); 833 TestImplicitAnimationObserver observer_notify(true);
838 TestImplicitAnimationObserver observer_do_not_notify(false); 834 TestImplicitAnimationObserver observer_do_not_notify(false);
839 TestLayerAnimationDelegate delegate; 835 TestLayerAnimationDelegate delegate;
840 animator->SetDelegate(&delegate); 836 animator->SetDelegate(&delegate);
841 837
842 EXPECT_FALSE(observer_notify.animations_completed()); 838 EXPECT_FALSE(observer_notify.animations_completed());
843 EXPECT_FALSE(observer_do_not_notify.animations_completed()); 839 EXPECT_FALSE(observer_do_not_notify.animations_completed());
844 840
845 animator->SetOpacity(1.0f); 841 animator->SetOpacity(1.0f);
846 842
847 { 843 {
848 ScopedLayerAnimationSettings settings(animator.get()); 844 ScopedLayerAnimationSettings settings(animator.get());
849 settings.AddObserver(&observer_notify); 845 settings.AddObserver(&observer_notify);
850 settings.AddObserver(&observer_do_not_notify); 846 settings.AddObserver(&observer_do_not_notify);
851 animator->SetOpacity(0.0f); 847 animator->SetOpacity(0.0f);
852 } 848 }
853 849
854 EXPECT_FALSE(observer_notify.animations_completed()); 850 EXPECT_FALSE(observer_notify.animations_completed());
855 EXPECT_FALSE(observer_do_not_notify.animations_completed()); 851 EXPECT_FALSE(observer_do_not_notify.animations_completed());
856 animator = NULL; 852 animator.reset(NULL);
857 EXPECT_TRUE(observer_notify.animations_completed()); 853 EXPECT_TRUE(observer_notify.animations_completed());
858 EXPECT_FALSE(observer_do_not_notify.animations_completed()); 854 EXPECT_FALSE(observer_do_not_notify.animations_completed());
859 } 855 }
860 856
861 857
862 TEST(LayerAnimatorTest, RemoveObserverShouldRemoveFromSequences) { 858 TEST(LayerAnimatorTest, RemoveObserverShouldRemoveFromSequences) {
863 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 859 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
864 AnimationContainerElement* element = animator.get(); 860 AnimationContainerElement* element = animator.get();
865 animator->set_disable_timer_for_test(true); 861 animator->set_disable_timer_for_test(true);
866 TestLayerAnimationObserver observer; 862 TestLayerAnimationObserver observer;
867 TestLayerAnimationObserver removed_observer; 863 TestLayerAnimationObserver removed_observer;
868 TestLayerAnimationDelegate delegate; 864 TestLayerAnimationDelegate delegate;
869 animator->SetDelegate(&delegate); 865 animator->SetDelegate(&delegate);
870 866
871 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 867 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
872 868
873 LayerAnimationSequence* sequence = new LayerAnimationSequence( 869 LayerAnimationSequence* sequence = new LayerAnimationSequence(
(...skipping 14 matching lines...) Expand all
888 884
889 base::TimeTicks start_time = animator->last_step_time(); 885 base::TimeTicks start_time = animator->last_step_time();
890 886
891 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); 887 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
892 888
893 EXPECT_EQ(observer.last_ended_sequence(), sequence); 889 EXPECT_EQ(observer.last_ended_sequence(), sequence);
894 EXPECT_TRUE(!removed_observer.last_ended_sequence()); 890 EXPECT_TRUE(!removed_observer.last_ended_sequence());
895 } 891 }
896 892
897 TEST(LayerAnimatorTest, ObserverReleasedBeforeAnimationSequenceEnds) { 893 TEST(LayerAnimatorTest, ObserverReleasedBeforeAnimationSequenceEnds) {
898 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 894 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
899 animator->set_disable_timer_for_test(true); 895 animator->set_disable_timer_for_test(true);
900 896
901 scoped_ptr<TestLayerAnimationObserver> observer( 897 scoped_ptr<TestLayerAnimationObserver> observer(
902 new TestLayerAnimationObserver); 898 new TestLayerAnimationObserver);
903 TestLayerAnimationDelegate delegate; 899 TestLayerAnimationDelegate delegate;
904 animator->SetDelegate(&delegate); 900 animator->SetDelegate(&delegate);
905 animator->AddObserver(observer.get()); 901 animator->AddObserver(observer.get());
906 902
907 delegate.SetOpacityFromAnimation(0.0f); 903 delegate.SetOpacityFromAnimation(0.0f);
908 904
909 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 905 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
910 LayerAnimationSequence* sequence = new LayerAnimationSequence( 906 LayerAnimationSequence* sequence = new LayerAnimationSequence(
911 LayerAnimationElement::CreateOpacityElement(1.0f, delta)); 907 LayerAnimationElement::CreateOpacityElement(1.0f, delta));
912 908
913 animator->StartAnimation(sequence); 909 animator->StartAnimation(sequence);
914 910
915 // |observer| should be attached to |sequence|. 911 // |observer| should be attached to |sequence|.
916 EXPECT_EQ(static_cast<size_t>(1), sequence->observers_.size()); 912 EXPECT_EQ(static_cast<size_t>(1), sequence->observers_.size());
917 913
918 // Now, release |observer| 914 // Now, release |observer|
919 observer.reset(); 915 observer.reset();
920 916
921 // And |sequence| should no longer be attached to |observer|. 917 // And |sequence| should no longer be attached to |observer|.
922 EXPECT_EQ(static_cast<size_t>(0), sequence->observers_.size()); 918 EXPECT_EQ(static_cast<size_t>(0), sequence->observers_.size());
923 } 919 }
924 920
925 TEST(LayerAnimatorTest, ObserverAttachedAfterAnimationStarted) { 921 TEST(LayerAnimatorTest, ObserverAttachedAfterAnimationStarted) {
926 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 922 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
927 AnimationContainerElement* element = animator.get(); 923 AnimationContainerElement* element = animator.get();
928 animator->set_disable_timer_for_test(true); 924 animator->set_disable_timer_for_test(true);
929 925
930 TestImplicitAnimationObserver observer(false); 926 TestImplicitAnimationObserver observer(false);
931 TestLayerAnimationDelegate delegate; 927 TestLayerAnimationDelegate delegate;
932 animator->SetDelegate(&delegate); 928 animator->SetDelegate(&delegate);
933 929
934 delegate.SetOpacityFromAnimation(0.0f); 930 delegate.SetOpacityFromAnimation(0.0f);
935 931
936 { 932 {
(...skipping 12 matching lines...) Expand all
949 // Start observing an in-flight animation. 945 // Start observing an in-flight animation.
950 sequence->AddObserver(&observer); 946 sequence->AddObserver(&observer);
951 947
952 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); 948 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
953 } 949 }
954 950
955 EXPECT_TRUE(observer.animations_completed()); 951 EXPECT_TRUE(observer.animations_completed());
956 } 952 }
957 953
958 TEST(LayerAnimatorTest, ObserverDetachedBeforeAnimationFinished) { 954 TEST(LayerAnimatorTest, ObserverDetachedBeforeAnimationFinished) {
959 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 955 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
960 AnimationContainerElement* element = animator.get(); 956 AnimationContainerElement* element = animator.get();
961 animator->set_disable_timer_for_test(true); 957 animator->set_disable_timer_for_test(true);
962 958
963 TestImplicitAnimationObserver observer(false); 959 TestImplicitAnimationObserver observer(false);
964 TestLayerAnimationDelegate delegate; 960 TestLayerAnimationDelegate delegate;
965 animator->SetDelegate(&delegate); 961 animator->SetDelegate(&delegate);
966 962
967 delegate.SetOpacityFromAnimation(0.0f); 963 delegate.SetOpacityFromAnimation(0.0f);
968 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 964 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
969 LayerAnimationSequence* sequence = new LayerAnimationSequence( 965 LayerAnimationSequence* sequence = new LayerAnimationSequence(
(...skipping 16 matching lines...) Expand all
986 EXPECT_TRUE(observer.animations_completed()); 982 EXPECT_TRUE(observer.animations_completed());
987 } 983 }
988 984
989 // This checks that if an animation is deleted due to a callback, that the 985 // This checks that if an animation is deleted due to a callback, that the
990 // animator does not try to use the deleted animation. For example, if we have 986 // animator does not try to use the deleted animation. For example, if we have
991 // two running animations, and the first finishes and the resulting callback 987 // two running animations, and the first finishes and the resulting callback
992 // causes the second to be deleted, we should not attempt to animate the second 988 // causes the second to be deleted, we should not attempt to animate the second
993 // animation. 989 // animation.
994 TEST(LayerAnimatorTest, ObserverDeletesAnimations) { 990 TEST(LayerAnimatorTest, ObserverDeletesAnimations) {
995 LayerAnimator::set_disable_animations_for_test(false); 991 LayerAnimator::set_disable_animations_for_test(false);
996 scoped_refptr<LayerAnimator> animator(new TestLayerAnimator()); 992 scoped_ptr<LayerAnimator> animator(new TestLayerAnimator());
997 AnimationContainerElement* element = animator.get(); 993 AnimationContainerElement* element = animator.get();
998 animator->set_disable_timer_for_test(true); 994 animator->set_disable_timer_for_test(true);
999 TestLayerAnimationDelegate delegate; 995 TestLayerAnimationDelegate delegate;
1000 animator->SetDelegate(&delegate); 996 animator->SetDelegate(&delegate);
1001 997
1002 double start_opacity(0.0); 998 double start_opacity(0.0);
1003 double target_opacity(1.0); 999 double target_opacity(1.0);
1004 1000
1005 gfx::Rect start_bounds(0, 0, 50, 50); 1001 gfx::Rect start_bounds(0, 0, 50, 50);
1006 gfx::Rect target_bounds(5, 5, 5, 5); 1002 gfx::Rect target_bounds(5, 5, 5, 5);
(...skipping 22 matching lines...) Expand all
1029 1025
1030 base::TimeTicks start_time = animator->last_step_time(); 1026 base::TimeTicks start_time = animator->last_step_time();
1031 element->Step(start_time + halfway_delta); 1027 element->Step(start_time + halfway_delta);
1032 1028
1033 animator->RemoveObserver(observer.get()); 1029 animator->RemoveObserver(observer.get());
1034 } 1030 }
1035 1031
1036 // Check that setting a property during an animation with a default animator 1032 // Check that setting a property during an animation with a default animator
1037 // cancels the original animation. 1033 // cancels the original animation.
1038 TEST(LayerAnimatorTest, SettingPropertyDuringAnAnimation) { 1034 TEST(LayerAnimatorTest, SettingPropertyDuringAnAnimation) {
1039 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 1035 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
1040 animator->set_disable_timer_for_test(true); 1036 animator->set_disable_timer_for_test(true);
1041 TestLayerAnimationDelegate delegate; 1037 TestLayerAnimationDelegate delegate;
1042 animator->SetDelegate(&delegate); 1038 animator->SetDelegate(&delegate);
1043 1039
1044 double start_opacity(0.0); 1040 double start_opacity(0.0);
1045 double target_opacity(1.0); 1041 double target_opacity(1.0);
1046 1042
1047 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 1043 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
1048 1044
1049 delegate.SetOpacityFromAnimation(start_opacity); 1045 delegate.SetOpacityFromAnimation(start_opacity);
1050 1046
1051 scoped_ptr<LayerAnimationSequence> sequence( 1047 scoped_ptr<LayerAnimationSequence> sequence(
1052 new LayerAnimationSequence( 1048 new LayerAnimationSequence(
1053 LayerAnimationElement::CreateOpacityElement(target_opacity, delta))); 1049 LayerAnimationElement::CreateOpacityElement(target_opacity, delta)));
1054 1050
1055 animator->StartAnimation(sequence.release()); 1051 animator->StartAnimation(sequence.release());
1056 1052
1057 animator->SetOpacity(0.5); 1053 animator->SetOpacity(0.5);
1058 1054
1059 EXPECT_FALSE(animator->is_animating()); 1055 EXPECT_FALSE(animator->is_animating());
1060 EXPECT_EQ(0.5, animator->GetTargetOpacity()); 1056 EXPECT_EQ(0.5, animator->GetTargetOpacity());
1061 } 1057 }
1062 1058
1063 // Tests that the preemption mode IMMEDIATELY_SET_NEW_TARGET, doesn't cause the 1059 // Tests that the preemption mode IMMEDIATELY_SET_NEW_TARGET, doesn't cause the
1064 // second sequence to be leaked. 1060 // second sequence to be leaked.
1065 TEST(LayerAnimatorTest, ImmediatelySettingNewTargetDoesNotLeak) { 1061 TEST(LayerAnimatorTest, ImmediatelySettingNewTargetDoesNotLeak) {
1066 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 1062 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
1067 animator->set_preemption_strategy(LayerAnimator::IMMEDIATELY_SET_NEW_TARGET); 1063 animator->set_preemption_strategy(LayerAnimator::IMMEDIATELY_SET_NEW_TARGET);
1068 animator->set_disable_timer_for_test(true); 1064 animator->set_disable_timer_for_test(true);
1069 TestLayerAnimationDelegate delegate; 1065 TestLayerAnimationDelegate delegate;
1070 animator->SetDelegate(&delegate); 1066 animator->SetDelegate(&delegate);
1071 1067
1072 gfx::Rect start_bounds(0, 0, 50, 50); 1068 gfx::Rect start_bounds(0, 0, 50, 50);
1073 gfx::Rect middle_bounds(10, 10, 100, 100); 1069 gfx::Rect middle_bounds(10, 10, 100, 100);
1074 gfx::Rect target_bounds(5, 5, 5, 5); 1070 gfx::Rect target_bounds(5, 5, 5, 5);
1075 1071
1076 delegate.SetBoundsFromAnimation(start_bounds); 1072 delegate.SetBoundsFromAnimation(start_bounds);
(...skipping 19 matching lines...) Expand all
1096 // the target value. The sequence should alse be destructed. 1092 // the target value. The sequence should alse be destructed.
1097 animator->StartAnimation(sequence.release()); 1093 animator->StartAnimation(sequence.release());
1098 1094
1099 EXPECT_FALSE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS)); 1095 EXPECT_FALSE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS));
1100 EXPECT_EQ(0, num_live_instances); 1096 EXPECT_EQ(0, num_live_instances);
1101 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds); 1097 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), target_bounds);
1102 } 1098 }
1103 1099
1104 // Verifies GetTargetOpacity() works when multiple sequences are scheduled. 1100 // Verifies GetTargetOpacity() works when multiple sequences are scheduled.
1105 TEST(LayerAnimatorTest, GetTargetOpacity) { 1101 TEST(LayerAnimatorTest, GetTargetOpacity) {
1106 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 1102 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
1107 animator->set_preemption_strategy(LayerAnimator::ENQUEUE_NEW_ANIMATION); 1103 animator->set_preemption_strategy(LayerAnimator::ENQUEUE_NEW_ANIMATION);
1108 animator->set_disable_timer_for_test(true); 1104 animator->set_disable_timer_for_test(true);
1109 TestLayerAnimationDelegate delegate; 1105 TestLayerAnimationDelegate delegate;
1110 animator->SetDelegate(&delegate); 1106 animator->SetDelegate(&delegate);
1111 1107
1112 delegate.SetOpacityFromAnimation(0.0); 1108 delegate.SetOpacityFromAnimation(0.0);
1113 1109
1114 { 1110 {
1115 ScopedLayerAnimationSettings settings(animator.get()); 1111 ScopedLayerAnimationSettings settings(animator.get());
1116 animator->SetOpacity(0.5); 1112 animator->SetOpacity(0.5);
1117 EXPECT_EQ(0.5, animator->GetTargetOpacity()); 1113 EXPECT_EQ(0.5, animator->GetTargetOpacity());
1118 1114
1119 // Because the strategy is ENQUEUE_NEW_ANIMATION the target should now be 1. 1115 // Because the strategy is ENQUEUE_NEW_ANIMATION the target should now be 1.
1120 animator->SetOpacity(1.0); 1116 animator->SetOpacity(1.0);
1121 EXPECT_EQ(1.0, animator->GetTargetOpacity()); 1117 EXPECT_EQ(1.0, animator->GetTargetOpacity());
1122 } 1118 }
1123 } 1119 }
1124 1120
1125 // Verifies GetTargetBrightness() works when multiple sequences are scheduled. 1121 // Verifies GetTargetBrightness() works when multiple sequences are scheduled.
1126 TEST(LayerAnimatorTest, GetTargetBrightness) { 1122 TEST(LayerAnimatorTest, GetTargetBrightness) {
1127 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 1123 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
1128 animator->set_preemption_strategy(LayerAnimator::ENQUEUE_NEW_ANIMATION); 1124 animator->set_preemption_strategy(LayerAnimator::ENQUEUE_NEW_ANIMATION);
1129 animator->set_disable_timer_for_test(true); 1125 animator->set_disable_timer_for_test(true);
1130 TestLayerAnimationDelegate delegate; 1126 TestLayerAnimationDelegate delegate;
1131 animator->SetDelegate(&delegate); 1127 animator->SetDelegate(&delegate);
1132 1128
1133 delegate.SetBrightnessFromAnimation(0.0); 1129 delegate.SetBrightnessFromAnimation(0.0);
1134 1130
1135 { 1131 {
1136 ScopedLayerAnimationSettings settings(animator.get()); 1132 ScopedLayerAnimationSettings settings(animator.get());
1137 animator->SetBrightness(0.5); 1133 animator->SetBrightness(0.5);
1138 EXPECT_EQ(0.5, animator->GetTargetBrightness()); 1134 EXPECT_EQ(0.5, animator->GetTargetBrightness());
1139 1135
1140 // Because the strategy is ENQUEUE_NEW_ANIMATION the target should now be 1. 1136 // Because the strategy is ENQUEUE_NEW_ANIMATION the target should now be 1.
1141 animator->SetBrightness(1.0); 1137 animator->SetBrightness(1.0);
1142 EXPECT_EQ(1.0, animator->GetTargetBrightness()); 1138 EXPECT_EQ(1.0, animator->GetTargetBrightness());
1143 } 1139 }
1144 } 1140 }
1145 1141
1146 // Verifies GetTargetGrayscale() works when multiple sequences are scheduled. 1142 // Verifies GetTargetGrayscale() works when multiple sequences are scheduled.
1147 TEST(LayerAnimatorTest, GetTargetGrayscale) { 1143 TEST(LayerAnimatorTest, GetTargetGrayscale) {
1148 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 1144 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
1149 animator->set_preemption_strategy(LayerAnimator::ENQUEUE_NEW_ANIMATION); 1145 animator->set_preemption_strategy(LayerAnimator::ENQUEUE_NEW_ANIMATION);
1150 animator->set_disable_timer_for_test(true); 1146 animator->set_disable_timer_for_test(true);
1151 TestLayerAnimationDelegate delegate; 1147 TestLayerAnimationDelegate delegate;
1152 animator->SetDelegate(&delegate); 1148 animator->SetDelegate(&delegate);
1153 1149
1154 delegate.SetGrayscaleFromAnimation(0.0); 1150 delegate.SetGrayscaleFromAnimation(0.0);
1155 1151
1156 { 1152 {
1157 ScopedLayerAnimationSettings settings(animator.get()); 1153 ScopedLayerAnimationSettings settings(animator.get());
1158 animator->SetGrayscale(0.5); 1154 animator->SetGrayscale(0.5);
1159 EXPECT_EQ(0.5, animator->GetTargetGrayscale()); 1155 EXPECT_EQ(0.5, animator->GetTargetGrayscale());
1160 1156
1161 // Because the strategy is ENQUEUE_NEW_ANIMATION the target should now be 1. 1157 // Because the strategy is ENQUEUE_NEW_ANIMATION the target should now be 1.
1162 animator->SetGrayscale(1.0); 1158 animator->SetGrayscale(1.0);
1163 EXPECT_EQ(1.0, animator->GetTargetGrayscale()); 1159 EXPECT_EQ(1.0, animator->GetTargetGrayscale());
1164 } 1160 }
1165 } 1161 }
1166 1162
1167 // Verifies SchedulePauseForProperties(). 1163 // Verifies SchedulePauseForProperties().
1168 TEST(LayerAnimatorTest, SchedulePauseForProperties) { 1164 TEST(LayerAnimatorTest, SchedulePauseForProperties) {
1169 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 1165 scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
1170 animator->set_preemption_strategy(LayerAnimator::ENQUEUE_NEW_ANIMATION); 1166 animator->set_preemption_strategy(LayerAnimator::ENQUEUE_NEW_ANIMATION);
1171 animator->SchedulePauseForProperties(base::TimeDelta::FromMilliseconds(100), 1167 animator->SchedulePauseForProperties(base::TimeDelta::FromMilliseconds(100),
1172 LayerAnimationElement::TRANSFORM, 1168 LayerAnimationElement::TRANSFORM,
1173 LayerAnimationElement::BOUNDS, -1); 1169 LayerAnimationElement::BOUNDS, -1);
1174 EXPECT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::TRANSFORM)); 1170 EXPECT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::TRANSFORM));
1175 EXPECT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS)); 1171 EXPECT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS));
1176 EXPECT_FALSE(animator->IsAnimatingProperty(LayerAnimationElement::OPACITY)); 1172 EXPECT_FALSE(animator->IsAnimatingProperty(LayerAnimationElement::OPACITY));
1177 } 1173 }
1178 1174
1179
1180 class AnimatorOwner {
1181 public:
1182 AnimatorOwner()
1183 : animator_(LayerAnimator::CreateDefaultAnimator()) {
1184 }
1185
1186 LayerAnimator* animator() { return animator_.get(); }
1187
1188 private:
1189 scoped_refptr<LayerAnimator> animator_;
1190
1191 DISALLOW_COPY_AND_ASSIGN(AnimatorOwner);
1192 };
1193
1194 class DeletingObserver : public LayerAnimationObserver {
1195 public:
1196 DeletingObserver(bool* was_deleted)
1197 : animator_owner_(new AnimatorOwner),
1198 delete_on_animation_ended_(false),
1199 delete_on_animation_aborted_(false),
1200 delete_on_animation_scheduled_(false),
1201 was_deleted_(was_deleted) {
1202 animator()->AddObserver(this);
1203 }
1204
1205 ~DeletingObserver() {
1206 animator()->RemoveObserver(this);
1207 *was_deleted_ = true;
1208 }
1209
1210 LayerAnimator* animator() { return animator_owner_->animator(); }
1211
1212 bool delete_on_animation_ended() const {
1213 return delete_on_animation_ended_;
1214 }
1215 void set_delete_on_animation_ended(bool enabled) {
1216 delete_on_animation_ended_ = enabled;
1217 }
1218
1219 bool delete_on_animation_aborted() const {
1220 return delete_on_animation_aborted_;
1221 }
1222 void set_delete_on_animation_aborted(bool enabled) {
1223 delete_on_animation_aborted_ = enabled;
1224 }
1225
1226 bool delete_on_animation_scheduled() const {
1227 return delete_on_animation_scheduled_;
1228 }
1229 void set_delete_on_animation_scheduled(bool enabled) {
1230 delete_on_animation_scheduled_ = enabled;
1231 }
1232
1233 // LayerAnimationObserver implementation.
1234 virtual void OnLayerAnimationEnded(
1235 LayerAnimationSequence* sequence) OVERRIDE {
1236 if (delete_on_animation_ended_)
1237 delete this;
1238 }
1239
1240 virtual void OnLayerAnimationAborted(
1241 LayerAnimationSequence* sequence) OVERRIDE {
1242 if (delete_on_animation_aborted_)
1243 delete this;
1244 }
1245
1246 virtual void OnLayerAnimationScheduled(
1247 LayerAnimationSequence* sequence) {
1248 if (delete_on_animation_scheduled_)
1249 delete this;
1250 }
1251
1252 private:
1253 scoped_ptr<AnimatorOwner> animator_owner_;
1254 bool delete_on_animation_ended_;
1255 bool delete_on_animation_aborted_;
1256 bool delete_on_animation_scheduled_;
1257 bool* was_deleted_;
1258
1259 DISALLOW_COPY_AND_ASSIGN(DeletingObserver);
1260 };
1261
1262 TEST(LayerAnimatorTest, ObserverDeletesAnimatorAfterFinishingAnimation) {
1263 bool observer_was_deleted = false;
1264 DeletingObserver* observer = new DeletingObserver(&observer_was_deleted);
1265 observer->set_delete_on_animation_ended(true);
1266 observer->set_delete_on_animation_aborted(true);
1267 LayerAnimator* animator = observer->animator();
1268 AnimationContainerElement* element = observer->animator();
1269 animator->set_disable_timer_for_test(true);
1270 TestLayerAnimationDelegate delegate;
1271 animator->SetDelegate(&delegate);
1272
1273 delegate.SetOpacityFromAnimation(0.0f);
1274
1275 gfx::Rect start_bounds(0, 0, 50, 50);
1276 gfx::Rect target_bounds(10, 10, 100, 100);
1277
1278 delegate.SetBoundsFromAnimation(start_bounds);
1279
1280 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
1281 LayerAnimationSequence* opacity_sequence = new LayerAnimationSequence(
1282 LayerAnimationElement::CreateOpacityElement(1.0f, delta));
1283 animator->StartAnimation(opacity_sequence);
1284
1285 delta = base::TimeDelta::FromSeconds(2);
1286 LayerAnimationSequence* bounds_sequence = new LayerAnimationSequence(
1287 LayerAnimationElement::CreateBoundsElement(target_bounds, delta));
1288 animator->StartAnimation(bounds_sequence);
1289
1290 base::TimeTicks start_time = animator->last_step_time();
1291 element->Step(start_time + base::TimeDelta::FromMilliseconds(1500));
1292
1293 EXPECT_TRUE(observer_was_deleted);
1294 }
1295
1296 TEST(LayerAnimatorTest, ObserverDeletesAnimatorAfterStoppingAnimating) {
1297 bool observer_was_deleted = false;
1298 DeletingObserver* observer = new DeletingObserver(&observer_was_deleted);
1299 observer->set_delete_on_animation_ended(true);
1300 observer->set_delete_on_animation_aborted(true);
1301 LayerAnimator* animator = observer->animator();
1302 animator->set_disable_timer_for_test(true);
1303 TestLayerAnimationDelegate delegate;
1304 animator->SetDelegate(&delegate);
1305
1306 delegate.SetOpacityFromAnimation(0.0f);
1307
1308 gfx::Rect start_bounds(0, 0, 50, 50);
1309 gfx::Rect target_bounds(10, 10, 100, 100);
1310
1311 delegate.SetBoundsFromAnimation(start_bounds);
1312
1313 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
1314 LayerAnimationSequence* opacity_sequence = new LayerAnimationSequence(
1315 LayerAnimationElement::CreateOpacityElement(1.0f, delta));
1316 animator->StartAnimation(opacity_sequence);
1317
1318 delta = base::TimeDelta::FromSeconds(2);
1319 LayerAnimationSequence* bounds_sequence = new LayerAnimationSequence(
1320 LayerAnimationElement::CreateBoundsElement(target_bounds, delta));
1321 animator->StartAnimation(bounds_sequence);
1322
1323 animator->StopAnimating();
1324
1325 EXPECT_TRUE(observer_was_deleted);
1326 }
1327
1328 TEST(LayerAnimatorTest, ObserverDeletesAnimatorAfterScheduling) {
1329 bool observer_was_deleted = false;
1330 DeletingObserver* observer = new DeletingObserver(&observer_was_deleted);
1331 observer->set_delete_on_animation_scheduled(true);
1332 LayerAnimator* animator = observer->animator();
1333 animator->set_disable_timer_for_test(true);
1334 TestLayerAnimationDelegate delegate;
1335 animator->SetDelegate(&delegate);
1336
1337 delegate.SetOpacityFromAnimation(0.0f);
1338
1339 gfx::Rect start_bounds(0, 0, 50, 50);
1340 gfx::Rect target_bounds(10, 10, 100, 100);
1341
1342 delegate.SetBoundsFromAnimation(start_bounds);
1343
1344 std::vector<LayerAnimationSequence*> to_start;
1345
1346 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
1347 to_start.push_back(new LayerAnimationSequence(
1348 LayerAnimationElement::CreateOpacityElement(1.0f, delta)));
1349
1350 delta = base::TimeDelta::FromSeconds(2);
1351 to_start.push_back(new LayerAnimationSequence(
1352 LayerAnimationElement::CreateBoundsElement(target_bounds, delta)));
1353
1354 animator->ScheduleTogether(to_start);
1355
1356 EXPECT_TRUE(observer_was_deleted);
1357 }
1358
1359 TEST(LayerAnimatorTest, ObserverDeletesAnimatorAfterAborted) {
1360 bool observer_was_deleted = false;
1361 DeletingObserver* observer = new DeletingObserver(&observer_was_deleted);
1362 observer->set_delete_on_animation_aborted(true);
1363 LayerAnimator* animator = observer->animator();
1364 animator->set_preemption_strategy(
1365 LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
1366 animator->set_disable_timer_for_test(true);
1367 TestLayerAnimationDelegate delegate;
1368 animator->SetDelegate(&delegate);
1369
1370 delegate.SetOpacityFromAnimation(0.0f);
1371
1372 gfx::Rect start_bounds(0, 0, 50, 50);
1373 gfx::Rect target_bounds(10, 10, 100, 100);
1374
1375 delegate.SetBoundsFromAnimation(start_bounds);
1376
1377 std::vector<LayerAnimationSequence*> to_start;
1378
1379 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
1380 to_start.push_back(new LayerAnimationSequence(
1381 LayerAnimationElement::CreateOpacityElement(1.0f, delta)));
1382
1383 delta = base::TimeDelta::FromSeconds(2);
1384 to_start.push_back(new LayerAnimationSequence(
1385 LayerAnimationElement::CreateBoundsElement(target_bounds, delta)));
1386
1387 animator->ScheduleTogether(to_start);
1388
1389 EXPECT_FALSE(observer_was_deleted);
1390
1391 animator->StartAnimation(new LayerAnimationSequence(
1392 LayerAnimationElement::CreateOpacityElement(1.0f, delta)));
1393
1394 EXPECT_TRUE(observer_was_deleted);
1395 }
1396
1397 } // namespace ui 1175 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_animator.cc ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698