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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 player->setStartTimeInternal(0); | 61 player->setStartTimeInternal(0); |
62 player->setSource(makeAnimation().get()); | 62 player->setSource(makeAnimation().get()); |
63 } | 63 } |
64 | 64 |
65 void startTimeline() | 65 void startTimeline() |
66 { | 66 { |
67 timeline->setZeroTime(0); | 67 timeline->setZeroTime(0); |
68 updateTimeline(0); | 68 updateTimeline(0); |
69 } | 69 } |
70 | 70 |
71 PassRefPtr<Animation> makeAnimation(double duration = 30, double playbackRat
e = 1) | 71 PassRefPtrWillBeRawPtr<Animation> makeAnimation(double duration = 30, double
playbackRate = 1) |
72 { | 72 { |
73 Timing timing; | 73 Timing timing; |
74 timing.iterationDuration = duration; | 74 timing.iterationDuration = duration; |
75 timing.playbackRate = playbackRate; | 75 timing.playbackRate = playbackRate; |
76 return Animation::create(0, nullptr, timing); | 76 return Animation::create(0, nullptr, timing); |
77 } | 77 } |
78 | 78 |
79 bool updateTimeline(double time) | 79 bool updateTimeline(double time) |
80 { | 80 { |
81 document->animationClock().updateTime(time); | 81 document->animationClock().updateTime(time); |
82 // The timeline does not know about our player, so we have to explicitly
call update(). | 82 // The timeline does not know about our player, so we have to explicitly
call update(). |
83 return player->update(TimingUpdateOnDemand); | 83 return player->update(TimingUpdateOnDemand); |
84 } | 84 } |
85 | 85 |
86 RefPtr<Document> document; | 86 RefPtr<Document> document; |
87 RefPtr<DocumentTimeline> timeline; | 87 RefPtrWillBePersistent<DocumentTimeline> timeline; |
88 RefPtr<AnimationPlayer> player; | 88 RefPtrWillBePersistent<AnimationPlayer> player; |
89 TrackExceptionState exceptionState; | 89 TrackExceptionState exceptionState; |
90 }; | 90 }; |
91 | 91 |
92 TEST_F(AnimationAnimationPlayerTest, InitialState) | 92 TEST_F(AnimationAnimationPlayerTest, InitialState) |
93 { | 93 { |
94 setUpWithoutStartingTimeline(); | 94 setUpWithoutStartingTimeline(); |
95 player = timeline->createAnimationPlayer(0); | 95 player = timeline->createAnimationPlayer(0); |
96 EXPECT_TRUE(isNull(timeline->currentTimeInternal())); | 96 EXPECT_TRUE(isNull(timeline->currentTimeInternal())); |
97 EXPECT_EQ(0, player->currentTimeInternal()); | 97 EXPECT_EQ(0, player->currentTimeInternal()); |
98 EXPECT_FALSE(player->paused()); | 98 EXPECT_FALSE(player->paused()); |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 EXPECT_EQ(0, player->currentTimeInternal()); | 555 EXPECT_EQ(0, player->currentTimeInternal()); |
556 updateTimeline(1); | 556 updateTimeline(1); |
557 EXPECT_EQ(30, player->currentTimeInternal()); | 557 EXPECT_EQ(30, player->currentTimeInternal()); |
558 } | 558 } |
559 | 559 |
560 | 560 |
561 TEST_F(AnimationAnimationPlayerTest, SetSource) | 561 TEST_F(AnimationAnimationPlayerTest, SetSource) |
562 { | 562 { |
563 player = timeline->createAnimationPlayer(0); | 563 player = timeline->createAnimationPlayer(0); |
564 player->setStartTimeInternal(0); | 564 player->setStartTimeInternal(0); |
565 RefPtr<TimedItem> source1 = makeAnimation(); | 565 RefPtrWillBeRawPtr<TimedItem> source1 = makeAnimation(); |
566 RefPtr<TimedItem> source2 = makeAnimation(); | 566 RefPtrWillBeRawPtr<TimedItem> source2 = makeAnimation(); |
567 player->setSource(source1.get()); | 567 player->setSource(source1.get()); |
568 EXPECT_EQ(source1, player->source()); | 568 EXPECT_EQ(source1, player->source()); |
569 EXPECT_EQ(0, player->currentTimeInternal()); | 569 EXPECT_EQ(0, player->currentTimeInternal()); |
570 player->setCurrentTimeInternal(15); | 570 player->setCurrentTimeInternal(15); |
571 player->setSource(source2.get()); | 571 player->setSource(source2.get()); |
572 EXPECT_EQ(15, player->currentTimeInternal()); | 572 EXPECT_EQ(15, player->currentTimeInternal()); |
573 EXPECT_EQ(0, source1->player()); | 573 EXPECT_EQ(0, source1->player()); |
574 EXPECT_EQ(player.get(), source2->player()); | 574 EXPECT_EQ(player.get(), source2->player()); |
575 EXPECT_EQ(source2, player->source()); | 575 EXPECT_EQ(source2, player->source()); |
576 } | 576 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 player->setSource(timedItem); | 614 player->setSource(timedItem); |
615 EXPECT_EQ(0, player2->source()); | 615 EXPECT_EQ(0, player2->source()); |
616 } | 616 } |
617 | 617 |
618 TEST_F(AnimationAnimationPlayerTest, AnimationPlayersReturnTimeToNextEffect) | 618 TEST_F(AnimationAnimationPlayerTest, AnimationPlayersReturnTimeToNextEffect) |
619 { | 619 { |
620 Timing timing; | 620 Timing timing; |
621 timing.startDelay = 1; | 621 timing.startDelay = 1; |
622 timing.iterationDuration = 1; | 622 timing.iterationDuration = 1; |
623 timing.endDelay = 1; | 623 timing.endDelay = 1; |
624 RefPtr<Animation> animation = Animation::create(0, nullptr, timing); | 624 RefPtrWillBeRawPtr<Animation> animation = Animation::create(0, nullptr, timi
ng); |
625 player = timeline->createAnimationPlayer(animation.get()); | 625 player = timeline->createAnimationPlayer(animation.get()); |
626 player->setStartTimeInternal(0); | 626 player->setStartTimeInternal(0); |
627 | 627 |
628 updateTimeline(0); | 628 updateTimeline(0); |
629 EXPECT_EQ(1, player->timeToEffectChange()); | 629 EXPECT_EQ(1, player->timeToEffectChange()); |
630 | 630 |
631 updateTimeline(0.5); | 631 updateTimeline(0.5); |
632 EXPECT_EQ(0.5, player->timeToEffectChange()); | 632 EXPECT_EQ(0.5, player->timeToEffectChange()); |
633 | 633 |
634 updateTimeline(1); | 634 updateTimeline(1); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 player->cancel(); | 691 player->cancel(); |
692 player->update(TimingUpdateOnDemand); | 692 player->update(TimingUpdateOnDemand); |
693 EXPECT_EQ(3, player->timeToEffectChange()); | 693 EXPECT_EQ(3, player->timeToEffectChange()); |
694 } | 694 } |
695 | 695 |
696 TEST_F(AnimationAnimationPlayerTest, AttachedAnimationPlayers) | 696 TEST_F(AnimationAnimationPlayerTest, AttachedAnimationPlayers) |
697 { | 697 { |
698 RefPtrWillBeRawPtr<Element> element = document->createElement("foo", ASSERT_
NO_EXCEPTION); | 698 RefPtrWillBeRawPtr<Element> element = document->createElement("foo", ASSERT_
NO_EXCEPTION); |
699 | 699 |
700 Timing timing; | 700 Timing timing; |
701 RefPtr<Animation> animation = Animation::create(element.get(), nullptr, timi
ng); | 701 RefPtrWillBeRawPtr<Animation> animation = Animation::create(element.get(), n
ullptr, timing); |
702 RefPtr<AnimationPlayer> player = timeline->createAnimationPlayer(animation.g
et()); | 702 RefPtrWillBeRawPtr<AnimationPlayer> player = timeline->createAnimationPlayer
(animation.get()); |
703 player->setStartTime(0); | 703 player->setStartTime(0); |
704 timeline->serviceAnimations(TimingUpdateForAnimationFrame); | 704 timeline->serviceAnimations(TimingUpdateForAnimationFrame); |
705 EXPECT_EQ(1, element->activeAnimations()->players().find(player.get())->valu
e); | 705 EXPECT_EQ(1, element->activeAnimations()->players().find(player.get())->valu
e); |
706 | 706 |
707 player.release(); | 707 player.release(); |
708 EXPECT_TRUE(element->activeAnimations()->players().isEmpty()); | 708 EXPECT_TRUE(element->activeAnimations()->players().isEmpty()); |
709 } | 709 } |
710 | 710 |
711 TEST_F(AnimationAnimationPlayerTest, HasLowerPriority) | 711 TEST_F(AnimationAnimationPlayerTest, HasLowerPriority) |
712 { | 712 { |
713 // Sort time defaults to timeline current time | 713 // Sort time defaults to timeline current time |
714 updateTimeline(15); | 714 updateTimeline(15); |
715 RefPtr<AnimationPlayer> player1 = timeline->createAnimationPlayer(0); | 715 RefPtrWillBeRawPtr<AnimationPlayer> player1 = timeline->createAnimationPlaye
r(0); |
716 RefPtr<AnimationPlayer> player2 = timeline->createAnimationPlayer(0); | 716 RefPtrWillBeRawPtr<AnimationPlayer> player2 = timeline->createAnimationPlaye
r(0); |
717 player2->setStartTimeInternal(10); | 717 player2->setStartTimeInternal(10); |
718 RefPtr<AnimationPlayer> player3 = timeline->createAnimationPlayer(0); | 718 RefPtrWillBeRawPtr<AnimationPlayer> player3 = timeline->createAnimationPlaye
r(0); |
719 RefPtr<AnimationPlayer> player4 = timeline->createAnimationPlayer(0); | 719 RefPtrWillBeRawPtr<AnimationPlayer> player4 = timeline->createAnimationPlaye
r(0); |
720 player4->setStartTimeInternal(20); | 720 player4->setStartTimeInternal(20); |
721 RefPtr<AnimationPlayer> player5 = timeline->createAnimationPlayer(0); | 721 RefPtrWillBeRawPtr<AnimationPlayer> player5 = timeline->createAnimationPlaye
r(0); |
722 player5->setStartTimeInternal(10); | 722 player5->setStartTimeInternal(10); |
723 RefPtr<AnimationPlayer> player6 = timeline->createAnimationPlayer(0); | 723 RefPtrWillBeRawPtr<AnimationPlayer> player6 = timeline->createAnimationPlaye
r(0); |
724 player6->setStartTimeInternal(-10); | 724 player6->setStartTimeInternal(-10); |
725 Vector<RefPtr<AnimationPlayer> > players; | 725 Vector<RefPtrWillBeMember<AnimationPlayer> > players; |
726 players.append(player6); | 726 players.append(player6); |
727 players.append(player2); | 727 players.append(player2); |
728 players.append(player5); | 728 players.append(player5); |
729 players.append(player1); | 729 players.append(player1); |
730 players.append(player3); | 730 players.append(player3); |
731 players.append(player4); | 731 players.append(player4); |
732 for (size_t i = 0; i < players.size(); i++) { | 732 for (size_t i = 0; i < players.size(); i++) { |
733 for (size_t j = 0; j < players.size(); j++) | 733 for (size_t j = 0; j < players.size(); j++) |
734 EXPECT_EQ(i < j, AnimationPlayer::hasLowerPriority(players[i].get(),
players[j].get())); | 734 EXPECT_EQ(i < j, AnimationPlayer::hasLowerPriority(players[i].get(),
players[j].get())); |
735 } | 735 } |
736 } | 736 } |
737 | 737 |
738 } | 738 } |
OLD | NEW |