932 group.start(); |
932 group.start(); |
933 QCOMPARE(group.state(), QAnimationGroup::Running); |
933 QCOMPARE(group.state(), QAnimationGroup::Running); |
934 |
934 |
935 QTest::qWait(500); |
935 QTest::qWait(500); |
936 |
936 |
|
937 QTRY_COMPARE(group.state(), QAnimationGroup::Stopped); |
937 QVERIFY(group.currentLoopTime() == 375); |
938 QVERIFY(group.currentLoopTime() == 375); |
938 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
|
939 } |
939 } |
940 |
940 |
941 void tst_QSequentialAnimationGroup::clearGroup() |
941 void tst_QSequentialAnimationGroup::clearGroup() |
942 { |
942 { |
943 QSequentialAnimationGroup group; |
943 QSequentialAnimationGroup group; |
1027 QCOMPARE(o.property("myProperty").toInt(), 43); |
1027 QCOMPARE(o.property("myProperty").toInt(), 43); |
1028 QCOMPARE(o.property("myOtherProperty").toInt(), 13); |
1028 QCOMPARE(o.property("myOtherProperty").toInt(), 13); |
1029 |
1029 |
1030 QTest::qWait(500); |
1030 QTest::qWait(500); |
1031 |
1031 |
1032 QCOMPARE(o.property("myProperty").toInt(), 44); |
1032 QTRY_COMPARE(o.property("myProperty").toInt(), 44); |
1033 QCOMPARE(o2.property("myProperty").toInt(), 42); |
1033 QCOMPARE(o2.property("myProperty").toInt(), 42); |
1034 QCOMPARE(o2.property("myOtherProperty").toInt(), 31); |
1034 QCOMPARE(o2.property("myOtherProperty").toInt(), 31); |
1035 QCOMPARE(a1->state(), QAnimationGroup::Stopped); |
1035 QCOMPARE(a1->state(), QAnimationGroup::Stopped); |
1036 QCOMPARE(a2->state(), QAnimationGroup::Stopped); |
1036 QCOMPARE(a2->state(), QAnimationGroup::Stopped); |
1037 QCOMPARE(a3->state(), QAnimationGroup::Stopped); |
1037 QCOMPARE(a3->state(), QAnimationGroup::Stopped); |
1169 group.start(); |
1169 group.start(); |
1170 QCOMPARE(group.state(), QAnimationGroup::Running); |
1170 QCOMPARE(group.state(), QAnimationGroup::Running); |
1171 QCOMPARE(anim1->state(), QAnimationGroup::Running); |
1171 QCOMPARE(anim1->state(), QAnimationGroup::Running); |
1172 |
1172 |
1173 QTest::qWait(100); |
1173 QTest::qWait(100); |
1174 QVERIFY(group.currentLoopTime() > 0); |
1174 QTRY_VERIFY(group.currentLoopTime() > 0); |
1175 |
1175 |
1176 delete anim1; |
1176 delete anim1; |
1177 QCOMPARE(group.animationCount(), 0); |
1177 QCOMPARE(group.animationCount(), 0); |
1178 QCOMPARE(group.duration(), 0); |
1178 QCOMPARE(group.duration(), 0); |
1179 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
1179 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
1428 QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running); |
1428 QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running); |
1429 QCOMPARE(group.currentLoopTime(), 0); |
1429 QCOMPARE(group.currentLoopTime(), 0); |
1430 QCOMPARE(notTimeDriven.currentLoopTime(), 0); |
1430 QCOMPARE(notTimeDriven.currentLoopTime(), 0); |
1431 |
1431 |
1432 QTest::qWait(300); //wait for the end of notTimeDriven |
1432 QTest::qWait(300); //wait for the end of notTimeDriven |
1433 QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped); |
1433 QTRY_COMPARE(notTimeDriven.state(), QAnimationGroup::Stopped); |
1434 const int actualDuration = notTimeDriven.currentLoopTime(); |
1434 const int actualDuration = notTimeDriven.currentLoopTime(); |
1435 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
1435 QCOMPARE(group.state(), QAnimationGroup::Stopped); |
1436 QCOMPARE(group.currentLoopTime(), actualDuration); |
1436 QCOMPARE(group.currentLoopTime(), actualDuration); |
1437 QCOMPARE(spy.count(), 1); |
1437 QCOMPARE(spy.count(), 1); |
1438 |
1438 |
1457 QCOMPARE(notTimeDriven.currentLoopTime(), 0); |
1457 QCOMPARE(notTimeDriven.currentLoopTime(), 0); |
1458 |
1458 |
1459 QCOMPARE(animStateChangedSpy.count(), 0); |
1459 QCOMPARE(animStateChangedSpy.count(), 0); |
1460 |
1460 |
1461 QTest::qWait(300); //wait for the end of notTimeDriven |
1461 QTest::qWait(300); //wait for the end of notTimeDriven |
1462 QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped); |
1462 QTRY_COMPARE(notTimeDriven.state(), QAnimationGroup::Stopped); |
1463 QCOMPARE(group.state(), QAnimationGroup::Running); |
1463 QCOMPARE(group.state(), QAnimationGroup::Running); |
1464 QCOMPARE(anim.state(), QAnimationGroup::Running); |
1464 QCOMPARE(anim.state(), QAnimationGroup::Running); |
1465 QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimation*>(&anim)); |
1465 QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimation*>(&anim)); |
1466 QCOMPARE(animStateChangedSpy.count(), 1); |
1466 QCOMPARE(animStateChangedSpy.count(), 1); |
1467 QTest::qWait(300); //wait for the end of anim |
1467 QTest::qWait(300); //wait for the end of anim |
1468 |
1468 |
1469 QCOMPARE(anim.state(), QAnimationGroup::Stopped); |
1469 QTRY_COMPARE(anim.state(), QAnimationGroup::Stopped); |
1470 QCOMPARE(anim.currentLoopTime(), anim.duration()); |
1470 QCOMPARE(anim.currentLoopTime(), anim.duration()); |
1471 |
1471 |
1472 //we should simply be at the end |
1472 //we should simply be at the end |
1473 QCOMPARE(spy.count(), 1); |
1473 QCOMPARE(spy.count(), 1); |
1474 QCOMPARE(animStateChangedSpy.count(), 2); |
1474 QCOMPARE(animStateChangedSpy.count(), 2); |
1619 new DummyPropertyAnimation(&group); |
1619 new DummyPropertyAnimation(&group); |
1620 QCOMPARE(group.animationCount(), 2); |
1620 QCOMPARE(group.animationCount(), 2); |
1621 |
1621 |
1622 group.start(); |
1622 group.start(); |
1623 QTest::qWait(anim1->duration() + 100); |
1623 QTest::qWait(anim1->duration() + 100); |
1624 QCOMPARE(group.animationCount(), 0); |
1624 QTRY_COMPARE(group.animationCount(), 0); |
1625 QCOMPARE(group.state(), QAbstractAnimation::Stopped); |
1625 QCOMPARE(group.state(), QAbstractAnimation::Stopped); |
1626 QCOMPARE(group.currentLoopTime(), 0); |
1626 QCOMPARE(group.currentLoopTime(), 0); |
1627 |
1627 |
1628 anim1 = new DummyPropertyAnimation(&group); |
1628 anim1 = new DummyPropertyAnimation(&group); |
1629 group.connect(anim1, SIGNAL(finished()), SLOT(refill())); |
1629 group.connect(anim1, SIGNAL(finished()), SLOT(refill())); |
1630 group.start(); |
1630 group.start(); |
1631 QTest::qWait(anim1->duration() + 100); |
1631 QTest::qWait(anim1->duration() + 100); |
|
1632 QTRY_COMPARE(group.state(), QAbstractAnimation::Running); |
1632 QVERIFY(anim1 == 0); //anim1 should have been deleted |
1633 QVERIFY(anim1 == 0); //anim1 should have been deleted |
1633 QCOMPARE(group.state(), QAbstractAnimation::Running); |
|
1634 } |
1634 } |
1635 |
1635 |
1636 void tst_QSequentialAnimationGroup::pauseResume() |
1636 void tst_QSequentialAnimationGroup::pauseResume() |
1637 { |
1637 { |
1638 QObject dummy; |
1638 QObject dummy; |
1643 anim->setEndValue(250); |
1643 anim->setEndValue(250); |
1644 QSignalSpy spy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); |
1644 QSignalSpy spy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); |
1645 QCOMPARE(group.duration(), 250); |
1645 QCOMPARE(group.duration(), 250); |
1646 group.start(); |
1646 group.start(); |
1647 QTest::qWait(100); |
1647 QTest::qWait(100); |
1648 QCOMPARE(group.state(), QAnimationGroup::Running); |
1648 QTRY_COMPARE(group.state(), QAnimationGroup::Running); |
1649 QCOMPARE(anim->state(), QAnimationGroup::Running); |
1649 QCOMPARE(anim->state(), QAnimationGroup::Running); |
1650 QCOMPARE(spy.count(), 1); |
1650 QCOMPARE(spy.count(), 1); |
1651 spy.clear(); |
1651 spy.clear(); |
1652 const int currentTime = group.currentLoopTime(); |
1652 const int currentTime = group.currentLoopTime(); |
1653 QCOMPARE(anim->currentLoopTime(), currentTime); |
1653 QCOMPARE(anim->currentLoopTime(), currentTime); |