| 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/ShadowStyleInterpolation.h" | 6 #include "core/animation/ShadowStyleInterpolation.h" |
| 7 | 7 |
| 8 #include "core/css/CSSPrimitiveValue.h" | 8 #include "core/css/CSSPrimitiveValue.h" |
| 9 #include "core/css/CSSShadowValue.h" | 9 #include "core/css/CSSShadowValue.h" |
| 10 #include "core/css/CSSValue.h" | 10 #include "core/css/CSSValue.h" |
| 11 #include "core/css/resolver/StyleBuilder.h" | 11 #include "core/css/resolver/StyleBuilder.h" |
| 12 #include "platform/graphics/Color.h" | 12 #include "platform/graphics/Color.h" |
| 13 | 13 |
| 14 #include <gtest/gtest.h> | 14 #include <gtest/gtest.h> |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 class AnimationShadowStyleInterpolationTest : public ::testing::Test { | 18 class AnimationShadowStyleInterpolationTest : public ::testing::Test { |
| 19 | 19 |
| 20 protected: | 20 protected: |
| 21 | 21 |
| 22 static PassOwnPtrWillBeRawPtr<InterpolableValue> shadowToInterpolableValue(c
onst CSSValue& value, bool styleFlag) | 22 static InterpolableValue* shadowToInterpolableValue(const CSSValue& value, b
ool styleFlag) |
| 23 { | 23 { |
| 24 return ShadowStyleInterpolation::shadowToInterpolableValue(value, styleF
lag); | 24 return ShadowStyleInterpolation::shadowToInterpolableValue(value, styleF
lag); |
| 25 } | 25 } |
| 26 | 26 |
| 27 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToShadow(Interpolab
leValue* value, bool styleFlag) | 27 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToShadow(Interpolab
leValue* value, bool styleFlag) |
| 28 { | 28 { |
| 29 return ShadowStyleInterpolation::interpolableValueToShadow(*value, style
Flag); | 29 return ShadowStyleInterpolation::interpolableValueToShadow(*value, style
Flag); |
| 30 } | 30 } |
| 31 | 31 |
| 32 static PassRefPtrWillBeRawPtr<CSSValue> roundTrip(PassRefPtrWillBeRawPtr<CSS
Value> value, bool styleFlag) | 32 static PassRefPtrWillBeRawPtr<CSSValue> roundTrip(PassRefPtrWillBeRawPtr<CSS
Value> value, bool styleFlag) |
| 33 { | 33 { |
| 34 return interpolableValueToShadow(shadowToInterpolableValue(*value, style
Flag).get(), styleFlag); | 34 return interpolableValueToShadow(shadowToInterpolableValue(*value, style
Flag), styleFlag); |
| 35 } | 35 } |
| 36 | 36 |
| 37 static void testPrimitiveValues(RefPtrWillBeRawPtr<CSSValue> value, double x
Expected, double yExpected, double blurExpected, double spreadExpected, | 37 static void testPrimitiveValues(RefPtrWillBeRawPtr<CSSValue> value, double x
Expected, double yExpected, double blurExpected, double spreadExpected, |
| 38 RGBA32 colorExpected, RefPtrWillBeRawPtr<CSSPrimitiveValue> idExpected,
CSSPrimitiveValue::UnitType unitType) | 38 RGBA32 colorExpected, RefPtrWillBeRawPtr<CSSPrimitiveValue> idExpected,
CSSPrimitiveValue::UnitType unitType) |
| 39 { | 39 { |
| 40 EXPECT_TRUE(value->isShadowValue()); | 40 EXPECT_TRUE(value->isShadowValue()); |
| 41 | 41 |
| 42 CSSShadowValue& shadowValue = toCSSShadowValue(*value); | 42 CSSShadowValue& shadowValue = toCSSShadowValue(*value); |
| 43 | 43 |
| 44 EXPECT_EQ(xExpected, shadowValue.x->getDoubleValue()); | 44 EXPECT_EQ(xExpected, shadowValue.x->getDoubleValue()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = CSSPrimitiveValue::create(40,
CSSPrimitiveValue::UnitType::Pixels); | 96 RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = CSSPrimitiveValue::create(40,
CSSPrimitiveValue::UnitType::Pixels); |
| 97 | 97 |
| 98 RefPtrWillBeRawPtr<CSSShadowValue> shadowValue = CSSShadowValue::create(x, y
, blur, spread, CSSPrimitiveValue::createIdentifier(CSSValueInset), color); | 98 RefPtrWillBeRawPtr<CSSShadowValue> shadowValue = CSSShadowValue::create(x, y
, blur, spread, CSSPrimitiveValue::createIdentifier(CSSValueInset), color); |
| 99 | 99 |
| 100 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(shadowValue.release(), true); | 100 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(shadowValue.release(), true); |
| 101 | 101 |
| 102 testPrimitiveValues(value, 10, 20, 30, 40, makeRGBA(54, 48, 214, 64), CSSPri
mitiveValue::createIdentifier(CSSValueInset), CSSPrimitiveValue::UnitType::Pixel
s); | 102 testPrimitiveValues(value, 10, 20, 30, 40, makeRGBA(54, 48, 214, 64), CSSPri
mitiveValue::createIdentifier(CSSValueInset), CSSPrimitiveValue::UnitType::Pixel
s); |
| 103 } | 103 } |
| 104 | 104 |
| 105 } | 105 } |
| OLD | NEW |