| Index: third_party/WebKit/Source/core/animation/AnimationTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/animation/AnimationTest.cpp b/third_party/WebKit/Source/core/animation/AnimationTest.cpp
|
| index c28dd9fed93c8052871a078fbca610df3cd70233..61beaff8f4b797058a4d5a699213293442e4b793 100644
|
| --- a/third_party/WebKit/Source/core/animation/AnimationTest.cpp
|
| +++ b/third_party/WebKit/Source/core/animation/AnimationTest.cpp
|
| @@ -38,7 +38,6 @@
|
| #include "core/dom/Document.h"
|
| #include "core/dom/ExceptionCode.h"
|
| #include "core/dom/QualifiedName.h"
|
| -#include "core/testing/DummyPageHolder.h"
|
| #include "platform/weborigin/KURL.h"
|
| #include <gtest/gtest.h>
|
|
|
| @@ -54,8 +53,7 @@
|
|
|
| void setUpWithoutStartingTimeline()
|
| {
|
| - pageHolder = DummyPageHolder::create();
|
| - document = &pageHolder->document();
|
| + document = Document::create();
|
| document->animationClock().resetTimeForTesting();
|
| timeline = AnimationTimeline::create(document.get());
|
| animation = timeline->play(0);
|
| @@ -78,7 +76,7 @@
|
|
|
| bool simulateFrame(double time)
|
| {
|
| - document->animationClock().updateTime(document->timeline().zeroTime() + time);
|
| + document->animationClock().updateTime(time);
|
| document->compositorPendingAnimations().update(false);
|
| // The timeline does not know about our animation, so we have to explicitly call update().
|
| return animation->update(TimingUpdateForAnimationFrame);
|
| @@ -88,7 +86,6 @@
|
| Persistent<AnimationTimeline> timeline;
|
| Persistent<Animation> animation;
|
| TrackExceptionState exceptionState;
|
| - OwnPtr<DummyPageHolder> pageHolder;
|
| };
|
|
|
| TEST_F(AnimationAnimationTest, InitialState)
|
| @@ -120,7 +117,7 @@
|
| // FIXME: We should split simulateFrame into a version that doesn't update
|
| // the animation and one that does, as most of the tests don't require update()
|
| // to be called.
|
| - document->animationClock().updateTime(document->timeline().zeroTime() + 10);
|
| + document->animationClock().updateTime(10);
|
| EXPECT_EQ(10, animation->currentTimeInternal());
|
| EXPECT_FALSE(animation->outdated());
|
| }
|
| @@ -184,6 +181,26 @@
|
| EXPECT_EQ(Animation::Running, animation->playStateInternal());
|
| simulateFrame(40);
|
| EXPECT_EQ(10, animation->currentTimeInternal());
|
| +}
|
| +
|
| +TEST_F(AnimationAnimationTest, SetCurrentTimeBeforeTimelineStarted)
|
| +{
|
| + setUpWithoutStartingTimeline();
|
| + animation->setCurrentTimeInternal(5);
|
| + EXPECT_EQ(5, animation->currentTimeInternal());
|
| + startTimeline();
|
| + simulateFrame(10);
|
| + EXPECT_EQ(15, animation->currentTimeInternal());
|
| +}
|
| +
|
| +TEST_F(AnimationAnimationTest, SetCurrentTimePastContentEndBeforeTimelineStarted)
|
| +{
|
| + setUpWithoutStartingTimeline();
|
| + animation->setCurrentTime(250 * 1000);
|
| + EXPECT_EQ(250, animation->currentTimeInternal());
|
| + startTimeline();
|
| + simulateFrame(10);
|
| + EXPECT_EQ(250, animation->currentTimeInternal());
|
| }
|
|
|
| TEST_F(AnimationAnimationTest, SetCurrentTimeMax)
|
| @@ -303,6 +320,21 @@
|
| EXPECT_EQ(20, animation->currentTimeInternal());
|
| }
|
|
|
| +TEST_F(AnimationAnimationTest, PauseBeforeTimelineStarted)
|
| +{
|
| + setUpWithoutStartingTimeline();
|
| + animation->pause();
|
| + EXPECT_TRUE(animation->paused());
|
| + animation->play();
|
| + EXPECT_FALSE(animation->paused());
|
| +
|
| + animation->pause();
|
| + startTimeline();
|
| + simulateFrame(100);
|
| + EXPECT_TRUE(animation->paused());
|
| + EXPECT_EQ(0, animation->currentTimeInternal());
|
| +}
|
| +
|
| TEST_F(AnimationAnimationTest, PlayRewindsToStart)
|
| {
|
| animation->setCurrentTimeInternal(30);
|
| @@ -519,6 +551,17 @@
|
| simulateFrame(0);
|
| EXPECT_EQ(2, animation->playbackRate());
|
| EXPECT_EQ(0, animation->currentTimeInternal());
|
| + simulateFrame(10);
|
| + EXPECT_EQ(20, animation->currentTimeInternal());
|
| +}
|
| +
|
| +TEST_F(AnimationAnimationTest, SetPlaybackRateBeforeTimelineStarted)
|
| +{
|
| + setUpWithoutStartingTimeline();
|
| + animation->setPlaybackRate(2);
|
| + EXPECT_EQ(2, animation->playbackRate());
|
| + EXPECT_EQ(0, animation->currentTimeInternal());
|
| + startTimeline();
|
| simulateFrame(10);
|
| EXPECT_EQ(20, animation->currentTimeInternal());
|
| }
|
|
|