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

Side by Side Diff: Source/core/animation/interpolation/LengthStyleInterpolationTest.cpp

Issue 273903002: Web Animations API: Length properties responsive to style changes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase 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
« no previous file with comments | « Source/core/animation/interpolation/LengthStyleInterpolation.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/animation/interpolation/LengthStyleInterpolation.h" 6 #include "core/animation/interpolation/LengthStyleInterpolation.h"
7 7
8 #include "core/css/CSSPrimitiveValue.h" 8 #include "core/css/CSSPrimitiveValue.h"
9 #include "core/css/StylePropertySet.h" 9 #include "core/css/StylePropertySet.h"
10 10
11 #include <gtest/gtest.h> 11 #include <gtest/gtest.h>
12 12
13 namespace WebCore { 13 namespace WebCore {
14 14
15 class AnimationLengthStyleInterpolationTest : public ::testing::Test { 15 class AnimationLengthStyleInterpolationTest : public ::testing::Test {
16 protected: 16 protected:
17 static PassOwnPtrWillBeRawPtr<InterpolableValue> lengthToInterpolableValue(C SSValue* value) 17 static PassOwnPtrWillBeRawPtr<InterpolableValue> lengthToInterpolableValue(C SSValue* value)
18 { 18 {
19 return LengthStyleInterpolation::lengthToInterpolableValue(value); 19 return LengthStyleInterpolation::lengthToInterpolableValue(value);
20 } 20 }
21 21
22 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToLength(Interpolab leValue* value) 22 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToLength(Interpolab leValue* value, ValueRange range)
23 { 23 {
24 return LengthStyleInterpolation::interpolableValueToLength(value); 24 return LengthStyleInterpolation::interpolableValueToLength(value, range) ;
25 } 25 }
26 26
27 static PassRefPtrWillBeRawPtr<CSSValue> roundTrip(PassRefPtrWillBeRawPtr<CSS Value> value) 27 static PassRefPtrWillBeRawPtr<CSSValue> roundTrip(PassRefPtrWillBeRawPtr<CSS Value> value)
28 { 28 {
29 return interpolableValueToLength(lengthToInterpolableValue(value.get()). get()); 29 return interpolableValueToLength(lengthToInterpolableValue(value.get()). get(), ValueRangeAll);
30 } 30 }
31 31
32 static void testPrimitiveValue(RefPtrWillBeRawPtr<CSSValue> value, double do ubleValue, CSSPrimitiveValue::UnitTypes unitType) 32 static void testPrimitiveValue(RefPtrWillBeRawPtr<CSSValue> value, double do ubleValue, CSSPrimitiveValue::UnitTypes unitType)
33 { 33 {
34 EXPECT_TRUE(value->isPrimitiveValue()); 34 EXPECT_TRUE(value->isPrimitiveValue());
35 EXPECT_EQ(doubleValue, toCSSPrimitiveValue(value.get())->getDoubleValue( )); 35 EXPECT_EQ(doubleValue, toCSSPrimitiveValue(value.get())->getDoubleValue( ));
36 EXPECT_EQ(unitType, toCSSPrimitiveValue(value.get())->primitiveType()); 36 EXPECT_EQ(unitType, toCSSPrimitiveValue(value.get())->primitiveType());
37 } 37 }
38 38
39 static PassOwnPtrWillBeRawPtr<InterpolableList> createInterpolableLength(dou ble a, double b, double c, double d, double e, double f, double g, double h, dou ble i, double j) 39 static PassOwnPtrWillBeRawPtr<InterpolableList> createInterpolableLength(dou ble a, double b, double c, double d, double e, double f, double g, double h, dou ble i, double j)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 testPrimitiveValue(value, 0, CSSPrimitiveValue::CSS_PX); 88 testPrimitiveValue(value, 0, CSSPrimitiveValue::CSS_PX);
89 } 89 }
90 90
91 TEST_F(AnimationLengthStyleInterpolationTest, SingleUnit) 91 TEST_F(AnimationLengthStyleInterpolationTest, SingleUnit)
92 { 92 {
93 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX)); 93 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX));
94 testPrimitiveValue(value, 10, CSSPrimitiveValue::CSS_PX); 94 testPrimitiveValue(value, 10, CSSPrimitiveValue::CSS_PX);
95 95
96 value = roundTrip(CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PERCE NTAGE)); 96 value = roundTrip(CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PERCE NTAGE));
97 testPrimitiveValue(value, 30, CSSPrimitiveValue::CSS_PERCENTAGE); 97 testPrimitiveValue(value, 30, CSSPrimitiveValue::CSS_PERCENTAGE);
98
99 value = roundTrip(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::CSS_EMS) );
100 testPrimitiveValue(value, -10, CSSPrimitiveValue::CSS_EMS);
101 }
102
103 TEST_F(AnimationLengthStyleInterpolationTest, SingleClampedUnit)
104 {
105 RefPtrWillBeRawPtr<CSSValue> value = CSSPrimitiveValue::create(-10, CSSPrimi tiveValue::CSS_EMS);
106 value = interpolableValueToLength(lengthToInterpolableValue(value.get()).get (), ValueRangeNonNegative);
107 testPrimitiveValue(value, 0, CSSPrimitiveValue::CSS_EMS);
98 } 108 }
99 109
100 TEST_F(AnimationLengthStyleInterpolationTest, MultipleUnits) 110 TEST_F(AnimationLengthStyleInterpolationTest, MultipleUnits)
101 { 111 {
102 CSSLengthArray actual, expectation; 112 CSSLengthArray actual, expectation;
103 initLengthArray(expectation); 113 initLengthArray(expectation);
104 OwnPtrWillBeRawPtr<InterpolableList> list = createInterpolableLength(0, 10, 0, 10, 0, 10, 0, 10, 0, 10); 114 OwnPtrWillBeRawPtr<InterpolableList> list = createInterpolableLength(0, 10, 0, 10, 0, 10, 0, 10, 0, 10);
105 toCSSPrimitiveValue(interpolableValueToLength(list.get()).get())->accumulate LengthArray(expectation); 115 toCSSPrimitiveValue(interpolableValueToLength(list.get(), ValueRangeAll).get ())->accumulateLengthArray(expectation);
106 EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, "calc(10%% + 10ex + 10ch + 10vh + 10vmax)"))); 116 EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, "calc(10%% + 10ex + 10ch + 10vh + 10vmax)")));
107 } 117 }
108 118
109 } 119 }
OLDNEW
« no previous file with comments | « Source/core/animation/interpolation/LengthStyleInterpolation.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698