| Index: Source/core/animation/LegacyStyleInterpolationTest.cpp
|
| diff --git a/Source/core/animation/LegacyStyleInterpolationTest.cpp b/Source/core/animation/LegacyStyleInterpolationTest.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c21185d8c0b90527432bf3fbfce3ff53b266c56a
|
| --- /dev/null
|
| +++ b/Source/core/animation/LegacyStyleInterpolationTest.cpp
|
| @@ -0,0 +1,87 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "config.h"
|
| +#include "core/animation/LegacyStyleInterpolation.h"
|
| +
|
| +#include "core/css/CSSInheritedValue.h"
|
| +#include "core/css/CSSPrimitiveValue.h"
|
| +#include "core/css/StylePropertySet.h"
|
| +
|
| +#include <gtest/gtest.h>
|
| +
|
| +namespace WebCore {
|
| +
|
| +bool testValue(CSSValue& value)
|
| +{
|
| + return LegacyStyleInterpolation::interpolationRequiresStyleResolve(value);
|
| +}
|
| +
|
| +bool testValue(CSSPropertyID id, const char* string)
|
| +{
|
| + RefPtrWillBeRawPtr<MutableStylePropertySet> propertySet = MutableStylePropertySet::create();
|
| + propertySet->setProperty(id, string);
|
| + return testValue(*propertySet->getPropertyCSSValue(id));
|
| +}
|
| +
|
| +TEST(AnimationLegacyStyleInterpolationTest, Inherit)
|
| +{
|
| + EXPECT_TRUE(testValue(*CSSInheritedValue::create()));
|
| +}
|
| +
|
| +TEST(AnimationLegacyStyleInterpolationTest, FontUnits)
|
| +{
|
| + EXPECT_TRUE(testValue(CSSPropertyLeft, "2em"));
|
| + EXPECT_TRUE(testValue(CSSPropertyLeft, "2ex"));
|
| + EXPECT_TRUE(testValue(CSSPropertyLeft, "2rem"));
|
| + EXPECT_TRUE(testValue(CSSPropertyLeft, "2ch"));
|
| +}
|
| +
|
| +TEST(AnimationLegacyStyleInterpolationTest, ViewportUnits)
|
| +{
|
| + EXPECT_TRUE(testValue(CSSPropertyLeft, "2vw"));
|
| + EXPECT_TRUE(testValue(CSSPropertyLeft, "2vh"));
|
| + EXPECT_TRUE(testValue(CSSPropertyLeft, "2vmin"));
|
| + EXPECT_TRUE(testValue(CSSPropertyLeft, "2vmax"));
|
| +}
|
| +
|
| +TEST(AnimationLegacyStyleInterpolationTest, FixedUnits)
|
| +{
|
| + EXPECT_FALSE(testValue(CSSPropertyZIndex, "2"));
|
| + EXPECT_FALSE(testValue(CSSPropertyLeft, "2px"));
|
| + EXPECT_FALSE(testValue(CSSPropertyLeft, "2cm"));
|
| + EXPECT_FALSE(testValue(CSSPropertyLeft, "2in"));
|
| +
|
| + RefPtrWillBeRawPtr<CSSPrimitiveValue> rotation = CSSPrimitiveValue::create(2, CSSPrimitiveValue::CSS_DEG);
|
| + EXPECT_FALSE(testValue(*rotation));
|
| +}
|
| +
|
| +TEST(AnimationLegacyStyleInterpolationTest, Calc)
|
| +{
|
| + EXPECT_FALSE(testValue(CSSPropertyLeft, "calc(5px + 30%%)"));
|
| + EXPECT_TRUE(testValue(CSSPropertyLeft, "calc(5px + 30em)"));
|
| + EXPECT_FALSE(testValue(CSSPropertyLeft, "calc(2 * 5px - 10%% + (4 * 20in) / 6)"));
|
| + EXPECT_TRUE(testValue(CSSPropertyLeft, "calc(2 * 5px - 10%% + (4 * 20vw) / 6)"));
|
| +}
|
| +
|
| +TEST(AnimationLegacyStyleInterpolationTest, Percent)
|
| +{
|
| + EXPECT_FALSE(testValue(CSSPropertyLeft, "2%%"));
|
| +}
|
| +
|
| +TEST(AnimationLegacyStyleInterpolationTest, Color)
|
| +{
|
| + EXPECT_FALSE(testValue(CSSPropertyColor, "red"));
|
| + EXPECT_FALSE(testValue(CSSPropertyColor, "rgb(1, 2, 3)"));
|
| + EXPECT_TRUE(testValue(CSSPropertyColor, "currentcolor"));
|
| +}
|
| +
|
| +TEST(AnimationLegacyStyleInterpolationTest, FontWeight)
|
| +{
|
| + EXPECT_FALSE(testValue(CSSPropertyFontWeight, "400"));
|
| + EXPECT_FALSE(testValue(CSSPropertyFontWeight, "bold"));
|
| + EXPECT_TRUE(testValue(CSSPropertyFontWeight, "lighter"));
|
| +}
|
| +
|
| +}
|
|
|