| 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/DoubleStyleInterpolation.h" | 6 #include "core/animation/DoubleStyleInterpolation.h" |
| 7 | 7 |
| 8 #include "core/css/CSSPrimitiveValue.h" | 8 #include "core/css/CSSPrimitiveValue.h" |
| 9 #include "core/css/CSSValueList.h" | 9 #include "core/css/CSSValueList.h" |
| 10 #include "core/css/StylePropertySet.h" | 10 #include "core/css/StylePropertySet.h" |
| 11 #include "wtf/MathExtras.h" | 11 #include "wtf/MathExtras.h" |
| 12 | 12 |
| 13 #include <gtest/gtest.h> | 13 #include <gtest/gtest.h> |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class AnimationDoubleStyleInterpolationTest : public ::testing::Test { | 17 class AnimationDoubleStyleInterpolationTest : public ::testing::Test { |
| 18 protected: | 18 protected: |
| 19 static PassOwnPtrWillBeRawPtr<InterpolableValue> doubleToInterpolableValue(c
onst CSSValue& value) | 19 static PassOwnPtr<InterpolableValue> doubleToInterpolableValue(const CSSValu
e& value) |
| 20 { | 20 { |
| 21 return DoubleStyleInterpolation::doubleToInterpolableValue(value); | 21 return DoubleStyleInterpolation::doubleToInterpolableValue(value); |
| 22 } | 22 } |
| 23 | 23 |
| 24 static PassOwnPtrWillBeRawPtr<InterpolableValue> motionRotationToInterpolabl
eValue(const CSSValue& value) | 24 static PassOwnPtr<InterpolableValue> motionRotationToInterpolableValue(const
CSSValue& value) |
| 25 { | 25 { |
| 26 return DoubleStyleInterpolation::motionRotationToInterpolableValue(value
); | 26 return DoubleStyleInterpolation::motionRotationToInterpolableValue(value
); |
| 27 } | 27 } |
| 28 | 28 |
| 29 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToDouble(Interpolab
leValue* value, bool isNumber, InterpolationRange clamp) | 29 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToDouble(Interpolab
leValue* value, bool isNumber, InterpolationRange clamp) |
| 30 { | 30 { |
| 31 return DoubleStyleInterpolation::interpolableValueToDouble(value, isNumb
er, clamp); | 31 return DoubleStyleInterpolation::interpolableValueToDouble(value, isNumb
er, clamp); |
| 32 } | 32 } |
| 33 | 33 |
| 34 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToMotionRotation(In
terpolableValue* value, bool flag) | 34 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToMotionRotation(In
terpolableValue* value, bool flag) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 value = roundTrip(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType:
:Radians)); | 93 value = roundTrip(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType:
:Radians)); |
| 94 testPrimitiveValue(value, rad2deg(10.0), CSSPrimitiveValue::UnitType::Degree
s); | 94 testPrimitiveValue(value, rad2deg(10.0), CSSPrimitiveValue::UnitType::Degree
s); |
| 95 | 95 |
| 96 value = roundTrip(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType:
:Gradians)); | 96 value = roundTrip(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType:
:Gradians)); |
| 97 testPrimitiveValue(value, grad2deg(10.0), CSSPrimitiveValue::UnitType::Degre
es); | 97 testPrimitiveValue(value, grad2deg(10.0), CSSPrimitiveValue::UnitType::Degre
es); |
| 98 } | 98 } |
| 99 | 99 |
| 100 TEST_F(AnimationDoubleStyleInterpolationTest, Clamping) | 100 TEST_F(AnimationDoubleStyleInterpolationTest, Clamping) |
| 101 { | 101 { |
| 102 RefPtrWillBeRawPtr<Interpolation> interpolableDouble = DoubleStyleInterpolat
ion::create( | 102 RefPtr<Interpolation> interpolableDouble = DoubleStyleInterpolation::create( |
| 103 *CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Number), | 103 *CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Number), |
| 104 *CSSPrimitiveValue::create(0.6, CSSPrimitiveValue::UnitType::Number), | 104 *CSSPrimitiveValue::create(0.6, CSSPrimitiveValue::UnitType::Number), |
| 105 CSSPropertyLineHeight, | 105 CSSPropertyLineHeight, |
| 106 true, | 106 true, |
| 107 RangeAll); | 107 RangeAll); |
| 108 interpolableDouble->interpolate(0, 0.4); | 108 interpolableDouble->interpolate(0, 0.4); |
| 109 // progVal = start*(1-prog) + end*prog | 109 // progVal = start*(1-prog) + end*prog |
| 110 EXPECT_EQ(0.24, toInterpolableNumber(getCachedValue(*interpolableDouble))->v
alue()); | 110 EXPECT_EQ(0.24, toInterpolableNumber(getCachedValue(*interpolableDouble))->v
alue()); |
| 111 } | 111 } |
| 112 | 112 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 138 TEST_F(AnimationDoubleStyleInterpolationTest, ValueAutoMotionRotation) | 138 TEST_F(AnimationDoubleStyleInterpolationTest, ValueAutoMotionRotation) |
| 139 { | 139 { |
| 140 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 140 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
| 141 list->append(CSSPrimitiveValue::createIdentifier(CSSValueAuto)); | 141 list->append(CSSPrimitiveValue::createIdentifier(CSSValueAuto)); |
| 142 list->append(CSSPrimitiveValue::create(90, CSSPrimitiveValue::UnitType::Degr
ees)); | 142 list->append(CSSPrimitiveValue::create(90, CSSPrimitiveValue::UnitType::Degr
ees)); |
| 143 RefPtrWillBeRawPtr<CSSValue> value = roundTripMotionRotation(list.release(),
true); | 143 RefPtrWillBeRawPtr<CSSValue> value = roundTripMotionRotation(list.release(),
true); |
| 144 testValueListMotionRotation(value, 90, true); | 144 testValueListMotionRotation(value, 90, true); |
| 145 } | 145 } |
| 146 | 146 |
| 147 } | 147 } |
| OLD | NEW |