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/Animation.h" | 6 #include "core/animation/Animation.h" |
7 | 7 |
8 #include "bindings/v8/Dictionary.h" | 8 #include "bindings/v8/Dictionary.h" |
9 #include "core/animation/AnimatableLength.h" | 9 #include "core/animation/AnimatableLength.h" |
10 #include "core/animation/AnimationClock.h" | 10 #include "core/animation/AnimationClock.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 class AnimationAnimationV8Test : public AnimationAnimationTest { | 38 class AnimationAnimationV8Test : public AnimationAnimationTest { |
39 protected: | 39 protected: |
40 AnimationAnimationV8Test() | 40 AnimationAnimationV8Test() |
41 : m_isolate(v8::Isolate::GetCurrent()) | 41 : m_isolate(v8::Isolate::GetCurrent()) |
42 , m_scope(V8ExecutionScope::create(m_isolate)) | 42 , m_scope(V8ExecutionScope::create(m_isolate)) |
43 { | 43 { |
44 } | 44 } |
45 | 45 |
46 template<typename T> | 46 template<typename T> |
47 static PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictio
nary> keyframeDictionaryVector, T timingInput, ExceptionState& exceptionState) | 47 static PassRefPtrWillBeRawPtr<Animation> createAnimation(Element* element, V
ector<Dictionary> keyframeDictionaryVector, T timingInput, ExceptionState& excep
tionState) |
48 { | 48 { |
49 return Animation::create(element, EffectInput::convert(element, keyframe
DictionaryVector, exceptionState, true), timingInput); | 49 return Animation::create(element, EffectInput::convert(element, keyframe
DictionaryVector, exceptionState, true), timingInput); |
50 } | 50 } |
51 static PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictio
nary> keyframeDictionaryVector, ExceptionState& exceptionState) | 51 static PassRefPtrWillBeRawPtr<Animation> createAnimation(Element* element, V
ector<Dictionary> keyframeDictionaryVector, ExceptionState& exceptionState) |
52 { | 52 { |
53 return Animation::create(element, EffectInput::convert(element, keyframe
DictionaryVector, exceptionState, true)); | 53 return Animation::create(element, EffectInput::convert(element, keyframe
DictionaryVector, exceptionState, true)); |
54 } | 54 } |
55 | 55 |
56 v8::Isolate* m_isolate; | 56 v8::Isolate* m_isolate; |
57 | 57 |
58 private: | 58 private: |
59 OwnPtr<V8ExecutionScope> m_scope; | 59 OwnPtr<V8ExecutionScope> m_scope; |
60 }; | 60 }; |
61 | 61 |
(...skipping 14 matching lines...) Expand all Loading... |
76 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 76 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
77 | 77 |
78 String value1; | 78 String value1; |
79 ASSERT_TRUE(jsKeyframes[0].get("width", value1)); | 79 ASSERT_TRUE(jsKeyframes[0].get("width", value1)); |
80 ASSERT_EQ("100px", value1); | 80 ASSERT_EQ("100px", value1); |
81 | 81 |
82 String value2; | 82 String value2; |
83 ASSERT_TRUE(jsKeyframes[1].get("width", value2)); | 83 ASSERT_TRUE(jsKeyframes[1].get("width", value2)); |
84 ASSERT_EQ("0px", value2); | 84 ASSERT_EQ("0px", value2); |
85 | 85 |
86 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0,
exceptionState); | 86 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, 0, exceptionState); |
87 | 87 |
88 Element* target = animation->target(); | 88 Element* target = animation->target(); |
89 EXPECT_EQ(*element.get(), *target); | 89 EXPECT_EQ(*element.get(), *target); |
90 | 90 |
91 const KeyframeVector keyframes = toKeyframeEffectModelBase(animation->effect
())->getFrames(); | 91 const KeyframeVector keyframes = toKeyframeEffectModelBase(animation->effect
())->getFrames(); |
92 | 92 |
93 EXPECT_EQ(0, keyframes[0]->offset()); | 93 EXPECT_EQ(0, keyframes[0]->offset()); |
94 EXPECT_EQ(1, keyframes[1]->offset()); | 94 EXPECT_EQ(1, keyframes[1]->offset()); |
95 | 95 |
96 const CSSValue* keyframe1Width = toStringKeyframe(keyframes[0].get())->prope
rtyValue(CSSPropertyWidth); | 96 const CSSValue* keyframe1Width = toStringKeyframe(keyframes[0].get())->prope
rtyValue(CSSPropertyWidth); |
97 const CSSValue* keyframe2Width = toStringKeyframe(keyframes[1].get())->prope
rtyValue(CSSPropertyWidth); | 97 const CSSValue* keyframe2Width = toStringKeyframe(keyframes[1].get())->prope
rtyValue(CSSPropertyWidth); |
98 ASSERT(keyframe1Width); | 98 ASSERT(keyframe1Width); |
99 ASSERT(keyframe2Width); | 99 ASSERT(keyframe2Width); |
100 | 100 |
101 EXPECT_EQ("100px", keyframe1Width->cssText()); | 101 EXPECT_EQ("100px", keyframe1Width->cssText()); |
102 EXPECT_EQ("0px", keyframe2Width->cssText()); | 102 EXPECT_EQ("0px", keyframe2Width->cssText()); |
103 | 103 |
104 EXPECT_EQ(*(CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Eas
eInOut)), *keyframes[0]->easing()); | 104 EXPECT_EQ(*(CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Eas
eInOut)), *keyframes[0]->easing()); |
105 EXPECT_EQ(*(CubicBezierTimingFunction::create(1, 1, 0.3, 0.3).get()), *keyfr
ames[1]->easing()); | 105 EXPECT_EQ(*(CubicBezierTimingFunction::create(1, 1, 0.3, 0.3).get()), *keyfr
ames[1]->easing()); |
106 } | 106 } |
107 | 107 |
108 TEST_F(AnimationAnimationV8Test, CanSetDuration) | 108 TEST_F(AnimationAnimationV8Test, CanSetDuration) |
109 { | 109 { |
110 Vector<Dictionary, 0> jsKeyframes; | 110 Vector<Dictionary, 0> jsKeyframes; |
111 double duration = 2000; | 111 double duration = 2000; |
112 | 112 |
113 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, du
ration, exceptionState); | 113 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, duration, exceptionState); |
114 | 114 |
115 EXPECT_EQ(duration / 1000, animation->specifiedTiming().iterationDuration); | 115 EXPECT_EQ(duration / 1000, animation->specifiedTiming().iterationDuration); |
116 } | 116 } |
117 | 117 |
118 TEST_F(AnimationAnimationV8Test, CanOmitSpecifiedDuration) | 118 TEST_F(AnimationAnimationV8Test, CanOmitSpecifiedDuration) |
119 { | 119 { |
120 Vector<Dictionary, 0> jsKeyframes; | 120 Vector<Dictionary, 0> jsKeyframes; |
121 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, ex
ceptionState); | 121 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, exceptionState); |
122 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); | 122 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); |
123 } | 123 } |
124 | 124 |
125 TEST_F(AnimationAnimationV8Test, NegativeDurationIsAuto) | 125 TEST_F(AnimationAnimationV8Test, NegativeDurationIsAuto) |
126 { | 126 { |
127 Vector<Dictionary, 0> jsKeyframes; | 127 Vector<Dictionary, 0> jsKeyframes; |
128 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, -2
, exceptionState); | 128 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, -2, exceptionState); |
129 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); | 129 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); |
130 } | 130 } |
131 | 131 |
132 TEST_F(AnimationAnimationV8Test, MismatchedKeyframePropertyRaisesException) | 132 TEST_F(AnimationAnimationV8Test, MismatchedKeyframePropertyRaisesException) |
133 { | 133 { |
134 Vector<Dictionary> jsKeyframes; | 134 Vector<Dictionary> jsKeyframes; |
135 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); | 135 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); |
136 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); | 136 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); |
137 | 137 |
138 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); | 138 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); |
139 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); | 139 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); |
140 | 140 |
141 // Height property appears only in keyframe2 | 141 // Height property appears only in keyframe2 |
142 setV8ObjectPropertyAsString(keyframe2, "height", "100px"); | 142 setV8ObjectPropertyAsString(keyframe2, "height", "100px"); |
143 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); | 143 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); |
144 setV8ObjectPropertyAsString(keyframe2, "offset", "1"); | 144 setV8ObjectPropertyAsString(keyframe2, "offset", "1"); |
145 | 145 |
146 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); | 146 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); |
147 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 147 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
148 | 148 |
149 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0,
exceptionState); | 149 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, 0, exceptionState); |
150 | 150 |
151 EXPECT_TRUE(exceptionState.hadException()); | 151 EXPECT_TRUE(exceptionState.hadException()); |
152 EXPECT_EQ(NotSupportedError, exceptionState.code()); | 152 EXPECT_EQ(NotSupportedError, exceptionState.code()); |
153 } | 153 } |
154 | 154 |
155 TEST_F(AnimationAnimationV8Test, MissingOffsetZeroRaisesException) | 155 TEST_F(AnimationAnimationV8Test, MissingOffsetZeroRaisesException) |
156 { | 156 { |
157 Vector<Dictionary> jsKeyframes; | 157 Vector<Dictionary> jsKeyframes; |
158 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); | 158 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); |
159 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); | 159 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); |
160 | 160 |
161 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); | 161 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); |
162 setV8ObjectPropertyAsString(keyframe1, "offset", "0.1"); | 162 setV8ObjectPropertyAsString(keyframe1, "offset", "0.1"); |
163 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); | 163 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); |
164 setV8ObjectPropertyAsString(keyframe2, "offset", "1"); | 164 setV8ObjectPropertyAsString(keyframe2, "offset", "1"); |
165 | 165 |
166 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); | 166 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); |
167 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 167 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
168 | 168 |
169 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0,
exceptionState); | 169 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, 0, exceptionState); |
170 | 170 |
171 EXPECT_TRUE(exceptionState.hadException()); | 171 EXPECT_TRUE(exceptionState.hadException()); |
172 EXPECT_EQ(NotSupportedError, exceptionState.code()); | 172 EXPECT_EQ(NotSupportedError, exceptionState.code()); |
173 } | 173 } |
174 | 174 |
175 TEST_F(AnimationAnimationV8Test, MissingOffsetOneRaisesException) | 175 TEST_F(AnimationAnimationV8Test, MissingOffsetOneRaisesException) |
176 { | 176 { |
177 Vector<Dictionary> jsKeyframes; | 177 Vector<Dictionary> jsKeyframes; |
178 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); | 178 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); |
179 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); | 179 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); |
180 | 180 |
181 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); | 181 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); |
182 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); | 182 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); |
183 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); | 183 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); |
184 setV8ObjectPropertyAsString(keyframe2, "offset", "0.1"); | 184 setV8ObjectPropertyAsString(keyframe2, "offset", "0.1"); |
185 | 185 |
186 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); | 186 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); |
187 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 187 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
188 | 188 |
189 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0,
exceptionState); | 189 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, 0, exceptionState); |
190 | 190 |
191 EXPECT_TRUE(exceptionState.hadException()); | 191 EXPECT_TRUE(exceptionState.hadException()); |
192 EXPECT_EQ(NotSupportedError, exceptionState.code()); | 192 EXPECT_EQ(NotSupportedError, exceptionState.code()); |
193 } | 193 } |
194 | 194 |
195 TEST_F(AnimationAnimationV8Test, MissingOffsetZeroAndOneRaisesException) | 195 TEST_F(AnimationAnimationV8Test, MissingOffsetZeroAndOneRaisesException) |
196 { | 196 { |
197 Vector<Dictionary> jsKeyframes; | 197 Vector<Dictionary> jsKeyframes; |
198 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); | 198 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); |
199 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); | 199 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); |
200 | 200 |
201 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); | 201 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); |
202 setV8ObjectPropertyAsString(keyframe1, "offset", "0.1"); | 202 setV8ObjectPropertyAsString(keyframe1, "offset", "0.1"); |
203 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); | 203 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); |
204 setV8ObjectPropertyAsString(keyframe2, "offset", "0.2"); | 204 setV8ObjectPropertyAsString(keyframe2, "offset", "0.2"); |
205 | 205 |
206 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); | 206 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); |
207 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 207 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
208 | 208 |
209 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0,
exceptionState); | 209 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, 0, exceptionState); |
210 | 210 |
211 EXPECT_TRUE(exceptionState.hadException()); | 211 EXPECT_TRUE(exceptionState.hadException()); |
212 EXPECT_EQ(NotSupportedError, exceptionState.code()); | 212 EXPECT_EQ(NotSupportedError, exceptionState.code()); |
213 } | 213 } |
214 | 214 |
215 TEST_F(AnimationAnimationV8Test, SpecifiedGetters) | 215 TEST_F(AnimationAnimationV8Test, SpecifiedGetters) |
216 { | 216 { |
217 Vector<Dictionary, 0> jsKeyframes; | 217 Vector<Dictionary, 0> jsKeyframes; |
218 | 218 |
219 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); | 219 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); |
220 setV8ObjectPropertyAsNumber(timingInput, "delay", 2); | 220 setV8ObjectPropertyAsNumber(timingInput, "delay", 2); |
221 setV8ObjectPropertyAsNumber(timingInput, "endDelay", 0.5); | 221 setV8ObjectPropertyAsNumber(timingInput, "endDelay", 0.5); |
222 setV8ObjectPropertyAsString(timingInput, "fill", "backwards"); | 222 setV8ObjectPropertyAsString(timingInput, "fill", "backwards"); |
223 setV8ObjectPropertyAsNumber(timingInput, "iterationStart", 2); | 223 setV8ObjectPropertyAsNumber(timingInput, "iterationStart", 2); |
224 setV8ObjectPropertyAsNumber(timingInput, "iterations", 10); | 224 setV8ObjectPropertyAsNumber(timingInput, "iterations", 10); |
225 setV8ObjectPropertyAsNumber(timingInput, "playbackRate", 2); | 225 setV8ObjectPropertyAsNumber(timingInput, "playbackRate", 2); |
226 setV8ObjectPropertyAsString(timingInput, "direction", "reverse"); | 226 setV8ObjectPropertyAsString(timingInput, "direction", "reverse"); |
227 setV8ObjectPropertyAsString(timingInput, "easing", "step-start"); | 227 setV8ObjectPropertyAsString(timingInput, "easing", "step-start"); |
228 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti
mingInput), m_isolate); | 228 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti
mingInput), m_isolate); |
229 | 229 |
230 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, ti
mingInputDictionary, exceptionState); | 230 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, timingInputDictionary, exceptionState); |
231 | 231 |
232 RefPtr<TimedItemTiming> specified = animation->timing(); | 232 RefPtrWillBeRawPtr<TimedItemTiming> specified = animation->timing(); |
233 EXPECT_EQ(2, specified->delay()); | 233 EXPECT_EQ(2, specified->delay()); |
234 EXPECT_EQ(0.5, specified->endDelay()); | 234 EXPECT_EQ(0.5, specified->endDelay()); |
235 EXPECT_EQ("backwards", specified->fill()); | 235 EXPECT_EQ("backwards", specified->fill()); |
236 EXPECT_EQ(2, specified->iterationStart()); | 236 EXPECT_EQ(2, specified->iterationStart()); |
237 EXPECT_EQ(10, specified->iterations()); | 237 EXPECT_EQ(10, specified->iterations()); |
238 EXPECT_EQ(2, specified->playbackRate()); | 238 EXPECT_EQ(2, specified->playbackRate()); |
239 EXPECT_EQ("reverse", specified->direction()); | 239 EXPECT_EQ("reverse", specified->direction()); |
240 EXPECT_EQ("step-start", specified->easing()); | 240 EXPECT_EQ("step-start", specified->easing()); |
241 } | 241 } |
242 | 242 |
243 TEST_F(AnimationAnimationV8Test, SpecifiedDurationGetter) | 243 TEST_F(AnimationAnimationV8Test, SpecifiedDurationGetter) |
244 { | 244 { |
245 Vector<Dictionary, 0> jsKeyframes; | 245 Vector<Dictionary, 0> jsKeyframes; |
246 | 246 |
247 v8::Handle<v8::Object> timingInputWithDuration = v8::Object::New(m_isolate); | 247 v8::Handle<v8::Object> timingInputWithDuration = v8::Object::New(m_isolate); |
248 setV8ObjectPropertyAsNumber(timingInputWithDuration, "duration", 2.5); | 248 setV8ObjectPropertyAsNumber(timingInputWithDuration, "duration", 2.5); |
249 Dictionary timingInputDictionaryWithDuration = Dictionary(v8::Handle<v8::Val
ue>::Cast(timingInputWithDuration), m_isolate); | 249 Dictionary timingInputDictionaryWithDuration = Dictionary(v8::Handle<v8::Val
ue>::Cast(timingInputWithDuration), m_isolate); |
250 | 250 |
251 RefPtr<Animation> animationWithDuration = createAnimation(element.get(), jsK
eyframes, timingInputDictionaryWithDuration, exceptionState); | 251 RefPtrWillBeRawPtr<Animation> animationWithDuration = createAnimation(elemen
t.get(), jsKeyframes, timingInputDictionaryWithDuration, exceptionState); |
252 | 252 |
253 RefPtr<TimedItemTiming> specifiedWithDuration = animationWithDuration->timin
g(); | 253 RefPtrWillBeRawPtr<TimedItemTiming> specifiedWithDuration = animationWithDur
ation->timing(); |
254 bool isNumber = false; | 254 bool isNumber = false; |
255 double numberDuration = std::numeric_limits<double>::quiet_NaN(); | 255 double numberDuration = std::numeric_limits<double>::quiet_NaN(); |
256 bool isString = false; | 256 bool isString = false; |
257 String stringDuration = ""; | 257 String stringDuration = ""; |
258 specifiedWithDuration->getDuration("duration", isNumber, numberDuration, isS
tring, stringDuration); | 258 specifiedWithDuration->getDuration("duration", isNumber, numberDuration, isS
tring, stringDuration); |
259 EXPECT_TRUE(isNumber); | 259 EXPECT_TRUE(isNumber); |
260 EXPECT_EQ(2.5, numberDuration); | 260 EXPECT_EQ(2.5, numberDuration); |
261 EXPECT_FALSE(isString); | 261 EXPECT_FALSE(isString); |
262 EXPECT_EQ("", stringDuration); | 262 EXPECT_EQ("", stringDuration); |
263 | 263 |
264 | 264 |
265 v8::Handle<v8::Object> timingInputNoDuration = v8::Object::New(m_isolate); | 265 v8::Handle<v8::Object> timingInputNoDuration = v8::Object::New(m_isolate); |
266 Dictionary timingInputDictionaryNoDuration = Dictionary(v8::Handle<v8::Value
>::Cast(timingInputNoDuration), m_isolate); | 266 Dictionary timingInputDictionaryNoDuration = Dictionary(v8::Handle<v8::Value
>::Cast(timingInputNoDuration), m_isolate); |
267 | 267 |
268 RefPtr<Animation> animationNoDuration = createAnimation(element.get(), jsKey
frames, timingInputDictionaryNoDuration, exceptionState); | 268 RefPtrWillBeRawPtr<Animation> animationNoDuration = createAnimation(element.
get(), jsKeyframes, timingInputDictionaryNoDuration, exceptionState); |
269 | 269 |
270 RefPtr<TimedItemTiming> specifiedNoDuration = animationNoDuration->timing(); | 270 RefPtrWillBeRawPtr<TimedItemTiming> specifiedNoDuration = animationNoDuratio
n->timing(); |
271 isNumber = false; | 271 isNumber = false; |
272 numberDuration = std::numeric_limits<double>::quiet_NaN(); | 272 numberDuration = std::numeric_limits<double>::quiet_NaN(); |
273 isString = false; | 273 isString = false; |
274 stringDuration = ""; | 274 stringDuration = ""; |
275 specifiedNoDuration->getDuration("duration", isNumber, numberDuration, isStr
ing, stringDuration); | 275 specifiedNoDuration->getDuration("duration", isNumber, numberDuration, isStr
ing, stringDuration); |
276 EXPECT_FALSE(isNumber); | 276 EXPECT_FALSE(isNumber); |
277 EXPECT_TRUE(std::isnan(numberDuration)); | 277 EXPECT_TRUE(std::isnan(numberDuration)); |
278 EXPECT_TRUE(isString); | 278 EXPECT_TRUE(isString); |
279 EXPECT_EQ("auto", stringDuration); | 279 EXPECT_EQ("auto", stringDuration); |
280 } | 280 } |
281 | 281 |
282 TEST_F(AnimationAnimationV8Test, SpecifiedSetters) | 282 TEST_F(AnimationAnimationV8Test, SpecifiedSetters) |
283 { | 283 { |
284 Vector<Dictionary, 0> jsKeyframes; | 284 Vector<Dictionary, 0> jsKeyframes; |
285 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); | 285 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); |
286 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti
mingInput), m_isolate); | 286 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti
mingInput), m_isolate); |
287 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, ti
mingInputDictionary, exceptionState); | 287 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, timingInputDictionary, exceptionState); |
288 | 288 |
289 RefPtr<TimedItemTiming> specified = animation->timing(); | 289 RefPtrWillBeRawPtr<TimedItemTiming> specified = animation->timing(); |
290 | 290 |
291 EXPECT_EQ(0, specified->delay()); | 291 EXPECT_EQ(0, specified->delay()); |
292 specified->setDelay(2); | 292 specified->setDelay(2); |
293 EXPECT_EQ(2, specified->delay()); | 293 EXPECT_EQ(2, specified->delay()); |
294 | 294 |
295 EXPECT_EQ(0, specified->endDelay()); | 295 EXPECT_EQ(0, specified->endDelay()); |
296 specified->setEndDelay(0.5); | 296 specified->setEndDelay(0.5); |
297 EXPECT_EQ(0.5, specified->endDelay()); | 297 EXPECT_EQ(0.5, specified->endDelay()); |
298 | 298 |
299 EXPECT_EQ("auto", specified->fill()); | 299 EXPECT_EQ("auto", specified->fill()); |
(...skipping 19 matching lines...) Expand all Loading... |
319 EXPECT_EQ("linear", specified->easing()); | 319 EXPECT_EQ("linear", specified->easing()); |
320 specified->setEasing("step-start"); | 320 specified->setEasing("step-start"); |
321 EXPECT_EQ("step-start", specified->easing()); | 321 EXPECT_EQ("step-start", specified->easing()); |
322 } | 322 } |
323 | 323 |
324 TEST_F(AnimationAnimationV8Test, SetSpecifiedDuration) | 324 TEST_F(AnimationAnimationV8Test, SetSpecifiedDuration) |
325 { | 325 { |
326 Vector<Dictionary, 0> jsKeyframes; | 326 Vector<Dictionary, 0> jsKeyframes; |
327 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); | 327 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); |
328 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti
mingInput), m_isolate); | 328 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti
mingInput), m_isolate); |
329 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, ti
mingInputDictionary, exceptionState); | 329 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, timingInputDictionary, exceptionState); |
330 | 330 |
331 RefPtr<TimedItemTiming> specified = animation->timing(); | 331 RefPtrWillBeRawPtr<TimedItemTiming> specified = animation->timing(); |
332 | 332 |
333 bool isNumber = false; | 333 bool isNumber = false; |
334 double numberDuration = std::numeric_limits<double>::quiet_NaN(); | 334 double numberDuration = std::numeric_limits<double>::quiet_NaN(); |
335 bool isString = false; | 335 bool isString = false; |
336 String stringDuration = ""; | 336 String stringDuration = ""; |
337 specified->getDuration("duration", isNumber, numberDuration, isString, strin
gDuration); | 337 specified->getDuration("duration", isNumber, numberDuration, isString, strin
gDuration); |
338 EXPECT_FALSE(isNumber); | 338 EXPECT_FALSE(isNumber); |
339 EXPECT_TRUE(std::isnan(numberDuration)); | 339 EXPECT_TRUE(std::isnan(numberDuration)); |
340 EXPECT_TRUE(isString); | 340 EXPECT_TRUE(isString); |
341 EXPECT_EQ("auto", stringDuration); | 341 EXPECT_EQ("auto", stringDuration); |
(...skipping 10 matching lines...) Expand all Loading... |
352 EXPECT_EQ("", stringDuration); | 352 EXPECT_EQ("", stringDuration); |
353 } | 353 } |
354 | 354 |
355 TEST_F(AnimationAnimationTest, TimeToEffectChange) | 355 TEST_F(AnimationAnimationTest, TimeToEffectChange) |
356 { | 356 { |
357 Timing timing; | 357 Timing timing; |
358 timing.iterationDuration = 100; | 358 timing.iterationDuration = 100; |
359 timing.startDelay = 100; | 359 timing.startDelay = 100; |
360 timing.endDelay = 100; | 360 timing.endDelay = 100; |
361 timing.fillMode = Timing::FillModeNone; | 361 timing.fillMode = Timing::FillModeNone; |
362 RefPtr<Animation> animation = Animation::create(0, nullptr, timing); | 362 RefPtrWillBeRawPtr<Animation> animation = Animation::create(0, nullptr, timi
ng); |
363 RefPtr<AnimationPlayer> player = document->timeline().play(animation.get()); | 363 RefPtrWillBeRawPtr<AnimationPlayer> player = document->timeline().play(anima
tion.get()); |
364 double inf = std::numeric_limits<double>::infinity(); | 364 double inf = std::numeric_limits<double>::infinity(); |
365 | 365 |
366 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); | 366 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); |
367 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); | 367 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); |
368 | 368 |
369 player->setCurrentTimeInternal(100); | 369 player->setCurrentTimeInternal(100); |
370 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); | 370 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); |
371 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 371 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
372 | 372 |
373 player->setCurrentTimeInternal(199); | 373 player->setCurrentTimeInternal(199); |
(...skipping 11 matching lines...) Expand all Loading... |
385 } | 385 } |
386 | 386 |
387 TEST_F(AnimationAnimationTest, TimeToEffectChangeWithPlaybackRate) | 387 TEST_F(AnimationAnimationTest, TimeToEffectChangeWithPlaybackRate) |
388 { | 388 { |
389 Timing timing; | 389 Timing timing; |
390 timing.iterationDuration = 100; | 390 timing.iterationDuration = 100; |
391 timing.startDelay = 100; | 391 timing.startDelay = 100; |
392 timing.endDelay = 100; | 392 timing.endDelay = 100; |
393 timing.playbackRate = 2; | 393 timing.playbackRate = 2; |
394 timing.fillMode = Timing::FillModeNone; | 394 timing.fillMode = Timing::FillModeNone; |
395 RefPtr<Animation> animation = Animation::create(0, nullptr, timing); | 395 RefPtrWillBeRawPtr<Animation> animation = Animation::create(0, nullptr, timi
ng); |
396 RefPtr<AnimationPlayer> player = document->timeline().play(animation.get()); | 396 RefPtrWillBeRawPtr<AnimationPlayer> player = document->timeline().play(anima
tion.get()); |
397 double inf = std::numeric_limits<double>::infinity(); | 397 double inf = std::numeric_limits<double>::infinity(); |
398 | 398 |
399 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); | 399 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); |
400 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); | 400 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); |
401 | 401 |
402 player->setCurrentTimeInternal(100); | 402 player->setCurrentTimeInternal(100); |
403 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); | 403 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); |
404 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 404 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
405 | 405 |
406 player->setCurrentTimeInternal(149); | 406 player->setCurrentTimeInternal(149); |
(...skipping 11 matching lines...) Expand all Loading... |
418 } | 418 } |
419 | 419 |
420 TEST_F(AnimationAnimationTest, TimeToEffectChangeWithNegativePlaybackRate) | 420 TEST_F(AnimationAnimationTest, TimeToEffectChangeWithNegativePlaybackRate) |
421 { | 421 { |
422 Timing timing; | 422 Timing timing; |
423 timing.iterationDuration = 100; | 423 timing.iterationDuration = 100; |
424 timing.startDelay = 100; | 424 timing.startDelay = 100; |
425 timing.endDelay = 100; | 425 timing.endDelay = 100; |
426 timing.playbackRate = -2; | 426 timing.playbackRate = -2; |
427 timing.fillMode = Timing::FillModeNone; | 427 timing.fillMode = Timing::FillModeNone; |
428 RefPtr<Animation> animation = Animation::create(0, nullptr, timing); | 428 RefPtrWillBeRawPtr<Animation> animation = Animation::create(0, nullptr, timi
ng); |
429 RefPtr<AnimationPlayer> player = document->timeline().play(animation.get()); | 429 RefPtrWillBeRawPtr<AnimationPlayer> player = document->timeline().play(anima
tion.get()); |
430 double inf = std::numeric_limits<double>::infinity(); | 430 double inf = std::numeric_limits<double>::infinity(); |
431 | 431 |
432 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); | 432 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); |
433 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); | 433 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); |
434 | 434 |
435 player->setCurrentTimeInternal(100); | 435 player->setCurrentTimeInternal(100); |
436 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); | 436 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); |
437 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 437 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
438 | 438 |
439 player->setCurrentTimeInternal(149); | 439 player->setCurrentTimeInternal(149); |
440 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); | 440 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); |
441 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 441 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
442 | 442 |
443 player->setCurrentTimeInternal(150); | 443 player->setCurrentTimeInternal(150); |
444 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); | 444 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); |
445 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 445 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
446 | 446 |
447 player->setCurrentTimeInternal(200); | 447 player->setCurrentTimeInternal(200); |
448 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); | 448 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); |
449 EXPECT_EQ(50, animation->timeToReverseEffectChange()); | 449 EXPECT_EQ(50, animation->timeToReverseEffectChange()); |
450 } | 450 } |
451 | 451 |
452 TEST_F(AnimationAnimationTest, ElementDestructorClearsAnimationTarget) | 452 TEST_F(AnimationAnimationTest, ElementDestructorClearsAnimationTarget) |
453 { | 453 { |
454 // This test expects incorrect behaviour should be removed once Element | 454 // This test expects incorrect behaviour should be removed once Element |
455 // and Animation are moved to Oilpan. See crbug.com/362404 for context. | 455 // and Animation are moved to Oilpan. See crbug.com/362404 for context. |
456 Timing timing; | 456 Timing timing; |
457 timing.iterationDuration = 5; | 457 timing.iterationDuration = 5; |
458 RefPtr<Animation> animation = Animation::create(element.get(), nullptr, timi
ng); | 458 RefPtrWillBeRawPtr<Animation> animation = Animation::create(element.get(), n
ullptr, timing); |
459 EXPECT_EQ(element.get(), animation->target()); | 459 EXPECT_EQ(element.get(), animation->target()); |
460 RefPtr<AnimationPlayer> player = document->timeline().play(animation.get()); | 460 RefPtrWillBeRawPtr<AnimationPlayer> player = document->timeline().play(anima
tion.get()); |
461 document.clear(); | 461 document.clear(); |
462 element.clear(); | 462 element.clear(); |
463 Heap::collectAllGarbage(); | 463 Heap::collectAllGarbage(); |
464 EXPECT_EQ(0, animation->target()); | 464 EXPECT_EQ(0, animation->target()); |
465 } | 465 } |
466 | 466 |
467 } // namespace WebCore | 467 } // namespace WebCore |
OLD | NEW |