OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
747 player->pause(); | 747 player->pause(); |
748 player->update(TimingUpdateOnDemand); | 748 player->update(TimingUpdateOnDemand); |
749 EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChang e()); | 749 EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChang e()); |
750 } | 750 } |
751 | 751 |
752 TEST_F(AnimationAnimationPlayerTest, TimeToNextEffectWhenCancelledBeforeStart) | 752 TEST_F(AnimationAnimationPlayerTest, TimeToNextEffectWhenCancelledBeforeStart) |
753 { | 753 { |
754 EXPECT_EQ(0, player->timeToEffectChange()); | 754 EXPECT_EQ(0, player->timeToEffectChange()); |
755 player->setCurrentTimeInternal(-8); | 755 player->setCurrentTimeInternal(-8); |
756 player->setPlaybackRate(2); | 756 player->setPlaybackRate(2); |
757 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal()); | |
757 player->cancel(); | 758 player->cancel(); |
759 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal()); | |
758 player->update(TimingUpdateOnDemand); | 760 player->update(TimingUpdateOnDemand); |
761 // This frame will fire the finish event event though no start time has been | |
762 // received from the compositor yet, as cancel() nukes start times. | |
759 simulateFrame(0); | 763 simulateFrame(0); |
760 EXPECT_EQ(4, player->timeToEffectChange()); | 764 EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChang e()); |
761 } | 765 } |
762 | 766 |
763 TEST_F(AnimationAnimationPlayerTest, TimeToNextEffectWhenCancelledBeforeStartRev erse) | 767 TEST_F(AnimationAnimationPlayerTest, TimeToNextEffectWhenCancelledBeforeStartRev erse) |
764 { | 768 { |
765 EXPECT_EQ(0, player->timeToEffectChange()); | 769 EXPECT_EQ(0, player->timeToEffectChange()); |
766 player->setCurrentTimeInternal(9); | 770 player->setCurrentTimeInternal(9); |
767 player->setPlaybackRate(-3); | 771 player->setPlaybackRate(-3); |
772 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal()); | |
773 player->cancel(); | |
774 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal()); | |
775 player->update(TimingUpdateOnDemand); | |
776 // This frame will fire the finish event event though no start time has been | |
777 // received from the compositor yet, as cancel() nukes start times. | |
778 simulateFrame(0); | |
779 EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChang e()); | |
780 } | |
781 | |
782 TEST_F(AnimationAnimationPlayerTest, TimeToNextEffectSimpleCancelledBeforeStart) | |
783 { | |
784 EXPECT_EQ(0, player->timeToEffectChange()); | |
785 EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal()); | |
768 player->cancel(); | 786 player->cancel(); |
769 player->update(TimingUpdateOnDemand); | 787 player->update(TimingUpdateOnDemand); |
788 // This frame will fire the finish event event though no start time has been | |
789 // received from the compositor yet, as cancel() nukes start times. | |
770 simulateFrame(0); | 790 simulateFrame(0); |
771 EXPECT_EQ(3, player->timeToEffectChange()); | 791 EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChang e()); |
772 } | 792 } |
773 | 793 |
774 TEST_F(AnimationAnimationPlayerTest, AttachedAnimationPlayers) | 794 TEST_F(AnimationAnimationPlayerTest, AttachedAnimationPlayers) |
775 { | 795 { |
776 RefPtrWillBePersistent<Element> element = document->createElement("foo", ASS ERT_NO_EXCEPTION); | 796 RefPtrWillBePersistent<Element> element = document->createElement("foo", ASS ERT_NO_EXCEPTION); |
777 | 797 |
778 Timing timing; | 798 Timing timing; |
779 RefPtrWillBeRawPtr<Animation> animation = Animation::create(element.get(), n ullptr, timing); | 799 RefPtrWillBeRawPtr<Animation> animation = Animation::create(element.get(), n ullptr, timing); |
780 RefPtrWillBeRawPtr<AnimationPlayer> player = timeline->createAnimationPlayer (animation.get()); | 800 RefPtrWillBeRawPtr<AnimationPlayer> player = timeline->createAnimationPlayer (animation.get()); |
781 simulateFrame(0); | 801 simulateFrame(0); |
782 timeline->serviceAnimations(TimingUpdateForAnimationFrame); | 802 timeline->serviceAnimations(TimingUpdateForAnimationFrame); |
783 EXPECT_EQ(1U, element->activeAnimations()->players().find(player.get())->val ue); | 803 EXPECT_EQ(1U, element->activeAnimations()->players().find(player.get())->val ue); |
784 | 804 |
785 player.release(); | 805 player.release(); |
786 Heap::collectAllGarbage(); | 806 Heap::collectAllGarbage(); |
787 EXPECT_TRUE(element->activeAnimations()->players().isEmpty()); | 807 EXPECT_TRUE(element->activeAnimations()->players().isEmpty()); |
788 } | 808 } |
789 | 809 |
790 TEST_F(AnimationAnimationPlayerTest, HasLowerPriority) | 810 TEST_F(AnimationAnimationPlayerTest, HasLowerPriority) |
791 { | 811 { |
792 RefPtrWillBeRawPtr<AnimationPlayer> player1 = timeline->createAnimationPlaye r(0); | 812 RefPtrWillBeRawPtr<AnimationPlayer> player1 = timeline->createAnimationPlaye r(0); |
793 RefPtrWillBeRawPtr<AnimationPlayer> player2 = timeline->createAnimationPlaye r(0); | 813 RefPtrWillBeRawPtr<AnimationPlayer> player2 = timeline->createAnimationPlaye r(0); |
794 EXPECT_TRUE(AnimationPlayer::hasLowerPriority(player1.get(), player2.get())) ; | 814 EXPECT_TRUE(AnimationPlayer::hasLowerPriority(player1.get(), player2.get())) ; |
795 } | 815 } |
796 | 816 |
817 TEST_F(AnimationAnimationPlayerTest, PlayAfterCancel) | |
818 { | |
819 player->cancel(); | |
820 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal()); | |
821 EXPECT_TRUE(std::isnan(player->currentTime())); | |
822 EXPECT_TRUE(std::isnan(player->startTime())); | |
823 player->play(); | |
824 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal()); | |
825 EXPECT_EQ(0, player->currentTime()); | |
dstockwell
2014/09/04 00:34:06
What should happen when the playback rate is negat
| |
826 EXPECT_TRUE(std::isnan(player->startTime())); | |
827 simulateFrame(10); | |
828 EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal()); | |
829 EXPECT_EQ(0, player->currentTime()); | |
830 EXPECT_EQ(10 * 1000, player->startTime()); | |
797 } | 831 } |
832 | |
833 // FIXME: crbug.com/410229, when fixed, will reuqire the expected results of | |
834 // this test to change (currentTime -> 30 * 1000). | |
835 TEST_F(AnimationAnimationPlayerTest, ReverseAfterCancel) | |
836 { | |
837 player->cancel(); | |
838 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal()); | |
839 EXPECT_TRUE(std::isnan(player->currentTime())); | |
840 EXPECT_TRUE(std::isnan(player->startTime())); | |
841 player->reverse(); | |
842 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal()); | |
843 EXPECT_TRUE(std::isnan(player->currentTime())); | |
844 EXPECT_TRUE(std::isnan(player->startTime())); | |
845 simulateFrame(10); | |
846 EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal()); | |
847 EXPECT_EQ(0 * 1000, player->currentTime()); | |
848 EXPECT_EQ(10 * 1000, player->startTime()); | |
849 } | |
850 | |
851 TEST_F(AnimationAnimationPlayerTest, FinishAfterCancel) | |
852 { | |
853 player->cancel(); | |
854 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal()); | |
855 EXPECT_TRUE(std::isnan(player->currentTime())); | |
856 EXPECT_TRUE(std::isnan(player->startTime())); | |
857 player->finish(exceptionState); | |
858 EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal()); | |
859 EXPECT_EQ(30 * 1000, player->currentTime()); | |
860 EXPECT_EQ(0, player->startTime()); | |
861 } | |
862 | |
863 TEST_F(AnimationAnimationPlayerTest, PauseAfterCancel) | |
864 { | |
865 player->cancel(); | |
866 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal()); | |
867 EXPECT_TRUE(std::isnan(player->currentTime())); | |
868 EXPECT_TRUE(std::isnan(player->startTime())); | |
869 player->pause(); | |
870 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal()); | |
871 EXPECT_TRUE(std::isnan(player->currentTime())); | |
872 EXPECT_TRUE(std::isnan(player->startTime())); | |
873 } | |
874 | |
875 } | |
OLD | NEW |