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