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

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

Issue 1303173007: Oilpan: Unship Oilpan from CSSValues 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 PassOwnPtrWillBeRawPtr<InterpolableValue> lengthToInterpolableValue(c onst CSSValue& 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 PassRefPtr<CSSValue> interpolableValueToLength(InterpolableValue* val ue, 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 PassRefPtr<CSSValue> roundTrip(PassRefPtr<CSSValue> 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 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)
33 { 33 {
34 OwnPtrWillBeRawPtr<InterpolableList> list = InterpolableList::create(10) ; 34 OwnPtrWillBeRawPtr<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));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 EXPECT_EQ((EXPECTED_DOUBLE_VALUE), toCSSPrimitiveValue((ACTUAL_VALUE).get()) ->getDoubleValue()); \ 69 EXPECT_EQ((EXPECTED_DOUBLE_VALUE), toCSSPrimitiveValue((ACTUAL_VALUE).get()) ->getDoubleValue()); \
70 EXPECT_EQ((EXPECTED_UNIT_TYPE), toCSSPrimitiveValue((ACTUAL_VALUE).get())->t ypeWithCalcResolved()); 70 EXPECT_EQ((EXPECTED_UNIT_TYPE), toCSSPrimitiveValue((ACTUAL_VALUE).get())->t ypeWithCalcResolved());
71 71
72 #define EXPECT_CSS_LENGTH_ARRAY_ELEMENTS_EQUAL(EXPECTED, ACTUAL) \ 72 #define EXPECT_CSS_LENGTH_ARRAY_ELEMENTS_EQUAL(EXPECTED, ACTUAL) \
73 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i) { \ 73 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i) { \
74 EXPECT_EQ((EXPECTED).at(i), (ACTUAL).at(i)); \ 74 EXPECT_EQ((EXPECTED).at(i), (ACTUAL).at(i)); \
75 } 75 }
76 76
77 TEST_F(AnimationLengthStyleInterpolationTest, ZeroLength) 77 TEST_F(AnimationLengthStyleInterpolationTest, ZeroLength)
78 { 78 {
79 RefPtrWillBeRawPtr<CSSValue> value1 = roundTrip(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pixels)); 79 RefPtr<CSSValue> value1 = roundTrip(CSSPrimitiveValue::create(0, CSSPrimitiv eValue::UnitType::Pixels));
80 TEST_PRIMITIVE_VALUE(value1, 0, CSSPrimitiveValue::UnitType::Pixels); 80 TEST_PRIMITIVE_VALUE(value1, 0, CSSPrimitiveValue::UnitType::Pixels);
81 81
82 RefPtrWillBeRawPtr<CSSValue> value2 = roundTrip(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Percentage)); 82 RefPtr<CSSValue> value2 = roundTrip(CSSPrimitiveValue::create(0, CSSPrimitiv eValue::UnitType::Percentage));
83 TEST_PRIMITIVE_VALUE(value2, 0, CSSPrimitiveValue::UnitType::Percentage); 83 TEST_PRIMITIVE_VALUE(value2, 0, CSSPrimitiveValue::UnitType::Percentage);
84 84
85 RefPtrWillBeRawPtr<CSSValue> value3 = roundTrip(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Ems)); 85 RefPtr<CSSValue> value3 = roundTrip(CSSPrimitiveValue::create(0, CSSPrimitiv eValue::UnitType::Ems));
86 TEST_PRIMITIVE_VALUE(value3, 0, CSSPrimitiveValue::UnitType::Ems); 86 TEST_PRIMITIVE_VALUE(value3, 0, CSSPrimitiveValue::UnitType::Ems);
87 } 87 }
88 88
89 TEST_F(AnimationLengthStyleInterpolationTest, SingleUnit) 89 TEST_F(AnimationLengthStyleInterpolationTest, SingleUnit)
90 { 90 {
91 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType::Pixels)); 91 RefPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(10, CSSPrimitiv eValue::UnitType::Pixels));
92 TEST_PRIMITIVE_VALUE(value, 10, CSSPrimitiveValue::UnitType::Pixels); 92 TEST_PRIMITIVE_VALUE(value, 10, CSSPrimitiveValue::UnitType::Pixels);
93 93
94 value = roundTrip(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType: :Percentage)); 94 value = roundTrip(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType: :Percentage));
95 TEST_PRIMITIVE_VALUE(value, 30, CSSPrimitiveValue::UnitType::Percentage); 95 TEST_PRIMITIVE_VALUE(value, 30, CSSPrimitiveValue::UnitType::Percentage);
96 96
97 value = roundTrip(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType: :Ems)); 97 value = roundTrip(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType: :Ems));
98 TEST_PRIMITIVE_VALUE(value, 10, CSSPrimitiveValue::UnitType::Ems); 98 TEST_PRIMITIVE_VALUE(value, 10, CSSPrimitiveValue::UnitType::Ems);
99 } 99 }
100 100
101 TEST_F(AnimationLengthStyleInterpolationTest, SingleClampedUnit) 101 TEST_F(AnimationLengthStyleInterpolationTest, SingleClampedUnit)
102 { 102 {
103 RefPtrWillBeRawPtr<CSSValue> value1 = CSSPrimitiveValue::create(-10, CSSPrim itiveValue::UnitType::Pixels); 103 RefPtr<CSSValue> value1 = CSSPrimitiveValue::create(-10, CSSPrimitiveValue:: UnitType::Pixels);
104 value1 = interpolableValueToLength(lengthToInterpolableValue(*value1).get(), RangeNonNegative); 104 value1 = interpolableValueToLength(lengthToInterpolableValue(*value1).get(), RangeNonNegative);
105 TEST_PRIMITIVE_VALUE(value1, 0, CSSPrimitiveValue::UnitType::Pixels); 105 TEST_PRIMITIVE_VALUE(value1, 0, CSSPrimitiveValue::UnitType::Pixels);
106 106
107 RefPtrWillBeRawPtr<CSSValue> value2 = CSSPrimitiveValue::create(-10, CSSPrim itiveValue::UnitType::Ems); 107 RefPtr<CSSValue> value2 = CSSPrimitiveValue::create(-10, CSSPrimitiveValue:: 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 OwnPtrWillBeRawPtr<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));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 initLengthArray(expectation); 163 initLengthArray(expectation);
164 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(2); 164 OwnPtrWillBeRawPtr<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
« no previous file with comments | « Source/core/animation/LengthStyleInterpolation.cpp ('k') | Source/core/animation/ListStyleInterpolation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698