222 QCOMPARE(a1_p_o2->state(), QAnimationGroup::Stopped); |
221 QCOMPARE(a1_p_o2->state(), QAnimationGroup::Stopped); |
223 QCOMPARE(a1_p_o3->state(), QAnimationGroup::Stopped); |
222 QCOMPARE(a1_p_o3->state(), QAnimationGroup::Stopped); |
224 QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped); |
223 QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped); |
225 QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped); |
224 QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped); |
226 |
225 |
227 QCOMPARE(group.currentTime(), 1); |
226 QCOMPARE(group.currentLoopTime(), 1); |
228 QCOMPARE(a1_p_o1->currentTime(), 1); |
227 QCOMPARE(a1_p_o1->currentLoopTime(), 1); |
229 QCOMPARE(a1_p_o2->currentTime(), 1); |
228 QCOMPARE(a1_p_o2->currentLoopTime(), 1); |
230 QCOMPARE(a1_p_o3->currentTime(), 1); |
229 QCOMPARE(a1_p_o3->currentLoopTime(), 1); |
231 QCOMPARE(notTimeDriven->currentTime(), 1); |
230 QCOMPARE(notTimeDriven->currentLoopTime(), 1); |
232 QCOMPARE(loopsForever->currentTime(), 1); |
231 QCOMPARE(loopsForever->currentLoopTime(), 1); |
233 |
232 |
234 // Current time = 250 |
233 // Current time = 250 |
235 group.setCurrentTime(250); |
234 group.setCurrentTime(250); |
236 QCOMPARE(group.currentTime(), 250); |
235 QCOMPARE(group.currentLoopTime(), 250); |
237 QCOMPARE(a1_p_o1->currentTime(), 250); |
236 QCOMPARE(a1_p_o1->currentLoopTime(), 250); |
238 QCOMPARE(a1_p_o2->currentTime(), 0); |
237 QCOMPARE(a1_p_o2->currentLoopTime(), 0); |
239 QCOMPARE(a1_p_o2->currentLoop(), 1); |
238 QCOMPARE(a1_p_o2->currentLoop(), 1); |
240 QCOMPARE(a1_p_o3->currentTime(), 250); |
239 QCOMPARE(a1_p_o3->currentLoopTime(), 250); |
241 QCOMPARE(notTimeDriven->currentTime(), 250); |
240 QCOMPARE(notTimeDriven->currentLoopTime(), 250); |
242 QCOMPARE(loopsForever->currentTime(), 0); |
241 QCOMPARE(loopsForever->currentLoopTime(), 0); |
243 QCOMPARE(loopsForever->currentLoop(), 1); |
242 QCOMPARE(loopsForever->currentLoop(), 1); |
244 |
243 |
245 // Current time = 251 |
244 // Current time = 251 |
246 group.setCurrentTime(251); |
245 group.setCurrentTime(251); |
247 QCOMPARE(group.currentTime(), 251); |
246 QCOMPARE(group.currentLoopTime(), 251); |
248 QCOMPARE(a1_p_o1->currentTime(), 250); |
247 QCOMPARE(a1_p_o1->currentLoopTime(), 250); |
249 QCOMPARE(a1_p_o2->currentTime(), 1); |
248 QCOMPARE(a1_p_o2->currentLoopTime(), 1); |
250 QCOMPARE(a1_p_o2->currentLoop(), 1); |
249 QCOMPARE(a1_p_o2->currentLoop(), 1); |
251 QCOMPARE(a1_p_o3->currentTime(), 250); |
250 QCOMPARE(a1_p_o3->currentLoopTime(), 250); |
252 QCOMPARE(notTimeDriven->currentTime(), 251); |
251 QCOMPARE(notTimeDriven->currentLoopTime(), 251); |
253 QCOMPARE(loopsForever->currentTime(), 1); |
252 QCOMPARE(loopsForever->currentLoopTime(), 1); |
254 } |
253 } |
255 |
254 |
256 void tst_QParallelAnimationGroup::stateChanged() |
255 void tst_QParallelAnimationGroup::stateChanged() |
257 { |
256 { |
258 //this ensures that the correct animations are started when starting the group |
257 //this ensures that the correct animations are started when starting the group |
277 |
276 |
278 //first; let's start forward |
277 //first; let's start forward |
279 group.start(); |
278 group.start(); |
280 //all the animations should be started |
279 //all the animations should be started |
281 QCOMPARE(spy1.count(), 1); |
280 QCOMPARE(spy1.count(), 1); |
282 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Running); |
281 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running); |
283 QCOMPARE(spy2.count(), 1); |
282 QCOMPARE(spy2.count(), 1); |
284 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Running); |
283 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running); |
285 QCOMPARE(spy3.count(), 1); |
284 QCOMPARE(spy3.count(), 1); |
286 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Running); |
285 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running); |
287 QCOMPARE(spy4.count(), 1); |
286 QCOMPARE(spy4.count(), 1); |
288 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Running); |
287 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running); |
289 |
288 |
290 group.setCurrentTime(1500); //anim1 should be finished |
289 group.setCurrentTime(1500); //anim1 should be finished |
291 QCOMPARE(group.state(), QAnimationGroup::Running); |
290 QCOMPARE(group.state(), QAnimationGroup::Running); |
292 QCOMPARE(spy1.count(), 2); |
291 QCOMPARE(spy1.count(), 2); |
293 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Stopped); |
292 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped); |
294 QCOMPARE(spy2.count(), 1); //no change |
293 QCOMPARE(spy2.count(), 1); //no change |
295 QCOMPARE(spy3.count(), 1); //no change |
294 QCOMPARE(spy3.count(), 1); //no change |
296 QCOMPARE(spy4.count(), 1); //no change |
295 QCOMPARE(spy4.count(), 1); //no change |
297 |
296 |
298 group.setCurrentTime(2500); //anim2 should be finished |
297 group.setCurrentTime(2500); //anim2 should be finished |
299 QCOMPARE(group.state(), QAnimationGroup::Running); |
298 QCOMPARE(group.state(), QAnimationGroup::Running); |
300 QCOMPARE(spy1.count(), 2); //no change |
299 QCOMPARE(spy1.count(), 2); //no change |
301 QCOMPARE(spy2.count(), 2); |
300 QCOMPARE(spy2.count(), 2); |
302 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Stopped); |
301 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped); |
303 QCOMPARE(spy3.count(), 1); //no change |
302 QCOMPARE(spy3.count(), 1); //no change |
304 QCOMPARE(spy4.count(), 1); //no change |
303 QCOMPARE(spy4.count(), 1); //no change |
305 |
304 |
306 group.setCurrentTime(3500); //everything should be finished |
305 group.setCurrentTime(3500); //everything should be finished |
307 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
306 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
308 QCOMPARE(spy1.count(), 2); //no change |
307 QCOMPARE(spy1.count(), 2); //no change |
309 QCOMPARE(spy2.count(), 2); //no change |
308 QCOMPARE(spy2.count(), 2); //no change |
310 QCOMPARE(spy3.count(), 2); |
309 QCOMPARE(spy3.count(), 2); |
311 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Stopped); |
310 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped); |
312 QCOMPARE(spy4.count(), 2); |
311 QCOMPARE(spy4.count(), 2); |
313 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Stopped); |
312 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped); |
314 |
313 |
315 //cleanup |
314 //cleanup |
316 spy1.clear(); |
315 spy1.clear(); |
317 spy2.clear(); |
316 spy2.clear(); |
318 spy3.clear(); |
317 spy3.clear(); |
325 //only anim3 and anim4 should be started |
324 //only anim3 and anim4 should be started |
326 QCOMPARE(group.state(), QAnimationGroup::Running); |
325 QCOMPARE(group.state(), QAnimationGroup::Running); |
327 QCOMPARE(spy1.count(), 0); |
326 QCOMPARE(spy1.count(), 0); |
328 QCOMPARE(spy2.count(), 0); |
327 QCOMPARE(spy2.count(), 0); |
329 QCOMPARE(spy3.count(), 1); |
328 QCOMPARE(spy3.count(), 1); |
330 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Running); |
329 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running); |
331 QCOMPARE(spy4.count(), 1); |
330 QCOMPARE(spy4.count(), 1); |
332 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Running); |
331 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running); |
333 |
332 |
334 group.setCurrentTime(1500); //anim2 should be started |
333 group.setCurrentTime(1500); //anim2 should be started |
335 QCOMPARE(group.state(), QAnimationGroup::Running); |
334 QCOMPARE(group.state(), QAnimationGroup::Running); |
336 QCOMPARE(spy1.count(), 0); //no change |
335 QCOMPARE(spy1.count(), 0); //no change |
337 QCOMPARE(spy2.count(), 1); |
336 QCOMPARE(spy2.count(), 1); |
338 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Running); |
337 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running); |
339 QCOMPARE(spy3.count(), 1); //no change |
338 QCOMPARE(spy3.count(), 1); //no change |
340 QCOMPARE(spy4.count(), 1); //no change |
339 QCOMPARE(spy4.count(), 1); //no change |
341 |
340 |
342 group.setCurrentTime(500); //anim1 is finally also started |
341 group.setCurrentTime(500); //anim1 is finally also started |
343 QCOMPARE(group.state(), QAnimationGroup::Running); |
342 QCOMPARE(group.state(), QAnimationGroup::Running); |
344 QCOMPARE(spy1.count(), 1); |
343 QCOMPARE(spy1.count(), 1); |
345 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Running); |
344 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running); |
346 QCOMPARE(spy2.count(), 1); //no change |
345 QCOMPARE(spy2.count(), 1); //no change |
347 QCOMPARE(spy3.count(), 1); //no change |
346 QCOMPARE(spy3.count(), 1); //no change |
348 QCOMPARE(spy4.count(), 1); //no change |
347 QCOMPARE(spy4.count(), 1); //no change |
349 |
348 |
350 group.setCurrentTime(0); //everything should be stopped |
349 group.setCurrentTime(0); //everything should be stopped |
351 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
350 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
352 QCOMPARE(spy1.count(), 2); |
351 QCOMPARE(spy1.count(), 2); |
353 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Stopped); |
352 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped); |
354 QCOMPARE(spy2.count(), 2); |
353 QCOMPARE(spy2.count(), 2); |
355 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Stopped); |
354 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped); |
356 QCOMPARE(spy3.count(), 2); |
355 QCOMPARE(spy3.count(), 2); |
357 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Stopped); |
356 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped); |
358 QCOMPARE(spy4.count(), 2); |
357 QCOMPARE(spy4.count(), 2); |
359 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Stopped); |
358 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped); |
360 } |
359 } |
361 |
360 |
362 void tst_QParallelAnimationGroup::clearGroup() |
361 void tst_QParallelAnimationGroup::clearGroup() |
363 { |
362 { |
364 QParallelAnimationGroup group; |
363 QParallelAnimationGroup group; |
459 QCOMPARE(anim.state(), QAnimationGroup::Running); |
458 QCOMPARE(anim.state(), QAnimationGroup::Running); |
460 |
459 |
461 QCOMPARE(groupStateChangedSpy.count(), 1); |
460 QCOMPARE(groupStateChangedSpy.count(), 1); |
462 QCOMPARE(childStateChangedSpy.count(), 1); |
461 QCOMPARE(childStateChangedSpy.count(), 1); |
463 |
462 |
464 QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).at(1)), |
463 QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()), |
465 QAnimationGroup::Running); |
464 QAnimationGroup::Running); |
466 QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).at(1)), |
465 QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).first()), |
467 QAnimationGroup::Running); |
466 QAnimationGroup::Running); |
468 |
467 |
469 // starting directly a running child will not have any effect |
468 // starting directly a running child will not have any effect |
470 anim.start(); |
469 anim.start(); |
471 |
470 |
504 group.start(); |
499 group.start(); |
505 QCOMPARE(group.state(), QAnimationGroup::Running); |
500 QCOMPARE(group.state(), QAnimationGroup::Running); |
506 QCOMPARE(anim1->state(), QAnimationGroup::Running); |
501 QCOMPARE(anim1->state(), QAnimationGroup::Running); |
507 |
502 |
508 QTest::qWait(80); |
503 QTest::qWait(80); |
509 QVERIFY(group.currentTime() > 0); |
504 QVERIFY(group.currentLoopTime() > 0); |
510 |
505 |
511 delete anim1; |
506 delete anim1; |
512 QVERIFY(group.animationCount() == 0); |
507 QVERIFY(group.animationCount() == 0); |
513 QCOMPARE(group.duration(), 0); |
508 QCOMPARE(group.duration(), 0); |
514 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
509 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
515 QCOMPARE(group.currentTime(), 0); //that's the invariant |
510 QCOMPARE(group.currentLoopTime(), 0); //that's the invariant |
516 } |
511 } |
517 |
512 |
518 void tst_QParallelAnimationGroup::startChildrenWithStoppedGroup() |
513 void tst_QParallelAnimationGroup::startChildrenWithStoppedGroup() |
519 { |
514 { |
520 // test if children can be activated when their group is stopped |
515 // test if children can be activated when their group is stopped |
625 |
620 |
626 anim1.start(); |
621 anim1.start(); |
627 anim2.start(); |
622 anim2.start(); |
628 anim2.pause(); |
623 anim2.pause(); |
629 |
624 |
630 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).at(1)), |
625 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()), |
631 QAnimationGroup::Running); |
626 QAnimationGroup::Running); |
632 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(0).at(1)), |
627 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(0).first()), |
633 QAnimationGroup::Running); |
628 QAnimationGroup::Running); |
634 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(1).at(1)), |
629 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(1).first()), |
635 QAnimationGroup::Paused); |
630 QAnimationGroup::Paused); |
636 |
631 |
637 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
632 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
638 QCOMPARE(anim1.state(), QAnimationGroup::Running); |
633 QCOMPARE(anim1.state(), QAnimationGroup::Running); |
639 QCOMPARE(anim2.state(), QAnimationGroup::Paused); |
634 QCOMPARE(anim2.state(), QAnimationGroup::Paused); |
640 |
635 |
641 group.start(); |
636 group.start(); |
642 |
637 |
643 QCOMPARE(stateChangedSpy1.count(), 3); |
638 QCOMPARE(stateChangedSpy1.count(), 3); |
644 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).at(1)), |
639 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()), |
645 QAnimationGroup::Stopped); |
640 QAnimationGroup::Stopped); |
646 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(2).at(1)), |
641 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(2).first()), |
647 QAnimationGroup::Running); |
642 QAnimationGroup::Running); |
648 |
643 |
649 QCOMPARE(stateChangedSpy2.count(), 4); |
644 QCOMPARE(stateChangedSpy2.count(), 4); |
650 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).at(1)), |
645 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()), |
651 QAnimationGroup::Stopped); |
646 QAnimationGroup::Stopped); |
652 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).at(1)), |
647 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()), |
653 QAnimationGroup::Running); |
648 QAnimationGroup::Running); |
654 |
649 |
655 QCOMPARE(group.state(), QAnimationGroup::Running); |
650 QCOMPARE(group.state(), QAnimationGroup::Running); |
656 QCOMPARE(anim1.state(), QAnimationGroup::Running); |
651 QCOMPARE(anim1.state(), QAnimationGroup::Running); |
657 QCOMPARE(anim2.state(), QAnimationGroup::Running); |
652 QCOMPARE(anim2.state(), QAnimationGroup::Running); |
690 group.addAnimation(&anim3); |
685 group.addAnimation(&anim3); |
691 QCOMPARE(stateChangedSpy1.count(), 0); |
686 QCOMPARE(stateChangedSpy1.count(), 0); |
692 group.start(); |
687 group.start(); |
693 QCOMPARE(stateChangedSpy1.count(), 2); |
688 QCOMPARE(stateChangedSpy1.count(), 2); |
694 QCOMPARE(finishedSpy1.count(), 1); |
689 QCOMPARE(finishedSpy1.count(), 1); |
695 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).at(1)), |
690 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()), |
696 QAnimationGroup::Running); |
691 QAnimationGroup::Running); |
697 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).at(1)), |
692 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()), |
698 QAnimationGroup::Stopped); |
693 QAnimationGroup::Stopped); |
699 |
694 |
700 QCOMPARE(stateChangedSpy2.count(), 1); |
695 QCOMPARE(stateChangedSpy2.count(), 1); |
701 QCOMPARE(finishedSpy2.count(), 0); |
696 QCOMPARE(finishedSpy2.count(), 0); |
702 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).at(1)), |
697 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()), |
703 QAnimationGroup::Running); |
698 QAnimationGroup::Running); |
704 |
699 |
705 QCOMPARE(stateChangedSpy3.count(), 1); |
700 QCOMPARE(stateChangedSpy3.count(), 1); |
706 QCOMPARE(finishedSpy3.count(), 0); |
701 QCOMPARE(finishedSpy3.count(), 0); |
707 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy3.at(0).at(1)), |
702 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy3.at(0).first()), |
708 QAnimationGroup::Running); |
703 QAnimationGroup::Running); |
709 |
704 |
710 |
705 |
711 QCOMPARE(anim1.state(), QAnimationGroup::Stopped); |
706 QCOMPARE(anim1.state(), QAnimationGroup::Stopped); |
712 QCOMPARE(anim2.state(), QAnimationGroup::Running); |
707 QCOMPARE(anim2.state(), QAnimationGroup::Running); |
765 group.addAnimation(&loopsForever); |
760 group.addAnimation(&loopsForever); |
766 |
761 |
767 group.start(); |
762 group.start(); |
768 |
763 |
769 QCOMPARE(stateChangedSpy.count(), 2); |
764 QCOMPARE(stateChangedSpy.count(), 2); |
770 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).at(1)), |
765 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).first()), |
771 QAnimationGroup::Running); |
766 QAnimationGroup::Running); |
772 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).at(1)), |
767 QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).first()), |
773 QAnimationGroup::Stopped); |
768 QAnimationGroup::Stopped); |
774 |
769 |
775 QCOMPARE(group.state(), QAnimationGroup::Running); |
770 QCOMPARE(group.state(), QAnimationGroup::Running); |
776 QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running); |
771 QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running); |
777 QCOMPARE(loopsForever.state(), QAnimationGroup::Running); |
772 QCOMPARE(loopsForever.state(), QAnimationGroup::Running); |
918 anim1.setCurrentTime(42); // 42 is "untouched" |
913 anim1.setCurrentTime(42); // 42 is "untouched" |
919 anim2.setCurrentTime(42); |
914 anim2.setCurrentTime(42); |
920 |
915 |
921 group.setCurrentTime(currentGroupTime); |
916 group.setCurrentTime(currentGroupTime); |
922 |
917 |
923 QCOMPARE(anim1.currentTime(), expected1.time); |
918 QCOMPARE(anim1.currentLoopTime(), expected1.time); |
924 QCOMPARE(anim2.currentTime(), expected2.time); |
919 QCOMPARE(anim2.currentLoopTime(), expected2.time); |
925 QCOMPARE(anim3.currentTime(), expected3.time); |
920 QCOMPARE(anim3.currentLoopTime(), expected3.time); |
926 |
921 |
927 if (expected1.state >=0) |
922 if (expected1.state >=0) |
928 QCOMPARE(int(anim1.state()), expected1.state); |
923 QCOMPARE(int(anim1.state()), expected1.state); |
929 if (expected2.state >=0) |
924 if (expected2.state >=0) |
930 QCOMPARE(int(anim2.state()), expected2.state); |
925 QCOMPARE(int(anim2.state()), expected2.state); |
971 QTest::qWait(100); |
966 QTest::qWait(100); |
972 QCOMPARE(group.state(), QAnimationGroup::Running); |
967 QCOMPARE(group.state(), QAnimationGroup::Running); |
973 QCOMPARE(anim->state(), QAnimationGroup::Running); |
968 QCOMPARE(anim->state(), QAnimationGroup::Running); |
974 QCOMPARE(spy.count(), 1); |
969 QCOMPARE(spy.count(), 1); |
975 spy.clear(); |
970 spy.clear(); |
976 const int currentTime = group.currentTime(); |
971 const int currentTime = group.currentLoopTime(); |
977 QCOMPARE(anim->currentTime(), currentTime); |
972 QCOMPARE(anim->currentLoopTime(), currentTime); |
978 |
973 |
979 group.pause(); |
974 group.pause(); |
980 QCOMPARE(group.state(), QAnimationGroup::Paused); |
975 QCOMPARE(group.state(), QAnimationGroup::Paused); |
981 QCOMPARE(group.currentTime(), currentTime); |
976 QCOMPARE(group.currentLoopTime(), currentTime); |
982 QCOMPARE(anim->state(), QAnimationGroup::Paused); |
977 QCOMPARE(anim->state(), QAnimationGroup::Paused); |
983 QCOMPARE(anim->currentTime(), currentTime); |
978 QCOMPARE(anim->currentLoopTime(), currentTime); |
984 QCOMPARE(spy.count(), 1); |
979 QCOMPARE(spy.count(), 1); |
985 spy.clear(); |
980 spy.clear(); |
986 |
981 |
987 group.resume(); |
982 group.resume(); |
988 QCOMPARE(group.state(), QAnimationGroup::Running); |
983 QCOMPARE(group.state(), QAnimationGroup::Running); |
989 QCOMPARE(group.currentTime(), currentTime); |
984 QCOMPARE(group.currentLoopTime(), currentTime); |
990 QCOMPARE(anim->state(), QAnimationGroup::Running); |
985 QCOMPARE(anim->state(), QAnimationGroup::Running); |
991 QCOMPARE(anim->currentTime(), currentTime); |
986 QCOMPARE(anim->currentLoopTime(), currentTime); |
992 QCOMPARE(spy.count(), 1); |
987 QCOMPARE(spy.count(), 1); |
993 |
988 |
994 group.stop(); |
989 group.stop(); |
995 spy.clear(); |
990 spy.clear(); |
996 new TestAnimation2(500, &group); |
991 new TestAnimation2(500, &group); |
997 group.start(); |
992 group.start(); |
998 QCOMPARE(spy.count(), 1); //the animation should have been started |
993 QCOMPARE(spy.count(), 1); //the animation should have been started |
999 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy.last().at(1)), TestAnimation::Running); |
994 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Running); |
1000 group.setCurrentTime(250); //end of first animation |
995 group.setCurrentTime(250); //end of first animation |
1001 QCOMPARE(spy.count(), 2); //the animation should have been stopped |
996 QCOMPARE(spy.count(), 2); //the animation should have been stopped |
1002 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy.last().at(1)), TestAnimation::Stopped); |
997 QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Stopped); |
1003 group.pause(); |
998 group.pause(); |
1004 QCOMPARE(spy.count(), 2); //this shouldn't have changed |
999 QCOMPARE(spy.count(), 2); //this shouldn't have changed |
1005 group.resume(); |
1000 group.resume(); |
1006 QCOMPARE(spy.count(), 2); //this shouldn't have changed |
1001 QCOMPARE(spy.count(), 2); //this shouldn't have changed |
1007 |
1002 |