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

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

Issue 1303173007: Oilpan: Unship Oilpan from CSSValues Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/SVGStrokeDasharrayStyleInterpolation.h" 6 #include "core/animation/SVGStrokeDasharrayStyleInterpolation.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 10
11 #include <gtest/gtest.h> 11 #include <gtest/gtest.h>
12 12
13 namespace blink { 13 namespace blink {
14 14
15 class AnimationSVGStrokeDasharrayStyleInterpolationTest : public ::testing::Test { 15 class AnimationSVGStrokeDasharrayStyleInterpolationTest : public ::testing::Test {
16 protected: 16 protected:
17 static PassRefPtrWillBeRawPtr<CSSValueList> interpolableValueToStrokeDasharr ay(const InterpolableValue& value) 17 static PassRefPtr<CSSValueList> interpolableValueToStrokeDasharray(const Int erpolableValue& value)
18 { 18 {
19 return SVGStrokeDasharrayStyleInterpolation::interpolableValueToStrokeDa sharray(value); 19 return SVGStrokeDasharrayStyleInterpolation::interpolableValueToStrokeDa sharray(value);
20 } 20 }
21 21
22 static PassRefPtrWillBeRawPtr<CSSValueList> roundTrip(const CSSValue& value) 22 static PassRefPtr<CSSValueList> roundTrip(const CSSValue& value)
23 { 23 {
24 RefPtrWillBeRawPtr<SVGStrokeDasharrayStyleInterpolation> interpolation = SVGStrokeDasharrayStyleInterpolation::maybeCreate(value, value, CSSPropertyStro keDasharray); 24 RefPtrWillBeRawPtr<SVGStrokeDasharrayStyleInterpolation> interpolation = SVGStrokeDasharrayStyleInterpolation::maybeCreate(value, value, CSSPropertyStro keDasharray);
25 ASSERT(interpolation); 25 ASSERT(interpolation);
26 return SVGStrokeDasharrayStyleInterpolation::interpolableValueToStrokeDa sharray(*interpolation->m_start); 26 return SVGStrokeDasharrayStyleInterpolation::interpolableValueToStrokeDa sharray(*interpolation->m_start);
27 } 27 }
28 28
29 static void testPrimitiveValue(const CSSValue& cssValue, double value, CSSPr imitiveValue::UnitType unitType) 29 static void testPrimitiveValue(const CSSValue& cssValue, double value, CSSPr imitiveValue::UnitType unitType)
30 { 30 {
31 EXPECT_TRUE(cssValue.isPrimitiveValue()); 31 EXPECT_TRUE(cssValue.isPrimitiveValue());
32 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(cssValue); 32 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(cssValue);
33 33
34 EXPECT_EQ(primitiveValue.typeWithCalcResolved(), unitType); 34 EXPECT_EQ(primitiveValue.typeWithCalcResolved(), unitType);
35 EXPECT_EQ(primitiveValue.getDoubleValue(), value); 35 EXPECT_EQ(primitiveValue.getDoubleValue(), value);
36 } 36 }
37 }; 37 };
38 38
39 TEST_F(AnimationSVGStrokeDasharrayStyleInterpolationTest, Zero) 39 TEST_F(AnimationSVGStrokeDasharrayStyleInterpolationTest, Zero)
40 { 40 {
41 RefPtrWillBeRawPtr<CSSValueList> start = CSSValueList::createCommaSeparated( ); 41 RefPtr<CSSValueList> start = CSSValueList::createCommaSeparated();
42 start->append(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Perc entage)); 42 start->append(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Perc entage));
43 start->append(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Ems) ); 43 start->append(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Ems) );
44 start->append(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pixe ls)); 44 start->append(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pixe ls));
45 45
46 RefPtrWillBeRawPtr<CSSValueList> value = roundTrip(*start); 46 RefPtr<CSSValueList> value = roundTrip(*start);
47 EXPECT_EQ(value->length(), 3u); 47 EXPECT_EQ(value->length(), 3u);
48 testPrimitiveValue(*value->item(0), 0, CSSPrimitiveValue::UnitType::Percenta ge); 48 testPrimitiveValue(*value->item(0), 0, CSSPrimitiveValue::UnitType::Percenta ge);
49 testPrimitiveValue(*value->item(1), 0, CSSPrimitiveValue::UnitType::Ems); 49 testPrimitiveValue(*value->item(1), 0, CSSPrimitiveValue::UnitType::Ems);
50 testPrimitiveValue(*value->item(2), 0, CSSPrimitiveValue::UnitType::Pixels); 50 testPrimitiveValue(*value->item(2), 0, CSSPrimitiveValue::UnitType::Pixels);
51 } 51 }
52 52
53 TEST_F(AnimationSVGStrokeDasharrayStyleInterpolationTest, SingleUnit) 53 TEST_F(AnimationSVGStrokeDasharrayStyleInterpolationTest, SingleUnit)
54 { 54 {
55 RefPtrWillBeRawPtr<CSSValueList> start = CSSValueList::createCommaSeparated( ); 55 RefPtr<CSSValueList> start = CSSValueList::createCommaSeparated();
56 start->append(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pixe ls)); 56 start->append(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pixe ls));
57 start->append(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType::Ems )); 57 start->append(CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType::Ems ));
58 start->append(CSSPrimitiveValue::create(-20, CSSPrimitiveValue::UnitType::Em s)); 58 start->append(CSSPrimitiveValue::create(-20, CSSPrimitiveValue::UnitType::Em s));
59 start->append(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Perc entage)); 59 start->append(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Perc entage));
60 start->append(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType::Ems )); 60 start->append(CSSPrimitiveValue::create(30, CSSPrimitiveValue::UnitType::Ems ));
61 61
62 RefPtrWillBeRawPtr<CSSValueList> value = roundTrip(*start); 62 RefPtr<CSSValueList> value = roundTrip(*start);
63 EXPECT_EQ(value->length(), 5u); 63 EXPECT_EQ(value->length(), 5u);
64 testPrimitiveValue(*value->item(0), 0, CSSPrimitiveValue::UnitType::Pixels); 64 testPrimitiveValue(*value->item(0), 0, CSSPrimitiveValue::UnitType::Pixels);
65 testPrimitiveValue(*value->item(1), 10, CSSPrimitiveValue::UnitType::Ems); 65 testPrimitiveValue(*value->item(1), 10, CSSPrimitiveValue::UnitType::Ems);
66 testPrimitiveValue(*value->item(2), 0, CSSPrimitiveValue::UnitType::Ems); 66 testPrimitiveValue(*value->item(2), 0, CSSPrimitiveValue::UnitType::Ems);
67 testPrimitiveValue(*value->item(3), 0, CSSPrimitiveValue::UnitType::Percenta ge); 67 testPrimitiveValue(*value->item(3), 0, CSSPrimitiveValue::UnitType::Percenta ge);
68 testPrimitiveValue(*value->item(4), 30, CSSPrimitiveValue::UnitType::Ems); 68 testPrimitiveValue(*value->item(4), 30, CSSPrimitiveValue::UnitType::Ems);
69 } 69 }
70 70
71 TEST_F(AnimationSVGStrokeDasharrayStyleInterpolationTest, None) 71 TEST_F(AnimationSVGStrokeDasharrayStyleInterpolationTest, None)
72 { 72 {
73 RefPtrWillBeRawPtr<CSSPrimitiveValue> start = CSSPrimitiveValue::createIdent ifier(CSSValueNone); 73 RefPtr<CSSPrimitiveValue> start = CSSPrimitiveValue::createIdentifier(CSSVal ueNone);
74 74
75 RefPtrWillBeRawPtr<CSSValueList> value = roundTrip(*start); 75 RefPtr<CSSValueList> value = roundTrip(*start);
76 EXPECT_EQ(value->length(), 1u); 76 EXPECT_EQ(value->length(), 1u);
77 testPrimitiveValue(*value->item(0), 0, CSSPrimitiveValue::UnitType::Pixels); 77 testPrimitiveValue(*value->item(0), 0, CSSPrimitiveValue::UnitType::Pixels);
78 } 78 }
79 79
80 } 80 }
OLDNEW
« no previous file with comments | « Source/core/animation/SVGStrokeDasharrayStyleInterpolation.cpp ('k') | Source/core/animation/ShadowStyleInterpolation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698