Chromium Code Reviews| Index: Source/core/css/CSSCalculationValueTest.cpp |
| diff --git a/Source/core/css/CSSCalculationValueTest.cpp b/Source/core/css/CSSCalculationValueTest.cpp |
| index 14476a8462b42e813fe1b57e5417b9b5338a7b03..8b7ca6b63915ab8d9d1a44e5809980d5f2c3a9cf 100644 |
| --- a/Source/core/css/CSSCalculationValueTest.cpp |
| +++ b/Source/core/css/CSSCalculationValueTest.cpp |
| @@ -69,12 +69,20 @@ void initLengthArray(CSSLengthArray& lengthArray) |
| lengthArray.at(i) = 0; |
| } |
| -CSSLengthArray& setLengthArray(CSSLengthArray& lengthArray, String text) |
| +void initLengthTypeArray(CSSLengthTypeArray& lengthTypeArray) |
| +{ |
| + lengthTypeArray.resize(CSSPrimitiveValue::LengthUnitTypeCount); |
| + for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; ++i) |
| + lengthTypeArray.clear(i); |
| +} |
| + |
| +CSSLengthArray& setLengthArray(CSSLengthArray& lengthArray, CSSLengthTypeArray& lengthTypeArray, String text) |
| { |
| initLengthArray(lengthArray); |
| + initLengthTypeArray(lengthTypeArray); |
| RefPtrWillBeRawPtr<MutableStylePropertySet> propertySet = MutableStylePropertySet::create(); |
| propertySet->setProperty(CSSPropertyLeft, text); |
| - toCSSPrimitiveValue(propertySet->getPropertyCSSValue(CSSPropertyLeft).get())->accumulateLengthArray(lengthArray); |
| + toCSSPrimitiveValue(propertySet->getPropertyCSSValue(CSSPropertyLeft).get())->accumulateLengthArray(lengthArray, lengthTypeArray); |
| return lengthArray; |
| } |
| @@ -171,28 +179,30 @@ TEST(CSSCalculationValue, RefCountLeak) |
| TEST(CSSCalculationValue, AddToLengthUnitValues) |
| { |
| CSSLengthArray expectation, actual; |
| + CSSLengthTypeArray expectedType, actualType; |
| initLengthArray(expectation); |
| - EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, "0"))); |
| + initLengthTypeArray(expectedType); |
|
samli
2014/12/22 03:38:04
Not actually used. Remove once you add the extra a
evemj (not active)
2014/12/22 06:09:05
Done.
|
| + EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, actualType, "0"))); |
| expectation.at(CSSPrimitiveValue::UnitTypePixels) = 10; |
| - EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, "10px"))); |
| + EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, actualType, "10px"))); |
| expectation.at(CSSPrimitiveValue::UnitTypePixels) = 0; |
| expectation.at(CSSPrimitiveValue::UnitTypePercentage) = 20; |
| - EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, "20%"))); |
| + EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, actualType, "20%"))); |
| expectation.at(CSSPrimitiveValue::UnitTypePixels) = 30; |
| expectation.at(CSSPrimitiveValue::UnitTypePercentage) = -40; |
| - EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, "calc(30px - 40%)"))); |
| + EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, actualType, "calc(30px - 40%)"))); |
| expectation.at(CSSPrimitiveValue::UnitTypePixels) = 90; |
| expectation.at(CSSPrimitiveValue::UnitTypePercentage) = 10; |
| - EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, "calc(1in + 10% - 6px)"))); |
| + EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, actualType, "calc(1in + 10% - 6px)"))); |
| expectation.at(CSSPrimitiveValue::UnitTypePixels) = 15; |
| expectation.at(CSSPrimitiveValue::UnitTypeFontSize) = 20; |
| expectation.at(CSSPrimitiveValue::UnitTypePercentage) = -40; |
| - EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, "calc((1 * 2) * (5px + 20em / 2) - 80% / (3 - 1) + 5px)"))); |
| + EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, actualType, "calc((1 * 2) * (5px + 20em / 2) - 80% / (3 - 1) + 5px)"))); |
| } |
| } |