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

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

Issue 555063002: Web Animations: Add tests for player state transitions and fix discovered issues (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Address comments. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/animation/AnimationPlayer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal()); 277 EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal());
278 EXPECT_TRUE(player->finished()); 278 EXPECT_TRUE(player->finished());
279 } 279 }
280 280
281 TEST_F(AnimationAnimationPlayerTest, StartTimePauseFinish) 281 TEST_F(AnimationAnimationPlayerTest, StartTimePauseFinish)
282 { 282 {
283 player->pause(); 283 player->pause();
284 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal()); 284 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
285 EXPECT_TRUE(std::isnan(player->startTime())); 285 EXPECT_TRUE(std::isnan(player->startTime()));
286 player->finish(exceptionState); 286 player->finish(exceptionState);
287 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal()); 287 EXPECT_EQ(AnimationPlayer::Paused, player->playStateInternal());
288 EXPECT_TRUE(std::isnan(player->startTime())); 288 EXPECT_TRUE(std::isnan(player->startTime()));
289 } 289 }
290 290
291 TEST_F(AnimationAnimationPlayerTest, PauseBeatsFinish) 291 TEST_F(AnimationAnimationPlayerTest, PauseBeatsFinish)
292 { 292 {
293 player->pause(); 293 player->pause();
294 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal()); 294 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
295 simulateFrame(10); 295 simulateFrame(10);
296 EXPECT_EQ(AnimationPlayer::Paused, player->playStateInternal()); 296 EXPECT_EQ(AnimationPlayer::Paused, player->playStateInternal());
297 player->finish(exceptionState); 297 player->finish(exceptionState);
298 EXPECT_EQ(AnimationPlayer::Paused, player->playStateInternal()); 298 EXPECT_EQ(AnimationPlayer::Paused, player->playStateInternal());
299 } 299 }
300 300
301 TEST_F(AnimationAnimationPlayerTest, StartTimeFinishPause) 301 TEST_F(AnimationAnimationPlayerTest, StartTimeFinishPause)
302 { 302 {
303 double startTime = player->startTime();
304 player->finish(exceptionState); 303 player->finish(exceptionState);
305 EXPECT_EQ(startTime, player->startTime()); 304 EXPECT_EQ(-30 * 1000, player->startTime());
306 player->pause(); 305 player->pause();
307 EXPECT_TRUE(std::isnan(player->startTime())); 306 EXPECT_TRUE(std::isnan(player->startTime()));
308 } 307 }
309 308
310 TEST_F(AnimationAnimationPlayerTest, StartTimeWithZeroPlaybackRate) 309 TEST_F(AnimationAnimationPlayerTest, StartTimeWithZeroPlaybackRate)
311 { 310 {
312 player->setPlaybackRate(0); 311 player->setPlaybackRate(0);
313 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal()); 312 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
314 EXPECT_TRUE(std::isnan(player->startTime())); 313 EXPECT_TRUE(std::isnan(player->startTime()));
315 simulateFrame(10); 314 simulateFrame(10);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 EXPECT_EQ(0, player->currentTimeInternal()); 453 EXPECT_EQ(0, player->currentTimeInternal());
455 } 454 }
456 455
457 TEST_F(AnimationAnimationPlayerTest, ReverseSeeksToEnd) 456 TEST_F(AnimationAnimationPlayerTest, ReverseSeeksToEnd)
458 { 457 {
459 player->setCurrentTimeInternal(40); 458 player->setCurrentTimeInternal(40);
460 player->reverse(); 459 player->reverse();
461 EXPECT_EQ(30, player->currentTimeInternal()); 460 EXPECT_EQ(30, player->currentTimeInternal());
462 } 461 }
463 462
464 TEST_F(AnimationAnimationPlayerTest, ReverseLimitsAnimationPlayer) 463 TEST_F(AnimationAnimationPlayerTest, ReverseBeyondLimit)
465 { 464 {
466 player->setCurrentTimeInternal(40); 465 player->setCurrentTimeInternal(40);
467 player->setPlaybackRate(-1); 466 player->setPlaybackRate(-1);
468 player->reverse(); 467 player->reverse();
469 EXPECT_TRUE(player->finished()); 468 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
470 EXPECT_EQ(40, player->currentTimeInternal()); 469 EXPECT_EQ(0, player->currentTimeInternal());
471 470
472 player->setCurrentTimeInternal(-10); 471 player->setCurrentTimeInternal(-10);
473 player->reverse(); 472 player->reverse();
474 EXPECT_TRUE(player->finished()); 473 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
475 EXPECT_EQ(-10, player->currentTimeInternal()); 474 EXPECT_EQ(30, player->currentTimeInternal());
476 } 475 }
477 476
478 477
479 TEST_F(AnimationAnimationPlayerTest, Finish) 478 TEST_F(AnimationAnimationPlayerTest, Finish)
480 { 479 {
481 player->finish(exceptionState); 480 player->finish(exceptionState);
482 EXPECT_EQ(30, player->currentTimeInternal()); 481 EXPECT_EQ(30, player->currentTimeInternal());
483 EXPECT_TRUE(player->finished()); 482 EXPECT_TRUE(player->finished());
484 483
485 player->setPlaybackRate(-1); 484 player->setPlaybackRate(-1);
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 player->play(); 841 player->play();
843 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal()); 842 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
844 EXPECT_EQ(30 * 1000, player->currentTime()); 843 EXPECT_EQ(30 * 1000, player->currentTime());
845 EXPECT_TRUE(std::isnan(player->startTime())); 844 EXPECT_TRUE(std::isnan(player->startTime()));
846 simulateFrame(10); 845 simulateFrame(10);
847 EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal()); 846 EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
848 EXPECT_EQ(30 * 1000, player->currentTime()); 847 EXPECT_EQ(30 * 1000, player->currentTime());
849 EXPECT_EQ(40 * 1000, player->startTime()); 848 EXPECT_EQ(40 * 1000, player->startTime());
850 } 849 }
851 850
852 // FIXME: crbug.com/410229, when fixed, will reuqire the expected results of
853 // this test to change (currentTime -> 30 * 1000).
854 TEST_F(AnimationAnimationPlayerTest, ReverseAfterCancel) 851 TEST_F(AnimationAnimationPlayerTest, ReverseAfterCancel)
855 { 852 {
856 player->cancel(); 853 player->cancel();
857 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal()); 854 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
858 EXPECT_TRUE(std::isnan(player->currentTime())); 855 EXPECT_TRUE(std::isnan(player->currentTime()));
859 EXPECT_TRUE(std::isnan(player->startTime())); 856 EXPECT_TRUE(std::isnan(player->startTime()));
860 player->reverse(); 857 player->reverse();
861 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal()); 858 EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
862 EXPECT_TRUE(std::isnan(player->currentTime())); 859 EXPECT_EQ(30 * 1000, player->currentTime());
863 EXPECT_TRUE(std::isnan(player->startTime())); 860 EXPECT_TRUE(std::isnan(player->startTime()));
864 simulateFrame(10); 861 simulateFrame(10);
865 EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal()); 862 EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
866 EXPECT_EQ(0 * 1000, player->currentTime()); 863 EXPECT_EQ(30 * 1000, player->currentTime());
867 EXPECT_EQ(10 * 1000, player->startTime()); 864 EXPECT_EQ(40 * 1000, player->startTime());
868 } 865 }
869 866
870 TEST_F(AnimationAnimationPlayerTest, FinishAfterCancel) 867 TEST_F(AnimationAnimationPlayerTest, FinishAfterCancel)
871 { 868 {
872 player->cancel(); 869 player->cancel();
873 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal()); 870 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
874 EXPECT_TRUE(std::isnan(player->currentTime())); 871 EXPECT_TRUE(std::isnan(player->currentTime()));
875 EXPECT_TRUE(std::isnan(player->startTime())); 872 EXPECT_TRUE(std::isnan(player->startTime()));
876 player->finish(exceptionState); 873 player->finish(exceptionState);
877 EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal()); 874 EXPECT_TRUE(std::isnan(player->currentTime()));
878 EXPECT_EQ(30 * 1000, player->currentTime()); 875 EXPECT_TRUE(std::isnan(player->startTime()));
879 EXPECT_EQ(0, player->startTime()); 876 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
880 } 877 }
881 878
882 TEST_F(AnimationAnimationPlayerTest, PauseAfterCancel) 879 TEST_F(AnimationAnimationPlayerTest, PauseAfterCancel)
883 { 880 {
884 player->cancel(); 881 player->cancel();
885 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal()); 882 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
886 EXPECT_TRUE(std::isnan(player->currentTime())); 883 EXPECT_TRUE(std::isnan(player->currentTime()));
887 EXPECT_TRUE(std::isnan(player->startTime())); 884 EXPECT_TRUE(std::isnan(player->startTime()));
888 player->pause(); 885 player->pause();
889 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal()); 886 EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
890 EXPECT_TRUE(std::isnan(player->currentTime())); 887 EXPECT_TRUE(std::isnan(player->currentTime()));
891 EXPECT_TRUE(std::isnan(player->startTime())); 888 EXPECT_TRUE(std::isnan(player->startTime()));
892 } 889 }
893 890
894 } 891 }
OLDNEW
« no previous file with comments | « Source/core/animation/AnimationPlayer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698