OLD | NEW |
---|---|
(Empty) | |
1 #include "config.h" | |
jadeg
2015/01/21 05:36:34
Need license shtuffs
evemj (not active)
2015/01/28 00:41:13
Done.
| |
2 #include "core/animation/ListStyleInterpolation.h" | |
3 | |
4 #include "core/animation/LengthStyleInterpolation.h" | |
5 #include "core/animation/ShadowStyleInterpolation.h" | |
6 | |
7 #include <gtest/gtest.h> | |
8 | |
9 namespace blink { | |
10 | |
11 class ListStyleInterpolationTest : public ::testing::Test { | |
12 | |
13 protected: | |
14 static PassRefPtrWillBeRawPtr<CSSValue> lengthRoundTrip(PassRefPtrWillBeRawP tr<CSSValue> value, InterpolationRange range) | |
15 { | |
16 return ListStyleInterpolationImpl<LengthStyleInterpolation, void>::inter polableValueToList( | |
17 ListStyleInterpolationImpl<LengthStyleInterpolation, void>::listToIn terpolableValue(*value).get(), range); | |
18 } | |
19 | |
20 static void compareLengthLists(PassRefPtrWillBeRawPtr<CSSValueList> expected List, PassRefPtrWillBeRawPtr<CSSValue> actualList) | |
21 { | |
22 ASSERT(actualList->isValueList()); | |
23 | |
24 for (size_t i = 0; i < 10; i++) { | |
25 CSSValue* currentExpectedValue = expectedList->item(i); | |
26 CSSValue* currentActualValue = toCSSValueList(*actualList).item(i); | |
27 ASSERT(currentExpectedValue->isPrimitiveValue()); | |
28 ASSERT(currentActualValue->isPrimitiveValue()); | |
29 | |
30 EXPECT_EQ(toCSSPrimitiveValue(currentExpectedValue)->getDoubleValue( ), toCSSPrimitiveValue(currentActualValue)->getDoubleValue()); | |
31 EXPECT_EQ(toCSSPrimitiveValue(currentExpectedValue)->getDoubleValue( ), toCSSPrimitiveValue(currentActualValue)->getDoubleValue()); | |
32 } | |
33 } | |
34 | |
35 static PassRefPtrWillBeRawPtr<CSSValue> shadowRoundTrip(PassRefPtrWillBeRawP tr<CSSValue> value) | |
36 { | |
37 Vector<bool> nonInterpolableData; | |
38 return ListStyleInterpolationImpl<ShadowStyleInterpolation, bool>::inter polableValueToList( | |
39 ListStyleInterpolationImpl<ShadowStyleInterpolation, bool>::listToIn terpolableValue(*value, nonInterpolableData).get(), nonInterpolableData); | |
40 } | |
41 | |
42 static RefPtrWillBeRawPtr<CSSShadowValue> createShadowValue() | |
43 { | |
44 RefPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor(makeRGB A(112, 123, 175, 255)); | |
45 RefPtr<CSSPrimitiveValue> x = CSSPrimitiveValue::create(10, CSSPrimitive Value::CSS_PX); | |
46 RefPtr<CSSPrimitiveValue> y = CSSPrimitiveValue::create(20, CSSPrimitive Value::CSS_PX); | |
47 RefPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(30, CSSPrimit iveValue::CSS_PX); | |
48 RefPtr<CSSPrimitiveValue> spread = CSSPrimitiveValue::create(40, CSSPrim itiveValue::CSS_PX); | |
49 | |
50 return CSSShadowValue::create(x, y, blur, spread, CSSPrimitiveValue::cre ateIdentifier(CSSValueNone), color); | |
51 | |
52 } | |
53 | |
54 static void compareShadowList(RefPtrWillBeRawPtr<CSSValueList> expectedList, RefPtrWillBeRawPtr<CSSValue> actualList) | |
55 { | |
56 ASSERT(actualList->isValueList()); | |
57 | |
58 for (size_t i = 0; i < 10; i++) { | |
59 | |
60 CSSShadowValue* expectedShadow = toCSSShadowValue(expectedList->item (i)); | |
61 CSSShadowValue* actualShadow = toCSSShadowValue(toCSSValueList(*actu alList).item(i)); | |
62 | |
63 EXPECT_EQ(expectedShadow->x->getDoubleValue(), actualShadow->x->getD oubleValue()); | |
64 EXPECT_EQ(expectedShadow->y->getDoubleValue(), actualShadow->y->getD oubleValue()); | |
65 EXPECT_EQ(expectedShadow->blur->getDoubleValue(), actualShadow->blur ->getDoubleValue()); | |
66 EXPECT_EQ(expectedShadow->spread->getDoubleValue(), actualShadow->sp read->getDoubleValue()); | |
67 EXPECT_EQ(expectedShadow->color->getRGBA32Value(), actualShadow->col or->getRGBA32Value()); | |
68 | |
69 EXPECT_EQ(expectedShadow->style->getValueID(), actualShadow->style-> getValueID()); | |
70 } | |
71 } | |
72 }; | |
73 | |
74 TEST_F(ListStyleInterpolationTest, LengthListMultipleValuesTest) | |
75 { | |
76 RefPtrWillBeRawPtr<CSSValueList> expectedList = CSSValueList::createCommaSep arated(); | |
77 for (size_t i = 0; i < 10; i++) { | |
78 RefPtrWillBeRawPtr<CSSPrimitiveValue> lengthValue = CSSPrimitiveValue::c reate(static_cast<double>(i), CSSPrimitiveValue::CSS_PX); | |
79 expectedList->append(lengthValue); | |
80 } | |
81 | |
82 compareLengthLists(expectedList, lengthRoundTrip(expectedList, RangeNonNegat ive)); | |
83 } | |
84 | |
85 TEST_F(ListStyleInterpolationTest, ShadowListMultipleValuesTest) | |
86 { | |
87 RefPtrWillBeRawPtr<CSSValueList> expectedList = CSSValueList::createCommaSep arated(); | |
88 RefPtrWillBeRawPtr<CSSShadowValue> shadowValue = createShadowValue(); | |
89 for (size_t i = 0; i < 10; i++) { | |
90 expectedList->append(shadowValue); | |
91 } | |
92 | |
93 compareShadowList(expectedList, shadowRoundTrip(expectedList)); | |
94 } | |
95 | |
jadeg
2015/01/21 05:36:34
Remove this new line ....
evemj (not active)
2015/01/28 00:41:13
Done.
| |
96 | |
jadeg
2015/01/21 05:36:34
please
evemj (not active)
2015/01/28 00:41:13
Done.
| |
97 } // namespace blink | |
jadeg
2015/01/21 05:36:34
New line
evemj (not active)
2015/01/28 00:41:13
Done.
| |
OLD | NEW |