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

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

Issue 1113173003: Web Animations: Update naming to reflect spec changes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: No, really. Created 5 years, 7 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/animation/AnimationTimeline.h" 32 #include "core/animation/AnimationTimeline.h"
33 33
34 #include "core/animation/Animation.h"
35 #include "core/animation/AnimationClock.h" 34 #include "core/animation/AnimationClock.h"
36 #include "core/animation/AnimationNode.h" 35 #include "core/animation/AnimationEffect.h"
36 #include "core/animation/KeyframeEffect.h"
37 #include "core/animation/KeyframeEffectModel.h" 37 #include "core/animation/KeyframeEffectModel.h"
38 #include "core/dom/Document.h" 38 #include "core/dom/Document.h"
39 #include "core/dom/Element.h" 39 #include "core/dom/Element.h"
40 #include "core/dom/QualifiedName.h" 40 #include "core/dom/QualifiedName.h"
41 #include "platform/weborigin/KURL.h" 41 #include "platform/weborigin/KURL.h"
42 42
43 #include <gmock/gmock.h> 43 #include <gmock/gmock.h>
44 #include <gtest/gtest.h> 44 #include <gtest/gtest.h>
45 45
46 namespace blink { 46 namespace blink {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 }; 132 };
133 133
134 TEST_F(AnimationAnimationTimelineTest, HasStarted) 134 TEST_F(AnimationAnimationTimelineTest, HasStarted)
135 { 135 {
136 timeline = AnimationTimeline::create(document.get()); 136 timeline = AnimationTimeline::create(document.get());
137 } 137 }
138 138
139 TEST_F(AnimationAnimationTimelineTest, EmptyKeyframeAnimation) 139 TEST_F(AnimationAnimationTimelineTest, EmptyKeyframeAnimation)
140 { 140 {
141 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa lueKeyframeEffectModel::create(AnimatableValueKeyframeVector()); 141 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa lueKeyframeEffectModel::create(AnimatableValueKeyframeVector());
142 RefPtrWillBeRawPtr<Animation> anim = Animation::create(element.get(), effect , timing); 142 RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect = KeyframeEffect::create(e lement.get(), effect, timing);
143 143
144 timeline->play(anim.get()); 144 timeline->play(keyframeEffect.get());
145 145
146 platformTiming->expectNoMoreActions(); 146 platformTiming->expectNoMoreActions();
147 updateClockAndService(0); 147 updateClockAndService(0);
148 EXPECT_FLOAT_EQ(0, timeline->currentTimeInternal()); 148 EXPECT_FLOAT_EQ(0, timeline->currentTimeInternal());
149 EXPECT_FALSE(anim->isInEffect()); 149 EXPECT_FALSE(keyframeEffect->isInEffect());
150 150
151 platformTiming->expectNoMoreActions(); 151 platformTiming->expectNoMoreActions();
152 updateClockAndService(100); 152 updateClockAndService(100);
153 EXPECT_FLOAT_EQ(100, timeline->currentTimeInternal()); 153 EXPECT_FLOAT_EQ(100, timeline->currentTimeInternal());
154 } 154 }
155 155
156 TEST_F(AnimationAnimationTimelineTest, EmptyForwardsKeyframeAnimation) 156 TEST_F(AnimationAnimationTimelineTest, EmptyForwardsKeyframeAnimation)
157 { 157 {
158 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa lueKeyframeEffectModel::create(AnimatableValueKeyframeVector()); 158 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa lueKeyframeEffectModel::create(AnimatableValueKeyframeVector());
159 timing.fillMode = Timing::FillModeForwards; 159 timing.fillMode = Timing::FillModeForwards;
160 RefPtrWillBeRawPtr<Animation> anim = Animation::create(element.get(), effect , timing); 160 RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect = KeyframeEffect::create(e lement.get(), effect, timing);
161 161
162 timeline->play(anim.get()); 162 timeline->play(keyframeEffect.get());
163 163
164 platformTiming->expectNoMoreActions(); 164 platformTiming->expectNoMoreActions();
165 updateClockAndService(0); 165 updateClockAndService(0);
166 EXPECT_FLOAT_EQ(0, timeline->currentTimeInternal()); 166 EXPECT_FLOAT_EQ(0, timeline->currentTimeInternal());
167 EXPECT_TRUE(anim->isInEffect()); 167 EXPECT_TRUE(keyframeEffect->isInEffect());
168 168
169 platformTiming->expectNoMoreActions(); 169 platformTiming->expectNoMoreActions();
170 updateClockAndService(100); 170 updateClockAndService(100);
171 EXPECT_FLOAT_EQ(100, timeline->currentTimeInternal()); 171 EXPECT_FLOAT_EQ(100, timeline->currentTimeInternal());
172 } 172 }
173 173
174 TEST_F(AnimationAnimationTimelineTest, ZeroTime) 174 TEST_F(AnimationAnimationTimelineTest, ZeroTime)
175 { 175 {
176 timeline = AnimationTimeline::create(document.get()); 176 timeline = AnimationTimeline::create(document.get());
177 bool isNull; 177 bool isNull;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 339
340 timeline->setCurrentTime(2000); 340 timeline->setCurrentTime(2000);
341 EXPECT_EQ(2000, timeline->currentTime()); 341 EXPECT_EQ(2000, timeline->currentTime());
342 EXPECT_EQ(zeroTime + 198, timeline->zeroTime()); 342 EXPECT_EQ(zeroTime + 198, timeline->zeroTime());
343 } 343 }
344 344
345 TEST_F(AnimationAnimationTimelineTest, PauseForTesting) 345 TEST_F(AnimationAnimationTimelineTest, PauseForTesting)
346 { 346 {
347 float seekTime = 1; 347 float seekTime = 1;
348 timing.fillMode = Timing::FillModeForwards; 348 timing.fillMode = Timing::FillModeForwards;
349 RefPtrWillBeRawPtr<Animation> anim1 = Animation::create(element.get(), Anima tableValueKeyframeEffectModel::create(AnimatableValueKeyframeVector()), timing); 349 RefPtrWillBeRawPtr<KeyframeEffect> anim1 = KeyframeEffect::create(element.ge t(), AnimatableValueKeyframeEffectModel::create(AnimatableValueKeyframeVector()) , timing);
350 RefPtrWillBeRawPtr<Animation> anim2 = Animation::create(element.get(), Anim atableValueKeyframeEffectModel::create(AnimatableValueKeyframeVector()), timing) ; 350 RefPtrWillBeRawPtr<KeyframeEffect> anim2 = KeyframeEffect::create(element.g et(), AnimatableValueKeyframeEffectModel::create(AnimatableValueKeyframeVector() ), timing);
351 AnimationPlayer* player1 = timeline->play(anim1.get()); 351 Animation* animation1 = timeline->play(anim1.get());
352 AnimationPlayer* player2 = timeline->play(anim2.get()); 352 Animation* animation2 = timeline->play(anim2.get());
353 timeline->pauseAnimationsForTesting(seekTime); 353 timeline->pauseAnimationsForTesting(seekTime);
354 354
355 EXPECT_FLOAT_EQ(seekTime, player1->currentTime() / 1000.0); 355 EXPECT_FLOAT_EQ(seekTime, animation1->currentTime() / 1000.0);
356 EXPECT_FLOAT_EQ(seekTime, player2->currentTime() / 1000.0); 356 EXPECT_FLOAT_EQ(seekTime, animation2->currentTime() / 1000.0);
357 } 357 }
358 358
359 TEST_F(AnimationAnimationTimelineTest, DelayBeforeAnimationStart) 359 TEST_F(AnimationAnimationTimelineTest, DelayBeforeAnimationStart)
360 { 360 {
361 timing.iterationDuration = 2; 361 timing.iterationDuration = 2;
362 timing.startDelay = 5; 362 timing.startDelay = 5;
363 363
364 RefPtrWillBeRawPtr<Animation> anim = Animation::create(element.get(), nullpt r, timing); 364 RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect = KeyframeEffect::create(e lement.get(), nullptr, timing);
365 365
366 timeline->play(anim.get()); 366 timeline->play(keyframeEffect.get());
367 367
368 // TODO: Put the player startTime in the future when we add the capability t o change player startTime 368 // TODO: Put the animation startTime in the future when we add the capabilit y to change animation startTime
369 platformTiming->expectDelayedAction(timing.startDelay - minimumDelay()); 369 platformTiming->expectDelayedAction(timing.startDelay - minimumDelay());
370 updateClockAndService(0); 370 updateClockAndService(0);
371 371
372 platformTiming->expectDelayedAction(timing.startDelay - minimumDelay() - 1.5 ); 372 platformTiming->expectDelayedAction(timing.startDelay - minimumDelay() - 1.5 );
373 updateClockAndService(1.5); 373 updateClockAndService(1.5);
374 374
375 EXPECT_CALL(*platformTiming, serviceOnNextFrame()); 375 EXPECT_CALL(*platformTiming, serviceOnNextFrame());
376 wake(); 376 wake();
377 377
378 platformTiming->expectNextFrameAction(); 378 platformTiming->expectNextFrameAction();
379 updateClockAndService(4.98); 379 updateClockAndService(4.98);
380 } 380 }
381 381
382 TEST_F(AnimationAnimationTimelineTest, PlayAfterDocumentDeref) 382 TEST_F(AnimationAnimationTimelineTest, PlayAfterDocumentDeref)
383 { 383 {
384 timing.iterationDuration = 2; 384 timing.iterationDuration = 2;
385 timing.startDelay = 5; 385 timing.startDelay = 5;
386 386
387 timeline = &document->timeline(); 387 timeline = &document->timeline();
388 element = nullptr; 388 element = nullptr;
389 document = nullptr; 389 document = nullptr;
390 390
391 RefPtrWillBeRawPtr<Animation> anim = Animation::create(0, nullptr, timing); 391 RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect = KeyframeEffect::create(0 , nullptr, timing);
392 // Test passes if this does not crash. 392 // Test passes if this does not crash.
393 timeline->play(anim.get()); 393 timeline->play(keyframeEffect.get());
394 } 394 }
395 395
396 TEST_F(AnimationAnimationTimelineTest, UseAnimationPlayerAfterTimelineDeref) 396 TEST_F(AnimationAnimationTimelineTest, UseAnimationAfterTimelineDeref)
397 { 397 {
398 RefPtrWillBeRawPtr<AnimationPlayer> player = timeline->play(0); 398 RefPtrWillBeRawPtr<Animation> animation = timeline->play(0);
399 timeline.clear(); 399 timeline.clear();
400 // Test passes if this does not crash. 400 // Test passes if this does not crash.
401 player->setStartTime(0); 401 animation->setStartTime(0);
402 } 402 }
403 403
404 } 404 }
OLDNEW
« no previous file with comments | « Source/core/animation/AnimationTimeline.idl ('k') | Source/core/animation/AnimationTimingProperties.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698