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

Side by Side Diff: Source/core/animation/ListStyleInterpolationTest.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/ListStyleInterpolation.h" 6 #include "core/animation/ListStyleInterpolation.h"
7 7
8 #include "core/animation/LengthStyleInterpolation.h" 8 #include "core/animation/LengthStyleInterpolation.h"
9 #include "core/animation/ShadowStyleInterpolation.h" 9 #include "core/animation/ShadowStyleInterpolation.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 ListStyleInterpolationTest : public ::testing::Test { 15 class ListStyleInterpolationTest : public ::testing::Test {
16 16
17 protected: 17 protected:
18 static PassRefPtrWillBeRawPtr<CSSValue> lengthRoundTrip(PassRefPtrWillBeRawP tr<CSSValue> value, InterpolationRange range) 18 static PassRefPtr<CSSValue> lengthRoundTrip(PassRefPtr<CSSValue> value, Inte rpolationRange range)
19 { 19 {
20 return ListStyleInterpolationImpl<LengthStyleInterpolation, void>::inter polableValueToList( 20 return ListStyleInterpolationImpl<LengthStyleInterpolation, void>::inter polableValueToList(
21 ListStyleInterpolationImpl<LengthStyleInterpolation, void>::listToIn terpolableValue(*value).get(), range); 21 ListStyleInterpolationImpl<LengthStyleInterpolation, void>::listToIn terpolableValue(*value).get(), range);
22 } 22 }
23 23
24 static void compareLengthLists(PassRefPtrWillBeRawPtr<CSSValueList> expected List, PassRefPtrWillBeRawPtr<CSSValue> actualList) 24 static void compareLengthLists(PassRefPtr<CSSValueList> expectedList, PassRe fPtr<CSSValue> actualList)
25 { 25 {
26 ASSERT(actualList->isValueList()); 26 ASSERT(actualList->isValueList());
27 27
28 for (size_t i = 0; i < 10; i++) { 28 for (size_t i = 0; i < 10; i++) {
29 CSSValue* currentExpectedValue = expectedList->item(i); 29 CSSValue* currentExpectedValue = expectedList->item(i);
30 CSSValue* currentActualValue = toCSSValueList(*actualList).item(i); 30 CSSValue* currentActualValue = toCSSValueList(*actualList).item(i);
31 ASSERT(currentExpectedValue->isPrimitiveValue()); 31 ASSERT(currentExpectedValue->isPrimitiveValue());
32 ASSERT(currentActualValue->isPrimitiveValue()); 32 ASSERT(currentActualValue->isPrimitiveValue());
33 33
34 EXPECT_EQ(toCSSPrimitiveValue(currentExpectedValue)->getDoubleValue( ), toCSSPrimitiveValue(currentActualValue)->getDoubleValue()); 34 EXPECT_EQ(toCSSPrimitiveValue(currentExpectedValue)->getDoubleValue( ), toCSSPrimitiveValue(currentActualValue)->getDoubleValue());
35 EXPECT_EQ(toCSSPrimitiveValue(currentExpectedValue)->getDoubleValue( ), toCSSPrimitiveValue(currentActualValue)->getDoubleValue()); 35 EXPECT_EQ(toCSSPrimitiveValue(currentExpectedValue)->getDoubleValue( ), toCSSPrimitiveValue(currentActualValue)->getDoubleValue());
36 } 36 }
37 } 37 }
38 38
39 static PassRefPtrWillBeRawPtr<CSSValue> shadowRoundTrip(PassRefPtrWillBeRawP tr<CSSValue> value) 39 static PassRefPtr<CSSValue> shadowRoundTrip(PassRefPtr<CSSValue> value)
40 { 40 {
41 Vector<bool> nonInterpolableData; 41 Vector<bool> nonInterpolableData;
42 return ListStyleInterpolationImpl<ShadowStyleInterpolation, bool>::inter polableValueToList( 42 return ListStyleInterpolationImpl<ShadowStyleInterpolation, bool>::inter polableValueToList(
43 ListStyleInterpolationImpl<ShadowStyleInterpolation, bool>::listToIn terpolableValue(*value, &nonInterpolableData).get(), nonInterpolableData); 43 ListStyleInterpolationImpl<ShadowStyleInterpolation, bool>::listToIn terpolableValue(*value, &nonInterpolableData).get(), nonInterpolableData);
44 } 44 }
45 45
46 static RefPtrWillBeRawPtr<CSSShadowValue> createShadowValue() 46 static RefPtr<CSSShadowValue> createShadowValue()
47 { 47 {
48 RefPtrWillBeRawPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createC olor(makeRGBA(112, 123, 175, 255)); 48 RefPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor(makeRGB A(112, 123, 175, 255));
49 RefPtrWillBeRawPtr<CSSPrimitiveValue> x = CSSPrimitiveValue::create(10, CSSPrimitiveValue::UnitType::Pixels); 49 RefPtr<CSSPrimitiveValue> x = CSSPrimitiveValue::create(10, CSSPrimitive Value::UnitType::Pixels);
50 RefPtrWillBeRawPtr<CSSPrimitiveValue> y = CSSPrimitiveValue::create(20, CSSPrimitiveValue::UnitType::Pixels); 50 RefPtr<CSSPrimitiveValue> y = CSSPrimitiveValue::create(20, CSSPrimitive Value::UnitType::Pixels);
51 RefPtrWillBeRawPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(3 0, CSSPrimitiveValue::UnitType::Pixels); 51 RefPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(30, CSSPrimit iveValue::UnitType::Pixels);
52 RefPtrWillBeRawPtr<CSSPrimitiveValue> spread = CSSPrimitiveValue::create (40, CSSPrimitiveValue::UnitType::Pixels); 52 RefPtr<CSSPrimitiveValue> spread = CSSPrimitiveValue::create(40, CSSPrim itiveValue::UnitType::Pixels);
53 53
54 return CSSShadowValue::create(x, y, blur, spread, CSSPrimitiveValue::cre ateIdentifier(CSSValueNone), color); 54 return CSSShadowValue::create(x, y, blur, spread, CSSPrimitiveValue::cre ateIdentifier(CSSValueNone), color);
55 55
56 } 56 }
57 57
58 static void compareShadowList(RefPtrWillBeRawPtr<CSSValueList> expectedList, RefPtrWillBeRawPtr<CSSValue> actualList) 58 static void compareShadowList(RefPtr<CSSValueList> expectedList, RefPtr<CSSV alue> actualList)
59 { 59 {
60 ASSERT(actualList->isValueList()); 60 ASSERT(actualList->isValueList());
61 61
62 for (size_t i = 0; i < 10; i++) { 62 for (size_t i = 0; i < 10; i++) {
63 63
64 CSSShadowValue* expectedShadow = toCSSShadowValue(expectedList->item (i)); 64 CSSShadowValue* expectedShadow = toCSSShadowValue(expectedList->item (i));
65 CSSShadowValue* actualShadow = toCSSShadowValue(toCSSValueList(*actu alList).item(i)); 65 CSSShadowValue* actualShadow = toCSSShadowValue(toCSSValueList(*actu alList).item(i));
66 66
67 EXPECT_EQ(expectedShadow->x->getDoubleValue(), actualShadow->x->getD oubleValue()); 67 EXPECT_EQ(expectedShadow->x->getDoubleValue(), actualShadow->x->getD oubleValue());
68 EXPECT_EQ(expectedShadow->y->getDoubleValue(), actualShadow->y->getD oubleValue()); 68 EXPECT_EQ(expectedShadow->y->getDoubleValue(), actualShadow->y->getD oubleValue());
69 EXPECT_EQ(expectedShadow->blur->getDoubleValue(), actualShadow->blur ->getDoubleValue()); 69 EXPECT_EQ(expectedShadow->blur->getDoubleValue(), actualShadow->blur ->getDoubleValue());
70 EXPECT_EQ(expectedShadow->spread->getDoubleValue(), actualShadow->sp read->getDoubleValue()); 70 EXPECT_EQ(expectedShadow->spread->getDoubleValue(), actualShadow->sp read->getDoubleValue());
71 EXPECT_EQ(expectedShadow->color->getRGBA32Value(), actualShadow->col or->getRGBA32Value()); 71 EXPECT_EQ(expectedShadow->color->getRGBA32Value(), actualShadow->col or->getRGBA32Value());
72 72
73 EXPECT_EQ(expectedShadow->style->getValueID(), actualShadow->style-> getValueID()); 73 EXPECT_EQ(expectedShadow->style->getValueID(), actualShadow->style-> getValueID());
74 } 74 }
75 } 75 }
76 }; 76 };
77 77
78 TEST_F(ListStyleInterpolationTest, LengthListMultipleValuesTest) 78 TEST_F(ListStyleInterpolationTest, LengthListMultipleValuesTest)
79 { 79 {
80 RefPtrWillBeRawPtr<CSSValueList> expectedList = CSSValueList::createCommaSep arated(); 80 RefPtr<CSSValueList> expectedList = CSSValueList::createCommaSeparated();
81 for (size_t i = 0; i < 10; i++) { 81 for (size_t i = 0; i < 10; i++) {
82 RefPtrWillBeRawPtr<CSSPrimitiveValue> lengthValue = CSSPrimitiveValue::c reate(static_cast<double>(i), CSSPrimitiveValue::UnitType::Pixels); 82 RefPtr<CSSPrimitiveValue> lengthValue = CSSPrimitiveValue::create(static _cast<double>(i), CSSPrimitiveValue::UnitType::Pixels);
83 expectedList->append(lengthValue); 83 expectedList->append(lengthValue);
84 } 84 }
85 85
86 compareLengthLists(expectedList, lengthRoundTrip(expectedList, RangeNonNegat ive)); 86 compareLengthLists(expectedList, lengthRoundTrip(expectedList, RangeNonNegat ive));
87 } 87 }
88 88
89 TEST_F(ListStyleInterpolationTest, ShadowListMultipleValuesTest) 89 TEST_F(ListStyleInterpolationTest, ShadowListMultipleValuesTest)
90 { 90 {
91 RefPtrWillBeRawPtr<CSSValueList> expectedList = CSSValueList::createCommaSep arated(); 91 RefPtr<CSSValueList> expectedList = CSSValueList::createCommaSeparated();
92 RefPtrWillBeRawPtr<CSSShadowValue> shadowValue = createShadowValue(); 92 RefPtr<CSSShadowValue> shadowValue = createShadowValue();
93 for (size_t i = 0; i < 10; i++) { 93 for (size_t i = 0; i < 10; i++) {
94 expectedList->append(shadowValue); 94 expectedList->append(shadowValue);
95 } 95 }
96 96
97 compareShadowList(expectedList, shadowRoundTrip(expectedList)); 97 compareShadowList(expectedList, shadowRoundTrip(expectedList));
98 } 98 }
99 99
100 } // namespace blink 100 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/animation/ListStyleInterpolation.h ('k') | Source/core/animation/SVGStrokeDasharrayStyleInterpolation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698