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