| 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 "core/animation/DeferredLegacyStyleInterpolation.h" | |
| 6 | |
| 7 #include "core/css/CSSInheritedValue.h" | |
| 8 #include "core/css/CSSPrimitiveValue.h" | |
| 9 #include "core/css/CSSValueList.h" | |
| 10 #include "core/css/StylePropertySet.h" | |
| 11 #include "core/css/parser/CSSParser.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 class AnimationDeferredLegacyStyleInterpolationTest : public ::testing::Test { | |
| 17 protected: | |
| 18 static bool test(CSSPropertyID propertyID, const String& string) | |
| 19 { | |
| 20 CSSParserMode parserMode = HTMLStandardMode; | |
| 21 if (propertyID == CSSPropertyFloodColor) | |
| 22 parserMode = SVGAttributeMode; | |
| 23 CSSValue* value = CSSParser::parseSingleValue(propertyID, string, CSSPar
serContext(parserMode, nullptr)); | |
| 24 ASSERT(value); | |
| 25 return DeferredLegacyStyleInterpolation::interpolationRequiresStyleResol
ve(*value); | |
| 26 } | |
| 27 }; | |
| 28 | |
| 29 TEST_F(AnimationDeferredLegacyStyleInterpolationTest, Inherit) | |
| 30 { | |
| 31 EXPECT_TRUE(test(CSSPropertyCaptionSide, "inherit")); | |
| 32 } | |
| 33 | |
| 34 TEST_F(AnimationDeferredLegacyStyleInterpolationTest, Color) | |
| 35 { | |
| 36 EXPECT_FALSE(test(CSSPropertyColor, "rgb(10, 20, 30)")); | |
| 37 EXPECT_FALSE(test(CSSPropertyColor, "aqua")); | |
| 38 EXPECT_FALSE(test(CSSPropertyColor, "yellow")); | |
| 39 EXPECT_FALSE(test(CSSPropertyColor, "transparent")); | |
| 40 EXPECT_FALSE(test(CSSPropertyFloodColor, "aliceblue")); | |
| 41 EXPECT_FALSE(test(CSSPropertyFloodColor, "yellowgreen")); | |
| 42 EXPECT_FALSE(test(CSSPropertyFloodColor, "grey")); | |
| 43 EXPECT_TRUE(test(CSSPropertyColor, "currentcolor")); | |
| 44 } | |
| 45 | |
| 46 TEST_F(AnimationDeferredLegacyStyleInterpolationTest, Relative) | |
| 47 { | |
| 48 EXPECT_TRUE(test(CSSPropertyFontWeight, "bolder")); | |
| 49 EXPECT_TRUE(test(CSSPropertyFontWeight, "lighter")); | |
| 50 EXPECT_TRUE(test(CSSPropertyFontSize, "smaller")); | |
| 51 EXPECT_TRUE(test(CSSPropertyFontSize, "larger")); | |
| 52 } | |
| 53 | |
| 54 TEST_F(AnimationDeferredLegacyStyleInterpolationTest, Length) | |
| 55 { | |
| 56 EXPECT_FALSE(test(CSSPropertyWidth, "10px")); | |
| 57 EXPECT_TRUE(test(CSSPropertyWidth, "10em")); | |
| 58 EXPECT_TRUE(test(CSSPropertyWidth, "10vh")); | |
| 59 } | |
| 60 | |
| 61 TEST_F(AnimationDeferredLegacyStyleInterpolationTest, Number) | |
| 62 { | |
| 63 EXPECT_FALSE(test(CSSPropertyOpacity, "0.5")); | |
| 64 } | |
| 65 | |
| 66 TEST_F(AnimationDeferredLegacyStyleInterpolationTest, Transform) | |
| 67 { | |
| 68 EXPECT_TRUE(test(CSSPropertyTransform, "translateX(1em)")); | |
| 69 EXPECT_FALSE(test(CSSPropertyTransform, "translateY(20px)")); | |
| 70 EXPECT_FALSE(test(CSSPropertyTransform, "skewX(10rad) perspective(400px)")); | |
| 71 EXPECT_TRUE(test(CSSPropertyTransform, "skewX(20rad) perspective(50em)")); | |
| 72 } | |
| 73 | |
| 74 TEST_F(AnimationDeferredLegacyStyleInterpolationTest, Filter) | |
| 75 { | |
| 76 EXPECT_FALSE(test(CSSPropertyFilter, "hue-rotate(180deg) blur(6px)")); | |
| 77 EXPECT_FALSE(test(CSSPropertyFilter, "grayscale(0) blur(0px)")); | |
| 78 EXPECT_FALSE(test(CSSPropertyFilter, "none")); | |
| 79 EXPECT_FALSE(test(CSSPropertyFilter, "brightness(0) contrast(0)")); | |
| 80 EXPECT_FALSE(test(CSSPropertyFilter, "drop-shadow(20px 10px green)")); | |
| 81 EXPECT_TRUE(test(CSSPropertyFilter, "drop-shadow(20px 10vw green)")); | |
| 82 EXPECT_TRUE(test(CSSPropertyFilter, "drop-shadow(0px 0px 0px currentcolor)")
); | |
| 83 EXPECT_FALSE(test(CSSPropertyFilter, "opacity(1)")); | |
| 84 EXPECT_FALSE(test(CSSPropertyFilter, "saturate(0)")); | |
| 85 EXPECT_FALSE(test(CSSPropertyFilter, "grayscale(1)")); | |
| 86 EXPECT_FALSE(test(CSSPropertyFilter, "invert(1)")); | |
| 87 EXPECT_FALSE(test(CSSPropertyFilter, "sepia(1)")); | |
| 88 EXPECT_TRUE(test(CSSPropertyFilter, "url(#svgfilter)")); | |
| 89 } | |
| 90 | |
| 91 TEST_F(AnimationDeferredLegacyStyleInterpolationTest, BackdropFilter) | |
| 92 { | |
| 93 EXPECT_FALSE(test(CSSPropertyBackdropFilter, "hue-rotate(180deg) blur(6px)")
); | |
| 94 EXPECT_FALSE(test(CSSPropertyBackdropFilter, "grayscale(0) blur(0px)")); | |
| 95 EXPECT_FALSE(test(CSSPropertyBackdropFilter, "none")); | |
| 96 EXPECT_FALSE(test(CSSPropertyBackdropFilter, "brightness(0) contrast(0)")); | |
| 97 EXPECT_FALSE(test(CSSPropertyBackdropFilter, "drop-shadow(20px 10px green)")
); | |
| 98 EXPECT_TRUE(test(CSSPropertyBackdropFilter, "drop-shadow(20px 10vw green)"))
; | |
| 99 EXPECT_TRUE(test(CSSPropertyBackdropFilter, "drop-shadow(0px 0px 0px current
color)")); | |
| 100 EXPECT_FALSE(test(CSSPropertyBackdropFilter, "opacity(1)")); | |
| 101 EXPECT_FALSE(test(CSSPropertyBackdropFilter, "saturate(0)")); | |
| 102 EXPECT_FALSE(test(CSSPropertyBackdropFilter, "grayscale(1)")); | |
| 103 EXPECT_FALSE(test(CSSPropertyBackdropFilter, "invert(1)")); | |
| 104 EXPECT_FALSE(test(CSSPropertyBackdropFilter, "sepia(1)")); | |
| 105 EXPECT_TRUE(test(CSSPropertyBackdropFilter, "url(#svgfilter)")); | |
| 106 } | |
| 107 } // namespace blink | |
| OLD | NEW |