1// Copyright 2014 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "config.h" 6#include "core/animation/AnimationInputHelpers.h" 7 8#include "platform/animation/TimingFunction.h" 9 10#include <gtest/gtest.h> 11 12namespace blink { 13 14TEST(AnimationAnimationInputHelpersTest, ParseKeyframePropertyAttributes) 15{ 16 EXPECT_EQ(CSSPropertyLineHeight, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("line-height"))); 17 EXPECT_EQ(CSSPropertyLineHeight, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("lineHeight"))); 18 EXPECT_EQ(CSSPropertyBorderTopWidth, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("borderTopWidth"))); 19 EXPECT_EQ(CSSPropertyBorderTopWidth, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("border-topWidth"))); 20 EXPECT_EQ(CSSPropertyWidth, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("width"))); 21 EXPECT_EQ(CSSPropertyFloat, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("float"))); 22 EXPECT_EQ(CSSPropertyFloat, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("cssFloat"))); 23 24 EXPECT_EQ(CSSPropertyInvalid, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("Width"))); 25 EXPECT_EQ(CSSPropertyInvalid, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("-epub-text-transform"))); 26 EXPECT_EQ(CSSPropertyInvalid, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("EpubTextTransform"))); 27 EXPECT_EQ(CSSPropertyInvalid, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("-internal-marquee-repetition"))); 28 EXPECT_EQ(CSSPropertyInvalid, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("InternalMarqueeRepetition"))); 29 EXPECT_EQ(CSSPropertyInvalid, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("-webkit-filter"))); 30 EXPECT_EQ(CSSPropertyInvalid, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("-webkit-transform"))); 31 EXPECT_EQ(CSSPropertyInvalid, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("webkitTransform"))); 32 EXPECT_EQ(CSSPropertyInvalid, AnimationInputHelpers::keyframeAttributeToCSSPropertyID(String("WebkitTransform"))); 33} 34 35static bool timingFunctionRoundTrips(const String& string) 36{ 37 RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::parseTimingFunction(string); 38 return timingFunction && string == timingFunction->toString(); 39} 40 41TEST(AnimationAnimationInputHelpersTest, ParseAnimationTimingFunction) 42{ 43 EXPECT_TRUE(timingFunctionRoundTrips("ease")); 44 EXPECT_TRUE(timingFunctionRoundTrips("linear")); 45 EXPECT_TRUE(timingFunctionRoundTrips("ease-in")); 46 EXPECT_TRUE(timingFunctionRoundTrips("ease-out")); 47 EXPECT_TRUE(timingFunctionRoundTrips("ease-in-out")); 48 EXPECT_TRUE(timingFunctionRoundTrips("step-start")); 49 EXPECT_TRUE(timingFunctionRoundTrips("step-middle")); 50 EXPECT_TRUE(timingFunctionRoundTrips("step-end")); 51 EXPECT_TRUE(timingFunctionRoundTrips("steps(3, start)")); 52 EXPECT_TRUE(timingFunctionRoundTrips("steps(3, middle)")); 53 EXPECT_TRUE(timingFunctionRoundTrips("steps(3, end)")); 54 EXPECT_TRUE(timingFunctionRoundTrips("cubic-bezier(0.1, 5, 0.23, 0)")); 55 56 EXPECT_EQ("steps(3, end)", AnimationInputHelpers::parseTimingFunction("steps(3)")->toString()); 57 58 EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("steps(3, nowhere)")); 59 EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("steps(-3, end)")); 60 EXPECT_EQ(nullptr, AnimationInputHelpers::parseTimingFunction("cubic-bezier(0.1, 0, 4, 0.4)")); 61} 62 63} // namespace blink 64