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

Side by Side Diff: Source/core/animation/AnimationPlayerTest.cpp

Issue 225073004: Oilpan: Completely move core/animations/ to oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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
OLDNEW
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
61 player->setStartTime(0); 61 player->setStartTime(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(nullptr, nullptr, timing); 76 return Animation::create(nullptr, 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->currentTime())); 96 EXPECT_TRUE(isNull(timeline->currentTime()));
97 EXPECT_EQ(0, player->currentTime()); 97 EXPECT_EQ(0, player->currentTime());
98 EXPECT_FALSE(player->paused()); 98 EXPECT_FALSE(player->paused());
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 EXPECT_EQ(0, player->currentTime()); 569 EXPECT_EQ(0, player->currentTime());
570 updateTimeline(1); 570 updateTimeline(1);
571 EXPECT_EQ(30, player->currentTime()); 571 EXPECT_EQ(30, player->currentTime());
572 } 572 }
573 573
574 574
575 TEST_F(AnimationAnimationPlayerTest, SetSource) 575 TEST_F(AnimationAnimationPlayerTest, SetSource)
576 { 576 {
577 player = timeline->createAnimationPlayer(0); 577 player = timeline->createAnimationPlayer(0);
578 player->setStartTime(0); 578 player->setStartTime(0);
579 RefPtr<TimedItem> source1 = makeAnimation(); 579 RefPtrWillBeRawPtr<TimedItem> source1 = makeAnimation();
580 RefPtr<TimedItem> source2 = makeAnimation(); 580 RefPtrWillBeRawPtr<TimedItem> source2 = makeAnimation();
581 player->setSource(source1.get()); 581 player->setSource(source1.get());
582 EXPECT_EQ(source1, player->source()); 582 EXPECT_EQ(source1, player->source());
583 EXPECT_EQ(0, player->currentTime()); 583 EXPECT_EQ(0, player->currentTime());
584 player->setCurrentTime(15); 584 player->setCurrentTime(15);
585 player->setSource(source2.get()); 585 player->setSource(source2.get());
586 EXPECT_EQ(15, player->currentTime()); 586 EXPECT_EQ(15, player->currentTime());
587 EXPECT_EQ(0, source1->player()); 587 EXPECT_EQ(0, source1->player());
588 EXPECT_EQ(player.get(), source2->player()); 588 EXPECT_EQ(player.get(), source2->player());
589 EXPECT_EQ(source2, player->source()); 589 EXPECT_EQ(source2, player->source());
590 } 590 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 player->setSource(timedItem); 627 player->setSource(timedItem);
628 EXPECT_EQ(0, player2->source()); 628 EXPECT_EQ(0, player2->source());
629 } 629 }
630 630
631 TEST_F(AnimationAnimationPlayerTest, AnimationPlayersReturnTimeToNextEffect) 631 TEST_F(AnimationAnimationPlayerTest, AnimationPlayersReturnTimeToNextEffect)
632 { 632 {
633 Timing timing; 633 Timing timing;
634 timing.startDelay = 1; 634 timing.startDelay = 1;
635 timing.iterationDuration = 1; 635 timing.iterationDuration = 1;
636 timing.endDelay = 1; 636 timing.endDelay = 1;
637 RefPtr<Animation> animation = Animation::create(nullptr, nullptr, timing); 637 RefPtrWillBeRawPtr<Animation> animation = Animation::create(nullptr, nullptr , timing);
638 player = timeline->createAnimationPlayer(animation.get()); 638 player = timeline->createAnimationPlayer(animation.get());
639 player->setStartTime(0); 639 player->setStartTime(0);
640 640
641 updateTimeline(0); 641 updateTimeline(0);
642 EXPECT_EQ(1, player->timeToEffectChange()); 642 EXPECT_EQ(1, player->timeToEffectChange());
643 643
644 updateTimeline(0.5); 644 updateTimeline(0.5);
645 EXPECT_EQ(0.5, player->timeToEffectChange()); 645 EXPECT_EQ(0.5, player->timeToEffectChange());
646 646
647 updateTimeline(1); 647 updateTimeline(1);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 player->cancel(); 704 player->cancel();
705 player->update(AnimationPlayer::UpdateOnDemand); 705 player->update(AnimationPlayer::UpdateOnDemand);
706 EXPECT_EQ(3, player->timeToEffectChange()); 706 EXPECT_EQ(3, player->timeToEffectChange());
707 } 707 }
708 708
709 TEST_F(AnimationAnimationPlayerTest, AttachedAnimationPlayers) 709 TEST_F(AnimationAnimationPlayerTest, AttachedAnimationPlayers)
710 { 710 {
711 RefPtr<Element> element = document->createElement("foo", ASSERT_NO_EXCEPTION ); 711 RefPtr<Element> element = document->createElement("foo", ASSERT_NO_EXCEPTION );
712 712
713 Timing timing; 713 Timing timing;
714 RefPtr<Animation> animation = Animation::create(element, nullptr, timing); 714 RefPtrWillBeRawPtr<Animation> animation = Animation::create(element, nullptr , timing);
715 RefPtr<AnimationPlayer> player = timeline->createAnimationPlayer(animation.g et()); 715 RefPtrWillBeRawPtr<AnimationPlayer> player = timeline->createAnimationPlayer (animation.get());
716 timeline->serviceAnimations(AnimationPlayer::UpdateForAnimationFrame); 716 timeline->serviceAnimations(AnimationPlayer::UpdateForAnimationFrame);
717 EXPECT_EQ(1U, element->activeAnimations()->players().find(player.get())->val ue); 717 EXPECT_EQ(element->activeAnimations()->players().get(player.get()));
718
719 player.release(); 718 player.release();
719 Heap::collectAllGarbage();
720 EXPECT_TRUE(element->activeAnimations()->players().isEmpty()); 720 EXPECT_TRUE(element->activeAnimations()->players().isEmpty());
721 } 721 }
722 722
723 TEST_F(AnimationAnimationPlayerTest, HasLowerPriority) 723 TEST_F(AnimationAnimationPlayerTest, HasLowerPriority)
724 { 724 {
725 // Sort time defaults to timeline current time 725 // Sort time defaults to timeline current time
726 updateTimeline(15); 726 updateTimeline(15);
727 RefPtr<AnimationPlayer> player1 = timeline->createAnimationPlayer(0); 727 RefPtrWillBeRawPtr<AnimationPlayer> player1 = timeline->createAnimationPlaye r(0);
728 RefPtr<AnimationPlayer> player2 = timeline->createAnimationPlayer(0); 728 RefPtrWillBeRawPtr<AnimationPlayer> player2 = timeline->createAnimationPlaye r(0);
729 player2->setStartTime(10); 729 player2->setStartTime(10);
730 RefPtr<AnimationPlayer> player3 = timeline->createAnimationPlayer(0); 730 RefPtrWillBeRawPtr<AnimationPlayer> player3 = timeline->createAnimationPlaye r(0);
731 RefPtr<AnimationPlayer> player4 = timeline->createAnimationPlayer(0); 731 RefPtrWillBeRawPtr<AnimationPlayer> player4 = timeline->createAnimationPlaye r(0);
732 player4->setStartTime(20); 732 player4->setStartTime(20);
733 RefPtr<AnimationPlayer> player5 = timeline->createAnimationPlayer(0); 733 RefPtrWillBeRawPtr<AnimationPlayer> player5 = timeline->createAnimationPlaye r(0);
734 player5->setStartTime(10); 734 player5->setStartTime(10);
735 RefPtr<AnimationPlayer> player6 = timeline->createAnimationPlayer(0); 735 RefPtrWillBeRawPtr<AnimationPlayer> player6 = timeline->createAnimationPlaye r(0);
736 player6->setStartTime(-10); 736 player6->setStartTime(-10);
737 Vector<RefPtr<AnimationPlayer> > players; 737 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> > players;
738 players.append(player6); 738 players.append(player6);
739 players.append(player2); 739 players.append(player2);
740 players.append(player5); 740 players.append(player5);
741 players.append(player1); 741 players.append(player1);
742 players.append(player3); 742 players.append(player3);
743 players.append(player4); 743 players.append(player4);
744 for (size_t i = 0; i < players.size(); i++) { 744 for (size_t i = 0; i < players.size(); i++) {
745 for (size_t j = 0; j < players.size(); j++) 745 for (size_t j = 0; j < players.size(); j++)
746 EXPECT_EQ(i < j, AnimationPlayer::hasLowerPriority(players[i].get(), players[j].get())); 746 EXPECT_EQ(i < j, AnimationPlayer::hasLowerPriority(players[i].get(), players[j].get()));
747 } 747 }
748 } 748 }
749 749
750 } 750 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698