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

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

Issue 365163004: Web Animations: Remove timeLag from Player API and model (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 6 years, 5 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.idl ('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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 TrackExceptionState exceptionState; 88 TrackExceptionState exceptionState;
89 }; 89 };
90 90
91 TEST_F(AnimationAnimationPlayerTest, InitialState) 91 TEST_F(AnimationAnimationPlayerTest, InitialState)
92 { 92 {
93 setUpWithoutStartingTimeline(); 93 setUpWithoutStartingTimeline();
94 player = timeline->createAnimationPlayer(0); 94 player = timeline->createAnimationPlayer(0);
95 EXPECT_EQ(0, player->currentTimeInternal()); 95 EXPECT_EQ(0, player->currentTimeInternal());
96 EXPECT_FALSE(player->paused()); 96 EXPECT_FALSE(player->paused());
97 EXPECT_EQ(1, player->playbackRate()); 97 EXPECT_EQ(1, player->playbackRate());
98 EXPECT_EQ(0, player->timeLagInternal());
99 EXPECT_FALSE(player->hasStartTime()); 98 EXPECT_FALSE(player->hasStartTime());
100 EXPECT_TRUE(isNull(player->startTimeInternal())); 99 EXPECT_TRUE(isNull(player->startTimeInternal()));
101 100
102 startTimeline(); 101 startTimeline();
103 player->setStartTimeInternal(0); 102 player->setStartTimeInternal(0);
104 EXPECT_EQ(0, timeline->currentTimeInternal()); 103 EXPECT_EQ(0, timeline->currentTimeInternal());
105 EXPECT_EQ(0, player->currentTimeInternal()); 104 EXPECT_EQ(0, player->currentTimeInternal());
106 EXPECT_FALSE(player->paused()); 105 EXPECT_FALSE(player->paused());
107 EXPECT_EQ(1, player->playbackRate()); 106 EXPECT_EQ(1, player->playbackRate());
108 EXPECT_EQ(0, player->startTimeInternal()); 107 EXPECT_EQ(0, player->startTimeInternal());
109 EXPECT_EQ(0, player->timeLagInternal());
110 EXPECT_TRUE(player->hasStartTime()); 108 EXPECT_TRUE(player->hasStartTime());
111 } 109 }
112 110
113 111
114 TEST_F(AnimationAnimationPlayerTest, CurrentTimeDoesNotSetOutdated) 112 TEST_F(AnimationAnimationPlayerTest, CurrentTimeDoesNotSetOutdated)
115 { 113 {
116 EXPECT_FALSE(player->outdated()); 114 EXPECT_FALSE(player->outdated());
117 EXPECT_EQ(0, player->currentTimeInternal()); 115 EXPECT_EQ(0, player->currentTimeInternal());
118 EXPECT_FALSE(player->outdated()); 116 EXPECT_FALSE(player->outdated());
119 // FIXME: We should split updateTimeline into a version that doesn't update 117 // FIXME: We should split updateTimeline into a version that doesn't update
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 { 182 {
185 player->setCurrentTimeInternal(std::numeric_limits<double>::max()); 183 player->setCurrentTimeInternal(std::numeric_limits<double>::max());
186 EXPECT_EQ(std::numeric_limits<double>::max(), player->currentTimeInternal()) ; 184 EXPECT_EQ(std::numeric_limits<double>::max(), player->currentTimeInternal()) ;
187 updateTimeline(100); 185 updateTimeline(100);
188 EXPECT_EQ(std::numeric_limits<double>::max(), player->currentTimeInternal()) ; 186 EXPECT_EQ(std::numeric_limits<double>::max(), player->currentTimeInternal()) ;
189 } 187 }
190 188
191 TEST_F(AnimationAnimationPlayerTest, SetCurrentTimeUnrestrictedDouble) 189 TEST_F(AnimationAnimationPlayerTest, SetCurrentTimeUnrestrictedDouble)
192 { 190 {
193 updateTimeline(10); 191 updateTimeline(10);
194 player->setCurrentTimeInternal(nullValue()); 192 player->setCurrentTime(nullValue());
195 EXPECT_EQ(10, player->currentTimeInternal()); 193 EXPECT_EQ(10, player->currentTimeInternal());
196 player->setCurrentTimeInternal(std::numeric_limits<double>::infinity()); 194 player->setCurrentTime(std::numeric_limits<double>::infinity());
197 EXPECT_EQ(10, player->currentTimeInternal()); 195 EXPECT_EQ(10, player->currentTimeInternal());
198 player->setCurrentTimeInternal(-std::numeric_limits<double>::infinity()); 196 player->setCurrentTime(-std::numeric_limits<double>::infinity());
199 EXPECT_EQ(10, player->currentTimeInternal()); 197 EXPECT_EQ(10, player->currentTimeInternal());
200 } 198 }
201 199
202 TEST_F(AnimationAnimationPlayerTest, TimeLag) 200
201 TEST_F(AnimationAnimationPlayerTest, SetCurrentTimeSetsStartTime)
203 { 202 {
204 player->setCurrentTimeInternal(10); 203 EXPECT_EQ(0, player->startTime());
205 EXPECT_EQ(-10, player->timeLagInternal()); 204 player->setCurrentTime(1000);
206 updateTimeline(10); 205 EXPECT_EQ(-1000, player->startTime());
207 EXPECT_EQ(-10, player->timeLagInternal()); 206 updateTimeline(1);
208 player->setCurrentTimeInternal(40); 207 EXPECT_EQ(-1000, player->startTime());
209 EXPECT_EQ(-30, player->timeLagInternal()); 208 EXPECT_EQ(2000, player->currentTime());
210 updateTimeline(20);
211 EXPECT_EQ(-20, player->timeLagInternal());
212 } 209 }
213 210
214
215 TEST_F(AnimationAnimationPlayerTest, SetStartTime) 211 TEST_F(AnimationAnimationPlayerTest, SetStartTime)
216 { 212 {
217 updateTimeline(20); 213 updateTimeline(20);
218 EXPECT_EQ(0, player->startTimeInternal()); 214 EXPECT_EQ(0, player->startTimeInternal());
219 EXPECT_EQ(20, player->currentTimeInternal()); 215 EXPECT_EQ(20, player->currentTimeInternal());
220 player->setStartTimeInternal(10); 216 player->setStartTimeInternal(10);
221 EXPECT_EQ(10, player->startTimeInternal()); 217 EXPECT_EQ(10, player->startTimeInternal());
222 EXPECT_EQ(10, player->currentTimeInternal()); 218 EXPECT_EQ(10, player->currentTimeInternal());
223 updateTimeline(30); 219 updateTimeline(30);
224 EXPECT_EQ(10, player->startTimeInternal()); 220 EXPECT_EQ(10, player->startTimeInternal());
(...skipping 14 matching lines...) Expand all
239 { 235 {
240 updateTimeline(30); 236 updateTimeline(30);
241 player->setStartTimeInternal(-10); 237 player->setStartTimeInternal(-10);
242 EXPECT_EQ(30, player->currentTimeInternal()); 238 EXPECT_EQ(30, player->currentTimeInternal());
243 player->setCurrentTimeInternal(50); 239 player->setCurrentTimeInternal(50);
244 player->setStartTimeInternal(-40); 240 player->setStartTimeInternal(-40);
245 EXPECT_EQ(50, player->currentTimeInternal()); 241 EXPECT_EQ(50, player->currentTimeInternal());
246 EXPECT_TRUE(player->finished()); 242 EXPECT_TRUE(player->finished());
247 } 243 }
248 244
245 TEST_F(AnimationAnimationPlayerTest, StartTimePauseFinish)
246 {
247 player->pause();
248 EXPECT_TRUE(std::isnan(player->startTime()));
249 player->finish(exceptionState);
250 EXPECT_TRUE(std::isnan(player->startTime()));
251 }
252
253 TEST_F(AnimationAnimationPlayerTest, StartTimeFinishPause)
254 {
255 double startTime = player->startTime();
256 player->finish(exceptionState);
257 EXPECT_EQ(startTime, player->startTime());
258 player->pause();
259 EXPECT_TRUE(std::isnan(player->startTime()));
260 }
261
262 TEST_F(AnimationAnimationPlayerTest, StartTimeWithZeroPlaybackRate)
263 {
264 player->setPlaybackRate(0);
265 EXPECT_TRUE(std::isnan(player->startTime()));
266 }
267
249 TEST_F(AnimationAnimationPlayerTest, SetStartTimeWhilePaused) 268 TEST_F(AnimationAnimationPlayerTest, SetStartTimeWhilePaused)
250 { 269 {
251 updateTimeline(10); 270 updateTimeline(10);
252 player->pause(); 271 player->pause();
253 player->setStartTimeInternal(-40); 272 player->setStartTimeInternal(-40);
254 EXPECT_EQ(10, player->currentTimeInternal()); 273 EXPECT_EQ(10, player->currentTimeInternal());
255 updateTimeline(50); 274 updateTimeline(50);
256 player->setStartTimeInternal(60); 275 player->setStartTimeInternal(60);
257 EXPECT_EQ(10, player->currentTimeInternal()); 276 EXPECT_EQ(10, player->currentTimeInternal());
258 } 277 }
259 278
260
261 TEST_F(AnimationAnimationPlayerTest, PausePlay) 279 TEST_F(AnimationAnimationPlayerTest, PausePlay)
262 { 280 {
263 updateTimeline(10); 281 updateTimeline(10);
264 player->pause(); 282 player->pause();
265 EXPECT_TRUE(player->paused()); 283 EXPECT_TRUE(player->paused());
266 EXPECT_EQ(10, player->currentTimeInternal()); 284 EXPECT_EQ(10, player->currentTimeInternal());
267 updateTimeline(20); 285 updateTimeline(20);
268 player->play(); 286 player->play();
269 EXPECT_FALSE(player->paused()); 287 EXPECT_FALSE(player->paused());
270 EXPECT_EQ(10, player->currentTimeInternal()); 288 EXPECT_EQ(10, player->currentTimeInternal());
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 } 726 }
709 727
710 TEST_F(AnimationAnimationPlayerTest, HasLowerPriority) 728 TEST_F(AnimationAnimationPlayerTest, HasLowerPriority)
711 { 729 {
712 RefPtrWillBeRawPtr<AnimationPlayer> player1 = timeline->createAnimationPlaye r(0); 730 RefPtrWillBeRawPtr<AnimationPlayer> player1 = timeline->createAnimationPlaye r(0);
713 RefPtrWillBeRawPtr<AnimationPlayer> player2 = timeline->createAnimationPlaye r(0); 731 RefPtrWillBeRawPtr<AnimationPlayer> player2 = timeline->createAnimationPlaye r(0);
714 EXPECT_TRUE(AnimationPlayer::hasLowerPriority(player1.get(), player2.get())) ; 732 EXPECT_TRUE(AnimationPlayer::hasLowerPriority(player1.get(), player2.get())) ;
715 } 733 }
716 734
717 } 735 }
OLDNEW
« no previous file with comments | « Source/core/animation/AnimationPlayer.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698