Chromium Code Reviews| Index: third_party/WebKit/Source/core/animation/AnimationInputHelpersTest.cpp |
| diff --git a/third_party/WebKit/Source/core/animation/AnimationInputHelpersTest.cpp b/third_party/WebKit/Source/core/animation/AnimationInputHelpersTest.cpp |
| index 29a99abba89c37cc95023118b8fe2fbbbd29da6a..80794557105c96a80066e3b6f800e28a1152c2f5 100644 |
| --- a/third_party/WebKit/Source/core/animation/AnimationInputHelpersTest.cpp |
| +++ b/third_party/WebKit/Source/core/animation/AnimationInputHelpersTest.cpp |
| @@ -5,6 +5,7 @@ |
| #include "core/animation/AnimationInputHelpers.h" |
| #include "core/dom/Element.h" |
| +#include "core/dom/ExceptionCode.h" |
| #include "core/testing/DummyPageHolder.h" |
| #include "platform/animation/TimingFunction.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -35,6 +36,7 @@ protected: |
| OwnPtr<DummyPageHolder> pageHolder; |
| Persistent<Document> document; |
| + TrackExceptionState exceptionState; |
| }; |
| TEST_F(AnimationAnimationInputHelpersTest, ParseKeyframePropertyAttributes) |
| @@ -58,36 +60,44 @@ TEST_F(AnimationAnimationInputHelpersTest, ParseKeyframePropertyAttributes) |
| EXPECT_EQ(CSSPropertyInvalid, keyframeAttributeToCSSProperty("WebkitTransform")); |
| } |
| -static bool timingFunctionRoundTrips(const String& string) |
| +static bool timingFunctionRoundTrips(const String& string, ExceptionState& exceptionState) |
| { |
| - RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::parseTimingFunction(string); |
| + RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::parseTimingFunction(string, exceptionState); |
| return timingFunction && string == timingFunction->toString(); |
|
alancutter (OOO until 2018)
2016/04/05 04:50:06
It's probably better to EXPECT_EQ here for informa
suzyh_UTC10 (ex-contributor)
2016/04/12 08:04:23
Done.
|
| } |
| +static void timingFunctionThrows(const String& string, ExceptionState& exceptionState) |
| +{ |
| + RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::parseTimingFunction(string, exceptionState); |
| + EXPECT_TRUE(exceptionState.hadException()); |
| + EXPECT_EQ(V8TypeError, exceptionState.code()); |
| +} |
| + |
| TEST_F(AnimationAnimationInputHelpersTest, ParseAnimationTimingFunction) |
| { |
| - EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("initial")); |
| - EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("inherit")); |
| - EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("unset")); |
| - |
| - EXPECT_TRUE(timingFunctionRoundTrips("ease")); |
| - EXPECT_TRUE(timingFunctionRoundTrips("linear")); |
| - EXPECT_TRUE(timingFunctionRoundTrips("ease-in")); |
| - EXPECT_TRUE(timingFunctionRoundTrips("ease-out")); |
| - EXPECT_TRUE(timingFunctionRoundTrips("ease-in-out")); |
| - EXPECT_TRUE(timingFunctionRoundTrips("step-start")); |
| - EXPECT_TRUE(timingFunctionRoundTrips("step-middle")); |
| - EXPECT_TRUE(timingFunctionRoundTrips("step-end")); |
| - EXPECT_TRUE(timingFunctionRoundTrips("steps(3, start)")); |
| - EXPECT_TRUE(timingFunctionRoundTrips("steps(3, middle)")); |
| - EXPECT_TRUE(timingFunctionRoundTrips("steps(3, end)")); |
| - EXPECT_TRUE(timingFunctionRoundTrips("cubic-bezier(0.1, 5, 0.23, 0)")); |
| - |
| - EXPECT_EQ("steps(3, end)", AnimationInputHelpers::parseTimingFunction("steps(3)")->toString()); |
| - |
| - EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("steps(3, nowhere)")); |
| - EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("steps(-3, end)")); |
| - EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("cubic-bezier(0.1, 0, 4, 0.4)")); |
| + timingFunctionThrows("", exceptionState); |
| + timingFunctionThrows("initial", exceptionState); |
| + timingFunctionThrows("inherit", exceptionState); |
| + timingFunctionThrows("unset", exceptionState); |
| + |
| + EXPECT_TRUE(timingFunctionRoundTrips("ease", exceptionState)); |
| + EXPECT_TRUE(timingFunctionRoundTrips("linear", exceptionState)); |
| + EXPECT_TRUE(timingFunctionRoundTrips("ease-in", exceptionState)); |
| + EXPECT_TRUE(timingFunctionRoundTrips("ease-out", exceptionState)); |
| + EXPECT_TRUE(timingFunctionRoundTrips("ease-in-out", exceptionState)); |
| + EXPECT_TRUE(timingFunctionRoundTrips("step-start", exceptionState)); |
| + EXPECT_TRUE(timingFunctionRoundTrips("step-middle", exceptionState)); |
| + EXPECT_TRUE(timingFunctionRoundTrips("step-end", exceptionState)); |
| + EXPECT_TRUE(timingFunctionRoundTrips("steps(3, start)", exceptionState)); |
| + EXPECT_TRUE(timingFunctionRoundTrips("steps(3, middle)", exceptionState)); |
| + EXPECT_TRUE(timingFunctionRoundTrips("steps(3, end)", exceptionState)); |
| + EXPECT_TRUE(timingFunctionRoundTrips("cubic-bezier(0.1, 5, 0.23, 0)", exceptionState)); |
| + |
| + EXPECT_EQ("steps(3, end)", AnimationInputHelpers::parseTimingFunction("steps(3)", exceptionState)->toString()); |
| + |
| + timingFunctionThrows("steps(3, nowhere)", exceptionState); |
| + timingFunctionThrows("steps(-3, end)", exceptionState); |
| + timingFunctionThrows("cubic-bezier(0.1, 0, 4, 0.4)", exceptionState); |
| } |
| } // namespace blink |