OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/animation/layer_animation_controller.h" | 5 #include "cc/animation/layer_animation_controller.h" |
6 | 6 |
7 #include "cc/animation/animation.h" | 7 #include "cc/animation/animation.h" |
8 #include "cc/animation/animation_curve.h" | 8 #include "cc/animation/animation_curve.h" |
9 #include "cc/animation/animation_delegate.h" | 9 #include "cc/animation/animation_delegate.h" |
10 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 77 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
78 controller_impl->GetAnimation(group_id, | 78 controller_impl->GetAnimation(group_id, |
79 Animation::Opacity)->run_state()); | 79 Animation::Opacity)->run_state()); |
80 | 80 |
81 AnimationEventsVector events; | 81 AnimationEventsVector events; |
82 controller_impl->Animate(kInitialTickTime); | 82 controller_impl->Animate(kInitialTickTime); |
83 controller_impl->UpdateState(true, &events); | 83 controller_impl->UpdateState(true, &events); |
84 | 84 |
85 // Synchronize the start times. | 85 // Synchronize the start times. |
86 EXPECT_EQ(1u, events.size()); | 86 EXPECT_EQ(1u, events.size()); |
87 controller->NotifyAnimationStarted(events[0], 0.0); | 87 controller->NotifyAnimationStarted(events[0]); |
88 EXPECT_EQ(controller->GetAnimation(group_id, | 88 EXPECT_EQ(controller->GetAnimation(group_id, |
89 Animation::Opacity)->start_time(), | 89 Animation::Opacity)->start_time(), |
90 controller_impl->GetAnimation(group_id, | 90 controller_impl->GetAnimation(group_id, |
91 Animation::Opacity)->start_time()); | 91 Animation::Opacity)->start_time()); |
92 | 92 |
93 // Start the animation on the main thread. Should not affect the start time. | 93 // Start the animation on the main thread. Should not affect the start time. |
94 controller->Animate(kInitialTickTime + 0.5); | 94 controller->Animate(kInitialTickTime + 0.5); |
95 controller->UpdateState(true, NULL); | 95 controller->UpdateState(true, NULL); |
96 EXPECT_EQ(controller->GetAnimation(group_id, | 96 EXPECT_EQ(controller->GetAnimation(group_id, |
97 Animation::Opacity)->start_time(), | 97 Animation::Opacity)->start_time(), |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 129 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
130 | 130 |
131 controller->PushAnimationUpdatesTo(controller_impl.get()); | 131 controller->PushAnimationUpdatesTo(controller_impl.get()); |
132 // Both controllers should now be active. | 132 // Both controllers should now be active. |
133 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 133 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
134 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); | 134 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); |
135 | 135 |
136 controller_impl->Animate(kInitialTickTime); | 136 controller_impl->Animate(kInitialTickTime); |
137 controller_impl->UpdateState(true, events.get()); | 137 controller_impl->UpdateState(true, events.get()); |
138 EXPECT_EQ(1u, events->size()); | 138 EXPECT_EQ(1u, events->size()); |
139 controller->NotifyAnimationStarted((*events)[0], 0.0); | 139 controller->NotifyAnimationStarted((*events)[0]); |
140 | 140 |
141 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 141 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
142 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); | 142 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); |
143 | 143 |
144 controller->Animate(kInitialTickTime + 0.5); | 144 controller->Animate(kInitialTickTime + 0.5); |
145 controller->UpdateState(true, NULL); | 145 controller->UpdateState(true, NULL); |
146 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 146 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
147 | 147 |
148 controller->Animate(kInitialTickTime + 1.0); | 148 controller->Animate(kInitialTickTime + 1.0); |
149 controller->UpdateState(true, NULL); | 149 controller->UpdateState(true, NULL); |
150 EXPECT_EQ(Animation::Finished, | 150 EXPECT_EQ(Animation::Finished, |
151 controller->GetAnimation(Animation::Opacity)->run_state()); | 151 controller->GetAnimation(Animation::Opacity)->run_state()); |
152 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 152 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
153 | 153 |
154 events.reset(new AnimationEventsVector); | 154 events.reset(new AnimationEventsVector); |
155 controller_impl->Animate(kInitialTickTime + 1.5); | 155 controller_impl->Animate(kInitialTickTime + 1.5); |
156 controller_impl->UpdateState(true, events.get()); | 156 controller_impl->UpdateState(true, events.get()); |
157 | 157 |
158 EXPECT_EQ(Animation::WaitingForDeletion, | 158 EXPECT_EQ(Animation::WaitingForDeletion, |
159 controller_impl->GetAnimation(Animation::Opacity)->run_state()); | 159 controller_impl->GetAnimation(Animation::Opacity)->run_state()); |
160 // The impl thread controller should have de-activated. | 160 // The impl thread controller should have de-activated. |
161 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); | 161 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); |
162 | 162 |
163 EXPECT_EQ(1u, events->size()); | 163 EXPECT_EQ(1u, events->size()); |
164 controller->NotifyAnimationFinished((*events)[0], 0.0); | 164 controller->NotifyAnimationFinished((*events)[0]); |
165 controller->Animate(kInitialTickTime + 1.5); | 165 controller->Animate(kInitialTickTime + 1.5); |
166 controller->UpdateState(true, NULL); | 166 controller->UpdateState(true, NULL); |
167 | 167 |
168 EXPECT_EQ(Animation::WaitingForDeletion, | 168 EXPECT_EQ(Animation::WaitingForDeletion, |
169 controller->GetAnimation(Animation::Opacity)->run_state()); | 169 controller->GetAnimation(Animation::Opacity)->run_state()); |
170 // The main thread controller should have de-activated. | 170 // The main thread controller should have de-activated. |
171 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); | 171 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); |
172 | 172 |
173 controller->PushAnimationUpdatesTo(controller_impl.get()); | 173 controller->PushAnimationUpdatesTo(controller_impl.get()); |
174 EXPECT_FALSE(controller->has_any_animation()); | 174 EXPECT_FALSE(controller->has_any_animation()); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 251 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
252 controller_impl->GetAnimation(group_id, | 252 controller_impl->GetAnimation(group_id, |
253 Animation::Opacity)->run_state()); | 253 Animation::Opacity)->run_state()); |
254 | 254 |
255 // Notify main thread controller that the animation has started. | 255 // Notify main thread controller that the animation has started. |
256 AnimationEvent animation_started_event(AnimationEvent::Started, | 256 AnimationEvent animation_started_event(AnimationEvent::Started, |
257 0, | 257 0, |
258 group_id, | 258 group_id, |
259 Animation::Opacity, | 259 Animation::Opacity, |
260 kInitialTickTime); | 260 kInitialTickTime); |
261 controller->NotifyAnimationStarted(animation_started_event, 0.0); | 261 controller->NotifyAnimationStarted(animation_started_event); |
262 | 262 |
263 // Force animation to complete on impl thread. | 263 // Force animation to complete on impl thread. |
264 controller_impl->RemoveAnimation(animation_id); | 264 controller_impl->RemoveAnimation(animation_id); |
265 | 265 |
266 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 266 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
267 | 267 |
268 controller->PushAnimationUpdatesTo(controller_impl.get()); | 268 controller->PushAnimationUpdatesTo(controller_impl.get()); |
269 | 269 |
270 // Even though the main thread has a 'new' animation, it should not be pushed | 270 // Even though the main thread has a 'new' animation, it should not be pushed |
271 // because the animation has already completed on the impl thread. | 271 // because the animation has already completed on the impl thread. |
(...skipping 18 matching lines...) Expand all Loading... |
290 controller->Animate(kInitialTickTime); | 290 controller->Animate(kInitialTickTime); |
291 controller->UpdateState(true, NULL); | 291 controller->UpdateState(true, NULL); |
292 controller->PushAnimationUpdatesTo(controller_impl.get()); | 292 controller->PushAnimationUpdatesTo(controller_impl.get()); |
293 | 293 |
294 controller_impl->Animate(kInitialTickTime + 0.5); | 294 controller_impl->Animate(kInitialTickTime + 0.5); |
295 controller_impl->UpdateState(true, events.get()); | 295 controller_impl->UpdateState(true, events.get()); |
296 | 296 |
297 // There should be a Started event for the animation. | 297 // There should be a Started event for the animation. |
298 EXPECT_EQ(1u, events->size()); | 298 EXPECT_EQ(1u, events->size()); |
299 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); | 299 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); |
300 controller->NotifyAnimationStarted((*events)[0], 0.0); | 300 controller->NotifyAnimationStarted((*events)[0]); |
301 | 301 |
302 controller->Animate(kInitialTickTime + 1.0); | 302 controller->Animate(kInitialTickTime + 1.0); |
303 controller->UpdateState(true, NULL); | 303 controller->UpdateState(true, NULL); |
304 | 304 |
305 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 305 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); |
306 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); | 306 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); |
307 | 307 |
308 events.reset(new AnimationEventsVector); | 308 events.reset(new AnimationEventsVector); |
309 controller_impl->Animate(kInitialTickTime + 2.0); | 309 controller_impl->Animate(kInitialTickTime + 2.0); |
310 controller_impl->UpdateState(true, events.get()); | 310 controller_impl->UpdateState(true, events.get()); |
311 | 311 |
312 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); | 312 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); |
313 | 313 |
314 // There should be a Finished event for the animation. | 314 // There should be a Finished event for the animation. |
315 EXPECT_EQ(1u, events->size()); | 315 EXPECT_EQ(1u, events->size()); |
316 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); | 316 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
317 | 317 |
318 // Neither controller should have deleted the animation yet. | 318 // Neither controller should have deleted the animation yet. |
319 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); | 319 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); |
320 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity)); | 320 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity)); |
321 | 321 |
322 controller->NotifyAnimationFinished((*events)[0], 0.0); | 322 controller->NotifyAnimationFinished((*events)[0]); |
323 | 323 |
324 controller->Animate(kInitialTickTime + 3.0); | 324 controller->Animate(kInitialTickTime + 3.0); |
325 controller->UpdateState(true, NULL); | 325 controller->UpdateState(true, NULL); |
326 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 326 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
327 | 327 |
328 controller->PushAnimationUpdatesTo(controller_impl.get()); | 328 controller->PushAnimationUpdatesTo(controller_impl.get()); |
329 | 329 |
330 // Both controllers should now have deleted the animation. | 330 // Both controllers should now have deleted the animation. |
331 EXPECT_FALSE(controller->has_any_animation()); | 331 EXPECT_FALSE(controller->has_any_animation()); |
332 EXPECT_FALSE(controller_impl->has_any_animation()); | 332 EXPECT_FALSE(controller_impl->has_any_animation()); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 EXPECT_EQ(initial_value, dummy.scroll_offset()); | 604 EXPECT_EQ(initial_value, dummy.scroll_offset()); |
605 | 605 |
606 controller_impl->Animate(kInitialTickTime); | 606 controller_impl->Animate(kInitialTickTime); |
607 controller_impl->UpdateState(true, events.get()); | 607 controller_impl->UpdateState(true, events.get()); |
608 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 608 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
609 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 609 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
610 // Scroll offset animations should not generate property updates. | 610 // Scroll offset animations should not generate property updates. |
611 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 611 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
612 EXPECT_FALSE(event); | 612 EXPECT_FALSE(event); |
613 | 613 |
614 controller->NotifyAnimationStarted((*events)[0], 0.0); | 614 controller->NotifyAnimationStarted((*events)[0]); |
615 controller->Animate(kInitialTickTime + duration/2.0); | 615 controller->Animate(kInitialTickTime + duration/2.0); |
616 controller->UpdateState(true, NULL); | 616 controller->UpdateState(true, NULL); |
617 EXPECT_TRUE(controller->HasActiveAnimation()); | 617 EXPECT_TRUE(controller->HasActiveAnimation()); |
618 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), dummy.scroll_offset()); | 618 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), dummy.scroll_offset()); |
619 | 619 |
620 controller_impl->Animate(kInitialTickTime + duration/2.0); | 620 controller_impl->Animate(kInitialTickTime + duration/2.0); |
621 controller_impl->UpdateState(true, events.get()); | 621 controller_impl->UpdateState(true, events.get()); |
622 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), | 622 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), |
623 dummy_impl.scroll_offset()); | 623 dummy_impl.scroll_offset()); |
624 event = GetMostRecentPropertyUpdateEvent(events.get()); | 624 event = GetMostRecentPropertyUpdateEvent(events.get()); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 EXPECT_EQ(initial_value, dummy.scroll_offset()); | 682 EXPECT_EQ(initial_value, dummy.scroll_offset()); |
683 | 683 |
684 controller_impl->Animate(kInitialTickTime); | 684 controller_impl->Animate(kInitialTickTime); |
685 controller_impl->UpdateState(true, events.get()); | 685 controller_impl->UpdateState(true, events.get()); |
686 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 686 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
687 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 687 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
688 // Scroll offset animations should not generate property updates. | 688 // Scroll offset animations should not generate property updates. |
689 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 689 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
690 EXPECT_FALSE(event); | 690 EXPECT_FALSE(event); |
691 | 691 |
692 controller->NotifyAnimationStarted((*events)[0], 0.0); | 692 controller->NotifyAnimationStarted((*events)[0]); |
693 controller->Animate(kInitialTickTime + duration/2.0); | 693 controller->Animate(kInitialTickTime + duration/2.0); |
694 controller->UpdateState(true, NULL); | 694 controller->UpdateState(true, NULL); |
695 EXPECT_TRUE(controller->HasActiveAnimation()); | 695 EXPECT_TRUE(controller->HasActiveAnimation()); |
696 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), dummy.scroll_offset()); | 696 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), dummy.scroll_offset()); |
697 | 697 |
698 controller_impl->Animate(kInitialTickTime + duration/2.0); | 698 controller_impl->Animate(kInitialTickTime + duration/2.0); |
699 controller_impl->UpdateState(true, events.get()); | 699 controller_impl->UpdateState(true, events.get()); |
700 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), | 700 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), |
701 dummy_impl.scroll_offset()); | 701 dummy_impl.scroll_offset()); |
702 event = GetMostRecentPropertyUpdateEvent(events.get()); | 702 event = GetMostRecentPropertyUpdateEvent(events.get()); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 EXPECT_FALSE(event); | 760 EXPECT_FALSE(event); |
761 } | 761 } |
762 | 762 |
763 class FakeAnimationDelegate : public AnimationDelegate { | 763 class FakeAnimationDelegate : public AnimationDelegate { |
764 public: | 764 public: |
765 FakeAnimationDelegate() | 765 FakeAnimationDelegate() |
766 : started_(false), | 766 : started_(false), |
767 finished_(false) {} | 767 finished_(false) {} |
768 | 768 |
769 virtual void NotifyAnimationStarted( | 769 virtual void NotifyAnimationStarted( |
770 double wall_clock_time, | |
771 base::TimeTicks monotonic_time, | 770 base::TimeTicks monotonic_time, |
772 Animation::TargetProperty target_property) OVERRIDE { | 771 Animation::TargetProperty target_property) OVERRIDE { |
773 started_ = true; | 772 started_ = true; |
774 } | 773 } |
775 | 774 |
776 virtual void NotifyAnimationFinished( | 775 virtual void NotifyAnimationFinished( |
777 double wall_clock_time, | |
778 base::TimeTicks monotonic_time, | 776 base::TimeTicks monotonic_time, |
779 Animation::TargetProperty target_property) OVERRIDE { | 777 Animation::TargetProperty target_property) OVERRIDE { |
780 finished_ = true; | 778 finished_ = true; |
781 } | 779 } |
782 | 780 |
783 bool started() { return started_; } | 781 bool started() { return started_; } |
784 | 782 |
785 bool finished() { return finished_; } | 783 bool finished() { return finished_; } |
786 | 784 |
787 private: | 785 private: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 // We should receive 2 events (a started notification and a property update). | 817 // We should receive 2 events (a started notification and a property update). |
820 EXPECT_EQ(2u, events->size()); | 818 EXPECT_EQ(2u, events->size()); |
821 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); | 819 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); |
822 EXPECT_TRUE((*events)[0].is_impl_only); | 820 EXPECT_TRUE((*events)[0].is_impl_only); |
823 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); | 821 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); |
824 EXPECT_TRUE((*events)[1].is_impl_only); | 822 EXPECT_TRUE((*events)[1].is_impl_only); |
825 | 823 |
826 // Passing on the start event to the main thread controller should cause the | 824 // Passing on the start event to the main thread controller should cause the |
827 // delegate to get notified. | 825 // delegate to get notified. |
828 EXPECT_FALSE(delegate.started()); | 826 EXPECT_FALSE(delegate.started()); |
829 controller->NotifyAnimationStarted((*events)[0], 0.0); | 827 controller->NotifyAnimationStarted((*events)[0]); |
830 EXPECT_TRUE(delegate.started()); | 828 EXPECT_TRUE(delegate.started()); |
831 | 829 |
832 events.reset(new AnimationEventsVector); | 830 events.reset(new AnimationEventsVector); |
833 controller_impl->Animate(kInitialTickTime + 1.0); | 831 controller_impl->Animate(kInitialTickTime + 1.0); |
834 controller_impl->UpdateState(true, events.get()); | 832 controller_impl->UpdateState(true, events.get()); |
835 | 833 |
836 // We should receive 2 events (a finished notification and a property update). | 834 // We should receive 2 events (a finished notification and a property update). |
837 EXPECT_EQ(2u, events->size()); | 835 EXPECT_EQ(2u, events->size()); |
838 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); | 836 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
839 EXPECT_TRUE((*events)[0].is_impl_only); | 837 EXPECT_TRUE((*events)[0].is_impl_only); |
840 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); | 838 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); |
841 EXPECT_TRUE((*events)[1].is_impl_only); | 839 EXPECT_TRUE((*events)[1].is_impl_only); |
842 | 840 |
843 // Passing on the finished event to the main thread controller should cause | 841 // Passing on the finished event to the main thread controller should cause |
844 // the delegate to get notified. | 842 // the delegate to get notified. |
845 EXPECT_FALSE(delegate.finished()); | 843 EXPECT_FALSE(delegate.finished()); |
846 controller->NotifyAnimationFinished((*events)[0], 0.0); | 844 controller->NotifyAnimationFinished((*events)[0]); |
847 EXPECT_TRUE(delegate.finished()); | 845 EXPECT_TRUE(delegate.finished()); |
848 } | 846 } |
849 | 847 |
850 // Tests animations that are waiting for a synchronized start time do not | 848 // Tests animations that are waiting for a synchronized start time do not |
851 // finish. | 849 // finish. |
852 TEST(LayerAnimationControllerTest, | 850 TEST(LayerAnimationControllerTest, |
853 AnimationsWaitingForStartTimeDoNotFinishIfTheyOutwaitTheirFinish) { | 851 AnimationsWaitingForStartTimeDoNotFinishIfTheyOutwaitTheirFinish) { |
854 scoped_ptr<AnimationEventsVector> events( | 852 scoped_ptr<AnimationEventsVector> events( |
855 make_scoped_ptr(new AnimationEventsVector)); | 853 make_scoped_ptr(new AnimationEventsVector)); |
856 FakeLayerAnimationValueObserver dummy; | 854 FakeLayerAnimationValueObserver dummy; |
(...skipping 17 matching lines...) Expand all Loading... |
874 controller->Animate(kInitialTickTime + 1.0); | 872 controller->Animate(kInitialTickTime + 1.0); |
875 controller->UpdateState(true, events.get()); | 873 controller->UpdateState(true, events.get()); |
876 EXPECT_TRUE(controller->HasActiveAnimation()); | 874 EXPECT_TRUE(controller->HasActiveAnimation()); |
877 EXPECT_EQ(0.f, dummy.opacity()); | 875 EXPECT_EQ(0.f, dummy.opacity()); |
878 controller->Animate(kInitialTickTime + 2.0); | 876 controller->Animate(kInitialTickTime + 2.0); |
879 controller->UpdateState(true, events.get()); | 877 controller->UpdateState(true, events.get()); |
880 EXPECT_TRUE(controller->HasActiveAnimation()); | 878 EXPECT_TRUE(controller->HasActiveAnimation()); |
881 EXPECT_EQ(0.f, dummy.opacity()); | 879 EXPECT_EQ(0.f, dummy.opacity()); |
882 | 880 |
883 // Send the synchronized start time. | 881 // Send the synchronized start time. |
884 controller->NotifyAnimationStarted(AnimationEvent(AnimationEvent::Started, | 882 controller->NotifyAnimationStarted(AnimationEvent( |
885 0, | 883 AnimationEvent::Started, 0, 1, Animation::Opacity, kInitialTickTime + 2)); |
886 1, | |
887 Animation::Opacity, | |
888 kInitialTickTime + 2), | |
889 0.0); | |
890 controller->Animate(kInitialTickTime + 5.0); | 884 controller->Animate(kInitialTickTime + 5.0); |
891 controller->UpdateState(true, events.get()); | 885 controller->UpdateState(true, events.get()); |
892 EXPECT_EQ(1.f, dummy.opacity()); | 886 EXPECT_EQ(1.f, dummy.opacity()); |
893 EXPECT_FALSE(controller->HasActiveAnimation()); | 887 EXPECT_FALSE(controller->HasActiveAnimation()); |
894 } | 888 } |
895 | 889 |
896 // Tests that two queued animations affecting the same property run in sequence. | 890 // Tests that two queued animations affecting the same property run in sequence. |
897 TEST(LayerAnimationControllerTest, TrivialQueuing) { | 891 TEST(LayerAnimationControllerTest, TrivialQueuing) { |
898 scoped_ptr<AnimationEventsVector> events( | 892 scoped_ptr<AnimationEventsVector> events( |
899 make_scoped_ptr(new AnimationEventsVector)); | 893 make_scoped_ptr(new AnimationEventsVector)); |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 // animation, and an Aborted event for the opacity animation. | 1672 // animation, and an Aborted event for the opacity animation. |
1679 EXPECT_EQ(2u, events->size()); | 1673 EXPECT_EQ(2u, events->size()); |
1680 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); | 1674 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
1681 EXPECT_EQ(Animation::Transform, (*events)[0].target_property); | 1675 EXPECT_EQ(Animation::Transform, (*events)[0].target_property); |
1682 EXPECT_EQ(AnimationEvent::Aborted, (*events)[1].type); | 1676 EXPECT_EQ(AnimationEvent::Aborted, (*events)[1].type); |
1683 EXPECT_EQ(Animation::Opacity, (*events)[1].target_property); | 1677 EXPECT_EQ(Animation::Opacity, (*events)[1].target_property); |
1684 } | 1678 } |
1685 | 1679 |
1686 } // namespace | 1680 } // namespace |
1687 } // namespace cc | 1681 } // namespace cc |
OLD | NEW |