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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 PassRefPtr<Animation> makeAnimation(double duration = 30, double playbackRat
e = 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, 0, 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(); | 83 return player->update(); |
84 } | 84 } |
85 | 85 |
86 RefPtr<Document> document; | 86 RefPtr<Document> document; |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 player->setPlaybackRate(0); | 445 player->setPlaybackRate(0); |
446 player->finish(exceptionState); | 446 player->finish(exceptionState); |
447 EXPECT_EQ(10, player->currentTime()); | 447 EXPECT_EQ(10, player->currentTime()); |
448 } | 448 } |
449 | 449 |
450 TEST_F(AnimationPlayerTest, FinishRaisesException) | 450 TEST_F(AnimationPlayerTest, FinishRaisesException) |
451 { | 451 { |
452 Timing timing; | 452 Timing timing; |
453 timing.iterationDuration = 1; | 453 timing.iterationDuration = 1; |
454 timing.iterationCount = std::numeric_limits<double>::infinity(); | 454 timing.iterationCount = std::numeric_limits<double>::infinity(); |
455 player->setSource(Animation::create(0, 0, timing).get()); | 455 player->setSource(Animation::create(nullptr, nullptr, timing).get()); |
456 player->setCurrentTime(10); | 456 player->setCurrentTime(10); |
457 | 457 |
458 player->finish(exceptionState); | 458 player->finish(exceptionState); |
459 EXPECT_EQ(10, player->currentTime()); | 459 EXPECT_EQ(10, player->currentTime()); |
460 EXPECT_TRUE(exceptionState.hadException()); | 460 EXPECT_TRUE(exceptionState.hadException()); |
461 EXPECT_EQ(InvalidStateError, exceptionState.code()); | 461 EXPECT_EQ(InvalidStateError, exceptionState.code()); |
462 } | 462 } |
463 | 463 |
464 | 464 |
465 TEST_F(AnimationPlayerTest, LimitingAtSourceEnd) | 465 TEST_F(AnimationPlayerTest, LimitingAtSourceEnd) |
(...skipping 148 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(AnimationPlayerTest, PlayersReturnTimeToNextEffect) | 618 TEST_F(AnimationPlayerTest, PlayersReturnTimeToNextEffect) |
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, 0, timing); | 624 RefPtr<Animation> animation = Animation::create(nullptr, nullptr, timing); |
625 player = timeline->createPlayer(animation.get()); | 625 player = timeline->createPlayer(animation.get()); |
626 player->setStartTime(0); | 626 player->setStartTime(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 28 matching lines...) Expand all Loading... |
663 player->setPlaybackRate(-2); | 663 player->setPlaybackRate(-2); |
664 player->update(); | 664 player->update(); |
665 EXPECT_EQ(0.5, player->timeToEffectChange()); | 665 EXPECT_EQ(0.5, player->timeToEffectChange()); |
666 } | 666 } |
667 | 667 |
668 TEST_F(AnimationPlayerTest, AttachedPlayers) | 668 TEST_F(AnimationPlayerTest, AttachedPlayers) |
669 { | 669 { |
670 RefPtr<Element> element = document->createElement("foo", ASSERT_NO_EXCEPTION
); | 670 RefPtr<Element> element = document->createElement("foo", ASSERT_NO_EXCEPTION
); |
671 | 671 |
672 Timing timing; | 672 Timing timing; |
673 RefPtr<Animation> animation = Animation::create(element, 0, timing); | 673 RefPtr<Animation> animation = Animation::create(element, nullptr, timing); |
674 RefPtr<Player> player = timeline->createPlayer(animation.get()); | 674 RefPtr<Player> player = timeline->createPlayer(animation.get()); |
675 timeline->serviceAnimations(); | 675 timeline->serviceAnimations(); |
676 EXPECT_EQ(1U, element->activeAnimations()->players().find(player.get())->val
ue); | 676 EXPECT_EQ(1U, element->activeAnimations()->players().find(player.get())->val
ue); |
677 | 677 |
678 player.release(); | 678 player.release(); |
679 EXPECT_TRUE(element->activeAnimations()->players().isEmpty()); | 679 EXPECT_TRUE(element->activeAnimations()->players().isEmpty()); |
680 } | 680 } |
681 | 681 |
682 } | 682 } |
OLD | NEW |