| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 namespace { | 44 namespace { |
| 45 | 45 |
| 46 class CoreAnimationPlayerTest : public ::testing::Test { | 46 class CoreAnimationPlayerTest : public ::testing::Test { |
| 47 protected: | 47 protected: |
| 48 virtual void SetUp() | 48 virtual void SetUp() |
| 49 { | 49 { |
| 50 document = Document::create(); | 50 document = Document::create(); |
| 51 document->animationClock().resetTimeForTesting(); | 51 document->animationClock().resetTimeForTesting(); |
| 52 timeline = DocumentTimeline::create(document.get()); | 52 timeline = DocumentTimeline::create(document.get()); |
| 53 player = Player::create(timeline.get(), 0); | 53 player = Player::create(*timeline, 0); |
| 54 timeline->setZeroTime(0); | 54 timeline->setZeroTime(0); |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool updateTimeline(double time, double* timeToEffectChange = 0) | 57 bool updateTimeline(double time, double* timeToEffectChange = 0) |
| 58 { | 58 { |
| 59 timeline->serviceAnimations(time); | 59 timeline->serviceAnimations(time); |
| 60 // The timeline does not know about our player, so we have to explicitly
call update(). | 60 // The timeline does not know about our player, so we have to explicitly
call update(). |
| 61 return player->update(timeToEffectChange); | 61 return player->update(timeToEffectChange); |
| 62 } | 62 } |
| 63 | 63 |
| 64 RefPtr<Document> document; | 64 RefPtr<Document> document; |
| 65 RefPtr<DocumentTimeline> timeline; | 65 RefPtr<DocumentTimeline> timeline; |
| 66 RefPtr<Player> player; | 66 RefPtr<Player> player; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 TEST_F(CoreAnimationPlayerTest, InitialState) | 69 TEST_F(CoreAnimationPlayerTest, InitialState) |
| 70 { | 70 { |
| 71 EXPECT_EQ(0, timeline->currentTime()); | 71 EXPECT_EQ(0, timeline->currentTime()); |
| 72 EXPECT_EQ(0, player->currentTime()); | 72 EXPECT_EQ(0, player->currentTime()); |
| 73 EXPECT_FALSE(player->paused()); | 73 EXPECT_FALSE(player->paused()); |
| 74 EXPECT_EQ(1, player->playbackRate()); | 74 EXPECT_EQ(1, player->playbackRate()); |
| 75 EXPECT_EQ(0, player->startTime()); | 75 EXPECT_EQ(0, player->startTime()); |
| 76 EXPECT_EQ(0, player->timeDrift()); | 76 EXPECT_EQ(0, player->timeDrift()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 TEST_F(CoreAnimationPlayerTest, CreatePlayerAfterTimelineStarted) | 79 TEST_F(CoreAnimationPlayerTest, CreatePlayerAfterTimelineStarted) |
| 80 { | 80 { |
| 81 updateTimeline(1234); | 81 updateTimeline(1234); |
| 82 EXPECT_EQ(1234, timeline->currentTime()); | 82 EXPECT_EQ(1234, timeline->currentTime()); |
| 83 RefPtr<Player> player = Player::create(timeline.get(), 0); | 83 RefPtr<Player> player = Player::create(*timeline, 0); |
| 84 EXPECT_EQ(1234, player->startTime()); | 84 EXPECT_EQ(1234, player->startTime()); |
| 85 EXPECT_EQ(0, player->currentTime()); | 85 EXPECT_EQ(0, player->currentTime()); |
| 86 } | 86 } |
| 87 | 87 |
| 88 TEST_F(CoreAnimationPlayerTest, PauseUnpause) | 88 TEST_F(CoreAnimationPlayerTest, PauseUnpause) |
| 89 { | 89 { |
| 90 updateTimeline(200); | 90 updateTimeline(200); |
| 91 player->setPaused(true); | 91 player->setPaused(true); |
| 92 EXPECT_TRUE(player->paused()); | 92 EXPECT_TRUE(player->paused()); |
| 93 EXPECT_EQ(200, player->currentTime()); | 93 EXPECT_EQ(200, player->currentTime()); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 EXPECT_EQ(std::numeric_limits<double>::infinity(), timeToNextEffect); | 272 EXPECT_EQ(std::numeric_limits<double>::infinity(), timeToNextEffect); |
| 273 } | 273 } |
| 274 | 274 |
| 275 TEST_F(CoreAnimationPlayerTest, PlayersReturnTimeToNextEffect) | 275 TEST_F(CoreAnimationPlayerTest, PlayersReturnTimeToNextEffect) |
| 276 { | 276 { |
| 277 Timing timing; | 277 Timing timing; |
| 278 timing.startDelay = 1; | 278 timing.startDelay = 1; |
| 279 timing.iterationDuration = 1; | 279 timing.iterationDuration = 1; |
| 280 timing.hasIterationDuration = true; | 280 timing.hasIterationDuration = true; |
| 281 RefPtr<Animation> animation = Animation::create(0, 0, timing); | 281 RefPtr<Animation> animation = Animation::create(0, 0, timing); |
| 282 player = Player::create(timeline.get(), animation.get()); | 282 player = Player::create(*timeline, animation.get()); |
| 283 | 283 |
| 284 double timeToNextEffect; | 284 double timeToNextEffect; |
| 285 updateTimeline(0, &timeToNextEffect); | 285 updateTimeline(0, &timeToNextEffect); |
| 286 EXPECT_EQ(1, timeToNextEffect); | 286 EXPECT_EQ(1, timeToNextEffect); |
| 287 | 287 |
| 288 updateTimeline(0.5, &timeToNextEffect); | 288 updateTimeline(0.5, &timeToNextEffect); |
| 289 EXPECT_EQ(0.5, timeToNextEffect); | 289 EXPECT_EQ(0.5, timeToNextEffect); |
| 290 | 290 |
| 291 updateTimeline(1, &timeToNextEffect); | 291 updateTimeline(1, &timeToNextEffect); |
| 292 EXPECT_EQ(0, timeToNextEffect); | 292 EXPECT_EQ(0, timeToNextEffect); |
| 293 | 293 |
| 294 updateTimeline(1.5, &timeToNextEffect); | 294 updateTimeline(1.5, &timeToNextEffect); |
| 295 EXPECT_EQ(0, timeToNextEffect); | 295 EXPECT_EQ(0, timeToNextEffect); |
| 296 | 296 |
| 297 updateTimeline(2, &timeToNextEffect); | 297 updateTimeline(2, &timeToNextEffect); |
| 298 EXPECT_EQ(std::numeric_limits<double>::infinity(), timeToNextEffect); | 298 EXPECT_EQ(std::numeric_limits<double>::infinity(), timeToNextEffect); |
| 299 | 299 |
| 300 updateTimeline(3, &timeToNextEffect); | 300 updateTimeline(3, &timeToNextEffect); |
| 301 EXPECT_EQ(std::numeric_limits<double>::infinity(), timeToNextEffect); | 301 EXPECT_EQ(std::numeric_limits<double>::infinity(), timeToNextEffect); |
| 302 } | 302 } |
| 303 | 303 |
| 304 } | 304 } |
| OLD | NEW |