| OLD | NEW |
| 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::lengthToInterpolableValue(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::interpolableValueToLength(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 void testPrimitiveValue(RefPtrWillBeRawPtr<CSSValue> value, double do
ubleValue, CSSPrimitiveValue::UnitType unitType) | 32 static void testPrimitiveValue(RefPtrWillBeRawPtr<CSSValue> value, double do
ubleValue, CSSPrimitiveValue::UnitType unitType) |
| 33 { | 33 { |
| 34 EXPECT_TRUE(value->isPrimitiveValue()); | 34 EXPECT_TRUE(value->isPrimitiveValue()); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 CSSLengthArray expectation, actual; | 167 CSSLengthArray expectation, actual; |
| 168 initLengthArray(expectation); | 168 initLengthArray(expectation); |
| 169 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(2); | 169 OwnPtrWillBeRawPtr<InterpolableList> result = InterpolableList::create(2); |
| 170 result->set(0, createInterpolableLength(0, 10, 0, 10, 0, 10, 0, 10, 0, 10)); | 170 result->set(0, createInterpolableLength(0, 10, 0, 10, 0, 10, 0, 10, 0, 10)); |
| 171 result->set(1, createInterpolableLength(1, 1, 1, 1, 0, 1, 0, 1, 1, 1)); | 171 result->set(1, createInterpolableLength(1, 1, 1, 1, 0, 1, 0, 1, 1, 1)); |
| 172 toCSSPrimitiveValue(interpolableValueToLength(result.get(), RangeAll).get())
->accumulateLengthArray(expectation); | 172 toCSSPrimitiveValue(interpolableValueToLength(result.get(), RangeAll).get())
->accumulateLengthArray(expectation); |
| 173 EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, "calc(0px
+ 10% + 0em + 10ex + 10ch + 10vh + 0vmin + 10vmax)"))); | 173 EXPECT_TRUE(lengthArraysEqual(expectation, setLengthArray(actual, "calc(0px
+ 10% + 0em + 10ex + 10ch + 10vh + 0vmin + 10vmax)"))); |
| 174 } | 174 } |
| 175 | 175 |
| 176 } | 176 } |
| OLD | NEW |