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

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

Issue 46043014: Web Animations CSS: Unfreeze AnimationClock if sampling timelines does not trigger style recalc (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Really fix unit tests Created 7 years, 1 month 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 void wake() 108 void wake()
109 { 109 {
110 timeline->wake(); 110 timeline->wake();
111 } 111 }
112 112
113 double minimumDelay() 113 double minimumDelay()
114 { 114 {
115 return DocumentTimeline::s_minimumDelay; 115 return DocumentTimeline::s_minimumDelay;
116 } 116 }
117
118 }; 117 };
119 118
120 TEST_F(CoreAnimationDocumentTimelineTest, EmptyKeyframeAnimation) 119 TEST_F(CoreAnimationDocumentTimelineTest, EmptyKeyframeAnimation)
121 { 120 {
122 RefPtr<KeyframeAnimationEffect> effect = KeyframeAnimationEffect::create(Key frameAnimationEffect::KeyframeVector()); 121 RefPtr<KeyframeAnimationEffect> effect = KeyframeAnimationEffect::create(Key frameAnimationEffect::KeyframeVector());
123 RefPtr<Animation> anim = Animation::create(element.get(), effect, timing); 122 RefPtr<Animation> anim = Animation::create(element.get(), effect, timing);
124 123
125 timeline->play(anim.get()); 124 timeline->play(anim.get());
126 125
127 platformTiming->expectNoMoreActions(); 126 platformTiming->expectNoMoreActions();
128 timeline->serviceAnimations(0); 127 timeline->serviceAnimations(0);
129 EXPECT_FLOAT_EQ(0, timeline->currentTime()); 128 EXPECT_FLOAT_EQ(0, timeline->currentTime());
130 EXPECT_TRUE(anim->compositableValues()->isEmpty()); 129 EXPECT_TRUE(anim->compositableValues()->isEmpty());
131 130
132 platformTiming->expectNoMoreActions(); 131 platformTiming->expectNoMoreActions();
133 timeline->serviceAnimations(100); 132 timeline->serviceAnimations(100);
134 EXPECT_FLOAT_EQ(100, timeline->currentTime()); 133 EXPECT_FLOAT_EQ(100, timeline->currentTime());
135 } 134 }
136 135
137 TEST_F(CoreAnimationDocumentTimelineTest, ZeroTimeAsPerfTime) 136 TEST_F(CoreAnimationDocumentTimelineTest, EmptyTimelineDoesNotFreezeTime)
137 {
138 timeline->serviceAnimations(100);
139 EXPECT_NE(100, timeline->currentTime());
140 }
141
142 TEST_F(CoreAnimationDocumentTimelineTest, EmptyPlayerDoesNotFreezeTime)
143 {
144 timeline->play(0);
145 timeline->serviceAnimations(100);
146 EXPECT_NE(100, timeline->currentTime());
147 }
148
149 TEST_F(CoreAnimationDocumentTimelineTest, EmptyTargetDoesNotFreezeTime)
150 {
151 timing.iterationDuration = 200;
152 timeline->play(Animation::create(0, KeyframeAnimationEffect::create(Keyframe AnimationEffect::KeyframeVector()), timing).get());
153 timeline->serviceAnimations(100);
154 EXPECT_NE(100, timeline->currentTime());
155 }
156
157 TEST_F(CoreAnimationDocumentTimelineTest, EmptyEffectDoesNotFreezeTime)
158 {
159 timeline->play(Animation::create(element.get(), 0, timing).get());
160 timeline->serviceAnimations(100);
161 EXPECT_NE(100, timeline->currentTime());
162 }
163
164 TEST_F(CoreAnimationDocumentTimelineTest, FreezeTime)
165 {
166 timeline->play(Animation::create(element.get(), KeyframeAnimationEffect::cre ate(KeyframeAnimationEffect::KeyframeVector()), timing).get());
167 timeline->serviceAnimations(100);
168 EXPECT_EQ(100, timeline->currentTime());
169 }
170
171 TEST_F(CoreAnimationDocumentTimelineTest, ZeroTime)
138 { 172 {
139 timeline = DocumentTimeline::create(document.get()); 173 timeline = DocumentTimeline::create(document.get());
140 174
141 timeline->serviceAnimations(100); 175 document->animationClock().updateTime(100);
142 EXPECT_TRUE(isNull(timeline->currentTime())); 176 EXPECT_TRUE(isNull(timeline->currentTime()));
143 177
144 timeline->serviceAnimations(200); 178 document->animationClock().updateTime(200);
145 EXPECT_TRUE(isNull(timeline->currentTime())); 179 EXPECT_TRUE(isNull(timeline->currentTime()));
146 180
147 timeline->setZeroTime(300); 181 timeline->setZeroTime(300);
148 document->animationClock().updateTime(300); 182 document->animationClock().updateTime(300);
149 timeline->serviceAnimations(300);
150 EXPECT_EQ(0, timeline->currentTime()); 183 EXPECT_EQ(0, timeline->currentTime());
151 184
152 timeline->serviceAnimations(400); 185 document->animationClock().updateTime(400);
153 EXPECT_EQ(100, timeline->currentTime()); 186 EXPECT_EQ(100, timeline->currentTime());
154 } 187 }
155 188
156 TEST_F(CoreAnimationDocumentTimelineTest, PauseForTesting) 189 TEST_F(CoreAnimationDocumentTimelineTest, PauseForTesting)
157 { 190 {
158 float seekTime = 1; 191 float seekTime = 1;
159 RefPtr<Animation> anim1 = Animation::create(element.get(), KeyframeAnimation Effect::create(KeyframeAnimationEffect::KeyframeVector()), timing); 192 RefPtr<Animation> anim1 = Animation::create(element.get(), KeyframeAnimation Effect::create(KeyframeAnimationEffect::KeyframeVector()), timing);
160 RefPtr<Animation> anim2 = Animation::create(element.get(), KeyframeAnimatio nEffect::create(KeyframeAnimationEffect::KeyframeVector()), timing); 193 RefPtr<Animation> anim2 = Animation::create(element.get(), KeyframeAnimatio nEffect::create(KeyframeAnimationEffect::KeyframeVector()), timing);
161 RefPtr<Player> player1 = timeline->play(anim1.get()); 194 RefPtr<Player> player1 = timeline->play(anim1.get());
162 RefPtr<Player> player2 = timeline->play(anim2.get()); 195 RefPtr<Player> player2 = timeline->play(anim2.get());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 platformTiming->expectNextFrameAction(); 241 platformTiming->expectNextFrameAction();
209 timeline->serviceAnimations(1.5); 242 timeline->serviceAnimations(1.5);
210 EXPECT_EQ(4U, timeline->numberOfActiveAnimationsForTesting()); 243 EXPECT_EQ(4U, timeline->numberOfActiveAnimationsForTesting());
211 platformTiming->expectNoMoreActions(); 244 platformTiming->expectNoMoreActions();
212 timeline->serviceAnimations(3); 245 timeline->serviceAnimations(3);
213 EXPECT_EQ(1U, timeline->numberOfActiveAnimationsForTesting()); 246 EXPECT_EQ(1U, timeline->numberOfActiveAnimationsForTesting());
214 } 247 }
215 248
216 TEST_F(CoreAnimationDocumentTimelineTest, DelayBeforeAnimationStart) 249 TEST_F(CoreAnimationDocumentTimelineTest, DelayBeforeAnimationStart)
217 { 250 {
218
219 timing.hasIterationDuration = true; 251 timing.hasIterationDuration = true;
220 timing.iterationDuration = 2; 252 timing.iterationDuration = 2;
221 timing.startDelay = 5; 253 timing.startDelay = 5;
222 254
223 RefPtr<Animation> anim = Animation::create(element.get(), 0, timing); 255 RefPtr<Animation> anim = Animation::create(element.get(), 0, timing);
224 256
225 RefPtr<Player> player = timeline->play(anim.get()); 257 RefPtr<Player> player = timeline->play(anim.get());
226 258
227 // TODO: Put the player startTime in the future when we add the capability t o change player startTime 259 // TODO: Put the player startTime in the future when we add the capability t o change player startTime
228 platformTiming->expectDelayedAction(timing.startDelay - minimumDelay()); 260 platformTiming->expectDelayedAction(timing.startDelay - minimumDelay());
229 timeline->serviceAnimations(0); 261 timeline->serviceAnimations(0);
230 262
231 platformTiming->expectDelayedAction(timing.startDelay - minimumDelay() - 1.5 ); 263 platformTiming->expectDelayedAction(timing.startDelay - minimumDelay() - 1.5 );
232 timeline->serviceAnimations(1.5); 264 timeline->serviceAnimations(1.5);
233 265
234 EXPECT_CALL(*platformTiming, serviceOnNextFrame()); 266 EXPECT_CALL(*platformTiming, serviceOnNextFrame());
235 wake(); 267 wake();
236 268
237 platformTiming->expectNextFrameAction(); 269 platformTiming->expectNextFrameAction();
238 timeline->serviceAnimations(4.98); 270 timeline->serviceAnimations(4.98);
239 } 271 }
240 272
241 } 273 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698