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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
OLDNEW
« 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