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

Unified Diff: Source/core/platform/animation/TimingFunctionTest.cpp

Issue 54743002: Adding a reverse function to the TimingFunctions and tests to prove it works. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@timing-function-helper
Patch Set: Moved operator== stuff into own patch. Created 7 years, 1 month 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 | « Source/core/platform/animation/TimingFunction.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/platform/animation/TimingFunctionTest.cpp
diff --git a/Source/core/platform/animation/TimingFunctionTest.cpp b/Source/core/platform/animation/TimingFunctionTest.cpp
index 2cd17c3751c4ad81293f291d30b02de45d341385..5e0e21cf1151c1dea236524d7c637289dbd1053c 100644
--- a/Source/core/platform/animation/TimingFunctionTest.cpp
+++ b/Source/core/platform/animation/TimingFunctionTest.cpp
@@ -64,7 +64,6 @@
} \
}
-
using namespace WebCore;
namespace {
@@ -260,4 +259,59 @@ TEST_F(TimingFunctionTest, ChainedEq)
EXPECT_REFV_NE(chainedMixed1, chainedMixed4);
}
+TEST_F(TimingFunctionTest, LinearReverse)
+{
+ RefPtr<TimingFunction> linearTiming = LinearTimingFunction::create();
+ EXPECT_REFV_EQ(linearTiming, linearTiming->reverse());
+}
+
+TEST_F(TimingFunctionTest, CubicReverse)
+{
+ RefPtr<TimingFunction> cubicEaseInTiming = CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseIn);
+ RefPtr<TimingFunction> cubicEaseOutTiming = CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseOut);
+ RefPtr<TimingFunction> cubicEaseInOutTiming = CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseInOut);
+
+ EXPECT_REFV_EQ(cubicEaseOutTiming, cubicEaseInTiming->reverse());
+ EXPECT_REFV_EQ(cubicEaseInTiming, cubicEaseOutTiming->reverse());
+ EXPECT_REFV_EQ(cubicEaseInOutTiming, cubicEaseInOutTiming->reverse());
+
+ RefPtr<TimingFunction> cubicCustomTiming = CubicBezierTimingFunction::create(0.17, 0.67, 1, -1.73);
+ RefPtr<TimingFunction> cubicCustomTimingReversed = CubicBezierTimingFunction::create(0.17, 0.67, 1, -1.73);
+ EXPECT_REFV_EQ(cubicCustomTimingReversed, cubicCustomTiming->reverse());
+}
+
+TEST_F(TimingFunctionTest, StepReverse)
+{
+ RefPtr<TimingFunction> stepTimingStart = StepsTimingFunction::preset(StepsTimingFunction::Start);
+ RefPtr<TimingFunction> stepTimingEnd = StepsTimingFunction::preset(StepsTimingFunction::End);
+
+ EXPECT_REFV_EQ(stepTimingEnd, stepTimingStart->reverse());
+ EXPECT_REFV_EQ(stepTimingStart, stepTimingEnd->reverse());
+
+ RefPtr<TimingFunction> stepTimingCustom = StepsTimingFunction::create(5, false);
+ RefPtr<TimingFunction> stepTimingCustomReversed = StepsTimingFunction::create(5, true);
+ EXPECT_REFV_EQ(stepTimingCustomReversed, stepTimingCustom);
+}
+
+TEST_F(TimingFunctionTest, ChainedReverse)
+{
+ RefPtr<TimingFunction> linearTiming = LinearTimingFunction::create();
+ RefPtr<ChainedTimingFunction> chainedLinearSingle = ChainedTimingFunction::create();
+ chainedLinearSingle->appendSegment(1.0, linearTiming.get());
+ EXPECT_REFV_EQ(chainedLinearSingle, chainedLinearSingle->reverse());
+
+ RefPtr<TimingFunction> cubicEaseInTiming = CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseIn);
+ RefPtr<TimingFunction> cubicEaseOutTiming = CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseOut);
+
+ RefPtr<ChainedTimingFunction> chainedMixed = ChainedTimingFunction::create();
+ chainedMixed->appendSegment(0.75, chainedLinearSingle.get());
+ chainedMixed->appendSegment(1.0, cubicEaseInTiming.get());
+
+ RefPtr<ChainedTimingFunction> chainedMixedReversed = ChainedTimingFunction::create();
+ chainedMixed->appendSegment(0.25, cubicEaseOutTiming.get());
+ chainedMixed->appendSegment(1.0, chainedLinearSingle.get());
+
+ EXPECT_REFV_EQ(chainedMixed, chainedMixedReversed);
+}
+
} // namespace
« no previous file with comments | « Source/core/platform/animation/TimingFunction.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698