Index: Source/core/animation/InterpolableValuePromiseTest.cpp |
diff --git a/Source/core/animation/InterpolableValuePromiseTest.cpp b/Source/core/animation/InterpolableValuePromiseTest.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b81079bff98f321d636434bf2310e51960ee022f |
--- /dev/null |
+++ b/Source/core/animation/InterpolableValuePromiseTest.cpp |
@@ -0,0 +1,88 @@ |
+// 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/InterpolableValuePromise.h" |
+ |
+#include "core/animation/AnimatableDouble.h" |
+#include "core/css/CSSInheritedValue.h" |
+#include "core/css/CSSPrimitiveValue.h" |
+#include "core/css/StylePropertySet.h" |
+ |
+#include <gtest/gtest.h> |
+ |
+namespace WebCore { |
+ |
+bool testValue(CSSPropertyID id, const char* string) |
+{ |
+ RefPtrWillBeRawPtr<MutableStylePropertySet> propertySet = MutableStylePropertySet::create(); |
+ propertySet->setProperty(id, string); |
+ testValue(*propertySet->getPropertyCSSValue(id)); |
+} |
+ |
+bool testValue(CSSValue& value) |
+{ |
+ return LegacyStyleInterpolation::interpolationRequiresStyleResolve(value) |
+} |
+ |
+TEST(AnimationInterpolableValuePromiseTest, LateBindingInherit) |
+{ |
+ EXPECT_TRUE(testValue(*CSSInheritedValue::create())); |
+} |
+ |
+TEST(AnimationInterpolableValuePromiseTest, LateBindingFontUnits) |
+{ |
+ EXPECT_TRUE(testValue(CSSPropertyLeft, "2em")); |
+ EXPECT_TRUE(testValue(CSSPropertyLeft, "2ex")); |
+ EXPECT_TRUE(testValue(CSSPropertyLeft, "2rem")); |
+ EXPECT_TRUE(testValue(CSSPropertyLeft, "2ch")); |
+} |
+ |
+TEST(AnimationInterpolableValuePromiseTest, LateBindingViewportUnits) |
+{ |
+ EXPECT_TRUE(testValue(CSSPropertyLeft, "2vw")); |
+ EXPECT_TRUE(testValue(CSSPropertyLeft, "2vh")); |
+ EXPECT_TRUE(testValue(CSSPropertyLeft, "2vmin")); |
+ EXPECT_TRUE(testValue(CSSPropertyLeft, "2vmax")); |
+} |
+ |
+TEST(AnimationInterpolableValuePromiseTest, 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(AnimationInterpolableValuePromiseTest, 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(AnimationInterpolableValuePromiseTest, Percent) |
+{ |
+ EXPECT_FALSE(testValue(CSSPropertyLeft, "2%%")); |
+} |
+ |
+TEST(AnimationInterpolableValuePromiseTest, Color) |
+{ |
+ EXPECT_FALSE(testValue(CSSPropertyColor, "red")); |
+ EXPECT_FALSE(testValue(CSSPropertyColor, "rgb(1, 2, 3)")); |
+ EXPECT_TRUE(testValue(CSSPropertyColor, "currentcolor")); |
+} |
+ |
+TEST(AnimationInterpolableValuePromiseTest, FontWeight) |
+{ |
+ EXPECT_FALSE(testValue(CSSPropertyFontWeight, "400")); |
+ EXPECT_FALSE(testValue(CSSPropertyFontWeight, "bold")); |
+ EXPECT_TRUE(testValue(CSSPropertyFontWeight, "lighter")); |
+} |
+ |
+} |