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

Unified Diff: Source/core/animation/PlayerTest.cpp

Issue 28263002: Plumb timeToNextEffect through players and animation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Moved location of timeToEffectChange calculation Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/animation/PlayerTest.cpp
diff --git a/Source/core/animation/PlayerTest.cpp b/Source/core/animation/PlayerTest.cpp
index 70351bf03d2ba97c73277544eb0b9044c365b439..349f27f312f565e741afa1f0bca473bc2203dd76 100644
--- a/Source/core/animation/PlayerTest.cpp
+++ b/Source/core/animation/PlayerTest.cpp
@@ -31,6 +31,7 @@
#include "config.h"
#include "core/animation/Player.h"
+#include "core/animation/Animation.h"
#include "core/animation/DocumentTimeline.h"
#include "core/dom/Document.h"
#include "core/dom/QualifiedName.h"
@@ -51,11 +52,11 @@ protected:
timeline->setZeroTimeAsPerfTime(0);
}
- bool updateTimeline(double time)
+ bool updateTimeline(double time, double* timeToEffectChange = 0)
{
timeline->serviceAnimations(time);
// The timeline does not know about our player, so we have to explicitly call update().
- return player->update();
+ return player->update(timeToEffectChange);
}
RefPtr<Document> document;
@@ -258,4 +259,44 @@ TEST_F(CoreAnimationPlayerTest, SetCurrentTimeMax)
EXPECT_EQ(-std::numeric_limits<double>::max(), player->timeDrift());
}
+TEST_F(CoreAnimationPlayerTest, EmptyPlayersDontUpdateEffects)
+{
+ double timeToNextEffect;
+ updateTimeline(0, &timeToNextEffect);
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), timeToNextEffect);
+
+ timeToNextEffect = 0;
+ updateTimeline(1234, &timeToNextEffect);
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), timeToNextEffect);
+}
+
+TEST_F(CoreAnimationPlayerTest, PlayersReturnTimeToNextEffect)
+{
+ Timing timing;
+ timing.startDelay = 1;
+ timing.iterationDuration = 1;
+ timing.hasIterationDuration = true;
+ RefPtr<Animation> animation = Animation::create(0, 0, timing);
+ player = Player::create(timeline.get(), animation.get());
+
+ double timeToNextEffect;
+ updateTimeline(0, &timeToNextEffect);
+ EXPECT_EQ(1, timeToNextEffect);
+
+ updateTimeline(0.5, &timeToNextEffect);
+ EXPECT_EQ(0.5, timeToNextEffect);
+
+ updateTimeline(1, &timeToNextEffect);
+ EXPECT_EQ(0, timeToNextEffect);
+
+ updateTimeline(1.5, &timeToNextEffect);
+ EXPECT_EQ(0, timeToNextEffect);
+
+ updateTimeline(2, &timeToNextEffect);
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), timeToNextEffect);
+
+ updateTimeline(3, &timeToNextEffect);
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), timeToNextEffect);
+}
+
}

Powered by Google App Engine
This is Rietveld 408576698