206 QCOMPARE(sequence->state(), QAnimationGroup::Stopped); |
206 QCOMPARE(sequence->state(), QAnimationGroup::Stopped); |
207 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
207 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
208 QCOMPARE(sequence2->state(), QAnimationGroup::Stopped); |
208 QCOMPARE(sequence2->state(), QAnimationGroup::Stopped); |
209 QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); |
209 QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); |
210 |
210 |
211 QCOMPARE(group.currentTime(), 1); |
211 QCOMPARE(group.currentLoopTime(), 1); |
212 QCOMPARE(sequence->currentTime(), 1); |
212 QCOMPARE(sequence->currentLoopTime(), 1); |
213 QCOMPARE(a1_s_o1->currentTime(), 1); |
213 QCOMPARE(a1_s_o1->currentLoopTime(), 1); |
214 QCOMPARE(a2_s_o1->currentTime(), 0); |
214 QCOMPARE(a2_s_o1->currentLoopTime(), 0); |
215 QCOMPARE(a3_s_o1->currentTime(), 0); |
215 QCOMPARE(a3_s_o1->currentLoopTime(), 0); |
216 QCOMPARE(a1_s_o2->currentTime(), 0); |
216 QCOMPARE(a1_s_o2->currentLoopTime(), 0); |
217 QCOMPARE(a1_s_o3->currentTime(), 0); |
217 QCOMPARE(a1_s_o3->currentLoopTime(), 0); |
218 |
218 |
219 // Current time = 250 |
219 // Current time = 250 |
220 group.setCurrentTime(250); |
220 group.setCurrentTime(250); |
221 QCOMPARE(group.currentTime(), 250); |
221 QCOMPARE(group.currentLoopTime(), 250); |
222 QCOMPARE(sequence->currentTime(), 250); |
222 QCOMPARE(sequence->currentLoopTime(), 250); |
223 QCOMPARE(a1_s_o1->currentTime(), 250); |
223 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
224 QCOMPARE(a2_s_o1->currentTime(), 0); |
224 QCOMPARE(a2_s_o1->currentLoopTime(), 0); |
225 QCOMPARE(a3_s_o1->currentTime(), 0); |
225 QCOMPARE(a3_s_o1->currentLoopTime(), 0); |
226 QCOMPARE(a1_s_o2->currentTime(), 0); |
226 QCOMPARE(a1_s_o2->currentLoopTime(), 0); |
227 QCOMPARE(a1_s_o3->currentTime(), 0); |
227 QCOMPARE(a1_s_o3->currentLoopTime(), 0); |
228 |
228 |
229 // Current time = 251 |
229 // Current time = 251 |
230 group.setCurrentTime(251); |
230 group.setCurrentTime(251); |
231 QCOMPARE(group.currentTime(), 251); |
231 QCOMPARE(group.currentLoopTime(), 251); |
232 QCOMPARE(sequence->currentTime(), 251); |
232 QCOMPARE(sequence->currentLoopTime(), 251); |
233 QCOMPARE(a1_s_o1->currentTime(), 250); |
233 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
234 QCOMPARE(a2_s_o1->currentTime(), 1); |
234 QCOMPARE(a2_s_o1->currentLoopTime(), 1); |
235 QCOMPARE(a2_s_o1->currentLoop(), 0); |
235 QCOMPARE(a2_s_o1->currentLoop(), 0); |
236 QCOMPARE(a3_s_o1->currentTime(), 0); |
236 QCOMPARE(a3_s_o1->currentLoopTime(), 0); |
237 QCOMPARE(sequence2->currentTime(), 0); |
237 QCOMPARE(sequence2->currentLoopTime(), 0); |
238 QCOMPARE(a1_s_o2->currentTime(), 0); |
238 QCOMPARE(a1_s_o2->currentLoopTime(), 0); |
239 QCOMPARE(a1_s_o3->currentTime(), 0); |
239 QCOMPARE(a1_s_o3->currentLoopTime(), 0); |
240 |
240 |
241 // Current time = 750 |
241 // Current time = 750 |
242 group.setCurrentTime(750); |
242 group.setCurrentTime(750); |
243 QCOMPARE(group.currentTime(), 750); |
243 QCOMPARE(group.currentLoopTime(), 750); |
244 QCOMPARE(sequence->currentTime(), 750); |
244 QCOMPARE(sequence->currentLoopTime(), 750); |
245 QCOMPARE(a1_s_o1->currentTime(), 250); |
245 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
246 QCOMPARE(a2_s_o1->currentTime(), 0); |
246 QCOMPARE(a2_s_o1->currentLoopTime(), 0); |
247 QCOMPARE(a2_s_o1->currentLoop(), 2); |
247 QCOMPARE(a2_s_o1->currentLoop(), 2); |
248 QCOMPARE(a3_s_o1->currentTime(), 0); |
248 QCOMPARE(a3_s_o1->currentLoopTime(), 0); |
249 QCOMPARE(sequence2->currentTime(), 0); |
249 QCOMPARE(sequence2->currentLoopTime(), 0); |
250 QCOMPARE(a1_s_o2->currentTime(), 0); |
250 QCOMPARE(a1_s_o2->currentLoopTime(), 0); |
251 QCOMPARE(a1_s_o3->currentTime(), 0); |
251 QCOMPARE(a1_s_o3->currentLoopTime(), 0); |
252 |
252 |
253 // Current time = 1000 |
253 // Current time = 1000 |
254 group.setCurrentTime(1000); |
254 group.setCurrentTime(1000); |
255 QCOMPARE(group.currentTime(), 1000); |
255 QCOMPARE(group.currentLoopTime(), 1000); |
256 QCOMPARE(sequence->currentTime(), 1000); |
256 QCOMPARE(sequence->currentLoopTime(), 1000); |
257 QCOMPARE(a1_s_o1->currentTime(), 250); |
257 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
258 QCOMPARE(a2_s_o1->currentTime(), 250); |
258 QCOMPARE(a2_s_o1->currentLoopTime(), 250); |
259 QCOMPARE(a2_s_o1->currentLoop(), 2); |
259 QCOMPARE(a2_s_o1->currentLoop(), 2); |
260 QCOMPARE(a3_s_o1->currentTime(), 0); |
260 QCOMPARE(a3_s_o1->currentLoopTime(), 0); |
261 QCOMPARE(sequence2->currentTime(), 0); |
261 QCOMPARE(sequence2->currentLoopTime(), 0); |
262 QCOMPARE(a1_s_o2->currentTime(), 0); |
262 QCOMPARE(a1_s_o2->currentLoopTime(), 0); |
263 QCOMPARE(a1_s_o3->currentTime(), 0); |
263 QCOMPARE(a1_s_o3->currentLoopTime(), 0); |
264 |
264 |
265 // Current time = 1010 |
265 // Current time = 1010 |
266 group.setCurrentTime(1010); |
266 group.setCurrentTime(1010); |
267 QCOMPARE(group.currentTime(), 1010); |
267 QCOMPARE(group.currentLoopTime(), 1010); |
268 QCOMPARE(sequence->currentTime(), 1010); |
268 QCOMPARE(sequence->currentLoopTime(), 1010); |
269 QCOMPARE(a1_s_o1->currentTime(), 250); |
269 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
270 QCOMPARE(a2_s_o1->currentTime(), 250); |
270 QCOMPARE(a2_s_o1->currentLoopTime(), 250); |
271 QCOMPARE(a2_s_o1->currentLoop(), 2); |
271 QCOMPARE(a2_s_o1->currentLoop(), 2); |
272 QCOMPARE(a3_s_o1->currentTime(), 10); |
272 QCOMPARE(a3_s_o1->currentLoopTime(), 10); |
273 QCOMPARE(sequence2->currentTime(), 0); |
273 QCOMPARE(sequence2->currentLoopTime(), 0); |
274 QCOMPARE(a1_s_o2->currentTime(), 0); |
274 QCOMPARE(a1_s_o2->currentLoopTime(), 0); |
275 QCOMPARE(a1_s_o3->currentTime(), 0); |
275 QCOMPARE(a1_s_o3->currentLoopTime(), 0); |
276 |
276 |
277 // Current time = 1250 |
277 // Current time = 1250 |
278 group.setCurrentTime(1250); |
278 group.setCurrentTime(1250); |
279 QCOMPARE(group.currentTime(), 1250); |
279 QCOMPARE(group.currentLoopTime(), 1250); |
280 QCOMPARE(sequence->currentTime(), 1250); |
280 QCOMPARE(sequence->currentLoopTime(), 1250); |
281 QCOMPARE(a1_s_o1->currentTime(), 250); |
281 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
282 QCOMPARE(a2_s_o1->currentTime(), 250); |
282 QCOMPARE(a2_s_o1->currentLoopTime(), 250); |
283 QCOMPARE(a2_s_o1->currentLoop(), 2); |
283 QCOMPARE(a2_s_o1->currentLoop(), 2); |
284 QCOMPARE(a3_s_o1->currentTime(), 250); |
284 QCOMPARE(a3_s_o1->currentLoopTime(), 250); |
285 QCOMPARE(sequence2->currentTime(), 0); |
285 QCOMPARE(sequence2->currentLoopTime(), 0); |
286 QCOMPARE(a1_s_o2->currentTime(), 0); |
286 QCOMPARE(a1_s_o2->currentLoopTime(), 0); |
287 QCOMPARE(a1_s_o3->currentTime(), 0); |
287 QCOMPARE(a1_s_o3->currentLoopTime(), 0); |
288 |
288 |
289 // Current time = 1500 |
289 // Current time = 1500 |
290 group.setCurrentTime(1500); |
290 group.setCurrentTime(1500); |
291 QCOMPARE(group.currentTime(), 1500); |
291 QCOMPARE(group.currentLoopTime(), 1500); |
292 QCOMPARE(sequence->currentTime(), 1250); |
292 QCOMPARE(sequence->currentLoopTime(), 1250); |
293 QCOMPARE(a1_s_o1->currentTime(), 250); |
293 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
294 QCOMPARE(a2_s_o1->currentTime(), 250); |
294 QCOMPARE(a2_s_o1->currentLoopTime(), 250); |
295 QCOMPARE(a2_s_o1->currentLoop(), 2); |
295 QCOMPARE(a2_s_o1->currentLoop(), 2); |
296 QCOMPARE(a3_s_o1->currentTime(), 250); |
296 QCOMPARE(a3_s_o1->currentLoopTime(), 250); |
297 QCOMPARE(sequence2->currentTime(), 250); |
297 QCOMPARE(sequence2->currentLoopTime(), 250); |
298 QCOMPARE(a1_s_o2->currentTime(), 250); |
298 QCOMPARE(a1_s_o2->currentLoopTime(), 250); |
299 QCOMPARE(a1_s_o3->currentTime(), 0); |
299 QCOMPARE(a1_s_o3->currentLoopTime(), 0); |
300 |
300 |
301 // Current time = 1750 |
301 // Current time = 1750 |
302 group.setCurrentTime(1750); |
302 group.setCurrentTime(1750); |
303 QCOMPARE(group.currentTime(), 1750); |
303 QCOMPARE(group.currentLoopTime(), 1750); |
304 QCOMPARE(sequence->currentTime(), 1250); |
304 QCOMPARE(sequence->currentLoopTime(), 1250); |
305 QCOMPARE(a1_s_o1->currentTime(), 250); |
305 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
306 QCOMPARE(a2_s_o1->currentTime(), 250); |
306 QCOMPARE(a2_s_o1->currentLoopTime(), 250); |
307 QCOMPARE(a2_s_o1->currentLoop(), 2); |
307 QCOMPARE(a2_s_o1->currentLoop(), 2); |
308 QCOMPARE(a3_s_o1->currentTime(), 250); |
308 QCOMPARE(a3_s_o1->currentLoopTime(), 250); |
309 QCOMPARE(sequence2->currentTime(), 500); |
309 QCOMPARE(sequence2->currentLoopTime(), 500); |
310 QCOMPARE(a1_s_o2->currentTime(), 250); |
310 QCOMPARE(a1_s_o2->currentLoopTime(), 250); |
311 QCOMPARE(a1_s_o3->currentTime(), 250); |
311 QCOMPARE(a1_s_o3->currentLoopTime(), 250); |
312 |
312 |
313 // Current time = 2000 |
313 // Current time = 2000 |
314 group.setCurrentTime(2000); |
314 group.setCurrentTime(2000); |
315 QCOMPARE(group.currentTime(), 1750); |
315 QCOMPARE(group.currentLoopTime(), 1750); |
316 QCOMPARE(sequence->currentTime(), 1250); |
316 QCOMPARE(sequence->currentLoopTime(), 1250); |
317 QCOMPARE(a1_s_o1->currentTime(), 250); |
317 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
318 QCOMPARE(a2_s_o1->currentTime(), 250); |
318 QCOMPARE(a2_s_o1->currentLoopTime(), 250); |
319 QCOMPARE(a2_s_o1->currentLoop(), 2); |
319 QCOMPARE(a2_s_o1->currentLoop(), 2); |
320 QCOMPARE(a3_s_o1->currentTime(), 250); |
320 QCOMPARE(a3_s_o1->currentLoopTime(), 250); |
321 QCOMPARE(sequence2->currentTime(), 500); |
321 QCOMPARE(sequence2->currentLoopTime(), 500); |
322 QCOMPARE(a1_s_o2->currentTime(), 250); |
322 QCOMPARE(a1_s_o2->currentLoopTime(), 250); |
323 QCOMPARE(a1_s_o3->currentTime(), 250); |
323 QCOMPARE(a1_s_o3->currentLoopTime(), 250); |
324 } |
324 } |
325 |
325 |
326 void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation() |
326 void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation() |
327 { |
327 { |
328 AnimationObject t_o1; |
328 AnimationObject t_o1; |
355 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Paused); |
355 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Paused); |
356 QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); |
356 QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); |
357 QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped); |
357 QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped); |
358 QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped); |
358 QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped); |
359 |
359 |
360 QCOMPARE(group.currentTime(), 1); |
360 QCOMPARE(group.currentLoopTime(), 1); |
361 QCOMPARE(sequence->currentTime(), 1); |
361 QCOMPARE(sequence->currentLoopTime(), 1); |
362 QCOMPARE(a1_s_o1->currentTime(), 1); |
362 QCOMPARE(a1_s_o1->currentLoopTime(), 1); |
363 QCOMPARE(a1_s_o2->currentTime(), 0); |
363 QCOMPARE(a1_s_o2->currentLoopTime(), 0); |
364 QCOMPARE(notTimeDriven->currentTime(), 0); |
364 QCOMPARE(notTimeDriven->currentLoopTime(), 0); |
365 QCOMPARE(loopsForever->currentTime(), 0); |
365 QCOMPARE(loopsForever->currentLoopTime(), 0); |
366 |
366 |
367 // Current time = 250 |
367 // Current time = 250 |
368 group.setCurrentTime(250); |
368 group.setCurrentTime(250); |
369 QCOMPARE(group.currentTime(), 250); |
369 QCOMPARE(group.currentLoopTime(), 250); |
370 QCOMPARE(sequence->currentTime(), 250); |
370 QCOMPARE(sequence->currentLoopTime(), 250); |
371 QCOMPARE(a1_s_o1->currentTime(), 250); |
371 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
372 QCOMPARE(a1_s_o2->currentTime(), 0); |
372 QCOMPARE(a1_s_o2->currentLoopTime(), 0); |
373 QCOMPARE(notTimeDriven->currentTime(), 0); |
373 QCOMPARE(notTimeDriven->currentLoopTime(), 0); |
374 QCOMPARE(loopsForever->currentTime(), 0); |
374 QCOMPARE(loopsForever->currentLoopTime(), 0); |
375 |
375 |
376 // Current time = 500 |
376 // Current time = 500 |
377 group.setCurrentTime(500); |
377 group.setCurrentTime(500); |
378 QCOMPARE(group.currentTime(), 500); |
378 QCOMPARE(group.currentLoopTime(), 500); |
379 QCOMPARE(sequence->currentTime(), 500); |
379 QCOMPARE(sequence->currentLoopTime(), 500); |
380 QCOMPARE(a1_s_o1->currentTime(), 250); |
380 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
381 QCOMPARE(a1_s_o2->currentTime(), 250); |
381 QCOMPARE(a1_s_o2->currentLoopTime(), 250); |
382 QCOMPARE(notTimeDriven->currentTime(), 0); |
382 QCOMPARE(notTimeDriven->currentLoopTime(), 0); |
383 QCOMPARE(loopsForever->currentTime(), 0); |
383 QCOMPARE(loopsForever->currentLoopTime(), 0); |
384 QCOMPARE(group.currentAnimation(), notTimeDriven); |
384 QCOMPARE(group.currentAnimation(), notTimeDriven); |
385 |
385 |
386 // Current time = 505 |
386 // Current time = 505 |
387 group.setCurrentTime(505); |
387 group.setCurrentTime(505); |
388 QCOMPARE(group.currentTime(), 505); |
388 QCOMPARE(group.currentLoopTime(), 505); |
389 QCOMPARE(sequence->currentTime(), 500); |
389 QCOMPARE(sequence->currentLoopTime(), 500); |
390 QCOMPARE(a1_s_o1->currentTime(), 250); |
390 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
391 QCOMPARE(a1_s_o2->currentTime(), 250); |
391 QCOMPARE(a1_s_o2->currentLoopTime(), 250); |
392 QCOMPARE(notTimeDriven->currentTime(), 5); |
392 QCOMPARE(notTimeDriven->currentLoopTime(), 5); |
393 QCOMPARE(loopsForever->currentTime(), 0); |
393 QCOMPARE(loopsForever->currentLoopTime(), 0); |
394 QCOMPARE(group.currentAnimation(), notTimeDriven); |
394 QCOMPARE(group.currentAnimation(), notTimeDriven); |
395 QCOMPARE(sequence->state(), QAnimationGroup::Stopped); |
395 QCOMPARE(sequence->state(), QAnimationGroup::Stopped); |
396 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
396 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
397 QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); |
397 QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); |
398 QCOMPARE(notTimeDriven->state(), QAnimationGroup::Paused); |
398 QCOMPARE(notTimeDriven->state(), QAnimationGroup::Paused); |
399 QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped); |
399 QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped); |
400 |
400 |
401 // Current time = 750 (end of notTimeDriven animation) |
401 // Current time = 750 (end of notTimeDriven animation) |
402 group.setCurrentTime(750); |
402 group.setCurrentTime(750); |
403 QCOMPARE(group.currentTime(), 750); |
403 QCOMPARE(group.currentLoopTime(), 750); |
404 QCOMPARE(sequence->currentTime(), 500); |
404 QCOMPARE(sequence->currentLoopTime(), 500); |
405 QCOMPARE(a1_s_o1->currentTime(), 250); |
405 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
406 QCOMPARE(a1_s_o2->currentTime(), 250); |
406 QCOMPARE(a1_s_o2->currentLoopTime(), 250); |
407 QCOMPARE(notTimeDriven->currentTime(), 250); |
407 QCOMPARE(notTimeDriven->currentLoopTime(), 250); |
408 QCOMPARE(loopsForever->currentTime(), 0); |
408 QCOMPARE(loopsForever->currentLoopTime(), 0); |
409 QCOMPARE(group.currentAnimation(), loopsForever); |
409 QCOMPARE(group.currentAnimation(), loopsForever); |
410 QCOMPARE(sequence->state(), QAnimationGroup::Stopped); |
410 QCOMPARE(sequence->state(), QAnimationGroup::Stopped); |
411 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
411 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
412 QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); |
412 QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); |
413 QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped); |
413 QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped); |
414 QCOMPARE(loopsForever->state(), QAnimationGroup::Paused); |
414 QCOMPARE(loopsForever->state(), QAnimationGroup::Paused); |
415 |
415 |
416 // Current time = 800 (as notTimeDriven was finished at 750, loopsforever should still run) |
416 // Current time = 800 (as notTimeDriven was finished at 750, loopsforever should still run) |
417 group.setCurrentTime(800); |
417 group.setCurrentTime(800); |
418 QCOMPARE(group.currentTime(), 800); |
418 QCOMPARE(group.currentLoopTime(), 800); |
419 QCOMPARE(group.currentAnimation(), loopsForever); |
419 QCOMPARE(group.currentAnimation(), loopsForever); |
420 QCOMPARE(sequence->currentTime(), 500); |
420 QCOMPARE(sequence->currentLoopTime(), 500); |
421 QCOMPARE(a1_s_o1->currentTime(), 250); |
421 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
422 QCOMPARE(a1_s_o2->currentTime(), 250); |
422 QCOMPARE(a1_s_o2->currentLoopTime(), 250); |
423 QCOMPARE(notTimeDriven->currentTime(), 250); |
423 QCOMPARE(notTimeDriven->currentLoopTime(), 250); |
424 QCOMPARE(loopsForever->currentTime(), 50); |
424 QCOMPARE(loopsForever->currentLoopTime(), 50); |
425 |
425 |
426 loopsForever->stop(); // this should stop the group |
426 loopsForever->stop(); // this should stop the group |
427 |
427 |
428 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
428 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
429 QCOMPARE(sequence->state(), QAnimationGroup::Stopped); |
429 QCOMPARE(sequence->state(), QAnimationGroup::Stopped); |
464 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
464 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
465 QCOMPARE(sequence2->state(), QAnimationGroup::Stopped); |
465 QCOMPARE(sequence2->state(), QAnimationGroup::Stopped); |
466 QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); |
466 QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); |
467 QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped); |
467 QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped); |
468 |
468 |
469 QCOMPARE(group.currentTime(), 1); |
469 QCOMPARE(group.currentLoopTime(), 1); |
470 QCOMPARE(sequence->currentTime(), 1); |
470 QCOMPARE(sequence->currentLoopTime(), 1); |
471 QCOMPARE(a1_s_o1->currentTime(), 1); |
471 QCOMPARE(a1_s_o1->currentLoopTime(), 1); |
472 QCOMPARE(a2_s_o1->currentTime(), 0); |
472 QCOMPARE(a2_s_o1->currentLoopTime(), 0); |
473 QCOMPARE(a3_s_o1->currentTime(), 0); |
473 QCOMPARE(a3_s_o1->currentLoopTime(), 0); |
474 QCOMPARE(sequence2->currentTime(), 0); |
474 QCOMPARE(sequence2->currentLoopTime(), 0); |
475 QCOMPARE(a1_s_o2->currentTime(), 0); |
475 QCOMPARE(a1_s_o2->currentLoopTime(), 0); |
476 QCOMPARE(a1_s_o3->currentTime(), 0); |
476 QCOMPARE(a1_s_o3->currentLoopTime(), 0); |
477 |
477 |
478 // Current time = 1500 |
478 // Current time = 1500 |
479 group.setCurrentTime(1500); |
479 group.setCurrentTime(1500); |
480 QCOMPARE(group.currentTime(), 1500); |
480 QCOMPARE(group.currentLoopTime(), 1500); |
481 QCOMPARE(sequence->currentTime(), 1250); |
481 QCOMPARE(sequence->currentLoopTime(), 1250); |
482 QCOMPARE(a1_s_o1->currentTime(), 250); |
482 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
483 QCOMPARE(a2_s_o1->currentTime(), 250); |
483 QCOMPARE(a2_s_o1->currentLoopTime(), 250); |
484 QCOMPARE(a2_s_o1->currentLoop(), 2); |
484 QCOMPARE(a2_s_o1->currentLoop(), 2); |
485 QCOMPARE(a3_s_o1->currentTime(), 250); |
485 QCOMPARE(a3_s_o1->currentLoopTime(), 250); |
486 QCOMPARE(sequence2->currentTime(), 250); |
486 QCOMPARE(sequence2->currentLoopTime(), 250); |
487 QCOMPARE(a1_s_o2->currentTime(), 250); |
487 QCOMPARE(a1_s_o2->currentLoopTime(), 250); |
488 QCOMPARE(a1_s_o3->currentTime(), 0); |
488 QCOMPARE(a1_s_o3->currentLoopTime(), 0); |
489 |
489 |
490 // this will restart the group |
490 // this will restart the group |
491 group.start(); |
491 group.start(); |
492 group.pause(); |
492 group.pause(); |
493 QCOMPARE(group.state(), QAnimationGroup::Paused); |
493 QCOMPARE(group.state(), QAnimationGroup::Paused); |
535 |
535 |
536 group.start(); |
536 group.start(); |
537 |
537 |
538 // Current time = 1600 |
538 // Current time = 1600 |
539 group.setCurrentTime(1600); |
539 group.setCurrentTime(1600); |
540 QCOMPARE(group.currentTime(), 1600); |
540 QCOMPARE(group.currentLoopTime(), 1600); |
541 QCOMPARE(sequence->currentTime(), 1250); |
541 QCOMPARE(sequence->currentLoopTime(), 1250); |
542 QCOMPARE(a1_s_o1->currentTime(), 250); |
542 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
543 QCOMPARE(a2_s_o1->currentTime(), 250); |
543 QCOMPARE(a2_s_o1->currentLoopTime(), 250); |
544 QCOMPARE(a2_s_o1->currentLoop(), 2); |
544 QCOMPARE(a2_s_o1->currentLoop(), 2); |
545 QCOMPARE(a3_s_o1->currentTime(), 250); |
545 QCOMPARE(a3_s_o1->currentLoopTime(), 250); |
546 QCOMPARE(sequence2->currentTime(), 350); |
546 QCOMPARE(sequence2->currentLoopTime(), 350); |
547 QCOMPARE(a1_s_o2->currentTime(), 250); |
547 QCOMPARE(a1_s_o2->currentLoopTime(), 250); |
548 QCOMPARE(a1_s_o3->currentTime(), 100); |
548 QCOMPARE(a1_s_o3->currentLoopTime(), 100); |
549 |
549 |
550 QCOMPARE(group.state(), QAnimationGroup::Running); |
550 QCOMPARE(group.state(), QAnimationGroup::Running); |
551 QCOMPARE(sequence->state(), QAnimationGroup::Stopped); |
551 QCOMPARE(sequence->state(), QAnimationGroup::Stopped); |
552 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
552 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
553 QCOMPARE(sequence2->state(), QAnimationGroup::Running); |
553 QCOMPARE(sequence2->state(), QAnimationGroup::Running); |
554 QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); |
554 QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); |
555 QCOMPARE(a1_s_o3->state(), QAnimationGroup::Running); |
555 QCOMPARE(a1_s_o3->state(), QAnimationGroup::Running); |
556 |
556 |
557 // Seeking backwards, current time = 1 |
557 // Seeking backwards, current time = 1 |
558 group.setCurrentTime(1); |
558 group.setCurrentTime(1); |
559 QCOMPARE(group.currentTime(), 1); |
559 QCOMPARE(group.currentLoopTime(), 1); |
560 QCOMPARE(sequence->currentTime(), 1); |
560 QCOMPARE(sequence->currentLoopTime(), 1); |
561 QCOMPARE(a1_s_o1->currentTime(), 1); |
561 QCOMPARE(a1_s_o1->currentLoopTime(), 1); |
562 |
562 |
563 QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children," |
563 QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children," |
564 "hence they don't reset from their current animation", Continue); |
564 "hence they don't reset from their current animation", Continue); |
565 QCOMPARE(a2_s_o1->currentTime(), 0); |
565 QCOMPARE(a2_s_o1->currentLoopTime(), 0); |
566 QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children," |
566 QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children," |
567 "hence they don't reset from their current animation", Continue); |
567 "hence they don't reset from their current animation", Continue); |
568 QCOMPARE(a2_s_o1->currentLoop(), 0); |
568 QCOMPARE(a2_s_o1->currentLoop(), 0); |
569 QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children," |
569 QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children," |
570 "hence they don't reset from their current animation", Continue); |
570 "hence they don't reset from their current animation", Continue); |
571 QCOMPARE(a3_s_o1->currentTime(), 0); |
571 QCOMPARE(a3_s_o1->currentLoopTime(), 0); |
572 QCOMPARE(sequence2->currentTime(), 0); |
572 QCOMPARE(sequence2->currentLoopTime(), 0); |
573 QCOMPARE(a1_s_o2->currentTime(), 0); |
573 QCOMPARE(a1_s_o2->currentLoopTime(), 0); |
574 QCOMPARE(a1_s_o3->currentTime(), 0); |
574 QCOMPARE(a1_s_o3->currentLoopTime(), 0); |
575 |
575 |
576 QCOMPARE(group.state(), QAnimationGroup::Running); |
576 QCOMPARE(group.state(), QAnimationGroup::Running); |
577 QCOMPARE(sequence->state(), QAnimationGroup::Running); |
577 QCOMPARE(sequence->state(), QAnimationGroup::Running); |
578 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Running); |
578 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Running); |
579 QCOMPARE(sequence2->state(), QAnimationGroup::Stopped); |
579 QCOMPARE(sequence2->state(), QAnimationGroup::Stopped); |
580 QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); |
580 QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); |
581 QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped); |
581 QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped); |
582 |
582 |
583 // Current time = 2000 |
583 // Current time = 2000 |
584 group.setCurrentTime(2000); |
584 group.setCurrentTime(2000); |
585 QCOMPARE(group.currentTime(), 1750); |
585 QCOMPARE(group.currentLoopTime(), 1750); |
586 QCOMPARE(sequence->currentTime(), 1250); |
586 QCOMPARE(sequence->currentLoopTime(), 1250); |
587 QCOMPARE(a1_s_o1->currentTime(), 250); |
587 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
588 QCOMPARE(a2_s_o1->currentTime(), 250); |
588 QCOMPARE(a2_s_o1->currentLoopTime(), 250); |
589 QCOMPARE(a2_s_o1->currentLoop(), 2); |
589 QCOMPARE(a2_s_o1->currentLoop(), 2); |
590 QCOMPARE(a3_s_o1->currentTime(), 250); |
590 QCOMPARE(a3_s_o1->currentLoopTime(), 250); |
591 QCOMPARE(sequence2->currentTime(), 500); |
591 QCOMPARE(sequence2->currentLoopTime(), 500); |
592 QCOMPARE(a1_s_o2->currentTime(), 250); |
592 QCOMPARE(a1_s_o2->currentLoopTime(), 250); |
593 QCOMPARE(a1_s_o3->currentTime(), 250); |
593 QCOMPARE(a1_s_o3->currentLoopTime(), 250); |
594 |
594 |
595 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
595 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
596 QCOMPARE(sequence->state(), QAnimationGroup::Stopped); |
596 QCOMPARE(sequence->state(), QAnimationGroup::Stopped); |
597 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
597 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
598 QCOMPARE(sequence2->state(), QAnimationGroup::Stopped); |
598 QCOMPARE(sequence2->state(), QAnimationGroup::Stopped); |
694 << QAbstractAnimation::Paused |
694 << QAbstractAnimation::Paused |
695 << QAbstractAnimation::Stopped |
695 << QAbstractAnimation::Stopped |
696 << QAbstractAnimation::Running |
696 << QAbstractAnimation::Running |
697 << QAbstractAnimation::Stopped))); |
697 << QAbstractAnimation::Stopped))); |
698 |
698 |
699 QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(0).at(1)), |
699 QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(0).first()), |
700 QAnimationGroup::Running); |
700 QAnimationGroup::Running); |
701 QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(1).at(1)), |
701 QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(1).first()), |
702 QAnimationGroup::Paused); |
702 QAnimationGroup::Paused); |
703 QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(2).at(1)), |
703 QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(2).first()), |
704 QAnimationGroup::Stopped); |
704 QAnimationGroup::Stopped); |
705 QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(3).at(1)), |
705 QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(3).first()), |
706 QAnimationGroup::Running); |
706 QAnimationGroup::Running); |
707 QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(4).at(1)), |
707 QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(4).first()), |
708 QAnimationGroup::Stopped); |
708 QAnimationGroup::Stopped); |
709 |
709 |
710 QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).at(1)), |
710 QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()), |
711 QAnimationGroup::Running); |
711 QAnimationGroup::Running); |
712 QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).at(1)), |
712 QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).first()), |
713 QAnimationGroup::Paused); |
713 QAnimationGroup::Paused); |
714 |
714 |
715 group.resume(); |
715 group.resume(); |
716 |
716 |
717 QCOMPARE(group.state(), QAnimationGroup::Running); |
717 QCOMPARE(group.state(), QAnimationGroup::Running); |
718 QCOMPARE(sequence->state(), QAnimationGroup::Running); |
718 QCOMPARE(sequence->state(), QAnimationGroup::Running); |
719 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
719 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
720 QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped); |
720 QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped); |
721 QCOMPARE(a3_s_o1->state(), QAnimationGroup::Running); |
721 QCOMPARE(a3_s_o1->state(), QAnimationGroup::Running); |
722 |
722 |
723 QVERIFY(group.currentTime() >= 1751); |
723 QVERIFY(group.currentLoopTime() >= 1751); |
724 QVERIFY(sequence->currentTime() >= 751); |
724 QVERIFY(sequence->currentLoopTime() >= 751); |
725 QCOMPARE(sequence->currentLoop(), 1); |
725 QCOMPARE(sequence->currentLoop(), 1); |
726 QCOMPARE(a1_s_o1->currentTime(), 250); |
726 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
727 QCOMPARE(a2_s_o1->currentTime(), 250); |
727 QCOMPARE(a2_s_o1->currentLoopTime(), 250); |
728 QCOMPARE(a2_s_o1->currentLoop(), 1); |
728 QCOMPARE(a2_s_o1->currentLoop(), 1); |
729 QCOMPARE(a3_s_o1->currentLoop(), 0); |
729 QCOMPARE(a3_s_o1->currentLoop(), 0); |
730 QVERIFY(a3_s_o1->currentTime() >= 1); |
730 QVERIFY(a3_s_o1->currentLoopTime() >= 1); |
731 |
731 |
732 QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running |
732 QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running |
733 QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(2).at(1)), |
733 QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(2).first()), |
734 QAnimationGroup::Running); |
734 QAnimationGroup::Running); |
735 |
735 |
736 group.pause(); |
736 group.pause(); |
737 |
737 |
738 QCOMPARE(group.state(), QAnimationGroup::Paused); |
738 QCOMPARE(group.state(), QAnimationGroup::Paused); |
739 QCOMPARE(sequence->state(), QAnimationGroup::Paused); |
739 QCOMPARE(sequence->state(), QAnimationGroup::Paused); |
740 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
740 QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); |
741 QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped); |
741 QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped); |
742 QCOMPARE(a3_s_o1->state(), QAnimationGroup::Paused); |
742 QCOMPARE(a3_s_o1->state(), QAnimationGroup::Paused); |
743 |
743 |
744 QVERIFY(group.currentTime() >= 1751); |
744 QVERIFY(group.currentLoopTime() >= 1751); |
745 QVERIFY(sequence->currentTime() >= 751); |
745 QVERIFY(sequence->currentLoopTime() >= 751); |
746 QCOMPARE(sequence->currentLoop(), 1); |
746 QCOMPARE(sequence->currentLoop(), 1); |
747 QCOMPARE(a1_s_o1->currentTime(), 250); |
747 QCOMPARE(a1_s_o1->currentLoopTime(), 250); |
748 QCOMPARE(a2_s_o1->currentTime(), 250); |
748 QCOMPARE(a2_s_o1->currentLoopTime(), 250); |
749 QCOMPARE(a2_s_o1->currentLoop(), 1); |
749 QCOMPARE(a2_s_o1->currentLoop(), 1); |
750 QCOMPARE(a3_s_o1->currentLoop(), 0); |
750 QCOMPARE(a3_s_o1->currentLoop(), 0); |
751 QVERIFY(a3_s_o1->currentTime() >= 1); |
751 QVERIFY(a3_s_o1->currentLoopTime() >= 1); |
752 |
752 |
753 QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused |
753 QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused |
754 QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(3).at(1)), |
754 QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(3).first()), |
755 QAnimationGroup::Paused); |
755 QAnimationGroup::Paused); |
756 |
756 |
757 group.stop(); |
757 group.stop(); |
758 |
758 |
759 QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped |
759 QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped |
760 QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(4).at(1)), |
760 QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(4).first()), |
761 QAnimationGroup::Stopped); |
761 QAnimationGroup::Stopped); |
762 } |
762 } |
763 |
763 |
764 void tst_QSequentialAnimationGroup::restart() |
764 void tst_QSequentialAnimationGroup::restart() |
765 { |
765 { |
1427 QSignalSpy spy(&group, SIGNAL(finished())); |
1424 QSignalSpy spy(&group, SIGNAL(finished())); |
1428 |
1425 |
1429 group.start(); |
1426 group.start(); |
1430 QCOMPARE(group.state(), QAnimationGroup::Running); |
1427 QCOMPARE(group.state(), QAnimationGroup::Running); |
1431 QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running); |
1428 QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running); |
1432 QCOMPARE(group.currentTime(), 0); |
1429 QCOMPARE(group.currentLoopTime(), 0); |
1433 QCOMPARE(notTimeDriven.currentTime(), 0); |
1430 QCOMPARE(notTimeDriven.currentLoopTime(), 0); |
1434 |
1431 |
1435 QTest::qWait(300); //wait for the end of notTimeDriven |
1432 QTest::qWait(300); //wait for the end of notTimeDriven |
1436 QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped); |
1433 QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped); |
1437 const int actualDuration = notTimeDriven.currentTime(); |
1434 const int actualDuration = notTimeDriven.currentLoopTime(); |
1438 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
1435 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
1439 QCOMPARE(group.currentTime(), actualDuration); |
1436 QCOMPARE(group.currentLoopTime(), actualDuration); |
1440 QCOMPARE(spy.count(), 1); |
1437 QCOMPARE(spy.count(), 1); |
1441 |
1438 |
1442 //2nd case: |
1439 //2nd case: |
1443 // lets make sure the seeking will work again |
1440 // lets make sure the seeking will work again |
1444 spy.clear(); |
1441 spy.clear(); |
1445 DummyPropertyAnimation anim(&group); |
1442 DummyPropertyAnimation anim(&group); |
1446 QSignalSpy animStateChangedSpy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); |
1443 QSignalSpy animStateChangedSpy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); |
1447 |
1444 |
1448 group.setCurrentTime(300); |
1445 group.setCurrentTime(300); |
1449 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
1446 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
1450 QCOMPARE(notTimeDriven.currentTime(), actualDuration); |
1447 QCOMPARE(notTimeDriven.currentLoopTime(), actualDuration); |
1451 QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimation*>(&anim)); |
1448 QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimation*>(&anim)); |
1452 |
1449 |
1453 //3rd case: |
1450 //3rd case: |
1454 //now let's add a perfectly defined animation at the end |
1451 //now let's add a perfectly defined animation at the end |
1455 QCOMPARE(animStateChangedSpy.count(), 0); |
1452 QCOMPARE(animStateChangedSpy.count(), 0); |
1456 group.start(); |
1453 group.start(); |
1457 QCOMPARE(group.state(), QAnimationGroup::Running); |
1454 QCOMPARE(group.state(), QAnimationGroup::Running); |
1458 QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running); |
1455 QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running); |
1459 QCOMPARE(group.currentTime(), 0); |
1456 QCOMPARE(group.currentLoopTime(), 0); |
1460 QCOMPARE(notTimeDriven.currentTime(), 0); |
1457 QCOMPARE(notTimeDriven.currentLoopTime(), 0); |
1461 |
1458 |
1462 QCOMPARE(animStateChangedSpy.count(), 0); |
1459 QCOMPARE(animStateChangedSpy.count(), 0); |
1463 |
1460 |
1464 QTest::qWait(300); //wait for the end of notTimeDriven |
1461 QTest::qWait(300); //wait for the end of notTimeDriven |
1465 QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped); |
1462 QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped); |
1468 QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimation*>(&anim)); |
1465 QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimation*>(&anim)); |
1469 QCOMPARE(animStateChangedSpy.count(), 1); |
1466 QCOMPARE(animStateChangedSpy.count(), 1); |
1470 QTest::qWait(300); //wait for the end of anim |
1467 QTest::qWait(300); //wait for the end of anim |
1471 |
1468 |
1472 QCOMPARE(anim.state(), QAnimationGroup::Stopped); |
1469 QCOMPARE(anim.state(), QAnimationGroup::Stopped); |
1473 QCOMPARE(anim.currentTime(), anim.duration()); |
1470 QCOMPARE(anim.currentLoopTime(), anim.duration()); |
1474 |
1471 |
1475 //we should simply be at the end |
1472 //we should simply be at the end |
1476 QCOMPARE(spy.count(), 1); |
1473 QCOMPARE(spy.count(), 1); |
1477 QCOMPARE(animStateChangedSpy.count(), 2); |
1474 QCOMPARE(animStateChangedSpy.count(), 2); |
1478 QCOMPARE(group.currentTime(), notTimeDriven.currentTime() + anim.currentTime()); |
1475 QCOMPARE(group.currentLoopTime(), notTimeDriven.currentLoopTime() + anim.currentLoopTime()); |
1479 } |
1476 } |
1480 |
1477 |
1481 void tst_QSequentialAnimationGroup::addRemoveAnimation() |
1478 void tst_QSequentialAnimationGroup::addRemoveAnimation() |
1482 { |
1479 { |
1483 //this test is specific to the sequential animation group |
1480 //this test is specific to the sequential animation group |
1484 QSequentialAnimationGroup group; |
1481 QSequentialAnimationGroup group; |
1485 |
1482 |
1486 QCOMPARE(group.duration(), 0); |
1483 QCOMPARE(group.duration(), 0); |
1487 QCOMPARE(group.currentTime(), 0); |
1484 QCOMPARE(group.currentLoopTime(), 0); |
1488 QAbstractAnimation *anim1 = new QPropertyAnimation; |
1485 QAbstractAnimation *anim1 = new QPropertyAnimation; |
1489 group.addAnimation(anim1); |
1486 group.addAnimation(anim1); |
1490 QCOMPARE(group.duration(), 250); |
1487 QCOMPARE(group.duration(), 250); |
1491 QCOMPARE(group.currentTime(), 0); |
1488 QCOMPARE(group.currentLoopTime(), 0); |
1492 QCOMPARE(group.currentAnimation(), anim1); |
1489 QCOMPARE(group.currentAnimation(), anim1); |
1493 |
1490 |
1494 //let's append an animation |
1491 //let's append an animation |
1495 QAbstractAnimation *anim2 = new QPropertyAnimation; |
1492 QAbstractAnimation *anim2 = new QPropertyAnimation; |
1496 group.addAnimation(anim2); |
1493 group.addAnimation(anim2); |
1497 QCOMPARE(group.duration(), 500); |
1494 QCOMPARE(group.duration(), 500); |
1498 QCOMPARE(group.currentTime(), 0); |
1495 QCOMPARE(group.currentLoopTime(), 0); |
1499 QCOMPARE(group.currentAnimation(), anim1); |
1496 QCOMPARE(group.currentAnimation(), anim1); |
1500 |
1497 |
1501 //let's prepend an animation |
1498 //let's prepend an animation |
1502 QAbstractAnimation *anim0 = new QPropertyAnimation; |
1499 QAbstractAnimation *anim0 = new QPropertyAnimation; |
1503 group.insertAnimationAt(0, anim0); |
1500 group.insertAnimation(0, anim0); |
1504 QCOMPARE(group.duration(), 750); |
1501 QCOMPARE(group.duration(), 750); |
1505 QCOMPARE(group.currentTime(), 0); |
1502 QCOMPARE(group.currentLoopTime(), 0); |
1506 QCOMPARE(group.currentAnimation(), anim0); //anim0 has become the new currentAnimation |
1503 QCOMPARE(group.currentAnimation(), anim0); //anim0 has become the new currentAnimation |
1507 |
1504 |
1508 group.setCurrentTime(300); //anim0 | anim1 | anim2 |
1505 group.setCurrentTime(300); //anim0 | anim1 | anim2 |
1509 QCOMPARE(group.currentTime(), 300); |
1506 QCOMPARE(group.currentLoopTime(), 300); |
1510 QCOMPARE(group.currentAnimation(), anim1); |
1507 QCOMPARE(group.currentAnimation(), anim1); |
1511 QCOMPARE(anim1->currentTime(), 50); |
1508 QCOMPARE(anim1->currentLoopTime(), 50); |
1512 |
1509 |
1513 group.removeAnimation(anim0); //anim1 | anim2 |
1510 group.removeAnimation(anim0); //anim1 | anim2 |
1514 QCOMPARE(group.currentTime(), 50); |
1511 QCOMPARE(group.currentLoopTime(), 50); |
1515 QCOMPARE(group.currentAnimation(), anim1); |
1512 QCOMPARE(group.currentAnimation(), anim1); |
1516 QCOMPARE(anim1->currentTime(), 50); |
1513 QCOMPARE(anim1->currentLoopTime(), 50); |
1517 |
1514 |
1518 group.setCurrentTime(0); |
1515 group.setCurrentTime(0); |
1519 group.insertAnimationAt(0, anim0); //anim0 | anim1 | anim2 |
1516 group.insertAnimation(0, anim0); //anim0 | anim1 | anim2 |
1520 group.setCurrentTime(300); |
1517 group.setCurrentTime(300); |
1521 QCOMPARE(group.currentTime(), 300); |
1518 QCOMPARE(group.currentLoopTime(), 300); |
1522 QCOMPARE(group.currentAnimation(), anim1); |
1519 QCOMPARE(group.currentAnimation(), anim1); |
1523 QCOMPARE(anim1->currentTime(), 50); |
1520 QCOMPARE(anim1->currentLoopTime(), 50); |
1524 |
1521 |
1525 group.removeAnimation(anim1); //anim0 | anim2 |
1522 group.removeAnimation(anim1); //anim0 | anim2 |
1526 QCOMPARE(group.currentTime(), 250); |
1523 QCOMPARE(group.currentLoopTime(), 250); |
1527 QCOMPARE(group.currentAnimation(), anim2); |
1524 QCOMPARE(group.currentAnimation(), anim2); |
1528 QCOMPARE(anim0->currentTime(), 250); |
1525 QCOMPARE(anim0->currentLoopTime(), 250); |
1529 } |
1526 } |
1530 |
1527 |
1531 void tst_QSequentialAnimationGroup::currentAnimation() |
1528 void tst_QSequentialAnimationGroup::currentAnimation() |
1532 { |
1529 { |
1533 QSequentialAnimationGroup group; |
1530 QSequentialAnimationGroup group; |