| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 protected: | 48 protected: |
| 49 virtual void SetUp() | 49 virtual void SetUp() |
| 50 { | 50 { |
| 51 setUpWithoutStartingTimeline(); | 51 setUpWithoutStartingTimeline(); |
| 52 startTimeline(); | 52 startTimeline(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void setUpWithoutStartingTimeline() | 55 void setUpWithoutStartingTimeline() |
| 56 { | 56 { |
| 57 document = Document::create(); | 57 document = Document::create(); |
| 58 document->animationClock().resetTimeForTesting(); | 58 document->animationClock().clearTimeForTesting(); |
| 59 document->animationClock().updateTime(AnimationClock::createTimeForTesti
ng(0, 0)); |
| 59 timeline = AnimationTimeline::create(document.get()); | 60 timeline = AnimationTimeline::create(document.get()); |
| 60 player = timeline->createAnimationPlayer(0); | 61 player = timeline->createAnimationPlayer(0); |
| 61 player->setStartTimeInternal(0); | 62 player->setStartTimeInternal(0); |
| 62 player->setSource(makeAnimation().get()); | 63 player->setSource(makeAnimation().get()); |
| 63 } | 64 } |
| 64 | 65 |
| 65 void startTimeline() | 66 void startTimeline() |
| 66 { | 67 { |
| 67 updateTimeline(0); | 68 updateTimeline(0); |
| 68 } | 69 } |
| 69 | 70 |
| 70 PassRefPtrWillBeRawPtr<Animation> makeAnimation(double duration = 30, double
playbackRate = 1) | 71 PassRefPtrWillBeRawPtr<Animation> makeAnimation(double duration = 30, double
playbackRate = 1) |
| 71 { | 72 { |
| 72 Timing timing; | 73 Timing timing; |
| 73 timing.iterationDuration = duration; | 74 timing.iterationDuration = duration; |
| 74 timing.playbackRate = playbackRate; | 75 timing.playbackRate = playbackRate; |
| 75 return Animation::create(0, nullptr, timing); | 76 return Animation::create(0, nullptr, timing); |
| 76 } | 77 } |
| 77 | 78 |
| 78 bool updateTimeline(double time) | 79 bool updateTimeline(double time) |
| 79 { | 80 { |
| 80 document->animationClock().updateTime(time); | 81 document->animationClock().updateTime(AnimationClock::createTimeForTesti
ng(time, time + 1)); |
| 81 // 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(). |
| 82 return player->update(TimingUpdateOnDemand); | 83 return player->update(TimingUpdateOnDemand); |
| 83 } | 84 } |
| 84 | 85 |
| 85 RefPtrWillBePersistent<Document> document; | 86 RefPtrWillBePersistent<Document> document; |
| 86 RefPtrWillBePersistent<AnimationTimeline> timeline; | 87 RefPtrWillBePersistent<AnimationTimeline> timeline; |
| 87 RefPtrWillBePersistent<AnimationPlayer> player; | 88 RefPtrWillBePersistent<AnimationPlayer> player; |
| 88 TrackExceptionState exceptionState; | 89 TrackExceptionState exceptionState; |
| 89 }; | 90 }; |
| 90 | 91 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 112 | 113 |
| 113 | 114 |
| 114 TEST_F(AnimationAnimationPlayerTest, CurrentTimeDoesNotSetOutdated) | 115 TEST_F(AnimationAnimationPlayerTest, CurrentTimeDoesNotSetOutdated) |
| 115 { | 116 { |
| 116 EXPECT_FALSE(player->outdated()); | 117 EXPECT_FALSE(player->outdated()); |
| 117 EXPECT_EQ(0, player->currentTimeInternal()); | 118 EXPECT_EQ(0, player->currentTimeInternal()); |
| 118 EXPECT_FALSE(player->outdated()); | 119 EXPECT_FALSE(player->outdated()); |
| 119 // FIXME: We should split updateTimeline into a version that doesn't update | 120 // FIXME: We should split updateTimeline into a version that doesn't update |
| 120 // the player and one that does, as most of the tests don't require update() | 121 // the player and one that does, as most of the tests don't require update() |
| 121 // to be called. | 122 // to be called. |
| 122 document->animationClock().updateTime(10); | 123 document->animationClock().updateTime(AnimationClock::createTimeForTesting(1
0, 11)); |
| 123 EXPECT_EQ(10, player->currentTimeInternal()); | 124 EXPECT_EQ(10, player->currentTimeInternal()); |
| 124 EXPECT_FALSE(player->outdated()); | 125 EXPECT_FALSE(player->outdated()); |
| 125 } | 126 } |
| 126 | 127 |
| 127 TEST_F(AnimationAnimationPlayerTest, SetCurrentTime) | 128 TEST_F(AnimationAnimationPlayerTest, SetCurrentTime) |
| 128 { | 129 { |
| 129 player->setCurrentTimeInternal(10); | 130 player->setCurrentTimeInternal(10); |
| 130 EXPECT_EQ(10, player->currentTimeInternal()); | 131 EXPECT_EQ(10, player->currentTimeInternal()); |
| 131 updateTimeline(10); | 132 updateTimeline(10); |
| 132 EXPECT_EQ(20, player->currentTimeInternal()); | 133 EXPECT_EQ(20, player->currentTimeInternal()); |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 players.append(player1); | 729 players.append(player1); |
| 729 players.append(player3); | 730 players.append(player3); |
| 730 players.append(player4); | 731 players.append(player4); |
| 731 for (size_t i = 0; i < players.size(); i++) { | 732 for (size_t i = 0; i < players.size(); i++) { |
| 732 for (size_t j = 0; j < players.size(); j++) | 733 for (size_t j = 0; j < players.size(); j++) |
| 733 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())); |
| 734 } | 735 } |
| 735 } | 736 } |
| 736 | 737 |
| 737 } | 738 } |
| OLD | NEW |