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/LengthBoxStyleInterpolation.h" | 6 #include "core/animation/LengthBoxStyleInterpolation.h" |
7 | 7 |
8 #include "core/animation/LengthStyleInterpolation.h" | 8 #include "core/animation/LengthStyleInterpolation.h" |
9 #include "core/css/CSSPrimitiveValue.h" | 9 #include "core/css/CSSPrimitiveValue.h" |
10 #include "core/css/Rect.h" | 10 #include "core/css/Rect.h" |
11 #include "core/css/StylePropertySet.h" | 11 #include "core/css/StylePropertySet.h" |
12 | 12 |
13 #include "stdio.h" | |
14 | |
15 #include <gtest/gtest.h> | 13 #include <gtest/gtest.h> |
16 | 14 |
17 namespace blink { | 15 namespace blink { |
18 | 16 |
19 class AnimationLengthBoxStyleInterpolationTest : public ::testing::Test { | 17 class AnimationLengthBoxStyleInterpolationTest : public ::testing::Test { |
20 protected: | 18 protected: |
21 static PassOwnPtrWillBeRawPtr<InterpolableValue> lengthBoxToInterpolableValu
e(const CSSValue& value) | 19 static PassOwnPtrWillBeRawPtr<InterpolableValue> lengthBoxToInterpolableValu
e(const CSSValue& value) |
22 { | 20 { |
23 return LengthBoxStyleInterpolation::lengthBoxtoInterpolableValue(value); | 21 return LengthBoxStyleInterpolation::lengthBoxtoInterpolableValue(value); |
24 } | 22 } |
(...skipping 20 matching lines...) Expand all Loading... |
45 | 43 |
46 EXPECT_EQ(unitType, rect->left()->primitiveType()); | 44 EXPECT_EQ(unitType, rect->left()->primitiveType()); |
47 EXPECT_EQ(unitType, rect->right()->primitiveType()); | 45 EXPECT_EQ(unitType, rect->right()->primitiveType()); |
48 EXPECT_EQ(unitType, rect->top()->primitiveType()); | 46 EXPECT_EQ(unitType, rect->top()->primitiveType()); |
49 EXPECT_EQ(unitType, rect->bottom()->primitiveType()); | 47 EXPECT_EQ(unitType, rect->bottom()->primitiveType()); |
50 } | 48 } |
51 }; | 49 }; |
52 | 50 |
53 TEST_F(AnimationLengthBoxStyleInterpolationTest, ZeroLengthBox) | 51 TEST_F(AnimationLengthBoxStyleInterpolationTest, ZeroLengthBox) |
54 { | 52 { |
55 RefPtr<Rect> rectPx = Rect::create(); | 53 RefPtrWillBeRawPtr<Rect> rectPx = Rect::create(); |
56 rectPx->setLeft(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX)); | 54 rectPx->setLeft(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX)); |
57 rectPx->setRight(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX)); | 55 rectPx->setRight(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX)); |
58 rectPx->setTop(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX)); | 56 rectPx->setTop(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX)); |
59 rectPx->setBottom(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX)); | 57 rectPx->setBottom(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX)); |
60 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(rec
tPx.release())); | 58 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(rec
tPx.release())); |
61 testPrimitiveValue(value, 0, 0, 0, 0, CSSPrimitiveValue::CSS_PX); | 59 testPrimitiveValue(value, 0, 0, 0, 0, CSSPrimitiveValue::CSS_PX); |
62 | 60 |
63 RefPtr<Rect> rectEms = Rect::create(); | 61 RefPtrWillBeRawPtr<Rect> rectEms = Rect::create(); |
64 rectEms->setLeft(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_EMS)); | 62 rectEms->setLeft(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_EMS)); |
65 rectEms->setRight(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_EMS)); | 63 rectEms->setRight(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_EMS)); |
66 rectEms->setTop(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_EMS)); | 64 rectEms->setTop(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_EMS)); |
67 rectEms->setBottom(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_EMS))
; | 65 rectEms->setBottom(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_EMS))
; |
68 | 66 |
69 value = roundTrip(CSSPrimitiveValue::create(rectEms.release())); | 67 value = roundTrip(CSSPrimitiveValue::create(rectEms.release())); |
70 testPrimitiveValue(value, 0, 0, 0, 0, CSSPrimitiveValue::CSS_PX); | 68 testPrimitiveValue(value, 0, 0, 0, 0, CSSPrimitiveValue::CSS_PX); |
71 } | 69 } |
72 | 70 |
73 TEST_F(AnimationLengthBoxStyleInterpolationTest, SingleUnitBox) | 71 TEST_F(AnimationLengthBoxStyleInterpolationTest, SingleUnitBox) |
74 { | 72 { |
75 RefPtr<Rect> rectPx = Rect::create(); | 73 RefPtrWillBeRawPtr<Rect> rectPx = Rect::create(); |
76 rectPx->setLeft(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX)); | 74 rectPx->setLeft(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX)); |
77 rectPx->setRight(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX)); | 75 rectPx->setRight(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX)); |
78 rectPx->setTop(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX)); | 76 rectPx->setTop(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX)); |
79 rectPx->setBottom(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX)); | 77 rectPx->setBottom(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX)); |
80 | 78 |
81 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(rec
tPx.release())); | 79 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(rec
tPx.release())); |
82 testPrimitiveValue(value, 10, 10, 10, 10, CSSPrimitiveValue::CSS_PX); | 80 testPrimitiveValue(value, 10, 10, 10, 10, CSSPrimitiveValue::CSS_PX); |
83 | 81 |
84 RefPtr<Rect> rectPer = Rect::create(); | 82 RefPtrWillBeRawPtr<Rect> rectPer = Rect::create(); |
85 rectPer->setLeft(CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PERCEN
TAGE)); | 83 rectPer->setLeft(CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PERCEN
TAGE)); |
86 rectPer->setRight(CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PERCE
NTAGE)); | 84 rectPer->setRight(CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PERCE
NTAGE)); |
87 rectPer->setTop(CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PERCENT
AGE)); | 85 rectPer->setTop(CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PERCENT
AGE)); |
88 rectPer->setBottom(CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PERC
ENTAGE)); | 86 rectPer->setBottom(CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PERC
ENTAGE)); |
89 | 87 |
90 value = roundTrip(CSSPrimitiveValue::create(rectPer.release())); | 88 value = roundTrip(CSSPrimitiveValue::create(rectPer.release())); |
91 testPrimitiveValue(value, 30, 30, 30, 30, CSSPrimitiveValue::CSS_PERCENTAGE)
; | 89 testPrimitiveValue(value, 30, 30, 30, 30, CSSPrimitiveValue::CSS_PERCENTAGE)
; |
92 | 90 |
93 RefPtr<Rect> rectEms = Rect::create(); | 91 RefPtrWillBeRawPtr<Rect> rectEms = Rect::create(); |
94 rectEms->setLeft(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::CSS_EMS))
; | 92 rectEms->setLeft(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::CSS_EMS))
; |
95 rectEms->setRight(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::CSS_EMS)
); | 93 rectEms->setRight(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::CSS_EMS)
); |
96 rectEms->setTop(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::CSS_EMS)); | 94 rectEms->setTop(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::CSS_EMS)); |
97 rectEms->setBottom(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::CSS_EMS
)); | 95 rectEms->setBottom(CSSPrimitiveValue::create(-10, CSSPrimitiveValue::CSS_EMS
)); |
98 | 96 |
99 value = roundTrip(CSSPrimitiveValue::create(rectEms.release())); | 97 value = roundTrip(CSSPrimitiveValue::create(rectEms.release())); |
100 testPrimitiveValue(value, 0, 0, 0, 0, CSSPrimitiveValue::CSS_EMS); | 98 testPrimitiveValue(value, 0, 0, 0, 0, CSSPrimitiveValue::CSS_EMS); |
101 } | 99 } |
102 | 100 |
103 TEST_F(AnimationLengthBoxStyleInterpolationTest, MultipleValues) | 101 TEST_F(AnimationLengthBoxStyleInterpolationTest, MultipleValues) |
104 { | 102 { |
105 RefPtr<Rect> rectPx = Rect::create(); | 103 RefPtrWillBeRawPtr<Rect> rectPx = Rect::create(); |
106 rectPx->setLeft(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX)); | 104 rectPx->setLeft(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX)); |
107 rectPx->setRight(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX)); | 105 rectPx->setRight(CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX)); |
108 rectPx->setTop(CSSPrimitiveValue::create(20, CSSPrimitiveValue::CSS_PX)); | 106 rectPx->setTop(CSSPrimitiveValue::create(20, CSSPrimitiveValue::CSS_PX)); |
109 rectPx->setBottom(CSSPrimitiveValue::create(40, CSSPrimitiveValue::CSS_PX)); | 107 rectPx->setBottom(CSSPrimitiveValue::create(40, CSSPrimitiveValue::CSS_PX)); |
110 | 108 |
111 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(rec
tPx.release())); | 109 RefPtrWillBeRawPtr<CSSValue> value = roundTrip(CSSPrimitiveValue::create(rec
tPx.release())); |
112 testPrimitiveValue(value, 10, 0, 20, 40, CSSPrimitiveValue::CSS_PX); | 110 testPrimitiveValue(value, 10, 0, 20, 40, CSSPrimitiveValue::CSS_PX); |
113 | 111 |
114 RefPtr<Rect> rectPer = Rect::create(); | 112 RefPtrWillBeRawPtr<Rect> rectPer = Rect::create(); |
115 rectPer->setLeft(CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PERCEN
TAGE)); | 113 rectPer->setLeft(CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PERCEN
TAGE)); |
116 rectPer->setRight(CSSPrimitiveValue::create(-30, CSSPrimitiveValue::CSS_PERC
ENTAGE)); | 114 rectPer->setRight(CSSPrimitiveValue::create(-30, CSSPrimitiveValue::CSS_PERC
ENTAGE)); |
117 rectPer->setTop(CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PERCENT
AGE)); | 115 rectPer->setTop(CSSPrimitiveValue::create(30, CSSPrimitiveValue::CSS_PERCENT
AGE)); |
118 rectPer->setBottom(CSSPrimitiveValue::create(-30, CSSPrimitiveValue::CSS_PER
CENTAGE)); | 116 rectPer->setBottom(CSSPrimitiveValue::create(-30, CSSPrimitiveValue::CSS_PER
CENTAGE)); |
119 | 117 |
120 value = roundTrip(CSSPrimitiveValue::create(rectPer.release())); | 118 value = roundTrip(CSSPrimitiveValue::create(rectPer.release())); |
121 testPrimitiveValue(value, 30, 0, 30, 0, CSSPrimitiveValue::CSS_PERCENTAGE); | 119 testPrimitiveValue(value, 30, 0, 30, 0, CSSPrimitiveValue::CSS_PERCENTAGE); |
122 } | 120 } |
123 | 121 |
124 } | 122 } |
OLD | NEW |