tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
    85     void finishWithUncontrolledAnimation();
    85     void finishWithUncontrolledAnimation();
    86     void addRemoveAnimation();
    86     void addRemoveAnimation();
    87     void currentAnimation();
    87     void currentAnimation();
    88     void currentAnimationWithZeroDuration();
    88     void currentAnimationWithZeroDuration();
    89     void insertAnimation();
    89     void insertAnimation();
    90     void clearAnimations();
    90     void clear();
    91     void pauseResume();
    91     void pauseResume();
    92 };
    92 };
    93 
    93 
    94 tst_QSequentialAnimationGroup::tst_QSequentialAnimationGroup()
    94 tst_QSequentialAnimationGroup::tst_QSequentialAnimationGroup()
    95 {
    95 {
   132 class TestAnimation : public QVariantAnimation
   132 class TestAnimation : public QVariantAnimation
   133 {
   133 {
   134     Q_OBJECT
   134     Q_OBJECT
   135 public:
   135 public:
   136     virtual void updateCurrentValue(const QVariant &value) { Q_UNUSED(value)};
   136     virtual void updateCurrentValue(const QVariant &value) { Q_UNUSED(value)};
   137     virtual void updateState(QAbstractAnimation::State oldState,
   137     virtual void updateState(QAbstractAnimation::State newState,
   138                              QAbstractAnimation::State newState)
   138                              QAbstractAnimation::State oldState)
   139     {
   139     {
   140         Q_UNUSED(oldState)
   140         Q_UNUSED(oldState)
   141         Q_UNUSED(newState)
   141         Q_UNUSED(newState)
   142     };
   142     };
   143 };
   143 };
   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);
   497     QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
   497     QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped);
   498     QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped);
   498     QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped);
   499 
   499 
   500     // Current time = 1750
   500     // Current time = 1750
   501     group.setCurrentTime(1750);
   501     group.setCurrentTime(1750);
   502     QCOMPARE(group.currentTime(), 1750);
   502     QCOMPARE(group.currentLoopTime(), 1750);
   503     QCOMPARE(sequence->currentTime(), 1250);
   503     QCOMPARE(sequence->currentLoopTime(), 1250);
   504     QCOMPARE(a1_s_o1->currentTime(), 250);
   504     QCOMPARE(a1_s_o1->currentLoopTime(), 250);
   505     QCOMPARE(a2_s_o1->currentTime(), 250);
   505     QCOMPARE(a2_s_o1->currentLoopTime(), 250);
   506     QCOMPARE(a2_s_o1->currentLoop(), 2);
   506     QCOMPARE(a2_s_o1->currentLoop(), 2);
   507     QCOMPARE(a3_s_o1->currentTime(), 250);
   507     QCOMPARE(a3_s_o1->currentLoopTime(), 250);
   508     QCOMPARE(sequence2->currentTime(), 500);
   508     QCOMPARE(sequence2->currentLoopTime(), 500);
   509     QCOMPARE(a1_s_o2->currentTime(), 250);
   509     QCOMPARE(a1_s_o2->currentLoopTime(), 250);
   510     QCOMPARE(a1_s_o3->currentTime(), 250);
   510     QCOMPARE(a1_s_o3->currentLoopTime(), 250);
   511 }
   511 }
   512 
   512 
   513 void tst_QSequentialAnimationGroup::seekingBackwards()
   513 void tst_QSequentialAnimationGroup::seekingBackwards()
   514 {
   514 {
   515     // sequence operating on same object/property
   515     // sequence operating on same object/property
   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);
   610             equals = false;
   610             equals = false;
   611             break;
   611             break;
   612         }
   612         }
   613         QList<QVariant> args = spy.at(i);
   613         QList<QVariant> args = spy.at(i);
   614         QAbstractAnimation::State st = expectedStates.at(i);
   614         QAbstractAnimation::State st = expectedStates.at(i);
   615         QAbstractAnimation::State actual = qVariantValue<QAbstractAnimation::State>(args.value(1));
   615         QAbstractAnimation::State actual = qVariantValue<QAbstractAnimation::State>(args.first());
   616         if (equals && actual != st) {
   616         if (equals && actual != st) {
   617             equals = false;
   617             equals = false;
   618             break;
   618             break;
   619         }
   619         }
   620     }
   620     }
   670     group.start();
   670     group.start();
   671     group.pause();
   671     group.pause();
   672 
   672 
   673     // Current time = 1751
   673     // Current time = 1751
   674     group.setCurrentTime(1751);
   674     group.setCurrentTime(1751);
   675     QCOMPARE(group.currentTime(), 1751);
   675     QCOMPARE(group.currentLoopTime(), 1751);
   676     QCOMPARE(sequence->currentTime(), 751);
   676     QCOMPARE(sequence->currentLoopTime(), 751);
   677     QCOMPARE(sequence->currentLoop(), 1);
   677     QCOMPARE(sequence->currentLoop(), 1);
   678     QCOMPARE(a1_s_o1->currentTime(), 250);
   678     QCOMPARE(a1_s_o1->currentLoopTime(), 250);
   679     QCOMPARE(a2_s_o1->currentTime(), 250);
   679     QCOMPARE(a2_s_o1->currentLoopTime(), 250);
   680     QCOMPARE(a2_s_o1->currentLoop(), 1);
   680     QCOMPARE(a2_s_o1->currentLoop(), 1);
   681     QCOMPARE(a3_s_o1->currentLoop(), 0);
   681     QCOMPARE(a3_s_o1->currentLoop(), 0);
   682     QCOMPARE(a3_s_o1->currentTime(), 1);
   682     QCOMPARE(a3_s_o1->currentLoopTime(), 1);
   683 
   683 
   684     QCOMPARE(group.state(), QAnimationGroup::Paused);
   684     QCOMPARE(group.state(), QAnimationGroup::Paused);
   685     QCOMPARE(sequence->state(), QAnimationGroup::Paused);
   685     QCOMPARE(sequence->state(), QAnimationGroup::Paused);
   686     QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
   686     QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
   687     QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped);
   687     QCOMPARE(a2_s_o1->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 {
   795     QTest::qWait(300);
   795     QTest::qWait(300);
   796     QTRY_COMPARE(group.state(), QAnimationGroup::Stopped);
   796     QTRY_COMPARE(group.state(), QAnimationGroup::Stopped);
   797 
   797 
   798     for (int i = 0; i < 3; i++) {
   798     for (int i = 0; i < 3; i++) {
   799         QCOMPARE(animsStateChanged[i]->count(), 4);
   799         QCOMPARE(animsStateChanged[i]->count(), 4);
   800         QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(0).at(1)),
   800         QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(0).first()),
   801                  QAnimationGroup::Running);
   801                  QAnimationGroup::Running);
   802         QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(1).at(1)),
   802         QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(1).first()),
   803                  QAnimationGroup::Stopped);
   803                  QAnimationGroup::Stopped);
   804         QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(2).at(1)),
   804         QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(2).first()),
   805                  QAnimationGroup::Running);
   805                  QAnimationGroup::Running);
   806         QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(3).at(1)),
   806         QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(3).first()),
   807                  QAnimationGroup::Stopped);
   807                  QAnimationGroup::Stopped);
   808     }
   808     }
   809 
   809 
   810     QCOMPARE(seqStateChangedSpy.count(), 2);
   810     QCOMPARE(seqStateChangedSpy.count(), 2);
   811     QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).at(1)),
   811     QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()),
   812              QAnimationGroup::Running);
   812              QAnimationGroup::Running);
   813     QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).at(1)),
   813     QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).first()),
   814              QAnimationGroup::Stopped);
   814              QAnimationGroup::Stopped);
   815 
   815 
   816     QCOMPARE(seqCurrentAnimChangedSpy.count(), 6);
   816     QCOMPARE(seqCurrentAnimChangedSpy.count(), 6);
   817     for(int i=0; i<seqCurrentAnimChangedSpy.count(); i++)
   817     for(int i=0; i<seqCurrentAnimChangedSpy.count(); i++)
   818             QCOMPARE(static_cast<QAbstractAnimation*>(anims[i%3]), qVariantValue<QAbstractAnimation*>(seqCurrentAnimChangedSpy.at(i).at(0)));
   818             QCOMPARE(static_cast<QAbstractAnimation*>(anims[i%3]), qVariantValue<QAbstractAnimation*>(seqCurrentAnimChangedSpy.at(i).at(0)));
   853     group.start();
   853     group.start();
   854     group.pause();
   854     group.pause();
   855 
   855 
   856     // Current time = 1750
   856     // Current time = 1750
   857     group.setCurrentTime(1750);
   857     group.setCurrentTime(1750);
   858     QCOMPARE(group.currentTime(), 1750);
   858     QCOMPARE(group.currentLoopTime(), 1750);
   859     QCOMPARE(sequence->currentTime(), 750);
   859     QCOMPARE(sequence->currentLoopTime(), 750);
   860     QCOMPARE(sequence->currentLoop(), 1);
   860     QCOMPARE(sequence->currentLoop(), 1);
   861     QCOMPARE(a1_s_o1->currentTime(), 250);
   861     QCOMPARE(a1_s_o1->currentLoopTime(), 250);
   862     QCOMPARE(a2_s_o1->currentTime(), 250);
   862     QCOMPARE(a2_s_o1->currentLoopTime(), 250);
   863     QCOMPARE(a2_s_o1->currentLoop(), 1);
   863     QCOMPARE(a2_s_o1->currentLoop(), 1);
   864     // this animation is at the beginning because it is the current one inside sequence
   864     // this animation is at the beginning because it is the current one inside sequence
   865     QCOMPARE(a3_s_o1->currentLoop(), 0);
   865     QCOMPARE(a3_s_o1->currentLoop(), 0);
   866     QCOMPARE(a3_s_o1->currentTime(), 0);
   866     QCOMPARE(a3_s_o1->currentLoopTime(), 0);
   867     QCOMPARE(sequence->currentAnimation(), a3_s_o1);
   867     QCOMPARE(sequence->currentAnimation(), a3_s_o1);
   868 
   868 
   869     QCOMPARE(group.state(), QAnimationGroup::Paused);
   869     QCOMPARE(group.state(), QAnimationGroup::Paused);
   870     QCOMPARE(sequence->state(), QAnimationGroup::Paused);
   870     QCOMPARE(sequence->state(), QAnimationGroup::Paused);
   871     QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
   871     QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped);
   888     QCOMPARE(seqSpy.count(), 2);    // Running,Paused
   888     QCOMPARE(seqSpy.count(), 2);    // Running,Paused
   889     QCOMPARE(groupSpy.count(), 2);  // Running,Paused
   889     QCOMPARE(groupSpy.count(), 2);  // Running,Paused
   890 
   890 
   891     // Looping, current time = duration + 1
   891     // Looping, current time = duration + 1
   892     group.setCurrentTime(group.duration() + 1);
   892     group.setCurrentTime(group.duration() + 1);
   893     QCOMPARE(group.currentTime(), 1);
   893     QCOMPARE(group.currentLoopTime(), 1);
   894     QCOMPARE(group.currentLoop(), 1);
   894     QCOMPARE(group.currentLoop(), 1);
   895     QCOMPARE(sequence->currentTime(), 1);
   895     QCOMPARE(sequence->currentLoopTime(), 1);
   896     QCOMPARE(sequence->currentLoop(), 0);
   896     QCOMPARE(sequence->currentLoop(), 0);
   897     QCOMPARE(a1_s_o1->currentTime(), 1);
   897     QCOMPARE(a1_s_o1->currentLoopTime(), 1);
   898     QCOMPARE(a2_s_o1->currentTime(), 250);
   898     QCOMPARE(a2_s_o1->currentLoopTime(), 250);
   899     QCOMPARE(a2_s_o1->currentLoop(), 1);
   899     QCOMPARE(a2_s_o1->currentLoop(), 1);
   900     // this animation is at the end because it was run on the previous loop
   900     // this animation is at the end because it was run on the previous loop
   901     QCOMPARE(a3_s_o1->currentLoop(), 0);
   901     QCOMPARE(a3_s_o1->currentLoop(), 0);
   902     QCOMPARE(a3_s_o1->currentTime(), 250);
   902     QCOMPARE(a3_s_o1->currentLoopTime(), 250);
   903 
   903 
   904     QCOMPARE(group.state(), QAnimationGroup::Paused);
   904     QCOMPARE(group.state(), QAnimationGroup::Paused);
   905     QCOMPARE(sequence->state(), QAnimationGroup::Paused);
   905     QCOMPARE(sequence->state(), QAnimationGroup::Paused);
   906     QCOMPARE(a1_s_o1->state(), QAnimationGroup::Paused);
   906     QCOMPARE(a1_s_o1->state(), QAnimationGroup::Paused);
   907     QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped);
   907     QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped);
   927     QSequentialAnimationGroup group;
   927     QSequentialAnimationGroup group;
   928     group.addPause(250);
   928     group.addPause(250);
   929     group.addPause(125);
   929     group.addPause(125);
   930     QCOMPARE(group.totalDuration(), 375);
   930     QCOMPARE(group.totalDuration(), 375);
   931 
   931 
   932     QEventLoop loop;
   932     group.start();
   933     QObject::connect(&group, SIGNAL(finished()), &loop, SLOT(quit()));
   933     QCOMPARE(group.state(), QAnimationGroup::Running);
   934 
   934 
   935     QTime time;
   935     QTest::qWait(500);
   936     time.start();
   936 
   937     group.start();
   937     QVERIFY(group.currentLoopTime() == 375);
   938     loop.exec();
   938     QCOMPARE(group.state(), QAnimationGroup::Stopped);
   939 
       
   940     QVERIFY(time.elapsed() >= 375);
       
   941     QVERIFY(time.elapsed() < 1000);
       
   942 }
   939 }
   943 
   940 
   944 void tst_QSequentialAnimationGroup::clearGroup()
   941 void tst_QSequentialAnimationGroup::clearGroup()
   945 {
   942 {
   946     QSequentialAnimationGroup group;
   943     QSequentialAnimationGroup group;
   959     for (int i = 0; i < animationCount; ++i) {
   956     for (int i = 0; i < animationCount; ++i) {
   960         QVERIFY(group.animationAt(i) != 0);
   957         QVERIFY(group.animationAt(i) != 0);
   961         children[i] = group.animationAt(i);
   958         children[i] = group.animationAt(i);
   962     }
   959     }
   963 
   960 
   964     group.clearAnimations();
   961     group.clear();
   965     QCOMPARE(group.animationCount(), 0);
   962     QCOMPARE(group.animationCount(), 0);
   966     QCOMPARE(group.currentTime(), 0);
   963     QCOMPARE(group.currentLoopTime(), 0);
   967     for (int i = 0; i < animationCount; ++i)
   964     for (int i = 0; i < animationCount; ++i)
   968         QVERIFY(children[i].isNull());
   965         QVERIFY(children[i].isNull());
   969 }
   966 }
   970 
   967 
   971 void tst_QSequentialAnimationGroup::groupWithZeroDurationAnimations()
   968 void tst_QSequentialAnimationGroup::groupWithZeroDurationAnimations()
  1131     QCOMPARE(anim.state(), QAnimationGroup::Running);
  1128     QCOMPARE(anim.state(), QAnimationGroup::Running);
  1132 
  1129 
  1133     QCOMPARE(groupStateChangedSpy.count(), 1);
  1130     QCOMPARE(groupStateChangedSpy.count(), 1);
  1134     QCOMPARE(childStateChangedSpy.count(), 1);
  1131     QCOMPARE(childStateChangedSpy.count(), 1);
  1135 
  1132 
  1136     QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).at(1)),
  1133     QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
  1137              QAnimationGroup::Running);
  1134              QAnimationGroup::Running);
  1138     QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).at(1)),
  1135     QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).first()),
  1139              QAnimationGroup::Running);
  1136              QAnimationGroup::Running);
  1140 
  1137 
  1141     // starting directly a running child will not have any effect
  1138     // starting directly a running child will not have any effect
  1142     anim.start();
  1139     anim.start();
  1143 
  1140 
  1172     group.start();
  1169     group.start();
  1173     QCOMPARE(group.state(), QAnimationGroup::Running);
  1170     QCOMPARE(group.state(), QAnimationGroup::Running);
  1174     QCOMPARE(anim1->state(), QAnimationGroup::Running);
  1171     QCOMPARE(anim1->state(), QAnimationGroup::Running);
  1175 
  1172 
  1176     QTest::qWait(100);
  1173     QTest::qWait(100);
  1177     QVERIFY(group.currentTime() > 0);
  1174     QVERIFY(group.currentLoopTime() > 0);
  1178 
  1175 
  1179     delete anim1;
  1176     delete anim1;
  1180     QCOMPARE(group.animationCount(), 0);
  1177     QCOMPARE(group.animationCount(), 0);
  1181     QCOMPARE(group.duration(), 0);
  1178     QCOMPARE(group.duration(), 0);
  1182     QCOMPARE(group.state(), QAnimationGroup::Stopped);
  1179     QCOMPARE(group.state(), QAnimationGroup::Stopped);
  1183     QCOMPARE(group.currentTime(), 0); //that's the invariant
  1180     QCOMPARE(group.currentLoopTime(), 0); //that's the invariant
  1184 }
  1181 }
  1185 
  1182 
  1186 void tst_QSequentialAnimationGroup::startChildrenWithStoppedGroup()
  1183 void tst_QSequentialAnimationGroup::startChildrenWithStoppedGroup()
  1187 {
  1184 {
  1188     // test if children can be activated when their group is stopped
  1185     // test if children can be activated when their group is stopped
  1321     QCOMPARE(group.state(), QAnimationGroup::Running);
  1318     QCOMPARE(group.state(), QAnimationGroup::Running);
  1322     QCOMPARE(anim1->state(), QAnimationGroup::Stopped);
  1319     QCOMPARE(anim1->state(), QAnimationGroup::Stopped);
  1323     QCOMPARE(anim2->state(), QAnimationGroup::Running);
  1320     QCOMPARE(anim2->state(), QAnimationGroup::Running);
  1324 
  1321 
  1325     QCOMPARE(stateChangedSpy2.count(), 4);
  1322     QCOMPARE(stateChangedSpy2.count(), 4);
  1326     QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).at(1)),
  1323     QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()),
  1327              QAnimationGroup::Stopped);
  1324              QAnimationGroup::Stopped);
  1328     QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).at(1)),
  1325     QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()),
  1329              QAnimationGroup::Running);
  1326              QAnimationGroup::Running);
  1330 
  1327 
  1331     group.stop();
  1328     group.stop();
  1332 
  1329 
  1333     QCOMPARE(group.state(), QAnimationGroup::Stopped);
  1330     QCOMPARE(group.state(), QAnimationGroup::Stopped);
  1360     group.addAnimation(anim3);
  1357     group.addAnimation(anim3);
  1361     group.setLoopCount(2);
  1358     group.setLoopCount(2);
  1362     group.start();
  1359     group.start();
  1363 
  1360 
  1364     QCOMPARE(stateChangedSpy.count(), 2);
  1361     QCOMPARE(stateChangedSpy.count(), 2);
  1365     QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).at(1)),
  1362     QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).first()),
  1366              QAnimationGroup::Running);
  1363              QAnimationGroup::Running);
  1367     QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).at(1)),
  1364     QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).first()),
  1368              QAnimationGroup::Stopped);
  1365              QAnimationGroup::Stopped);
  1369 
  1366 
  1370     QCOMPARE(anim1->state(), QAnimationGroup::Stopped);
  1367     QCOMPARE(anim1->state(), QAnimationGroup::Stopped);
  1371     QCOMPARE(anim2->state(), QAnimationGroup::Running);
  1368     QCOMPARE(anim2->state(), QAnimationGroup::Running);
  1372     QCOMPARE(group.state(), QAnimationGroup::Running);
  1369     QCOMPARE(group.state(), QAnimationGroup::Running);
  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;
  1596 
  1593 
  1597 class SequentialAnimationGroup : public QSequentialAnimationGroup
  1594 class SequentialAnimationGroup : public QSequentialAnimationGroup
  1598 {
  1595 {
  1599     Q_OBJECT
  1596     Q_OBJECT
  1600 public slots:
  1597 public slots:
  1601     void clearAnimations()
  1598     void clear()
  1602     {
  1599     {
  1603         QSequentialAnimationGroup::clearAnimations();
  1600         QSequentialAnimationGroup::clear();
  1604     }
  1601     }
  1605 
  1602 
  1606     void refill()
  1603     void refill()
  1607     {
  1604     {
  1608         stop();
  1605         stop();
  1609         clearAnimations();
  1606         clear();
  1610         new DummyPropertyAnimation(this);
  1607         new DummyPropertyAnimation(this);
  1611         start();
  1608         start();
  1612     }
  1609     }
  1613 
  1610 
  1614 };
  1611 };
  1615 
  1612 
  1616 
  1613 
  1617 void tst_QSequentialAnimationGroup::clearAnimations()
  1614 void tst_QSequentialAnimationGroup::clear()
  1618 {
  1615 {
  1619     SequentialAnimationGroup group;
  1616     SequentialAnimationGroup group;
  1620     QPointer<QAbstractAnimation> anim1 = new DummyPropertyAnimation(&group);
  1617     QPointer<QAbstractAnimation> anim1 = new DummyPropertyAnimation(&group);
  1621     group.connect(anim1, SIGNAL(finished()), SLOT(clearAnimations()));
  1618     group.connect(anim1, SIGNAL(finished()), SLOT(clear()));
  1622     new DummyPropertyAnimation(&group);
  1619     new DummyPropertyAnimation(&group);
  1623     QCOMPARE(group.animationCount(), 2);
  1620     QCOMPARE(group.animationCount(), 2);
  1624 
  1621 
  1625     group.start();
  1622     group.start();
  1626     QTest::qWait(anim1->duration() + 100);
  1623     QTest::qWait(anim1->duration() + 100);
  1627     QCOMPARE(group.animationCount(), 0);
  1624     QCOMPARE(group.animationCount(), 0);
  1628     QCOMPARE(group.state(), QAbstractAnimation::Stopped);
  1625     QCOMPARE(group.state(), QAbstractAnimation::Stopped);
  1629     QCOMPARE(group.currentTime(), 0);
  1626     QCOMPARE(group.currentLoopTime(), 0);
  1630 
  1627 
  1631     anim1 = new DummyPropertyAnimation(&group);
  1628     anim1 = new DummyPropertyAnimation(&group);
  1632     group.connect(anim1, SIGNAL(finished()), SLOT(refill()));
  1629     group.connect(anim1, SIGNAL(finished()), SLOT(refill()));
  1633     group.start();
  1630     group.start();
  1634     QTest::qWait(anim1->duration() + 100);
  1631     QTest::qWait(anim1->duration() + 100);
  1650     QTest::qWait(100);
  1647     QTest::qWait(100);
  1651     QCOMPARE(group.state(), QAnimationGroup::Running);
  1648     QCOMPARE(group.state(), QAnimationGroup::Running);
  1652     QCOMPARE(anim->state(), QAnimationGroup::Running);
  1649     QCOMPARE(anim->state(), QAnimationGroup::Running);
  1653     QCOMPARE(spy.count(), 1);
  1650     QCOMPARE(spy.count(), 1);
  1654     spy.clear();
  1651     spy.clear();
  1655     const int currentTime = group.currentTime();
  1652     const int currentTime = group.currentLoopTime();
  1656     QCOMPARE(anim->currentTime(), currentTime);
  1653     QCOMPARE(anim->currentLoopTime(), currentTime);
  1657 
  1654 
  1658     group.pause();
  1655     group.pause();
  1659     QCOMPARE(group.state(), QAnimationGroup::Paused);
  1656     QCOMPARE(group.state(), QAnimationGroup::Paused);
  1660     QCOMPARE(group.currentTime(), currentTime);
  1657     QCOMPARE(group.currentLoopTime(), currentTime);
  1661     QCOMPARE(anim->state(), QAnimationGroup::Paused);
  1658     QCOMPARE(anim->state(), QAnimationGroup::Paused);
  1662     QCOMPARE(anim->currentTime(), currentTime);
  1659     QCOMPARE(anim->currentLoopTime(), currentTime);
  1663     QCOMPARE(spy.count(), 1);
  1660     QCOMPARE(spy.count(), 1);
  1664     spy.clear();
  1661     spy.clear();
  1665 
  1662 
  1666     group.resume();
  1663     group.resume();
  1667     QCOMPARE(group.state(), QAnimationGroup::Running);
  1664     QCOMPARE(group.state(), QAnimationGroup::Running);
  1668     QCOMPARE(group.currentTime(), currentTime);
  1665     QCOMPARE(group.currentLoopTime(), currentTime);
  1669     QCOMPARE(anim->state(), QAnimationGroup::Running);
  1666     QCOMPARE(anim->state(), QAnimationGroup::Running);
  1670     QCOMPARE(anim->currentTime(), currentTime);
  1667     QCOMPARE(anim->currentLoopTime(), currentTime);
  1671     QCOMPARE(spy.count(), 1);
  1668     QCOMPARE(spy.count(), 1);
  1672 }
  1669 }
  1673 
  1670 
  1674 QTEST_MAIN(tst_QSequentialAnimationGroup)
  1671 QTEST_MAIN(tst_QSequentialAnimationGroup)
  1675 #include "tst_qsequentialanimationgroup.moc"
  1672 #include "tst_qsequentialanimationgroup.moc"