| OLD | NEW |
| (Empty) |
| 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 "sky/engine/core/animation/DeferredLegacyStyleInterpolation.h" | |
| 6 | |
| 7 #include "sky/engine/core/css/CSSInheritedValue.h" | |
| 8 #include "sky/engine/core/css/CSSPrimitiveValue.h" | |
| 9 #include "sky/engine/core/css/CSSValueList.h" | |
| 10 #include "sky/engine/core/css/StylePropertySet.h" | |
| 11 #include "sky/engine/core/css/parser/BisonCSSParser.h" | |
| 12 | |
| 13 #include <gtest/gtest.h> | |
| 14 | |
| 15 namespace blink { | |
| 16 | |
| 17 class AnimationDeferredLegacyStyleInterpolationTest : public ::testing::Test { | |
| 18 protected: | |
| 19 static bool test(CSSPropertyID propertyID, const String& string) | |
| 20 { | |
| 21 CSSParserMode parserMode = HTMLStandardMode; | |
| 22 RefPtr<MutableStylePropertySet> dummyStyle = MutableStylePropertySet::cr
eate(); | |
| 23 bool parseSuccess = BisonCSSParser::parseValue(dummyStyle.get(), propert
yID, string, parserMode, 0); | |
| 24 ASSERT_UNUSED(parseSuccess, parseSuccess); | |
| 25 return DeferredLegacyStyleInterpolation::interpolationRequiresStyleResol
ve(*dummyStyle->getPropertyCSSValue(propertyID)); | |
| 26 } | |
| 27 }; | |
| 28 | |
| 29 TEST_F(AnimationDeferredLegacyStyleInterpolationTest, Color) | |
| 30 { | |
| 31 EXPECT_FALSE(test(CSSPropertyColor, "rgb(10, 20, 30)")); | |
| 32 EXPECT_FALSE(test(CSSPropertyColor, "aqua")); | |
| 33 EXPECT_FALSE(test(CSSPropertyColor, "yellow")); | |
| 34 EXPECT_FALSE(test(CSSPropertyColor, "transparent")); | |
| 35 EXPECT_TRUE(test(CSSPropertyColor, "currentcolor")); | |
| 36 } | |
| 37 | |
| 38 TEST_F(AnimationDeferredLegacyStyleInterpolationTest, Relative) | |
| 39 { | |
| 40 EXPECT_TRUE(test(CSSPropertyFontWeight, "bolder")); | |
| 41 EXPECT_TRUE(test(CSSPropertyFontWeight, "lighter")); | |
| 42 EXPECT_TRUE(test(CSSPropertyFontSize, "smaller")); | |
| 43 EXPECT_TRUE(test(CSSPropertyFontSize, "larger")); | |
| 44 } | |
| 45 | |
| 46 TEST_F(AnimationDeferredLegacyStyleInterpolationTest, Length) | |
| 47 { | |
| 48 EXPECT_FALSE(test(CSSPropertyWidth, "10px")); | |
| 49 EXPECT_TRUE(test(CSSPropertyWidth, "10em")); | |
| 50 EXPECT_TRUE(test(CSSPropertyWidth, "10vh")); | |
| 51 } | |
| 52 | |
| 53 TEST_F(AnimationDeferredLegacyStyleInterpolationTest, Number) | |
| 54 { | |
| 55 EXPECT_FALSE(test(CSSPropertyOpacity, "0.5")); | |
| 56 } | |
| 57 | |
| 58 TEST_F(AnimationDeferredLegacyStyleInterpolationTest, Transform) | |
| 59 { | |
| 60 EXPECT_TRUE(test(CSSPropertyTransform, "translateX(1em)")); | |
| 61 EXPECT_FALSE(test(CSSPropertyTransform, "translateY(20px)")); | |
| 62 EXPECT_FALSE(test(CSSPropertyTransform, "skewX(10rad) perspective(400px)")); | |
| 63 EXPECT_TRUE(test(CSSPropertyTransform, "skewX(20rad) perspective(50em)")); | |
| 64 } | |
| 65 | |
| 66 TEST_F(AnimationDeferredLegacyStyleInterpolationTest, Filter) | |
| 67 { | |
| 68 EXPECT_FALSE(test(CSSPropertyFilter, "hue-rotate(180deg) blur(6px)")); | |
| 69 EXPECT_FALSE(test(CSSPropertyFilter, "grayscale(0) blur(0px)")); | |
| 70 EXPECT_FALSE(test(CSSPropertyFilter, "none")); | |
| 71 EXPECT_FALSE(test(CSSPropertyFilter, "brightness(0) contrast(0)")); | |
| 72 EXPECT_FALSE(test(CSSPropertyFilter, "drop-shadow(20px 10px green)")); | |
| 73 EXPECT_TRUE(test(CSSPropertyFilter, "drop-shadow(20px 10vw green)")); | |
| 74 EXPECT_TRUE(test(CSSPropertyFilter, "drop-shadow(0px 0px 0px currentcolor)")
); | |
| 75 EXPECT_FALSE(test(CSSPropertyFilter, "opacity(1)")); | |
| 76 EXPECT_FALSE(test(CSSPropertyFilter, "saturate(0)")); | |
| 77 EXPECT_FALSE(test(CSSPropertyFilter, "grayscale(1)")); | |
| 78 EXPECT_FALSE(test(CSSPropertyFilter, "invert(1)")); | |
| 79 EXPECT_FALSE(test(CSSPropertyFilter, "sepia(1)")); | |
| 80 EXPECT_TRUE(test(CSSPropertyFilter, "url(#svgfilter)")); | |
| 81 } | |
| 82 | |
| 83 } | |
| OLD | NEW |