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/KeyframeEffect.h" | 6 #include "core/animation/KeyframeEffect.h" |
7 | 7 |
8 #include "bindings/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.h" |
9 #include "bindings/core/v8/UnionTypesCore.h" | 9 #include "bindings/core/v8/UnionTypesCore.h" |
10 #include "bindings/core/v8/V8BindingForTesting.h" | 10 #include "bindings/core/v8/V8BindingForTesting.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 class AnimationKeyframeEffectV8Test : public KeyframeEffectTest { | 44 class AnimationKeyframeEffectV8Test : public KeyframeEffectTest { |
45 protected: | 45 protected: |
46 AnimationKeyframeEffectV8Test() | 46 AnimationKeyframeEffectV8Test() |
47 : m_isolate(v8::Isolate::GetCurrent()) | 47 : m_isolate(v8::Isolate::GetCurrent()) |
48 , m_scope(m_isolate) | 48 , m_scope(m_isolate) |
49 { | 49 { |
50 } | 50 } |
51 | 51 |
52 template<typename T> | 52 template<typename T> |
53 static PassRefPtrWillBeRawPtr<KeyframeEffect> createAnimation(Element* eleme
nt, Vector<Dictionary> keyframeDictionaryVector, T timingInput, ExceptionState&
exceptionState) | 53 static KeyframeEffect* createAnimation(Element* element, Vector<Dictionary>
keyframeDictionaryVector, T timingInput, ExceptionState& exceptionState) |
54 { | 54 { |
55 return KeyframeEffect::create(element, keyframeDictionaryVector, timingI
nput, exceptionState); | 55 return KeyframeEffect::create(element, keyframeDictionaryVector, timingI
nput, exceptionState); |
56 } | 56 } |
57 static PassRefPtrWillBeRawPtr<KeyframeEffect> createAnimation(Element* eleme
nt, Vector<Dictionary> keyframeDictionaryVector, ExceptionState& exceptionState) | 57 static KeyframeEffect* createAnimation(Element* element, Vector<Dictionary>
keyframeDictionaryVector, ExceptionState& exceptionState) |
58 { | 58 { |
59 return KeyframeEffect::create(element, keyframeDictionaryVector, excepti
onState); | 59 return KeyframeEffect::create(element, keyframeDictionaryVector, excepti
onState); |
60 } | 60 } |
61 | 61 |
62 v8::Isolate* m_isolate; | 62 v8::Isolate* m_isolate; |
63 | 63 |
64 private: | 64 private: |
65 V8TestingScope m_scope; | 65 V8TestingScope m_scope; |
66 }; | 66 }; |
67 | 67 |
(...skipping 14 matching lines...) Expand all Loading... |
82 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState)); | 82 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState)); |
83 | 83 |
84 String value1; | 84 String value1; |
85 ASSERT_TRUE(DictionaryHelper::get(jsKeyframes[0], "width", value1)); | 85 ASSERT_TRUE(DictionaryHelper::get(jsKeyframes[0], "width", value1)); |
86 ASSERT_EQ("100px", value1); | 86 ASSERT_EQ("100px", value1); |
87 | 87 |
88 String value2; | 88 String value2; |
89 ASSERT_TRUE(DictionaryHelper::get(jsKeyframes[1], "width", value2)); | 89 ASSERT_TRUE(DictionaryHelper::get(jsKeyframes[1], "width", value2)); |
90 ASSERT_EQ("0px", value2); | 90 ASSERT_EQ("0px", value2); |
91 | 91 |
92 RefPtrWillBeRawPtr<KeyframeEffect> animation = createAnimation(element.get()
, jsKeyframes, 0, exceptionState); | 92 KeyframeEffect* animation = createAnimation(element.get(), jsKeyframes, 0, e
xceptionState); |
93 | 93 |
94 Element* target = animation->target(); | 94 Element* target = animation->target(); |
95 EXPECT_EQ(*element.get(), *target); | 95 EXPECT_EQ(*element.get(), *target); |
96 | 96 |
97 const KeyframeVector keyframes = toKeyframeEffectModelBase(animation->model(
))->getFrames(); | 97 const KeyframeVector keyframes = toKeyframeEffectModelBase(animation->model(
))->getFrames(); |
98 | 98 |
99 EXPECT_EQ(0, keyframes[0]->offset()); | 99 EXPECT_EQ(0, keyframes[0]->offset()); |
100 EXPECT_EQ(1, keyframes[1]->offset()); | 100 EXPECT_EQ(1, keyframes[1]->offset()); |
101 | 101 |
102 const CSSValue* keyframe1Width = toStringKeyframe(keyframes[0].get())->cssPr
opertyValue(CSSPropertyWidth); | 102 const CSSValue* keyframe1Width = toStringKeyframe(keyframes[0].get())->cssPr
opertyValue(CSSPropertyWidth); |
103 const CSSValue* keyframe2Width = toStringKeyframe(keyframes[1].get())->cssPr
opertyValue(CSSPropertyWidth); | 103 const CSSValue* keyframe2Width = toStringKeyframe(keyframes[1].get())->cssPr
opertyValue(CSSPropertyWidth); |
104 ASSERT(keyframe1Width); | 104 ASSERT(keyframe1Width); |
105 ASSERT(keyframe2Width); | 105 ASSERT(keyframe2Width); |
106 | 106 |
107 EXPECT_EQ("100px", keyframe1Width->cssText()); | 107 EXPECT_EQ("100px", keyframe1Width->cssText()); |
108 EXPECT_EQ("0px", keyframe2Width->cssText()); | 108 EXPECT_EQ("0px", keyframe2Width->cssText()); |
109 | 109 |
110 EXPECT_EQ(*(CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Eas
eInOut)), keyframes[0]->easing()); | 110 EXPECT_EQ(*(CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Eas
eInOut)), keyframes[0]->easing()); |
111 EXPECT_EQ(*(CubicBezierTimingFunction::create(1, 1, 0.3, 0.3).get()), keyfra
mes[1]->easing()); | 111 EXPECT_EQ(*(CubicBezierTimingFunction::create(1, 1, 0.3, 0.3).get()), keyfra
mes[1]->easing()); |
112 } | 112 } |
113 | 113 |
114 TEST_F(AnimationKeyframeEffectV8Test, CanSetDuration) | 114 TEST_F(AnimationKeyframeEffectV8Test, CanSetDuration) |
115 { | 115 { |
116 Vector<Dictionary, 0> jsKeyframes; | 116 Vector<Dictionary, 0> jsKeyframes; |
117 double duration = 2000; | 117 double duration = 2000; |
118 | 118 |
119 RefPtrWillBeRawPtr<KeyframeEffect> animation = createAnimation(element.get()
, jsKeyframes, duration, exceptionState); | 119 KeyframeEffect* animation = createAnimation(element.get(), jsKeyframes, dura
tion, exceptionState); |
120 | 120 |
121 EXPECT_EQ(duration / 1000, animation->specifiedTiming().iterationDuration); | 121 EXPECT_EQ(duration / 1000, animation->specifiedTiming().iterationDuration); |
122 } | 122 } |
123 | 123 |
124 TEST_F(AnimationKeyframeEffectV8Test, CanOmitSpecifiedDuration) | 124 TEST_F(AnimationKeyframeEffectV8Test, CanOmitSpecifiedDuration) |
125 { | 125 { |
126 Vector<Dictionary, 0> jsKeyframes; | 126 Vector<Dictionary, 0> jsKeyframes; |
127 RefPtrWillBeRawPtr<KeyframeEffect> animation = createAnimation(element.get()
, jsKeyframes, exceptionState); | 127 KeyframeEffect* animation = createAnimation(element.get(), jsKeyframes, exce
ptionState); |
128 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); | 128 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); |
129 } | 129 } |
130 | 130 |
131 TEST_F(AnimationKeyframeEffectV8Test, NegativeDurationIsAuto) | 131 TEST_F(AnimationKeyframeEffectV8Test, NegativeDurationIsAuto) |
132 { | 132 { |
133 Vector<Dictionary, 0> jsKeyframes; | 133 Vector<Dictionary, 0> jsKeyframes; |
134 RefPtrWillBeRawPtr<KeyframeEffect> animation = createAnimation(element.get()
, jsKeyframes, -2, exceptionState); | 134 KeyframeEffect* animation = createAnimation(element.get(), jsKeyframes, -2,
exceptionState); |
135 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); | 135 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); |
136 } | 136 } |
137 | 137 |
138 TEST_F(AnimationKeyframeEffectV8Test, MismatchedKeyframePropertyRaisesException) | 138 TEST_F(AnimationKeyframeEffectV8Test, MismatchedKeyframePropertyRaisesException) |
139 { | 139 { |
140 Vector<Dictionary> jsKeyframes; | 140 Vector<Dictionary> jsKeyframes; |
141 v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate); | 141 v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate); |
142 v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate); | 142 v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate); |
143 | 143 |
144 setV8ObjectPropertyAsString(m_isolate, keyframe1, "width", "100px"); | 144 setV8ObjectPropertyAsString(m_isolate, keyframe1, "width", "100px"); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "endDelay", 0.5); | 227 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "endDelay", 0.5); |
228 setV8ObjectPropertyAsString(m_isolate, timingInput, "fill", "backwards"); | 228 setV8ObjectPropertyAsString(m_isolate, timingInput, "fill", "backwards"); |
229 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "iterationStart", 2); | 229 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "iterationStart", 2); |
230 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "iterations", 10); | 230 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "iterations", 10); |
231 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "playbackRate", 2); | 231 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "playbackRate", 2); |
232 setV8ObjectPropertyAsString(m_isolate, timingInput, "direction", "reverse"); | 232 setV8ObjectPropertyAsString(m_isolate, timingInput, "direction", "reverse"); |
233 setV8ObjectPropertyAsString(m_isolate, timingInput, "easing", "step-start"); | 233 setV8ObjectPropertyAsString(m_isolate, timingInput, "easing", "step-start"); |
234 KeyframeEffectOptions timingInputDictionary; | 234 KeyframeEffectOptions timingInputDictionary; |
235 V8KeyframeEffectOptions::toImpl(m_isolate, timingInput, timingInputDictionar
y, exceptionState); | 235 V8KeyframeEffectOptions::toImpl(m_isolate, timingInput, timingInputDictionar
y, exceptionState); |
236 | 236 |
237 RefPtrWillBeRawPtr<KeyframeEffect> animation = createAnimation(element.get()
, jsKeyframes, timingInputDictionary, exceptionState); | 237 KeyframeEffect* animation = createAnimation(element.get(), jsKeyframes, timi
ngInputDictionary, exceptionState); |
238 | 238 |
239 RefPtrWillBeRawPtr<AnimationEffectTiming> specified = animation->timing(); | 239 AnimationEffectTiming* specified = animation->timing(); |
240 EXPECT_EQ(2, specified->delay()); | 240 EXPECT_EQ(2, specified->delay()); |
241 EXPECT_EQ(0.5, specified->endDelay()); | 241 EXPECT_EQ(0.5, specified->endDelay()); |
242 EXPECT_EQ("backwards", specified->fill()); | 242 EXPECT_EQ("backwards", specified->fill()); |
243 EXPECT_EQ(2, specified->iterationStart()); | 243 EXPECT_EQ(2, specified->iterationStart()); |
244 EXPECT_EQ(10, specified->iterations()); | 244 EXPECT_EQ(10, specified->iterations()); |
245 EXPECT_EQ(2, specified->playbackRate()); | 245 EXPECT_EQ(2, specified->playbackRate()); |
246 EXPECT_EQ("reverse", specified->direction()); | 246 EXPECT_EQ("reverse", specified->direction()); |
247 EXPECT_EQ("step-start", specified->easing()); | 247 EXPECT_EQ("step-start", specified->easing()); |
248 } | 248 } |
249 | 249 |
250 TEST_F(AnimationKeyframeEffectV8Test, SpecifiedDurationGetter) | 250 TEST_F(AnimationKeyframeEffectV8Test, SpecifiedDurationGetter) |
251 { | 251 { |
252 Vector<Dictionary, 0> jsKeyframes; | 252 Vector<Dictionary, 0> jsKeyframes; |
253 | 253 |
254 v8::Local<v8::Object> timingInputWithDuration = v8::Object::New(m_isolate); | 254 v8::Local<v8::Object> timingInputWithDuration = v8::Object::New(m_isolate); |
255 setV8ObjectPropertyAsNumber(m_isolate, timingInputWithDuration, "duration",
2.5); | 255 setV8ObjectPropertyAsNumber(m_isolate, timingInputWithDuration, "duration",
2.5); |
256 KeyframeEffectOptions timingInputDictionaryWithDuration; | 256 KeyframeEffectOptions timingInputDictionaryWithDuration; |
257 V8KeyframeEffectOptions::toImpl(m_isolate, timingInputWithDuration, timingIn
putDictionaryWithDuration, exceptionState); | 257 V8KeyframeEffectOptions::toImpl(m_isolate, timingInputWithDuration, timingIn
putDictionaryWithDuration, exceptionState); |
258 | 258 |
259 RefPtrWillBeRawPtr<KeyframeEffect> animationWithDuration = createAnimation(e
lement.get(), jsKeyframes, timingInputDictionaryWithDuration, exceptionState); | 259 KeyframeEffect* animationWithDuration = createAnimation(element.get(), jsKey
frames, timingInputDictionaryWithDuration, exceptionState); |
260 | 260 |
261 RefPtrWillBeRawPtr<AnimationEffectTiming> specifiedWithDuration = animationW
ithDuration->timing(); | 261 AnimationEffectTiming* specifiedWithDuration = animationWithDuration->timing
(); |
262 UnrestrictedDoubleOrString duration; | 262 UnrestrictedDoubleOrString duration; |
263 specifiedWithDuration->duration(duration); | 263 specifiedWithDuration->duration(duration); |
264 EXPECT_TRUE(duration.isUnrestrictedDouble()); | 264 EXPECT_TRUE(duration.isUnrestrictedDouble()); |
265 EXPECT_EQ(2.5, duration.getAsUnrestrictedDouble()); | 265 EXPECT_EQ(2.5, duration.getAsUnrestrictedDouble()); |
266 EXPECT_FALSE(duration.isString()); | 266 EXPECT_FALSE(duration.isString()); |
267 | 267 |
268 | 268 |
269 v8::Local<v8::Object> timingInputNoDuration = v8::Object::New(m_isolate); | 269 v8::Local<v8::Object> timingInputNoDuration = v8::Object::New(m_isolate); |
270 KeyframeEffectOptions timingInputDictionaryNoDuration; | 270 KeyframeEffectOptions timingInputDictionaryNoDuration; |
271 V8KeyframeEffectOptions::toImpl(m_isolate, timingInputNoDuration, timingInpu
tDictionaryNoDuration, exceptionState); | 271 V8KeyframeEffectOptions::toImpl(m_isolate, timingInputNoDuration, timingInpu
tDictionaryNoDuration, exceptionState); |
272 | 272 |
273 RefPtrWillBeRawPtr<KeyframeEffect> animationNoDuration = createAnimation(ele
ment.get(), jsKeyframes, timingInputDictionaryNoDuration, exceptionState); | 273 KeyframeEffect* animationNoDuration = createAnimation(element.get(), jsKeyfr
ames, timingInputDictionaryNoDuration, exceptionState); |
274 | 274 |
275 RefPtrWillBeRawPtr<AnimationEffectTiming> specifiedNoDuration = animationNoD
uration->timing(); | 275 AnimationEffectTiming* specifiedNoDuration = animationNoDuration->timing(); |
276 UnrestrictedDoubleOrString duration2; | 276 UnrestrictedDoubleOrString duration2; |
277 specifiedNoDuration->duration(duration2); | 277 specifiedNoDuration->duration(duration2); |
278 EXPECT_FALSE(duration2.isUnrestrictedDouble()); | 278 EXPECT_FALSE(duration2.isUnrestrictedDouble()); |
279 EXPECT_TRUE(duration2.isString()); | 279 EXPECT_TRUE(duration2.isString()); |
280 EXPECT_EQ("auto", duration2.getAsString()); | 280 EXPECT_EQ("auto", duration2.getAsString()); |
281 } | 281 } |
282 | 282 |
283 TEST_F(AnimationKeyframeEffectV8Test, SpecifiedSetters) | 283 TEST_F(AnimationKeyframeEffectV8Test, SpecifiedSetters) |
284 { | 284 { |
285 Vector<Dictionary, 0> jsKeyframes; | 285 Vector<Dictionary, 0> jsKeyframes; |
286 v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate); | 286 v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate); |
287 KeyframeEffectOptions timingInputDictionary; | 287 KeyframeEffectOptions timingInputDictionary; |
288 V8KeyframeEffectOptions::toImpl(m_isolate, timingInput, timingInputDictionar
y, exceptionState); | 288 V8KeyframeEffectOptions::toImpl(m_isolate, timingInput, timingInputDictionar
y, exceptionState); |
289 RefPtrWillBeRawPtr<KeyframeEffect> animation = createAnimation(element.get()
, jsKeyframes, timingInputDictionary, exceptionState); | 289 KeyframeEffect* animation = createAnimation(element.get(), jsKeyframes, timi
ngInputDictionary, exceptionState); |
290 | 290 |
291 RefPtrWillBeRawPtr<AnimationEffectTiming> specified = animation->timing(); | 291 AnimationEffectTiming* specified = animation->timing(); |
292 | 292 |
293 EXPECT_EQ(0, specified->delay()); | 293 EXPECT_EQ(0, specified->delay()); |
294 specified->setDelay(2); | 294 specified->setDelay(2); |
295 EXPECT_EQ(2, specified->delay()); | 295 EXPECT_EQ(2, specified->delay()); |
296 | 296 |
297 EXPECT_EQ(0, specified->endDelay()); | 297 EXPECT_EQ(0, specified->endDelay()); |
298 specified->setEndDelay(0.5); | 298 specified->setEndDelay(0.5); |
299 EXPECT_EQ(0.5, specified->endDelay()); | 299 EXPECT_EQ(0.5, specified->endDelay()); |
300 | 300 |
301 EXPECT_EQ("auto", specified->fill()); | 301 EXPECT_EQ("auto", specified->fill()); |
(...skipping 20 matching lines...) Expand all Loading... |
322 specified->setEasing("step-start"); | 322 specified->setEasing("step-start"); |
323 EXPECT_EQ("step-start", specified->easing()); | 323 EXPECT_EQ("step-start", specified->easing()); |
324 } | 324 } |
325 | 325 |
326 TEST_F(AnimationKeyframeEffectV8Test, SetSpecifiedDuration) | 326 TEST_F(AnimationKeyframeEffectV8Test, SetSpecifiedDuration) |
327 { | 327 { |
328 Vector<Dictionary, 0> jsKeyframes; | 328 Vector<Dictionary, 0> jsKeyframes; |
329 v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate); | 329 v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate); |
330 KeyframeEffectOptions timingInputDictionary; | 330 KeyframeEffectOptions timingInputDictionary; |
331 V8KeyframeEffectOptions::toImpl(m_isolate, timingInput, timingInputDictionar
y, exceptionState); | 331 V8KeyframeEffectOptions::toImpl(m_isolate, timingInput, timingInputDictionar
y, exceptionState); |
332 RefPtrWillBeRawPtr<KeyframeEffect> animation = createAnimation(element.get()
, jsKeyframes, timingInputDictionary, exceptionState); | 332 KeyframeEffect* animation = createAnimation(element.get(), jsKeyframes, timi
ngInputDictionary, exceptionState); |
333 | 333 |
334 RefPtrWillBeRawPtr<AnimationEffectTiming> specified = animation->timing(); | 334 AnimationEffectTiming* specified = animation->timing(); |
335 | 335 |
336 UnrestrictedDoubleOrString duration; | 336 UnrestrictedDoubleOrString duration; |
337 specified->duration(duration); | 337 specified->duration(duration); |
338 EXPECT_FALSE(duration.isUnrestrictedDouble()); | 338 EXPECT_FALSE(duration.isUnrestrictedDouble()); |
339 EXPECT_TRUE(duration.isString()); | 339 EXPECT_TRUE(duration.isString()); |
340 EXPECT_EQ("auto", duration.getAsString()); | 340 EXPECT_EQ("auto", duration.getAsString()); |
341 | 341 |
342 UnrestrictedDoubleOrString inDuration; | 342 UnrestrictedDoubleOrString inDuration; |
343 inDuration.setUnrestrictedDouble(2.5); | 343 inDuration.setUnrestrictedDouble(2.5); |
344 specified->setDuration(inDuration); | 344 specified->setDuration(inDuration); |
345 UnrestrictedDoubleOrString duration2; | 345 UnrestrictedDoubleOrString duration2; |
346 specified->duration(duration2); | 346 specified->duration(duration2); |
347 EXPECT_TRUE(duration2.isUnrestrictedDouble()); | 347 EXPECT_TRUE(duration2.isUnrestrictedDouble()); |
348 EXPECT_EQ(2.5, duration2.getAsUnrestrictedDouble()); | 348 EXPECT_EQ(2.5, duration2.getAsUnrestrictedDouble()); |
349 EXPECT_FALSE(duration2.isString()); | 349 EXPECT_FALSE(duration2.isString()); |
350 } | 350 } |
351 | 351 |
352 TEST_F(KeyframeEffectTest, TimeToEffectChange) | 352 TEST_F(KeyframeEffectTest, TimeToEffectChange) |
353 { | 353 { |
354 Timing timing; | 354 Timing timing; |
355 timing.iterationDuration = 100; | 355 timing.iterationDuration = 100; |
356 timing.startDelay = 100; | 356 timing.startDelay = 100; |
357 timing.endDelay = 100; | 357 timing.endDelay = 100; |
358 timing.fillMode = Timing::FillModeNone; | 358 timing.fillMode = Timing::FillModeNone; |
359 RefPtrWillBeRawPtr<KeyframeEffect> animation = KeyframeEffect::create(0, nul
lptr, timing); | 359 KeyframeEffect* animation = KeyframeEffect::create(0, nullptr, timing); |
360 RefPtrWillBeRawPtr<Animation> player = document.timeline().play(animation.ge
t()); | 360 Animation* player = document.timeline().play(animation); |
361 double inf = std::numeric_limits<double>::infinity(); | 361 double inf = std::numeric_limits<double>::infinity(); |
362 | 362 |
363 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); | 363 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); |
364 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); | 364 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); |
365 | 365 |
366 player->setCurrentTimeInternal(100); | 366 player->setCurrentTimeInternal(100); |
367 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); | 367 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); |
368 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 368 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
369 | 369 |
370 player->setCurrentTimeInternal(199); | 370 player->setCurrentTimeInternal(199); |
(...skipping 11 matching lines...) Expand all Loading... |
382 } | 382 } |
383 | 383 |
384 TEST_F(KeyframeEffectTest, TimeToEffectChangeWithPlaybackRate) | 384 TEST_F(KeyframeEffectTest, TimeToEffectChangeWithPlaybackRate) |
385 { | 385 { |
386 Timing timing; | 386 Timing timing; |
387 timing.iterationDuration = 100; | 387 timing.iterationDuration = 100; |
388 timing.startDelay = 100; | 388 timing.startDelay = 100; |
389 timing.endDelay = 100; | 389 timing.endDelay = 100; |
390 timing.playbackRate = 2; | 390 timing.playbackRate = 2; |
391 timing.fillMode = Timing::FillModeNone; | 391 timing.fillMode = Timing::FillModeNone; |
392 RefPtrWillBeRawPtr<KeyframeEffect> animation = KeyframeEffect::create(0, nul
lptr, timing); | 392 KeyframeEffect* animation = KeyframeEffect::create(0, nullptr, timing); |
393 RefPtrWillBeRawPtr<Animation> player = document.timeline().play(animation.ge
t()); | 393 Animation* player = document.timeline().play(animation); |
394 double inf = std::numeric_limits<double>::infinity(); | 394 double inf = std::numeric_limits<double>::infinity(); |
395 | 395 |
396 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); | 396 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); |
397 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); | 397 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); |
398 | 398 |
399 player->setCurrentTimeInternal(100); | 399 player->setCurrentTimeInternal(100); |
400 EXPECT_EQ(50, animation->timeToForwardsEffectChange()); | 400 EXPECT_EQ(50, animation->timeToForwardsEffectChange()); |
401 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 401 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
402 | 402 |
403 player->setCurrentTimeInternal(149); | 403 player->setCurrentTimeInternal(149); |
(...skipping 11 matching lines...) Expand all Loading... |
415 } | 415 } |
416 | 416 |
417 TEST_F(KeyframeEffectTest, TimeToEffectChangeWithNegativePlaybackRate) | 417 TEST_F(KeyframeEffectTest, TimeToEffectChangeWithNegativePlaybackRate) |
418 { | 418 { |
419 Timing timing; | 419 Timing timing; |
420 timing.iterationDuration = 100; | 420 timing.iterationDuration = 100; |
421 timing.startDelay = 100; | 421 timing.startDelay = 100; |
422 timing.endDelay = 100; | 422 timing.endDelay = 100; |
423 timing.playbackRate = -2; | 423 timing.playbackRate = -2; |
424 timing.fillMode = Timing::FillModeNone; | 424 timing.fillMode = Timing::FillModeNone; |
425 RefPtrWillBeRawPtr<KeyframeEffect> animation = KeyframeEffect::create(0, nul
lptr, timing); | 425 KeyframeEffect* animation = KeyframeEffect::create(0, nullptr, timing); |
426 RefPtrWillBeRawPtr<Animation> player = document.timeline().play(animation.ge
t()); | 426 Animation* player = document.timeline().play(animation); |
427 double inf = std::numeric_limits<double>::infinity(); | 427 double inf = std::numeric_limits<double>::infinity(); |
428 | 428 |
429 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); | 429 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); |
430 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); | 430 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); |
431 | 431 |
432 player->setCurrentTimeInternal(100); | 432 player->setCurrentTimeInternal(100); |
433 EXPECT_EQ(50, animation->timeToForwardsEffectChange()); | 433 EXPECT_EQ(50, animation->timeToForwardsEffectChange()); |
434 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 434 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
435 | 435 |
436 player->setCurrentTimeInternal(149); | 436 player->setCurrentTimeInternal(149); |
437 EXPECT_EQ(1, animation->timeToForwardsEffectChange()); | 437 EXPECT_EQ(1, animation->timeToForwardsEffectChange()); |
438 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 438 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
439 | 439 |
440 player->setCurrentTimeInternal(150); | 440 player->setCurrentTimeInternal(150); |
441 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); | 441 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); |
442 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 442 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
443 | 443 |
444 player->setCurrentTimeInternal(200); | 444 player->setCurrentTimeInternal(200); |
445 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); | 445 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); |
446 EXPECT_EQ(50, animation->timeToReverseEffectChange()); | 446 EXPECT_EQ(50, animation->timeToReverseEffectChange()); |
447 } | 447 } |
448 | 448 |
449 TEST_F(KeyframeEffectTest, ElementDestructorClearsAnimationTarget) | 449 TEST_F(KeyframeEffectTest, ElementDestructorClearsAnimationTarget) |
450 { | 450 { |
451 // This test expects incorrect behaviour should be removed once Element | 451 // This test expects incorrect behaviour should be removed once Element |
452 // and KeyframeEffect are moved to Oilpan. See crbug.com/362404 for context. | 452 // and KeyframeEffect are moved to Oilpan. See crbug.com/362404 for context. |
453 Timing timing; | 453 Timing timing; |
454 timing.iterationDuration = 5; | 454 timing.iterationDuration = 5; |
455 RefPtrWillBeRawPtr<KeyframeEffect> animation = KeyframeEffect::create(elemen
t.get(), nullptr, timing); | 455 KeyframeEffect* animation = KeyframeEffect::create(element.get(), nullptr, t
iming); |
456 EXPECT_EQ(element.get(), animation->target()); | 456 EXPECT_EQ(element.get(), animation->target()); |
457 document.timeline().play(animation.get()); | 457 document.timeline().play(animation); |
458 pageHolder.clear(); | 458 pageHolder.clear(); |
459 element.clear(); | 459 element.clear(); |
460 #if !ENABLE(OILPAN) | |
461 EXPECT_EQ(0, animation->target()); | |
462 #endif | |
463 } | 460 } |
464 | 461 |
465 } // namespace blink | 462 } // namespace blink |
OLD | NEW |