Chromium Code Reviews| 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(AnimationPlayer::UpdateOnDemand); | 83 return player->update(AnimationPlayer::UpdateOnDemand); |
| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 613 player->setSource(timedItem); | 613 player->setSource(timedItem); |
| 614 EXPECT_EQ(0, player2->source()); | 614 EXPECT_EQ(0, player2->source()); |
| 615 } | 615 } |
| 616 | 616 |
| 617 TEST_F(AnimationAnimationPlayerTest, AnimationPlayersReturnTimeToNextEffect) | 617 TEST_F(AnimationAnimationPlayerTest, AnimationPlayersReturnTimeToNextEffect) |
| 618 { | 618 { |
| 619 Timing timing; | 619 Timing timing; |
| 620 timing.startDelay = 1; | 620 timing.startDelay = 1; |
| 621 timing.iterationDuration = 1; | 621 timing.iterationDuration = 1; |
| 622 timing.endDelay = 1; | 622 timing.endDelay = 1; |
| 623 RefPtr<Animation> animation = Animation::create(0, nullptr, timing); | 623 RefPtrWillBeRawPtr<Animation> animation = Animation::create(0, nullptr, timi ng); |
| 624 player = timeline->createAnimationPlayer(animation.get()); | 624 player = timeline->createAnimationPlayer(animation.get()); |
| 625 player->setStartTimeInternal(0); | 625 player->setStartTimeInternal(0); |
| 626 | 626 |
| 627 updateTimeline(0); | 627 updateTimeline(0); |
| 628 EXPECT_EQ(1, player->timeToEffectChange()); | 628 EXPECT_EQ(1, player->timeToEffectChange()); |
| 629 | 629 |
| 630 updateTimeline(0.5); | 630 updateTimeline(0.5); |
| 631 EXPECT_EQ(0.5, player->timeToEffectChange()); | 631 EXPECT_EQ(0.5, player->timeToEffectChange()); |
| 632 | 632 |
| 633 updateTimeline(1); | 633 updateTimeline(1); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 690 player->cancel(); | 690 player->cancel(); |
| 691 player->update(AnimationPlayer::UpdateOnDemand); | 691 player->update(AnimationPlayer::UpdateOnDemand); |
| 692 EXPECT_EQ(3, player->timeToEffectChange()); | 692 EXPECT_EQ(3, player->timeToEffectChange()); |
| 693 } | 693 } |
| 694 | 694 |
| 695 TEST_F(AnimationAnimationPlayerTest, AttachedAnimationPlayers) | 695 TEST_F(AnimationAnimationPlayerTest, AttachedAnimationPlayers) |
| 696 { | 696 { |
| 697 RefPtr<Element> element = document->createElement("foo", ASSERT_NO_EXCEPTION ); | 697 RefPtr<Element> element = document->createElement("foo", ASSERT_NO_EXCEPTION ); |
| 698 | 698 |
| 699 Timing timing; | 699 Timing timing; |
| 700 RefPtr<Animation> animation = Animation::create(element.get(), nullptr, timi ng); | 700 RefPtrWillBeRawPtr<Animation> animation = Animation::create(element.get(), n ullptr, timing); |
| 701 RefPtr<AnimationPlayer> player = timeline->createAnimationPlayer(animation.g et()); | 701 RefPtrWillBeRawPtr<AnimationPlayer> player = timeline->createAnimationPlayer (animation.get()); |
| 702 timeline->serviceAnimations(AnimationPlayer::UpdateForAnimationFrame); | 702 timeline->serviceAnimations(AnimationPlayer::UpdateForAnimationFrame); |
| 703 EXPECT_EQ(1, element->activeAnimations()->players().find(player.get())->valu e); | 703 EXPECT_EQ(1, element->activeAnimations()->players().find(player.get())->valu e); |
| 704 | 704 |
| 705 player.release(); | 705 player.release(); |
| 706 EXPECT_EQ(0, element->activeAnimations()->players().find(player.get())->valu e); | 706 EXPECT_EQ(0, element->activeAnimations()->players().find(player.get())->valu e); |
| 707 EXPECT_TRUE(element->activeAnimations()->players().isEmpty()); | 707 EXPECT_TRUE(element->activeAnimations()->players().isEmpty()); |
| 708 } | 708 } |
| 709 | 709 |
| 710 TEST_F(AnimationAnimationPlayerTest, HasLowerPriority) | 710 TEST_F(AnimationAnimationPlayerTest, HasLowerPriority) |
| 711 { | 711 { |
| 712 // Sort time defaults to timeline current time | 712 // Sort time defaults to timeline current time |
| 713 updateTimeline(15); | 713 updateTimeline(15); |
| 714 RefPtr<AnimationPlayer> player1 = timeline->createAnimationPlayer(0); | 714 RefPtrWillBeRawPtr<AnimationPlayer> player1 = timeline->createAnimationPlaye r(0); |
| 715 RefPtr<AnimationPlayer> player2 = timeline->createAnimationPlayer(0); | 715 RefPtrWillBeRawPtr<AnimationPlayer> player2 = timeline->createAnimationPlaye r(0); |
| 716 player2->setStartTimeInternal(10); | 716 player2->setStartTimeInternal(10); |
| 717 RefPtr<AnimationPlayer> player3 = timeline->createAnimationPlayer(0); | 717 RefPtrWillBeRawPtr<AnimationPlayer> player3 = timeline->createAnimationPlaye r(0); |
| 718 RefPtr<AnimationPlayer> player4 = timeline->createAnimationPlayer(0); | 718 RefPtrWillBeRawPtr<AnimationPlayer> player4 = timeline->createAnimationPlaye r(0); |
| 719 player4->setStartTimeInternal(20); | 719 player4->setStartTimeInternal(20); |
| 720 RefPtr<AnimationPlayer> player5 = timeline->createAnimationPlayer(0); | 720 RefPtrWillBeRawPtr<AnimationPlayer> player5 = timeline->createAnimationPlaye r(0); |
| 721 player5->setStartTimeInternal(10); | 721 player5->setStartTimeInternal(10); |
| 722 RefPtr<AnimationPlayer> player6 = timeline->createAnimationPlayer(0); | 722 RefPtrWillBeRawPtr<AnimationPlayer> player6 = timeline->createAnimationPlaye r(0); |
| 723 player6->setStartTimeInternal(-10); | 723 player6->setStartTimeInternal(-10); |
| 724 Vector<RefPtr<AnimationPlayer> > players; | 724 Vector<RefPtrWillBeMember<AnimationPlayer> > players; |
|
Mads Ager (chromium)
2014/04/29 10:29:41
WillBeHeapVector, otherwise it will not be traced.
| |
| 725 players.append(player6); | 725 players.append(player6); |
| 726 players.append(player2); | 726 players.append(player2); |
| 727 players.append(player5); | 727 players.append(player5); |
| 728 players.append(player1); | 728 players.append(player1); |
| 729 players.append(player3); | 729 players.append(player3); |
| 730 players.append(player4); | 730 players.append(player4); |
| 731 for (size_t i = 0; i < players.size(); i++) { | 731 for (size_t i = 0; i < players.size(); i++) { |
| 732 for (size_t j = 0; j < players.size(); j++) | 732 for (size_t j = 0; j < players.size(); j++) |
| 733 EXPECT_EQ(i < j, AnimationPlayer::hasLowerPriority(players[i].get(), players[j].get())); | 733 EXPECT_EQ(i < j, AnimationPlayer::hasLowerPriority(players[i].get(), players[j].get())); |
| 734 } | 734 } |
| 735 } | 735 } |
| 736 | 736 |
| 737 } | 737 } |
| OLD | NEW |