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

Side by Side Diff: Source/core/animation/KeyframeEffectTest.cpp

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

Powered by Google App Engine
This is Rietveld 408576698