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

Side by Side Diff: third_party/WebKit/Source/core/animation/AnimationTest.cpp

Issue 2272313003: binding: Makes ExceptionState STACK_ALLOCATED(). (Closed)
Patch Set: Synced. Created 4 years, 3 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 /* 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 { 81 {
82 document->animationClock().updateTime(time); 82 document->animationClock().updateTime(time);
83 document->compositorPendingAnimations().update(false); 83 document->compositorPendingAnimations().update(false);
84 // The timeline does not know about our animation, so we have to explici tly call update(). 84 // The timeline does not know about our animation, so we have to explici tly call update().
85 return animation->update(TimingUpdateForAnimationFrame); 85 return animation->update(TimingUpdateForAnimationFrame);
86 } 86 }
87 87
88 Persistent<Document> document; 88 Persistent<Document> document;
89 Persistent<AnimationTimeline> timeline; 89 Persistent<AnimationTimeline> timeline;
90 Persistent<Animation> animation; 90 Persistent<Animation> animation;
91 TrackExceptionState exceptionState;
92 std::unique_ptr<DummyPageHolder> pageHolder; 91 std::unique_ptr<DummyPageHolder> pageHolder;
93 }; 92 };
94 93
95 TEST_F(AnimationAnimationTest, InitialState) 94 TEST_F(AnimationAnimationTest, InitialState)
96 { 95 {
97 setUpWithoutStartingTimeline(); 96 setUpWithoutStartingTimeline();
98 animation = timeline->play(0); 97 animation = timeline->play(0);
99 EXPECT_EQ(Animation::Pending, animation->playStateInternal()); 98 EXPECT_EQ(Animation::Pending, animation->playStateInternal());
100 EXPECT_EQ(0, animation->currentTimeInternal()); 99 EXPECT_EQ(0, animation->currentTimeInternal());
101 EXPECT_FALSE(animation->paused()); 100 EXPECT_FALSE(animation->paused());
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 EXPECT_EQ(30, animation->currentTimeInternal()); 242 EXPECT_EQ(30, animation->currentTimeInternal());
244 animation->setCurrentTimeInternal(50); 243 animation->setCurrentTimeInternal(50);
245 animation->setStartTime(-40 * 1000); 244 animation->setStartTime(-40 * 1000);
246 EXPECT_EQ(30, animation->currentTimeInternal()); 245 EXPECT_EQ(30, animation->currentTimeInternal());
247 EXPECT_EQ(Animation::Finished, animation->playStateInternal()); 246 EXPECT_EQ(Animation::Finished, animation->playStateInternal());
248 EXPECT_TRUE(animation->limited()); 247 EXPECT_TRUE(animation->limited());
249 } 248 }
250 249
251 TEST_F(AnimationAnimationTest, StartTimePauseFinish) 250 TEST_F(AnimationAnimationTest, StartTimePauseFinish)
252 { 251 {
252 NonThrowableExceptionState exceptionState;
253 animation->pause(); 253 animation->pause();
254 EXPECT_EQ(Animation::Pending, animation->playStateInternal()); 254 EXPECT_EQ(Animation::Pending, animation->playStateInternal());
255 EXPECT_TRUE(std::isnan(animation->startTime())); 255 EXPECT_TRUE(std::isnan(animation->startTime()));
256 animation->finish(exceptionState); 256 animation->finish(exceptionState);
257 EXPECT_EQ(Animation::Finished, animation->playStateInternal()); 257 EXPECT_EQ(Animation::Finished, animation->playStateInternal());
258 EXPECT_EQ(-30000, animation->startTime()); 258 EXPECT_EQ(-30000, animation->startTime());
259 } 259 }
260 260
261 TEST_F(AnimationAnimationTest, FinishWhenPaused) 261 TEST_F(AnimationAnimationTest, FinishWhenPaused)
262 { 262 {
263 NonThrowableExceptionState exceptionState;
263 animation->pause(); 264 animation->pause();
264 EXPECT_EQ(Animation::Pending, animation->playStateInternal()); 265 EXPECT_EQ(Animation::Pending, animation->playStateInternal());
265 simulateFrame(10); 266 simulateFrame(10);
266 EXPECT_EQ(Animation::Paused, animation->playStateInternal()); 267 EXPECT_EQ(Animation::Paused, animation->playStateInternal());
267 animation->finish(exceptionState); 268 animation->finish(exceptionState);
268 EXPECT_EQ(Animation::Finished, animation->playStateInternal()); 269 EXPECT_EQ(Animation::Finished, animation->playStateInternal());
269 } 270 }
270 271
271 TEST_F(AnimationAnimationTest, StartTimeFinishPause) 272 TEST_F(AnimationAnimationTest, StartTimeFinishPause)
272 { 273 {
274 NonThrowableExceptionState exceptionState;
273 animation->finish(exceptionState); 275 animation->finish(exceptionState);
274 EXPECT_EQ(-30 * 1000, animation->startTime()); 276 EXPECT_EQ(-30 * 1000, animation->startTime());
275 animation->pause(); 277 animation->pause();
276 EXPECT_TRUE(std::isnan(animation->startTime())); 278 EXPECT_TRUE(std::isnan(animation->startTime()));
277 } 279 }
278 280
279 TEST_F(AnimationAnimationTest, StartTimeWithZeroPlaybackRate) 281 TEST_F(AnimationAnimationTest, StartTimeWithZeroPlaybackRate)
280 { 282 {
281 animation->setPlaybackRate(0); 283 animation->setPlaybackRate(0);
282 EXPECT_EQ(Animation::Pending, animation->playStateInternal()); 284 EXPECT_EQ(Animation::Pending, animation->playStateInternal());
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 EXPECT_EQ(0, animation->currentTimeInternal()); 420 EXPECT_EQ(0, animation->currentTimeInternal());
419 421
420 animation->setCurrentTimeInternal(-10); 422 animation->setCurrentTimeInternal(-10);
421 animation->reverse(); 423 animation->reverse();
422 EXPECT_EQ(Animation::Pending, animation->playStateInternal()); 424 EXPECT_EQ(Animation::Pending, animation->playStateInternal());
423 EXPECT_EQ(30, animation->currentTimeInternal()); 425 EXPECT_EQ(30, animation->currentTimeInternal());
424 } 426 }
425 427
426 TEST_F(AnimationAnimationTest, Finish) 428 TEST_F(AnimationAnimationTest, Finish)
427 { 429 {
430 NonThrowableExceptionState exceptionState;
428 animation->finish(exceptionState); 431 animation->finish(exceptionState);
429 EXPECT_EQ(30, animation->currentTimeInternal()); 432 EXPECT_EQ(30, animation->currentTimeInternal());
430 EXPECT_EQ(Animation::Finished, animation->playStateInternal()); 433 EXPECT_EQ(Animation::Finished, animation->playStateInternal());
431 434
432 animation->setPlaybackRate(-1); 435 animation->setPlaybackRate(-1);
433 animation->finish(exceptionState); 436 animation->finish(exceptionState);
434 EXPECT_EQ(0, animation->currentTimeInternal()); 437 EXPECT_EQ(0, animation->currentTimeInternal());
435 EXPECT_EQ(Animation::Finished, animation->playStateInternal()); 438 EXPECT_EQ(Animation::Finished, animation->playStateInternal());
436
437 EXPECT_FALSE(exceptionState.hadException());
438 } 439 }
439 440
440 TEST_F(AnimationAnimationTest, FinishAfterEffectEnd) 441 TEST_F(AnimationAnimationTest, FinishAfterEffectEnd)
441 { 442 {
443 NonThrowableExceptionState exceptionState;
442 animation->setCurrentTime(40 * 1000); 444 animation->setCurrentTime(40 * 1000);
443 animation->finish(exceptionState); 445 animation->finish(exceptionState);
444 EXPECT_EQ(40, animation->currentTimeInternal()); 446 EXPECT_EQ(40, animation->currentTimeInternal());
445 } 447 }
446 448
447 TEST_F(AnimationAnimationTest, FinishBeforeStart) 449 TEST_F(AnimationAnimationTest, FinishBeforeStart)
448 { 450 {
451 NonThrowableExceptionState exceptionState;
449 animation->setCurrentTimeInternal(-10); 452 animation->setCurrentTimeInternal(-10);
450 animation->setPlaybackRate(-1); 453 animation->setPlaybackRate(-1);
451 animation->finish(exceptionState); 454 animation->finish(exceptionState);
452 EXPECT_EQ(0, animation->currentTimeInternal()); 455 EXPECT_EQ(0, animation->currentTimeInternal());
453 } 456 }
454 457
455 TEST_F(AnimationAnimationTest, FinishDoesNothingWithPlaybackRateZero) 458 TEST_F(AnimationAnimationTest, FinishDoesNothingWithPlaybackRateZero)
456 { 459 {
460 TrackExceptionState exceptionState;
457 animation->setCurrentTimeInternal(10); 461 animation->setCurrentTimeInternal(10);
458 animation->setPlaybackRate(0); 462 animation->setPlaybackRate(0);
459 animation->finish(exceptionState); 463 animation->finish(exceptionState);
460 EXPECT_EQ(10, animation->currentTimeInternal()); 464 EXPECT_EQ(10, animation->currentTimeInternal());
465 EXPECT_TRUE(exceptionState.hadException());
461 } 466 }
462 467
463 TEST_F(AnimationAnimationTest, FinishRaisesException) 468 TEST_F(AnimationAnimationTest, FinishRaisesException)
464 { 469 {
465 Timing timing; 470 Timing timing;
466 timing.iterationDuration = 1; 471 timing.iterationDuration = 1;
467 timing.iterationCount = std::numeric_limits<double>::infinity(); 472 timing.iterationCount = std::numeric_limits<double>::infinity();
468 animation->setEffect(KeyframeEffect::create(0, nullptr, timing)); 473 animation->setEffect(KeyframeEffect::create(0, nullptr, timing));
469 animation->setCurrentTimeInternal(10); 474 animation->setCurrentTimeInternal(10);
470 475
476 TrackExceptionState exceptionState;
471 animation->finish(exceptionState); 477 animation->finish(exceptionState);
472 EXPECT_EQ(10, animation->currentTimeInternal()); 478 EXPECT_EQ(10, animation->currentTimeInternal());
473 EXPECT_TRUE(exceptionState.hadException()); 479 EXPECT_TRUE(exceptionState.hadException());
474 EXPECT_EQ(InvalidStateError, exceptionState.code()); 480 EXPECT_EQ(InvalidStateError, exceptionState.code());
475 } 481 }
476 482
477 TEST_F(AnimationAnimationTest, LimitingAtEffectEnd) 483 TEST_F(AnimationAnimationTest, LimitingAtEffectEnd)
478 { 484 {
479 simulateFrame(30); 485 simulateFrame(30);
480 EXPECT_EQ(30, animation->currentTimeInternal()); 486 EXPECT_EQ(30, animation->currentTimeInternal());
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 EXPECT_EQ(30 * 1000, animation->currentTime()); 800 EXPECT_EQ(30 * 1000, animation->currentTime());
795 EXPECT_TRUE(std::isnan(animation->startTime())); 801 EXPECT_TRUE(std::isnan(animation->startTime()));
796 simulateFrame(10); 802 simulateFrame(10);
797 EXPECT_EQ(Animation::Running, animation->playStateInternal()); 803 EXPECT_EQ(Animation::Running, animation->playStateInternal());
798 EXPECT_EQ(30 * 1000, animation->currentTime()); 804 EXPECT_EQ(30 * 1000, animation->currentTime());
799 EXPECT_EQ(40 * 1000, animation->startTime()); 805 EXPECT_EQ(40 * 1000, animation->startTime());
800 } 806 }
801 807
802 TEST_F(AnimationAnimationTest, FinishAfterCancel) 808 TEST_F(AnimationAnimationTest, FinishAfterCancel)
803 { 809 {
810 NonThrowableExceptionState exceptionState;
804 animation->cancel(); 811 animation->cancel();
805 EXPECT_EQ(Animation::Idle, animation->playStateInternal()); 812 EXPECT_EQ(Animation::Idle, animation->playStateInternal());
806 EXPECT_TRUE(std::isnan(animation->currentTime())); 813 EXPECT_TRUE(std::isnan(animation->currentTime()));
807 EXPECT_TRUE(std::isnan(animation->startTime())); 814 EXPECT_TRUE(std::isnan(animation->startTime()));
808 animation->finish(exceptionState); 815 animation->finish(exceptionState);
809 EXPECT_EQ(30000, animation->currentTime()); 816 EXPECT_EQ(30000, animation->currentTime());
810 EXPECT_EQ(-30000, animation->startTime()); 817 EXPECT_EQ(-30000, animation->startTime());
811 EXPECT_EQ(Animation::Finished, animation->playStateInternal()); 818 EXPECT_EQ(Animation::Finished, animation->playStateInternal());
812 } 819 }
813 820
814 TEST_F(AnimationAnimationTest, PauseAfterCancel) 821 TEST_F(AnimationAnimationTest, PauseAfterCancel)
815 { 822 {
816 animation->cancel(); 823 animation->cancel();
817 EXPECT_EQ(Animation::Idle, animation->playStateInternal()); 824 EXPECT_EQ(Animation::Idle, animation->playStateInternal());
818 EXPECT_TRUE(std::isnan(animation->currentTime())); 825 EXPECT_TRUE(std::isnan(animation->currentTime()));
819 EXPECT_TRUE(std::isnan(animation->startTime())); 826 EXPECT_TRUE(std::isnan(animation->startTime()));
820 animation->pause(); 827 animation->pause();
821 EXPECT_EQ(Animation::Pending, animation->playStateInternal()); 828 EXPECT_EQ(Animation::Pending, animation->playStateInternal());
822 EXPECT_EQ(0, animation->currentTime()); 829 EXPECT_EQ(0, animation->currentTime());
823 EXPECT_TRUE(std::isnan(animation->startTime())); 830 EXPECT_TRUE(std::isnan(animation->startTime()));
824 } 831 }
825 832
826 } // namespace blink 833 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698