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

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: Reinstate assert 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 ASSERT_EQ(0, timeline->currentTime()); 92 ASSERT_EQ(0, timeline->currentTime());
93 } 93 }
94 94
95 virtual void TearDown() 95 virtual void TearDown()
96 { 96 {
97 timeline.release(); 97 timeline.release();
98 document.release(); 98 document.release();
99 element.release(); 99 element.release();
100 } 100 }
101 101
102 void updateClockAndService(double time)
103 {
104 document->animationClock().updateTime(time);
105 timeline->serviceAnimations();
106 }
107
102 RefPtr<Document> document; 108 RefPtr<Document> document;
103 RefPtr<Element> element; 109 RefPtr<Element> element;
104 RefPtr<DocumentTimeline> timeline; 110 RefPtr<DocumentTimeline> timeline;
105 Timing timing; 111 Timing timing;
106 MockPlatformTiming* platformTiming; 112 MockPlatformTiming* platformTiming;
107 113
108 void wake() 114 void wake()
109 { 115 {
110 timeline->wake(); 116 timeline->wake();
111 } 117 }
112 118
113 double minimumDelay() 119 double minimumDelay()
114 { 120 {
115 return DocumentTimeline::s_minimumDelay; 121 return DocumentTimeline::s_minimumDelay;
116 } 122 }
117
118 }; 123 };
119 124
120 TEST_F(CoreAnimationDocumentTimelineTest, EmptyKeyframeAnimation) 125 TEST_F(CoreAnimationDocumentTimelineTest, EmptyKeyframeAnimation)
121 { 126 {
122 RefPtr<KeyframeAnimationEffect> effect = KeyframeAnimationEffect::create(Key frameAnimationEffect::KeyframeVector()); 127 RefPtr<KeyframeAnimationEffect> effect = KeyframeAnimationEffect::create(Key frameAnimationEffect::KeyframeVector());
123 RefPtr<Animation> anim = Animation::create(element.get(), effect, timing); 128 RefPtr<Animation> anim = Animation::create(element.get(), effect, timing);
124 129
125 timeline->play(anim.get()); 130 timeline->play(anim.get());
126 131
127 platformTiming->expectNoMoreActions(); 132 platformTiming->expectNoMoreActions();
128 timeline->serviceAnimations(0); 133 updateClockAndService(0);
129 EXPECT_FLOAT_EQ(0, timeline->currentTime()); 134 EXPECT_FLOAT_EQ(0, timeline->currentTime());
130 EXPECT_TRUE(anim->compositableValues()->isEmpty()); 135 EXPECT_TRUE(anim->compositableValues()->isEmpty());
131 136
132 platformTiming->expectNoMoreActions(); 137 platformTiming->expectNoMoreActions();
133 timeline->serviceAnimations(100); 138 updateClockAndService(100);
134 EXPECT_FLOAT_EQ(100, timeline->currentTime()); 139 EXPECT_FLOAT_EQ(100, timeline->currentTime());
135 } 140 }
136 141
137 TEST_F(CoreAnimationDocumentTimelineTest, ZeroTimeAsPerfTime) 142 TEST_F(CoreAnimationDocumentTimelineTest, EmptyTimelineDoesNotTriggerStyleRecalc )
143 {
144 document->animationClock().updateTime(100);
145 EXPECT_FALSE(timeline->serviceAnimations());
146 }
147
148 TEST_F(CoreAnimationDocumentTimelineTest, EmptyPlayerDoesNotTriggerStyleRecalc)
149 {
150 timeline->play(0);
151 document->animationClock().updateTime(100);
152 EXPECT_FALSE(timeline->serviceAnimations());
153 }
154
155 TEST_F(CoreAnimationDocumentTimelineTest, EmptyTargetDoesNotTriggerStyleRecalc)
156 {
157 timing.iterationDuration = 200;
158 timeline->play(Animation::create(0, KeyframeAnimationEffect::create(Keyframe AnimationEffect::KeyframeVector()), timing).get());
159 document->animationClock().updateTime(100);
160 EXPECT_FALSE(timeline->serviceAnimations());
161 }
162
163 TEST_F(CoreAnimationDocumentTimelineTest, EmptyEffectDoesNotTriggerStyleRecalc)
164 {
165 timeline->play(Animation::create(element.get(), 0, timing).get());
166 document->animationClock().updateTime(100);
167 EXPECT_FALSE(timeline->serviceAnimations());
168 }
169
170 TEST_F(CoreAnimationDocumentTimelineTest, TriggerStyleRecalc)
171 {
172 timeline->play(Animation::create(element.get(), KeyframeAnimationEffect::cre ate(KeyframeAnimationEffect::KeyframeVector()), timing).get());
173 document->animationClock().updateTime(100);
174 EXPECT_TRUE(timeline->serviceAnimations());
175 }
176
177 TEST_F(CoreAnimationDocumentTimelineTest, ZeroTime)
138 { 178 {
139 timeline = DocumentTimeline::create(document.get()); 179 timeline = DocumentTimeline::create(document.get());
140 180
141 timeline->serviceAnimations(100); 181 document->animationClock().updateTime(100);
142 EXPECT_TRUE(isNull(timeline->currentTime())); 182 EXPECT_TRUE(isNull(timeline->currentTime()));
143 183
144 timeline->serviceAnimations(200); 184 document->animationClock().updateTime(200);
145 EXPECT_TRUE(isNull(timeline->currentTime())); 185 EXPECT_TRUE(isNull(timeline->currentTime()));
146 186
147 timeline->setZeroTime(300); 187 timeline->setZeroTime(300);
148 document->animationClock().updateTime(300); 188 document->animationClock().updateTime(300);
149 timeline->serviceAnimations(300);
150 EXPECT_EQ(0, timeline->currentTime()); 189 EXPECT_EQ(0, timeline->currentTime());
151 190
152 timeline->serviceAnimations(400); 191 document->animationClock().updateTime(400);
153 EXPECT_EQ(100, timeline->currentTime()); 192 EXPECT_EQ(100, timeline->currentTime());
154 } 193 }
155 194
156 TEST_F(CoreAnimationDocumentTimelineTest, PauseForTesting) 195 TEST_F(CoreAnimationDocumentTimelineTest, PauseForTesting)
157 { 196 {
158 float seekTime = 1; 197 float seekTime = 1;
159 RefPtr<Animation> anim1 = Animation::create(element.get(), KeyframeAnimation Effect::create(KeyframeAnimationEffect::KeyframeVector()), timing); 198 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); 199 RefPtr<Animation> anim2 = Animation::create(element.get(), KeyframeAnimatio nEffect::create(KeyframeAnimationEffect::KeyframeVector()), timing);
161 RefPtr<Player> player1 = timeline->play(anim1.get()); 200 RefPtr<Player> player1 = timeline->play(anim1.get());
162 RefPtr<Player> player2 = timeline->play(anim2.get()); 201 RefPtr<Player> player2 = timeline->play(anim2.get());
(...skipping 30 matching lines...) Expand all
193 RefPtr<Animation> anim2 = Animation::create(element.get(), KeyframeAnimation Effect::create(KeyframeAnimationEffect::KeyframeVector()), timingNoFill); 232 RefPtr<Animation> anim2 = Animation::create(element.get(), KeyframeAnimation Effect::create(KeyframeAnimationEffect::KeyframeVector()), timingNoFill);
194 RefPtr<Animation> anim3 = Animation::create(element.get(), KeyframeAnimation Effect::create(KeyframeAnimationEffect::KeyframeVector()), timingBackwardFillDel ay); 233 RefPtr<Animation> anim3 = Animation::create(element.get(), KeyframeAnimation Effect::create(KeyframeAnimationEffect::KeyframeVector()), timingBackwardFillDel ay);
195 RefPtr<Animation> anim4 = Animation::create(element.get(), KeyframeAnimation Effect::create(KeyframeAnimationEffect::KeyframeVector()), timingNoFillDelay); 234 RefPtr<Animation> anim4 = Animation::create(element.get(), KeyframeAnimation Effect::create(KeyframeAnimationEffect::KeyframeVector()), timingNoFillDelay);
196 235
197 RefPtr<Player> player1 = timeline->play(anim1.get()); 236 RefPtr<Player> player1 = timeline->play(anim1.get());
198 RefPtr<Player> player2 = timeline->play(anim2.get()); 237 RefPtr<Player> player2 = timeline->play(anim2.get());
199 RefPtr<Player> player3 = timeline->play(anim3.get()); 238 RefPtr<Player> player3 = timeline->play(anim3.get());
200 RefPtr<Player> player4 = timeline->play(anim4.get()); 239 RefPtr<Player> player4 = timeline->play(anim4.get());
201 240
202 platformTiming->expectNextFrameAction(); 241 platformTiming->expectNextFrameAction();
203 timeline->serviceAnimations(0); 242 updateClockAndService(0);
204 EXPECT_EQ(4U, timeline->numberOfActiveAnimationsForTesting()); 243 EXPECT_EQ(4U, timeline->numberOfActiveAnimationsForTesting());
205 platformTiming->expectNextFrameAction(); 244 platformTiming->expectNextFrameAction();
206 timeline->serviceAnimations(0.5); 245 updateClockAndService(0.5);
207 EXPECT_EQ(4U, timeline->numberOfActiveAnimationsForTesting()); 246 EXPECT_EQ(4U, timeline->numberOfActiveAnimationsForTesting());
208 platformTiming->expectNextFrameAction(); 247 platformTiming->expectNextFrameAction();
209 timeline->serviceAnimations(1.5); 248 updateClockAndService(1.5);
210 EXPECT_EQ(4U, timeline->numberOfActiveAnimationsForTesting()); 249 EXPECT_EQ(4U, timeline->numberOfActiveAnimationsForTesting());
211 platformTiming->expectNoMoreActions(); 250 platformTiming->expectNoMoreActions();
212 timeline->serviceAnimations(3); 251 updateClockAndService(3);
213 EXPECT_EQ(1U, timeline->numberOfActiveAnimationsForTesting()); 252 EXPECT_EQ(1U, timeline->numberOfActiveAnimationsForTesting());
214 } 253 }
215 254
216 TEST_F(CoreAnimationDocumentTimelineTest, DelayBeforeAnimationStart) 255 TEST_F(CoreAnimationDocumentTimelineTest, DelayBeforeAnimationStart)
217 { 256 {
218
219 timing.hasIterationDuration = true; 257 timing.hasIterationDuration = true;
220 timing.iterationDuration = 2; 258 timing.iterationDuration = 2;
221 timing.startDelay = 5; 259 timing.startDelay = 5;
222 260
223 RefPtr<Animation> anim = Animation::create(element.get(), 0, timing); 261 RefPtr<Animation> anim = Animation::create(element.get(), 0, timing);
224 262
225 RefPtr<Player> player = timeline->play(anim.get()); 263 RefPtr<Player> player = timeline->play(anim.get());
226 264
227 // TODO: Put the player startTime in the future when we add the capability t o change player startTime 265 // TODO: Put the player startTime in the future when we add the capability t o change player startTime
228 platformTiming->expectDelayedAction(timing.startDelay - minimumDelay()); 266 platformTiming->expectDelayedAction(timing.startDelay - minimumDelay());
229 timeline->serviceAnimations(0); 267 updateClockAndService(0);
230 268
231 platformTiming->expectDelayedAction(timing.startDelay - minimumDelay() - 1.5 ); 269 platformTiming->expectDelayedAction(timing.startDelay - minimumDelay() - 1.5 );
232 timeline->serviceAnimations(1.5); 270 updateClockAndService(1.5);
233 271
234 EXPECT_CALL(*platformTiming, serviceOnNextFrame()); 272 EXPECT_CALL(*platformTiming, serviceOnNextFrame());
235 wake(); 273 wake();
236 274
237 platformTiming->expectNextFrameAction(); 275 platformTiming->expectNextFrameAction();
238 timeline->serviceAnimations(4.98); 276 updateClockAndService(4.98);
239 } 277 }
240 278
241 } 279 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698