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

Unified Diff: third_party/WebKit/Source/platform/animation/TimingFunctionTest.cpp

Issue 2775143002: Implement frames() timing function (Closed)
Patch Set: Fix behaviour outside input range [0,1] Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/platform/animation/TimingFunction.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/animation/TimingFunctionTest.cpp
diff --git a/third_party/WebKit/Source/platform/animation/TimingFunctionTest.cpp b/third_party/WebKit/Source/platform/animation/TimingFunctionTest.cpp
index 787278219d81be0d5ac801de5a1ec251b5d7a80a..9c2bc03aa723095622e7304db019b6bf0191f5bb 100644
--- a/third_party/WebKit/Source/platform/animation/TimingFunctionTest.cpp
+++ b/third_party/WebKit/Source/platform/animation/TimingFunctionTest.cpp
@@ -117,6 +117,11 @@ TEST_F(TimingFunctionTest, StepToString) {
EXPECT_EQ("steps(5)", step_timing_custom_end->ToString());
}
+TEST_F(TimingFunctionTest, FrameToString) {
+ RefPtr<TimingFunction> frame_timing = FramesTimingFunction::Create(3);
+ EXPECT_EQ("frames(3)", frame_timing->ToString());
+}
+
TEST_F(TimingFunctionTest, BaseOperatorEq) {
RefPtr<TimingFunction> linear_timing = LinearTimingFunction::Shared();
RefPtr<TimingFunction> cubic_timing1 = CubicBezierTimingFunction::Preset(
@@ -127,6 +132,7 @@ TEST_F(TimingFunctionTest, BaseOperatorEq) {
StepsTimingFunction::Preset(StepsTimingFunction::StepPosition::END);
RefPtr<TimingFunction> steps_timing2 =
StepsTimingFunction::Create(5, StepsTimingFunction::StepPosition::START);
+ RefPtr<TimingFunction> frames_timing = FramesTimingFunction::Create(5);
Vector<std::pair<std::string, RefPtr<TimingFunction>>> v;
v.push_back(std::make_pair("linearTiming", linear_timing));
@@ -134,6 +140,7 @@ TEST_F(TimingFunctionTest, BaseOperatorEq) {
v.push_back(std::make_pair("cubicTiming2", cubic_timing2));
v.push_back(std::make_pair("stepsTiming1", steps_timing1));
v.push_back(std::make_pair("stepsTiming2", steps_timing2));
+ v.push_back(std::make_pair("framesTiming", frames_timing));
NotEqualHelperLoop(v);
}
@@ -253,6 +260,19 @@ TEST_F(TimingFunctionTest, StepsOperatorEqPreset) {
EXPECT_EQ(*steps_b, *steps_a);
}
+TEST_F(TimingFunctionTest, FramesOperatorEq) {
+ RefPtr<TimingFunction> frames_timing1 = FramesTimingFunction::Create(5);
+ RefPtr<TimingFunction> frames_timing2 = FramesTimingFunction::Create(7);
+
+ EXPECT_EQ(*FramesTimingFunction::Create(5), *frames_timing1);
+ EXPECT_EQ(*FramesTimingFunction::Create(7), *frames_timing2);
+
+ Vector<std::pair<std::string, RefPtr<TimingFunction>>> v;
+ v.push_back(std::make_pair("framesTiming1", frames_timing1));
+ v.push_back(std::make_pair("framesTiming2", frames_timing2));
+ NotEqualHelperLoop(v);
+}
+
TEST_F(TimingFunctionTest, LinearEvaluate) {
RefPtr<TimingFunction> linear_timing = LinearTimingFunction::Shared();
EXPECT_EQ(0.2, linear_timing->Evaluate(0.2, 0));
@@ -291,6 +311,21 @@ TEST_F(TimingFunctionTest, StepRange) {
EXPECT_NEAR(1, end, 0.01);
}
+TEST_F(TimingFunctionTest, FrameRange) {
+ double start = 0;
+ double end = 1;
+ RefPtr<TimingFunction> frames = FramesTimingFunction::Create(4);
+ frames->Range(&start, &end);
+ EXPECT_NEAR(0, start, 0.01);
+ EXPECT_NEAR(1, end, 0.01);
+
+ start = -1;
+ end = 10;
+ frames->Range(&start, &end);
+ EXPECT_NEAR(0, start, 0.01);
+ EXPECT_NEAR(1, end, 0.01);
+}
+
TEST_F(TimingFunctionTest, CubicRange) {
double start = 0;
double end = 1;
@@ -484,6 +519,22 @@ TEST_F(TimingFunctionTest, StepsEvaluate) {
EXPECT_EQ(2.00, steps_timing_custom_end->Evaluate(2.00, 0));
}
+TEST_F(TimingFunctionTest, FramesEvaluate) {
+ RefPtr<TimingFunction> frames_timing = FramesTimingFunction::Create(5);
+ EXPECT_EQ(-2.50, frames_timing->Evaluate(-2.00, 0));
+ EXPECT_EQ(0.00, frames_timing->Evaluate(0.00, 0));
+ EXPECT_EQ(0.00, frames_timing->Evaluate(0.19, 0));
+ EXPECT_EQ(0.25, frames_timing->Evaluate(0.20, 0));
+ EXPECT_EQ(0.25, frames_timing->Evaluate(0.39, 0));
+ EXPECT_EQ(0.50, frames_timing->Evaluate(0.40, 0));
+ EXPECT_EQ(0.50, frames_timing->Evaluate(0.59, 0));
+ EXPECT_EQ(0.75, frames_timing->Evaluate(0.60, 0));
+ EXPECT_EQ(0.75, frames_timing->Evaluate(0.79, 0));
+ EXPECT_EQ(1.00, frames_timing->Evaluate(0.80, 0));
+ EXPECT_EQ(1.00, frames_timing->Evaluate(1.00, 0));
+ EXPECT_EQ(3.75, frames_timing->Evaluate(3.00, 0));
+}
+
} // namespace
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/animation/TimingFunction.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698