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/ColorStyleInterpolation.h" | 6 #include "core/animation/ColorStyleInterpolation.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 #include "platform/graphics/Color.h" | 10 #include "platform/graphics/Color.h" |
11 | 11 |
12 #include <gtest/gtest.h> | 12 #include <gtest/gtest.h> |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 class AnimationColorStyleInterpolationTest : public ::testing::Test { | 16 class AnimationColorStyleInterpolationTest : public ::testing::Test { |
17 protected: | 17 protected: |
18 static PassOwnPtrWillBeRawPtr<InterpolableValue> colorToInterpolableValue(co
nst CSSValue& value) | 18 static PassOwnPtr<InterpolableValue> colorToInterpolableValue(const CSSValue
& value) |
19 { | 19 { |
20 return ColorStyleInterpolation::colorToInterpolableValue(value); | 20 return ColorStyleInterpolation::colorToInterpolableValue(value); |
21 } | 21 } |
22 | 22 |
23 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToColor(Interpolabl
eValue* value) | 23 static PassRefPtrWillBeRawPtr<CSSValue> interpolableValueToColor(Interpolabl
eValue* value) |
24 { | 24 { |
25 return ColorStyleInterpolation::interpolableValueToColor(*value); | 25 return ColorStyleInterpolation::interpolableValueToColor(*value); |
26 } | 26 } |
27 | 27 |
28 static PassRefPtrWillBeRawPtr<CSSValue> roundTrip(PassRefPtrWillBeRawPtr<CSS
Value> value) | 28 static PassRefPtrWillBeRawPtr<CSSValue> roundTrip(PassRefPtrWillBeRawPtr<CSS
Value> value) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 64 } |
65 | 65 |
66 TEST_F(AnimationColorStyleInterpolationTest, ValueIDColor) | 66 TEST_F(AnimationColorStyleInterpolationTest, ValueIDColor) |
67 { | 67 { |
68 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::createIden
tifier(CSSValueID::CSSValueBlue)); | 68 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::createIden
tifier(CSSValueID::CSSValueBlue)); |
69 testPrimitiveValue(value, makeRGB(0, 0, 255)); | 69 testPrimitiveValue(value, makeRGB(0, 0, 255)); |
70 } | 70 } |
71 | 71 |
72 TEST_F(AnimationColorStyleInterpolationTest, Interpolation) | 72 TEST_F(AnimationColorStyleInterpolationTest, Interpolation) |
73 { | 73 { |
74 RefPtrWillBeRawPtr<Interpolation> interpolation = ColorStyleInterpolation::c
reate( | 74 RefPtr<Interpolation> interpolation = ColorStyleInterpolation::create( |
75 *CSSPrimitiveValue::createColor(makeRGBA(0, 0, 0, 255)), | 75 *CSSPrimitiveValue::createColor(makeRGBA(0, 0, 0, 255)), |
76 *CSSPrimitiveValue::createColor(makeRGBA(255, 255, 255, 255)), | 76 *CSSPrimitiveValue::createColor(makeRGBA(255, 255, 255, 255)), |
77 CSSPropertyColor | 77 CSSPropertyColor |
78 ); | 78 ); |
79 | 79 |
80 interpolation->interpolate(0, 0.5); | 80 interpolation->interpolate(0, 0.5); |
81 RefPtrWillBeRawPtr<CSSValue> value = interpolableValueToColor(interpolationV
alue(*interpolation)); | 81 RefPtrWillBeRawPtr<CSSValue> value = interpolableValueToColor(interpolationV
alue(*interpolation)); |
82 | 82 |
83 testPrimitiveValue(value, makeRGBA(128, 128, 128, 255)); | 83 testPrimitiveValue(value, makeRGBA(128, 128, 128, 255)); |
84 } | 84 } |
85 } | 85 } |
OLD | NEW |