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/LegacyStyleInterpolation.h" |
| 7 |
| 8 #include "core/css/CSSInheritedValue.h" |
| 9 #include "core/css/CSSPrimitiveValue.h" |
| 10 #include "core/css/StylePropertySet.h" |
| 11 |
| 12 #include <gtest/gtest.h> |
| 13 |
| 14 namespace WebCore { |
| 15 |
| 16 bool testValue(CSSValue& value) |
| 17 { |
| 18 return LegacyStyleInterpolation::interpolationRequiresStyleResolve(value); |
| 19 } |
| 20 |
| 21 bool testValue(CSSPropertyID id, const char* string) |
| 22 { |
| 23 RefPtrWillBeRawPtr<MutableStylePropertySet> propertySet = MutableStyleProper
tySet::create(); |
| 24 propertySet->setProperty(id, string); |
| 25 return testValue(*propertySet->getPropertyCSSValue(id)); |
| 26 } |
| 27 |
| 28 TEST(AnimationLegacyStyleInterpolationTest, Inherit) |
| 29 { |
| 30 EXPECT_TRUE(testValue(*CSSInheritedValue::create())); |
| 31 } |
| 32 |
| 33 TEST(AnimationLegacyStyleInterpolationTest, FontUnits) |
| 34 { |
| 35 EXPECT_TRUE(testValue(CSSPropertyLeft, "2em")); |
| 36 EXPECT_TRUE(testValue(CSSPropertyLeft, "2ex")); |
| 37 EXPECT_TRUE(testValue(CSSPropertyLeft, "2rem")); |
| 38 EXPECT_TRUE(testValue(CSSPropertyLeft, "2ch")); |
| 39 } |
| 40 |
| 41 TEST(AnimationLegacyStyleInterpolationTest, ViewportUnits) |
| 42 { |
| 43 EXPECT_TRUE(testValue(CSSPropertyLeft, "2vw")); |
| 44 EXPECT_TRUE(testValue(CSSPropertyLeft, "2vh")); |
| 45 EXPECT_TRUE(testValue(CSSPropertyLeft, "2vmin")); |
| 46 EXPECT_TRUE(testValue(CSSPropertyLeft, "2vmax")); |
| 47 } |
| 48 |
| 49 TEST(AnimationLegacyStyleInterpolationTest, FixedUnits) |
| 50 { |
| 51 EXPECT_FALSE(testValue(CSSPropertyZIndex, "2")); |
| 52 EXPECT_FALSE(testValue(CSSPropertyLeft, "2px")); |
| 53 EXPECT_FALSE(testValue(CSSPropertyLeft, "2cm")); |
| 54 EXPECT_FALSE(testValue(CSSPropertyLeft, "2in")); |
| 55 |
| 56 RefPtrWillBeRawPtr<CSSPrimitiveValue> rotation = CSSPrimitiveValue::create(2
, CSSPrimitiveValue::CSS_DEG); |
| 57 EXPECT_FALSE(testValue(*rotation)); |
| 58 } |
| 59 |
| 60 TEST(AnimationLegacyStyleInterpolationTest, Calc) |
| 61 { |
| 62 EXPECT_FALSE(testValue(CSSPropertyLeft, "calc(5px + 30%%)")); |
| 63 EXPECT_TRUE(testValue(CSSPropertyLeft, "calc(5px + 30em)")); |
| 64 EXPECT_FALSE(testValue(CSSPropertyLeft, "calc(2 * 5px - 10%% + (4 * 20in) /
6)")); |
| 65 EXPECT_TRUE(testValue(CSSPropertyLeft, "calc(2 * 5px - 10%% + (4 * 20vw) / 6
)")); |
| 66 } |
| 67 |
| 68 TEST(AnimationLegacyStyleInterpolationTest, Percent) |
| 69 { |
| 70 EXPECT_FALSE(testValue(CSSPropertyLeft, "2%%")); |
| 71 } |
| 72 |
| 73 TEST(AnimationLegacyStyleInterpolationTest, Color) |
| 74 { |
| 75 EXPECT_FALSE(testValue(CSSPropertyColor, "red")); |
| 76 EXPECT_FALSE(testValue(CSSPropertyColor, "rgb(1, 2, 3)")); |
| 77 EXPECT_TRUE(testValue(CSSPropertyColor, "currentcolor")); |
| 78 } |
| 79 |
| 80 TEST(AnimationLegacyStyleInterpolationTest, FontWeight) |
| 81 { |
| 82 EXPECT_FALSE(testValue(CSSPropertyFontWeight, "400")); |
| 83 EXPECT_FALSE(testValue(CSSPropertyFontWeight, "bold")); |
| 84 EXPECT_TRUE(testValue(CSSPropertyFontWeight, "lighter")); |
| 85 } |
| 86 |
| 87 } |
OLD | NEW |