Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1225)

Side by Side Diff: Source/core/animation/ShadowStyleInterpolationTest.cpp

Issue 1164573002: CSSValue Immediates: Change CSSValue to an object instead of a pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 PassOwnPtrWillBeRawPtr<InterpolableValue> shadowToInterpolableValue(c onst CSSValue& value, bool 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 CSSValue interpolableValueToShadow(InterpolableValue* value, bool sty leFlag)
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 CSSValue roundTrip(CSSValue value, bool styleFlag)
33 { 33 {
34 return interpolableValueToShadow(shadowToInterpolableValue(*value, style Flag).get(), styleFlag); 34 return interpolableValueToShadow(shadowToInterpolableValue(value, styleF lag).get(), 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(CSSValue value, double xExpected, double yEx pected, 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());
45 EXPECT_EQ(yExpected, shadowValue.y->getDoubleValue()); 45 EXPECT_EQ(yExpected, shadowValue.y->getDoubleValue());
46 EXPECT_EQ(blurExpected, shadowValue.blur->getDoubleValue()); 46 EXPECT_EQ(blurExpected, shadowValue.blur->getDoubleValue());
47 EXPECT_EQ(spreadExpected, shadowValue.spread->getDoubleValue()); 47 EXPECT_EQ(spreadExpected, shadowValue.spread->getDoubleValue());
48 EXPECT_EQ(colorExpected, shadowValue.color->getRGBA32Value()); 48 EXPECT_EQ(colorExpected, shadowValue.color->getRGBA32Value());
49 49
50 EXPECT_EQ(idExpected->getValueID(), shadowValue.style->getValueID()); 50 EXPECT_EQ(idExpected->getValueID(), shadowValue.style->getValueID());
51 51
52 EXPECT_EQ(shadowValue.x->primitiveType(), unitType); 52 EXPECT_EQ(shadowValue.x->primitiveType(), unitType);
53 EXPECT_EQ(shadowValue.y->primitiveType(), unitType); 53 EXPECT_EQ(shadowValue.y->primitiveType(), unitType);
54 EXPECT_EQ(shadowValue.blur->primitiveType(), unitType); 54 EXPECT_EQ(shadowValue.blur->primitiveType(), unitType);
55 EXPECT_EQ(shadowValue.spread->primitiveType(), unitType); 55 EXPECT_EQ(shadowValue.spread->primitiveType(), unitType);
56 } 56 }
57 57
58 }; 58 };
59 59
60 TEST_F(AnimationShadowStyleInterpolationTest, ZeroTest) 60 TEST_F(AnimationShadowStyleInterpolationTest, ZeroTest)
61 { 61 {
62 RefPtrWillBeRawPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor (makeRGBA(0, 0, 0, 0)); 62 RefPtrWillBeRawPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor (makeRGBA(0, 0, 0, 0));
63 RefPtrWillBeRawPtr<CSSPrimitiveValue> x = CSSPrimitiveValue::create(0, CSSPr imitiveValue::CSS_PX); 63 RefPtrWillBeRawPtr<CSSPrimitiveValue> x = CSSPrimitiveValue::create(0, CSSPr imitiveValue::CSS_PX);
64 RefPtrWillBeRawPtr<CSSPrimitiveValue> y = CSSPrimitiveValue::create(0, CSSPr imitiveValue::CSS_PX); 64 RefPtrWillBeRawPtr<CSSPrimitiveValue> y = CSSPrimitiveValue::create(0, CSSPr imitiveValue::CSS_PX);
65 RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(0, CS SPrimitiveValue::CSS_PX); 65 RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(0, CS SPrimitiveValue::CSS_PX);
66 RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX); 66 RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX);
67 67
68 RefPtrWillBeRawPtr<CSSShadowValue> shadowValue = CSSShadowValue::create(x, y , blur, spread, CSSPrimitiveValue::createIdentifier(CSSValueNone), color); 68 RefPtrWillBeRawPtr<CSSShadowValue> shadowValue = CSSShadowValue::create(x, y , blur, spread, CSSPrimitiveValue::createIdentifier(CSSValueNone), color);
69 69
70 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(shadowValue.release(), false) ; 70 CSSValue value = roundTrip(shadowValue.release(), false);
71 71
72 testPrimitiveValues(value, 0, 0, 0, 0, makeRGBA(0, 0, 0, 0), CSSPrimitiveVal ue::createIdentifier(CSSValueNone), CSSPrimitiveValue::CSS_PX); 72 testPrimitiveValues(value, 0, 0, 0, 0, makeRGBA(0, 0, 0, 0), CSSPrimitiveVal ue::createIdentifier(CSSValueNone), CSSPrimitiveValue::CSS_PX);
73 } 73 }
74 74
75 TEST_F(AnimationShadowStyleInterpolationTest, MultipleValueNonPixelTest) 75 TEST_F(AnimationShadowStyleInterpolationTest, MultipleValueNonPixelTest)
76 { 76 {
77 RefPtrWillBeRawPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor (makeRGBA(112, 123, 175, 255)); 77 RefPtrWillBeRawPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor (makeRGBA(112, 123, 175, 255));
78 RefPtrWillBeRawPtr<CSSPrimitiveValue> x = CSSPrimitiveValue::create(10, CSSP rimitiveValue::CSS_EMS); 78 RefPtrWillBeRawPtr<CSSPrimitiveValue> x = CSSPrimitiveValue::create(10, CSSP rimitiveValue::CSS_EMS);
79 RefPtrWillBeRawPtr<CSSPrimitiveValue> y = CSSPrimitiveValue::create(20, CSSP rimitiveValue::CSS_EMS); 79 RefPtrWillBeRawPtr<CSSPrimitiveValue> y = CSSPrimitiveValue::create(20, CSSP rimitiveValue::CSS_EMS);
80 RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(30, C SSPrimitiveValue::CSS_EMS); 80 RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(30, C SSPrimitiveValue::CSS_EMS);
81 RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = CSSPrimitiveValue::create(40, CSSPrimitiveValue::CSS_EMS); 81 RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = CSSPrimitiveValue::create(40, CSSPrimitiveValue::CSS_EMS);
82 82
83 RefPtrWillBeRawPtr<CSSShadowValue> shadowValue = CSSShadowValue::create(x, y , blur, spread, CSSPrimitiveValue::createIdentifier(CSSValueNone), color); 83 RefPtrWillBeRawPtr<CSSShadowValue> shadowValue = CSSShadowValue::create(x, y , blur, spread, CSSPrimitiveValue::createIdentifier(CSSValueNone), color);
84 84
85 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(shadowValue.release(), false) ; 85 CSSValue value = roundTrip(shadowValue.release(), false);
86 86
87 testPrimitiveValues(value, 10, 20, 30, 40, makeRGBA(112, 123, 175, 255), CSS PrimitiveValue::createIdentifier(CSSValueNone), CSSPrimitiveValue::CSS_EMS); 87 testPrimitiveValues(value, 10, 20, 30, 40, makeRGBA(112, 123, 175, 255), CSS PrimitiveValue::createIdentifier(CSSValueNone), CSSPrimitiveValue::CSS_EMS);
88 } 88 }
89 89
90 TEST_F(AnimationShadowStyleInterpolationTest, InsetShadowTest) 90 TEST_F(AnimationShadowStyleInterpolationTest, InsetShadowTest)
91 { 91 {
92 RefPtrWillBeRawPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor (makeRGBA(54, 48, 214, 64)); 92 RefPtrWillBeRawPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor (makeRGBA(54, 48, 214, 64));
93 RefPtrWillBeRawPtr<CSSPrimitiveValue> x = CSSPrimitiveValue::create(10, CSSP rimitiveValue::CSS_PX); 93 RefPtrWillBeRawPtr<CSSPrimitiveValue> x = CSSPrimitiveValue::create(10, CSSP rimitiveValue::CSS_PX);
94 RefPtrWillBeRawPtr<CSSPrimitiveValue> y = CSSPrimitiveValue::create(20, CSSP rimitiveValue::CSS_PX); 94 RefPtrWillBeRawPtr<CSSPrimitiveValue> y = CSSPrimitiveValue::create(20, CSSP rimitiveValue::CSS_PX);
95 RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(30, C SSPrimitiveValue::CSS_PX); 95 RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(30, C SSPrimitiveValue::CSS_PX);
96 RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = CSSPrimitiveValue::create(40, CSSPrimitiveValue::CSS_PX); 96 RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = CSSPrimitiveValue::create(40, CSSPrimitiveValue::CSS_PX);
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 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::CSS_PX); 102 testPrimitiveValues(value, 10, 20, 30, 40, makeRGBA(54, 48, 214, 64), CSSPri mitiveValue::createIdentifier(CSSValueInset), CSSPrimitiveValue::CSS_PX);
103 } 103 }
104 104
105 } 105 }
OLDNEW
« no previous file with comments | « Source/core/animation/ShadowStyleInterpolation.cpp ('k') | Source/core/animation/StringKeyframe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698