Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Unified Diff: Source/core/animation/LegacyStyleInterpolationTest.cpp

Issue 273683005: Web Animations API: Deferred computation of interpolated values (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add missing test file Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/animation/LegacyStyleInterpolation.cpp ('k') | Source/core/animation/StringKeyframe.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"));
+}
+
+}
« no previous file with comments | « Source/core/animation/LegacyStyleInterpolation.cpp ('k') | Source/core/animation/StringKeyframe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698