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

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

Issue 1276183004: Oilpan: Unship oilpan from temporary animation objects (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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
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/LengthStyleInterpolation.h" 6 #include "core/animation/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 blink { 13 namespace blink {
14 14
15 class AnimationLengthStyleInterpolationTest : public ::testing::Test { 15 class AnimationLengthStyleInterpolationTest : public ::testing::Test {
16 protected: 16 protected:
17 static PassOwnPtrWillBeRawPtr<InterpolableValue> lengthToInterpolableValue(c onst CSSValue& value) 17 static PassOwnPtr<InterpolableValue> lengthToInterpolableValue(const CSSValu e& value)
18 { 18 {
19 return LengthStyleInterpolation::toInterpolableValue(value); 19 return LengthStyleInterpolation::toInterpolableValue(value);
20 } 20 }
21 21
22 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToLength(Interpolab leValue* value, InterpolationRange range) 22 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToLength(Interpolab leValue* value, InterpolationRange range)
23 { 23 {
24 return LengthStyleInterpolation::fromInterpolableValue(*value, range); 24 return LengthStyleInterpolation::fromInterpolableValue(*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() , RangeAll); 29 return interpolableValueToLength(lengthToInterpolableValue(*value).get() , RangeAll);
30 } 30 }
31 31
32 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) 32 static PassOwnPtr<InterpolableList> createInterpolableLength(double a, doubl e b, double c, double d, double e, double f, double g, double h, double i, doubl e j)
33 { 33 {
34 OwnPtrWillBeRawPtr<InterpolableList> list = InterpolableList::create(10) ; 34 OwnPtr<InterpolableList> list = InterpolableList::create(10);
35 list->set(0, InterpolableNumber::create(a)); 35 list->set(0, InterpolableNumber::create(a));
36 list->set(1, InterpolableNumber::create(b)); 36 list->set(1, InterpolableNumber::create(b));
37 list->set(2, InterpolableNumber::create(c)); 37 list->set(2, InterpolableNumber::create(c));
38 list->set(3, InterpolableNumber::create(d)); 38 list->set(3, InterpolableNumber::create(d));
39 list->set(4, InterpolableNumber::create(e)); 39 list->set(4, InterpolableNumber::create(e));
40 list->set(5, InterpolableNumber::create(f)); 40 list->set(5, InterpolableNumber::create(f));
41 list->set(6, InterpolableNumber::create(g)); 41 list->set(6, InterpolableNumber::create(g));
42 list->set(7, InterpolableNumber::create(h)); 42 list->set(7, InterpolableNumber::create(h));
43 list->set(8, InterpolableNumber::create(i)); 43 list->set(8, InterpolableNumber::create(i));
44 list->set(9, InterpolableNumber::create(j)); 44 list->set(9, InterpolableNumber::create(j));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 RefPtrWillBeRawPtr<CSSValue> value2 = CSSPrimitiveValue::create(-10, CSSPrim itiveValue::UnitType::Ems); 107 RefPtrWillBeRawPtr<CSSValue> value2 = CSSPrimitiveValue::create(-10, CSSPrim itiveValue::UnitType::Ems);
108 value2 = interpolableValueToLength(lengthToInterpolableValue(*value2).get(), RangeNonNegative); 108 value2 = interpolableValueToLength(lengthToInterpolableValue(*value2).get(), RangeNonNegative);
109 TEST_PRIMITIVE_VALUE(value2, 0, CSSPrimitiveValue::UnitType::Ems); 109 TEST_PRIMITIVE_VALUE(value2, 0, CSSPrimitiveValue::UnitType::Ems);
110 } 110 }
111 111
112 TEST_F(AnimationLengthStyleInterpolationTest, MultipleUnits) 112 TEST_F(AnimationLengthStyleInterpolationTest, MultipleUnits)
113 { 113 {
114 CSSLengthArray expectation, actual; 114 CSSLengthArray expectation, actual;
115 initLengthArray(expectation); 115 initLengthArray(expectation);
116 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(2); 116 OwnPtr<InterpolableList> result = InterpolableList::create(2);
117 result->set(0, createInterpolableLength(0, 10, 0, 10, 0, 10, 0, 10, 0, 10)); 117 result->set(0, createInterpolableLength(0, 10, 0, 10, 0, 10, 0, 10, 0, 10));
118 result->set(1, createInterpolableLength(0, 1, 0, 1, 0, 1, 0, 1, 0, 1)); 118 result->set(1, createInterpolableLength(0, 1, 0, 1, 0, 1, 0, 1, 0, 1));
119 toCSSPrimitiveValue(interpolableValueToLength(result.get(), RangeAll).get()) ->accumulateLengthArray(expectation); 119 toCSSPrimitiveValue(interpolableValueToLength(result.get(), RangeAll).get()) ->accumulateLengthArray(expectation);
120 setLengthArray(actual, "calc(10% + 10ex + 10ch + 10vh + 10vmax)"); 120 setLengthArray(actual, "calc(10% + 10ex + 10ch + 10vh + 10vmax)");
121 EXPECT_CSS_LENGTH_ARRAY_ELEMENTS_EQUAL(expectation, actual); 121 EXPECT_CSS_LENGTH_ARRAY_ELEMENTS_EQUAL(expectation, actual);
122 } 122 }
123 123
124 TEST_F(AnimationLengthStyleInterpolationTest, MultipleUnitsWithSingleValues) 124 TEST_F(AnimationLengthStyleInterpolationTest, MultipleUnitsWithSingleValues)
125 { 125 {
126 CSSLengthArray expectation, actual; 126 CSSLengthArray expectation, actual;
127 initLengthArray(expectation); 127 initLengthArray(expectation);
128 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(2); 128 OwnPtr<InterpolableList> result = InterpolableList::create(2);
129 result->set(0, createInterpolableLength(0, 10, 0, 10, 0, 10, 0, 10, 0, 10)); 129 result->set(0, createInterpolableLength(0, 10, 0, 10, 0, 10, 0, 10, 0, 10));
130 result->set(1, createInterpolableLength(0, 1, 0, 1, 0, 1, 0, 1, 0, 1)); 130 result->set(1, createInterpolableLength(0, 1, 0, 1, 0, 1, 0, 1, 0, 1));
131 toCSSPrimitiveValue(interpolableValueToLength(result.get(), RangeAll).get()) ->accumulateLengthArray(expectation); 131 toCSSPrimitiveValue(interpolableValueToLength(result.get(), RangeAll).get()) ->accumulateLengthArray(expectation);
132 setLengthArray(actual, "calc(10% + 10ex + 10ch + 10vh + 10vmax)"); 132 setLengthArray(actual, "calc(10% + 10ex + 10ch + 10vh + 10vmax)");
133 EXPECT_CSS_LENGTH_ARRAY_ELEMENTS_EQUAL(expectation, actual); 133 EXPECT_CSS_LENGTH_ARRAY_ELEMENTS_EQUAL(expectation, actual);
134 } 134 }
135 135
136 TEST_F(AnimationLengthStyleInterpolationTest, MultipleUnitsWithMultipleValues) 136 TEST_F(AnimationLengthStyleInterpolationTest, MultipleUnitsWithMultipleValues)
137 { 137 {
138 CSSLengthArray expectation, actual; 138 CSSLengthArray expectation, actual;
139 initLengthArray(expectation); 139 initLengthArray(expectation);
140 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(2); 140 OwnPtr<InterpolableList> result = InterpolableList::create(2);
141 result->set(0, createInterpolableLength(0, 20, 0, 30, 0, 8, 0, 10, 0, 7)); 141 result->set(0, createInterpolableLength(0, 20, 0, 30, 0, 8, 0, 10, 0, 7));
142 result->set(1, createInterpolableLength(0, 1, 0, 1, 0, 1, 0, 1, 0, 1)); 142 result->set(1, createInterpolableLength(0, 1, 0, 1, 0, 1, 0, 1, 0, 1));
143 toCSSPrimitiveValue(interpolableValueToLength(result.get(), RangeAll).get()) ->accumulateLengthArray(expectation); 143 toCSSPrimitiveValue(interpolableValueToLength(result.get(), RangeAll).get()) ->accumulateLengthArray(expectation);
144 setLengthArray(actual, "calc(20% + 30ex + 8ch + 10vh + 7vmax)"); 144 setLengthArray(actual, "calc(20% + 30ex + 8ch + 10vh + 7vmax)");
145 EXPECT_CSS_LENGTH_ARRAY_ELEMENTS_EQUAL(expectation, actual); 145 EXPECT_CSS_LENGTH_ARRAY_ELEMENTS_EQUAL(expectation, actual);
146 } 146 }
147 147
148 TEST_F(AnimationLengthStyleInterpolationTest, MultipleUnitsWithZeroValue) 148 TEST_F(AnimationLengthStyleInterpolationTest, MultipleUnitsWithZeroValue)
149 { 149 {
150 CSSLengthArray expectation, actual; 150 CSSLengthArray expectation, actual;
151 initLengthArray(expectation); 151 initLengthArray(expectation);
152 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(2); 152 OwnPtr<InterpolableList> result = InterpolableList::create(2);
153 result->set(0, createInterpolableLength(0, 10, 0, 10, 0, 10, 0, 10, 0, 10)); 153 result->set(0, createInterpolableLength(0, 10, 0, 10, 0, 10, 0, 10, 0, 10));
154 result->set(1, createInterpolableLength(1, 1, 0, 1, 0, 1, 0, 1, 0, 1)); 154 result->set(1, createInterpolableLength(1, 1, 0, 1, 0, 1, 0, 1, 0, 1));
155 toCSSPrimitiveValue(interpolableValueToLength(result.get(), RangeAll).get()) ->accumulateLengthArray(expectation); 155 toCSSPrimitiveValue(interpolableValueToLength(result.get(), RangeAll).get()) ->accumulateLengthArray(expectation);
156 setLengthArray(actual, "calc(0px + 10% + 10ex + 10ch + 10vh + 10vmax)"); 156 setLengthArray(actual, "calc(0px + 10% + 10ex + 10ch + 10vh + 10vmax)");
157 EXPECT_CSS_LENGTH_ARRAY_ELEMENTS_EQUAL(expectation, actual); 157 EXPECT_CSS_LENGTH_ARRAY_ELEMENTS_EQUAL(expectation, actual);
158 } 158 }
159 159
160 TEST_F(AnimationLengthStyleInterpolationTest, MultipleUnitsWithZeroValues) 160 TEST_F(AnimationLengthStyleInterpolationTest, MultipleUnitsWithZeroValues)
161 { 161 {
162 CSSLengthArray expectation, actual; 162 CSSLengthArray expectation, actual;
163 initLengthArray(expectation); 163 initLengthArray(expectation);
164 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(2); 164 OwnPtr<InterpolableList> result = InterpolableList::create(2);
165 result->set(0, createInterpolableLength(0, 10, 0, 10, 0, 10, 0, 10, 0, 10)); 165 result->set(0, createInterpolableLength(0, 10, 0, 10, 0, 10, 0, 10, 0, 10));
166 result->set(1, createInterpolableLength(1, 1, 1, 1, 0, 1, 0, 1, 1, 1)); 166 result->set(1, createInterpolableLength(1, 1, 1, 1, 0, 1, 0, 1, 1, 1));
167 toCSSPrimitiveValue(interpolableValueToLength(result.get(), RangeAll).get()) ->accumulateLengthArray(expectation); 167 toCSSPrimitiveValue(interpolableValueToLength(result.get(), RangeAll).get()) ->accumulateLengthArray(expectation);
168 setLengthArray(actual, "calc(0px + 10% + 0em + 10ex + 10ch + 10vh + 0vmin + 10vmax)"); 168 setLengthArray(actual, "calc(0px + 10% + 0em + 10ex + 10ch + 10vh + 0vmin + 10vmax)");
169 EXPECT_CSS_LENGTH_ARRAY_ELEMENTS_EQUAL(expectation, actual); 169 EXPECT_CSS_LENGTH_ARRAY_ELEMENTS_EQUAL(expectation, actual);
170 } 170 }
171 171
172 } 172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698