summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-04-22 04:52:44 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-04-22 04:52:44 (GMT)
commitf2c5ea07b2ed5f96bd32f9a1d71ec9613c240fa6 (patch)
tree390ae15f24cd5b6af85b9bc74c39fd90ba03144b /tests/auto
parent1139eb432a18d556efb4ecfc079e82c2e2093b96 (diff)
parent3f39c3380f97339a1ffb9d13d7b184a8315d3821 (diff)
downloadQt-f2c5ea07b2ed5f96bd32f9a1d71ec9613c240fa6.zip
Qt-f2c5ea07b2ed5f96bd32f9a1d71ec9613c240fa6.tar.gz
Qt-f2c5ea07b2ed5f96bd32f9a1d71ec9613c240fa6.tar.bz2
Merge branch 'kinetic-animations' of ../../qt/kinetic into kinetic-declarativeui
Conflicts: src/gui/graphicsview/qgraphicsitem.cpp
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qanimationgroup/tst_qanimationgroup.cpp80
-rw-r--r--tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp30
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp40
-rw-r--r--tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp88
-rw-r--r--tests/auto/qstate/tst_qstate.cpp111
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp206
6 files changed, 272 insertions, 283 deletions
diff --git a/tests/auto/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp
index ff5c3b4..2952a39 100644
--- a/tests/auto/qanimationgroup/tst_qanimationgroup.cpp
+++ b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp
@@ -68,6 +68,8 @@ private slots:
void statesAndSignals();
void setParentAutoAdd();
void beginNestedGroup();
+ void addChildTwice();
+ void loopWithoutStartValue();
};
tst_QAnimationGroup::tst_QAnimationGroup()
@@ -207,7 +209,7 @@ void tst_QAnimationGroup::setCurrentTime()
QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
- a2_s_o1->setIterationCount(3);
+ a2_s_o1->setLoopCount(3);
sequence->addAnimation(a1_s_o1);
sequence->addAnimation(a2_s_o1);
sequence->addAnimation(a3_s_o1);
@@ -224,7 +226,7 @@ void tst_QAnimationGroup::setCurrentTime()
QVariantAnimation *a1_p_o1 = new QPropertyAnimation(&p_o1, "value");
QVariantAnimation *a1_p_o2 = new QPropertyAnimation(&p_o2, "value");
QVariantAnimation *a1_p_o3 = new QPropertyAnimation(&p_o3, "value");
- a1_p_o2->setIterationCount(3);
+ a1_p_o2->setLoopCount(3);
parallel->addAnimation(a1_p_o1);
parallel->addAnimation(a1_p_o2);
parallel->addAnimation(a1_p_o3);
@@ -233,7 +235,7 @@ void tst_QAnimationGroup::setCurrentTime()
QCOMPARE(notTimeDriven->totalDuration(), -1);
QVariantAnimation *loopsForever = new QPropertyAnimation(&t_o2, "value");
- loopsForever->setIterationCount(-1);
+ loopsForever->setLoopCount(-1);
QCOMPARE(loopsForever->totalDuration(), -1);
QParallelAnimationGroup group;
@@ -281,11 +283,11 @@ void tst_QAnimationGroup::setCurrentTime()
QCOMPARE(a1_s_o3->currentTime(), 0);
QCOMPARE(a1_p_o1->currentTime(), 250);
QCOMPARE(a1_p_o2->currentTime(), 0);
- QCOMPARE(a1_p_o2->currentIteration(), 1);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
QCOMPARE(a1_p_o3->currentTime(), 250);
QCOMPARE(notTimeDriven->currentTime(), 250);
QCOMPARE(loopsForever->currentTime(), 0);
- QCOMPARE(loopsForever->currentIteration(), 1);
+ QCOMPARE(loopsForever->currentLoop(), 1);
QCOMPARE(sequence->currentAnimation(), a2_s_o1);
// Current time = 251
@@ -294,14 +296,14 @@ void tst_QAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 251);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 1);
- QCOMPARE(a2_s_o1->currentIteration(), 0);
+ QCOMPARE(a2_s_o1->currentLoop(), 0);
QCOMPARE(a3_s_o1->currentTime(), 0);
QCOMPARE(sequence2->currentTime(), 251);
QCOMPARE(a1_s_o2->currentTime(), 250);
QCOMPARE(a1_s_o3->currentTime(), 1);
QCOMPARE(a1_p_o1->currentTime(), 250);
QCOMPARE(a1_p_o2->currentTime(), 1);
- QCOMPARE(a1_p_o2->currentIteration(), 1);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
QCOMPARE(a1_p_o3->currentTime(), 250);
QCOMPARE(notTimeDriven->currentTime(), 251);
QCOMPARE(loopsForever->currentTime(), 1);
@@ -343,5 +345,69 @@ void tst_QAnimationGroup::beginNestedGroup()
}
}
+void tst_QAnimationGroup::addChildTwice()
+{
+ QPropertyAnimation *subGroup;
+ QPropertyAnimation *subGroup2;
+ QAnimationGroup *parent = new QSequentialAnimationGroup();
+
+ subGroup = new QPropertyAnimation();
+ subGroup->setParent(parent);
+ parent->addAnimation(subGroup);
+ QCOMPARE(parent->animationCount(), 1);
+
+ parent->clearAnimations();
+
+ QCOMPARE(parent->animationCount(), 0);
+
+ // adding the same item twice to a group will remove the item from its current position
+ // and append it to the end
+ subGroup = new QPropertyAnimation(parent);
+ subGroup2 = new QPropertyAnimation(parent);
+
+ QCOMPARE(parent->animationCount(), 2);
+ QCOMPARE(parent->animationAt(0), subGroup);
+ QCOMPARE(parent->animationAt(1), subGroup2);
+
+ parent->addAnimation(subGroup);
+
+ QCOMPARE(parent->animationCount(), 2);
+ QCOMPARE(parent->animationAt(0), subGroup2);
+ QCOMPARE(parent->animationAt(1), subGroup);
+
+ delete parent;
+}
+
+void tst_QAnimationGroup::loopWithoutStartValue()
+{
+ QAnimationGroup *parent = new QSequentialAnimationGroup();
+ QObject o;
+ o.setProperty("ole", 0);
+ QCOMPARE(o.property("ole").toInt(), 0);
+
+ QPropertyAnimation anim1(&o, "ole");
+ anim1.setEndValue(-50);
+ anim1.setDuration(100);
+
+ QPropertyAnimation anim2(&o, "ole");
+ anim2.setEndValue(50);
+ anim2.setDuration(100);
+
+ parent->addAnimation(&anim1);
+ parent->addAnimation(&anim2);
+
+ parent->setLoopCount(-1);
+ parent->start();
+
+ QVERIFY(anim1.startValue().isNull());
+ QCOMPARE(anim1.currentValue().toInt(), 0);
+ QCOMPARE(parent->currentLoop(), 0);
+
+ parent->setCurrentTime(200);
+ QCOMPARE(parent->currentLoop(), 1);
+ QCOMPARE(anim1.currentValue().toInt(), 50);
+ parent->stop();
+}
+
QTEST_MAIN(tst_QAnimationGroup)
#include "tst_qanimationgroup.moc"
diff --git a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
index c7f33b7..f2ab57a 100644
--- a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
+++ b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
@@ -71,8 +71,8 @@ private slots:
void startGroupWithRunningChild();
void zeroDurationAnimation();
void stopUncontrolledAnimations();
- void iterationCount_data();
- void iterationCount();
+ void loopCount_data();
+ void loopCount();
void autoAdd();
};
@@ -194,7 +194,7 @@ void tst_QParallelAnimationGroup::setCurrentTime()
QVariantAnimation *a1_p_o1 = new QPropertyAnimation(&p_o1, "value");
QVariantAnimation *a1_p_o2 = new QPropertyAnimation(&p_o2, "value");
QVariantAnimation *a1_p_o3 = new QPropertyAnimation(&p_o3, "value");
- a1_p_o2->setIterationCount(3);
+ a1_p_o2->setLoopCount(3);
parallel->addAnimation(a1_p_o1);
parallel->addAnimation(a1_p_o2);
parallel->addAnimation(a1_p_o3);
@@ -203,7 +203,7 @@ void tst_QParallelAnimationGroup::setCurrentTime()
QCOMPARE(notTimeDriven->totalDuration(), -1);
QVariantAnimation *loopsForever = new QPropertyAnimation(&t_o2, "value");
- loopsForever->setIterationCount(-1);
+ loopsForever->setLoopCount(-1);
QCOMPARE(loopsForever->totalDuration(), -1);
QParallelAnimationGroup group;
@@ -233,18 +233,18 @@ void tst_QParallelAnimationGroup::setCurrentTime()
QCOMPARE(group.currentTime(), 250);
QCOMPARE(a1_p_o1->currentTime(), 250);
QCOMPARE(a1_p_o2->currentTime(), 0);
- QCOMPARE(a1_p_o2->currentIteration(), 1);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
QCOMPARE(a1_p_o3->currentTime(), 250);
QCOMPARE(notTimeDriven->currentTime(), 250);
QCOMPARE(loopsForever->currentTime(), 0);
- QCOMPARE(loopsForever->currentIteration(), 1);
+ QCOMPARE(loopsForever->currentLoop(), 1);
// Current time = 251
group.setCurrentTime(251);
QCOMPARE(group.currentTime(), 251);
QCOMPARE(a1_p_o1->currentTime(), 250);
QCOMPARE(a1_p_o2->currentTime(), 1);
- QCOMPARE(a1_p_o2->currentIteration(), 1);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
QCOMPARE(a1_p_o3->currentTime(), 250);
QCOMPARE(notTimeDriven->currentTime(), 251);
QCOMPARE(loopsForever->currentTime(), 1);
@@ -589,7 +589,7 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation()
group.stop();
- group.setIterationCount(4);
+ group.setLoopCount(4);
stateChangedSpy1.clear();
stateChangedSpy2.clear();
@@ -625,7 +625,7 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations()
loopsForever.setStartValue(0);
loopsForever.setEndValue(100);
loopsForever.setDuration(100);
- loopsForever.setIterationCount(-1);
+ loopsForever.setLoopCount(-1);
QSignalSpy stateChangedSpy(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
@@ -670,10 +670,10 @@ struct AnimState {
#define Stopped QAbstractAnimation::Stopped
Q_DECLARE_METATYPE(AnimState)
-void tst_QParallelAnimationGroup::iterationCount_data()
+void tst_QParallelAnimationGroup::loopCount_data()
{
QTest::addColumn<bool>("directionBackward");
- QTest::addColumn<int>("setIterationCount");
+ QTest::addColumn<int>("setLoopCount");
QTest::addColumn<int>("initialGroupTime");
QTest::addColumn<int>("currentGroupTime");
QTest::addColumn<AnimState>("expected1");
@@ -742,10 +742,10 @@ void tst_QParallelAnimationGroup::iterationCount_data()
}
-void tst_QParallelAnimationGroup::iterationCount()
+void tst_QParallelAnimationGroup::loopCount()
{
QFETCH(bool, directionBackward);
- QFETCH(int, setIterationCount);
+ QFETCH(int, setLoopCount);
QFETCH(int, initialGroupTime);
QFETCH(int, currentGroupTime);
QFETCH(AnimState, expected1);
@@ -763,7 +763,7 @@ void tst_QParallelAnimationGroup::iterationCount()
anim2.setStartValue(0);
anim2.setEndValue(100);
anim2.setDuration(60); //total 120
- anim2.setIterationCount(2);
+ anim2.setLoopCount(2);
TestAnimation anim3;
anim3.setStartValue(0);
@@ -774,7 +774,7 @@ void tst_QParallelAnimationGroup::iterationCount()
group.addAnimation(&anim2);
group.addAnimation(&anim3);
- group.setIterationCount(setIterationCount);
+ group.setLoopCount(setLoopCount);
if (initialGroupTime >= 0)
group.setCurrentTime(initialGroupTime);
if (directionBackward)
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
index f61df49..437c862 100644
--- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -42,7 +42,6 @@
#include <QtTest/QtTest>
#include <QtCore/qpropertyanimation.h>
-#include <QtGui/qitemanimation.h>
#include <QtGui/qwidget.h>
//TESTED_CLASS=QPropertyAnimation
@@ -144,7 +143,7 @@ void tst_QPropertyAnimation::construction()
void tst_QPropertyAnimation::setCurrentTime_data()
{
QTest::addColumn<int>("duration");
- QTest::addColumn<int>("iterationCount");
+ QTest::addColumn<int>("loopCount");
QTest::addColumn<int>("currentTime");
QTest::addColumn<int>("testCurrentTime");
QTest::addColumn<int>("testCurrentLoop");
@@ -177,7 +176,7 @@ void tst_QPropertyAnimation::setCurrentTime_data()
void tst_QPropertyAnimation::setCurrentTime()
{
QFETCH(int, duration);
- QFETCH(int, iterationCount);
+ QFETCH(int, loopCount);
QFETCH(int, currentTime);
QFETCH(int, testCurrentTime);
QFETCH(int, testCurrentLoop);
@@ -186,11 +185,11 @@ void tst_QPropertyAnimation::setCurrentTime()
if (duration < 0)
QTest::ignoreMessage(QtWarningMsg, "QVariantAnimation::setDuration: cannot set a negative duration");
animation.setDuration(duration);
- animation.setIterationCount(iterationCount);
+ animation.setLoopCount(loopCount);
animation.setCurrentTime(currentTime);
QCOMPARE(animation.currentTime(), testCurrentTime);
- QCOMPARE(animation.currentIteration(), testCurrentLoop);
+ QCOMPARE(animation.currentLoop(), testCurrentLoop);
}
void tst_QPropertyAnimation::statesAndSignals_data()
@@ -208,7 +207,7 @@ void tst_QPropertyAnimation::statesAndSignals()
QSignalSpy finishedSpy(anim, SIGNAL(finished()));
QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
- QSignalSpy currentLoopSpy(anim, SIGNAL(currentIterationChanged(int)));
+ QSignalSpy currentLoopSpy(anim, SIGNAL(currentLoopChanged(int)));
anim->setCurrentTime(1);
anim->setCurrentTime(100);
@@ -217,23 +216,23 @@ void tst_QPropertyAnimation::statesAndSignals()
QCOMPARE(currentLoopSpy.count(), 0);
QCOMPARE(anim->state(), QAnimationGroup::Stopped);
- anim->setIterationCount(3);
+ anim->setLoopCount(3);
anim->setCurrentTime(101);
if (uncontrolled)
QSKIP("Uncontrolled animations don't handle looping", SkipSingle);
QCOMPARE(currentLoopSpy.count(), 1);
- QCOMPARE(anim->currentIteration(), 1);
+ QCOMPARE(anim->currentLoop(), 1);
anim->setCurrentTime(0);
QCOMPARE(currentLoopSpy.count(), 2);
- QCOMPARE(anim->currentIteration(), 0);
+ QCOMPARE(anim->currentLoop(), 0);
anim->start();
QCOMPARE(anim->state(), QAnimationGroup::Running);
QCOMPARE(runningSpy.count(), 1); //anim must have started
- QCOMPARE(anim->currentIteration(), 0);
+ QCOMPARE(anim->currentLoop(), 0);
runningSpy.clear();
anim->stop();
@@ -241,7 +240,7 @@ void tst_QPropertyAnimation::statesAndSignals()
QCOMPARE(runningSpy.count(), 1); //anim must have stopped
QCOMPARE(finishedSpy.count(), 0);
QCOMPARE(anim->currentTime(), 0);
- QCOMPARE(anim->currentIteration(), 0);
+ QCOMPARE(anim->currentLoop(), 0);
QCOMPARE(currentLoopSpy.count(), 2);
runningSpy.clear();
@@ -252,24 +251,24 @@ void tst_QPropertyAnimation::statesAndSignals()
runningSpy.clear();
QCOMPARE(finishedSpy.count(), 1);
QCOMPARE(anim->currentTime(), 100);
- QCOMPARE(anim->currentIteration(), 2);
+ QCOMPARE(anim->currentLoop(), 2);
QCOMPARE(currentLoopSpy.count(), 4);
anim->start(); // auto-rewinds
QCOMPARE(anim->state(), QAnimationGroup::Running);
QCOMPARE(anim->currentTime(), 0);
- QCOMPARE(anim->currentIteration(), 0);
+ QCOMPARE(anim->currentLoop(), 0);
QCOMPARE(currentLoopSpy.count(), 5);
QCOMPARE(runningSpy.count(), 1); // anim has started
QCOMPARE(finishedSpy.count(), 1);
- QCOMPARE(anim->currentIteration(), 0);
+ QCOMPARE(anim->currentLoop(), 0);
runningSpy.clear();
QTest::qWait(1000);
QCOMPARE(currentLoopSpy.count(), 7);
QCOMPARE(anim->state(), QAnimationGroup::Stopped);
- QCOMPARE(anim->currentIteration(), 2);
+ QCOMPARE(anim->currentLoop(), 2);
QCOMPARE(runningSpy.count(), 1); // anim has stopped
QCOMPARE(finishedSpy.count(), 2);
QCOMPARE(anim->currentTime(), 100);
@@ -340,7 +339,7 @@ void tst_QPropertyAnimation::deletion2()
QCOMPARE(runningSpy.count(), 1);
QCOMPARE(finishedSpy.count(), 0);
- //we can't call deletaLater directly because the delete would only happen in the next iteration of _this_ event loop
+ //we can't call deletaLater directly because the delete would only happen in the next loop of _this_ event loop
QTimer::singleShot(0, object, SLOT(deleteLater()));
QTest::qWait(50);
@@ -526,13 +525,14 @@ void tst_QPropertyAnimation::startWithoutStartValue()
anim.setEndValue(110);
anim.start();
current = anim.currentValue().toInt();
- QCOMPARE(current, 42); // the initial default start value
-
+ // the default start value will reevaluate the current property
+ // and set it to the end value of the last iteration
+ QCOMPARE(current, 100);
QTest::qWait(100);
current = anim.currentValue().toInt();
//it is somewhere in the animation
- QVERIFY(current > 42);
- QVERIFY(current < 110);
+ QVERIFY(current >= 100);
+ QVERIFY(current <= 110);
}
void tst_QPropertyAnimation::playForwardBackward()
diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
index 18b57b2..0631343 100644
--- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
+++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
@@ -173,7 +173,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
- a2_s_o1->setIterationCount(3);
+ a2_s_o1->setLoopCount(3);
sequence->addAnimation(a1_s_o1);
sequence->addAnimation(a2_s_o1);
sequence->addAnimation(a3_s_o1);
@@ -221,7 +221,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 251);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 1);
- QCOMPARE(a2_s_o1->currentIteration(), 0);
+ QCOMPARE(a2_s_o1->currentLoop(), 0);
QCOMPARE(a3_s_o1->currentTime(), 0);
QCOMPARE(sequence2->currentTime(), 0);
QCOMPARE(a1_s_o2->currentTime(), 0);
@@ -233,7 +233,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 750);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 0);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 0);
QCOMPARE(sequence2->currentTime(), 0);
QCOMPARE(a1_s_o2->currentTime(), 0);
@@ -245,7 +245,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 1000);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 0);
QCOMPARE(sequence2->currentTime(), 0);
QCOMPARE(a1_s_o2->currentTime(), 0);
@@ -257,7 +257,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 1010);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 10);
QCOMPARE(sequence2->currentTime(), 0);
QCOMPARE(a1_s_o2->currentTime(), 0);
@@ -269,7 +269,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 0);
QCOMPARE(a1_s_o2->currentTime(), 0);
@@ -281,7 +281,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 250);
QCOMPARE(a1_s_o2->currentTime(), 250);
@@ -293,7 +293,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 500);
QCOMPARE(a1_s_o2->currentTime(), 250);
@@ -305,7 +305,7 @@ void tst_QSequentialAnimationGroup::setCurrentTime()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 500);
QCOMPARE(a1_s_o2->currentTime(), 250);
@@ -330,7 +330,7 @@ void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation()
QCOMPARE(notTimeDriven->totalDuration(), -1);
QVariantAnimation *loopsForever = new QPropertyAnimation(&t_o2, "value");
- loopsForever->setIterationCount(-1);
+ loopsForever->setLoopCount(-1);
QCOMPARE(loopsForever->totalDuration(), -1);
QSequentialAnimationGroup group;
@@ -436,7 +436,7 @@ void tst_QSequentialAnimationGroup::seekingForwards()
QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
- a2_s_o1->setIterationCount(3);
+ a2_s_o1->setLoopCount(3);
sequence->addAnimation(a1_s_o1);
sequence->addAnimation(a2_s_o1);
sequence->addAnimation(a3_s_o1);
@@ -476,7 +476,7 @@ void tst_QSequentialAnimationGroup::seekingForwards()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 250);
QCOMPARE(a1_s_o2->currentTime(), 250);
@@ -498,7 +498,7 @@ void tst_QSequentialAnimationGroup::seekingForwards()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 500);
QCOMPARE(a1_s_o2->currentTime(), 250);
@@ -516,7 +516,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards()
QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
- a2_s_o1->setIterationCount(3);
+ a2_s_o1->setLoopCount(3);
sequence->addAnimation(a1_s_o1);
sequence->addAnimation(a2_s_o1);
sequence->addAnimation(a3_s_o1);
@@ -540,7 +540,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 350);
QCOMPARE(a1_s_o2->currentTime(), 250);
@@ -564,7 +564,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards()
QCOMPARE(a2_s_o1->currentTime(), 0);
QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
"hence they don't reset from their current animation", Continue);
- QCOMPARE(a2_s_o1->currentIteration(), 0);
+ QCOMPARE(a2_s_o1->currentLoop(), 0);
QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
"hence they don't reset from their current animation", Continue);
QCOMPARE(a3_s_o1->currentTime(), 0);
@@ -585,7 +585,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards()
QCOMPARE(sequence->currentTime(), 1250);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 2);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(sequence2->currentTime(), 500);
QCOMPARE(a1_s_o2->currentTime(), 250);
@@ -656,11 +656,11 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
QVariantAnimation *a1_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a2_s_o1 = new QPropertyAnimation(&s_o1, "value");
QVariantAnimation *a3_s_o1 = new QPropertyAnimation(&s_o1, "value");
- a2_s_o1->setIterationCount(2);
+ a2_s_o1->setLoopCount(2);
sequence->addAnimation(a1_s_o1);
sequence->addAnimation(a2_s_o1);
sequence->addAnimation(a3_s_o1);
- sequence->setIterationCount(2);
+ sequence->setLoopCount(2);
QSignalSpy a1StateChangedSpy(a1_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
QSignalSpy seqStateChangedSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
@@ -675,11 +675,11 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
group.setCurrentTime(1751);
QCOMPARE(group.currentTime(), 1751);
QCOMPARE(sequence->currentTime(), 751);
- QCOMPARE(sequence->currentIteration(), 1);
+ QCOMPARE(sequence->currentLoop(), 1);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 1);
- QCOMPARE(a3_s_o1->currentIteration(), 0);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
QCOMPARE(a3_s_o1->currentTime(), 1);
QCOMPARE(group.state(), QAnimationGroup::Paused);
@@ -723,11 +723,11 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
QVERIFY(group.currentTime() >= 1751);
QVERIFY(sequence->currentTime() >= 751);
- QCOMPARE(sequence->currentIteration(), 1);
+ QCOMPARE(sequence->currentLoop(), 1);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 1);
- QCOMPARE(a3_s_o1->currentIteration(), 0);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
QVERIFY(a3_s_o1->currentTime() >= 1);
QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running
@@ -744,11 +744,11 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
QVERIFY(group.currentTime() >= 1751);
QVERIFY(sequence->currentTime() >= 751);
- QCOMPARE(sequence->currentIteration(), 1);
+ QCOMPARE(sequence->currentLoop(), 1);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 1);
- QCOMPARE(a3_s_o1->currentIteration(), 0);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
QVERIFY(a3_s_o1->currentTime() >= 1);
QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused
@@ -780,11 +780,11 @@ void tst_QSequentialAnimationGroup::restart()
animsStateChanged[i] = new QSignalSpy(anims[i], SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
}
- anims[1]->setIterationCount(2);
+ anims[1]->setLoopCount(2);
sequence->addAnimation(anims[0]);
sequence->addAnimation(anims[1]);
sequence->addAnimation(anims[2]);
- sequence->setIterationCount(2);
+ sequence->setLoopCount(2);
QSequentialAnimationGroup group;
group.addAnimation(sequence);
@@ -845,17 +845,17 @@ void tst_QSequentialAnimationGroup::looping()
QSignalSpy a3Spy(a3_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
QSignalSpy seqSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
- a2_s_o1->setIterationCount(2);
+ a2_s_o1->setLoopCount(2);
sequence->addAnimation(a1_s_o1);
sequence->addAnimation(a2_s_o1);
sequence->addAnimation(a3_s_o1);
- sequence->setIterationCount(2);
+ sequence->setLoopCount(2);
QSequentialAnimationGroup group;
QSignalSpy groupSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
group.addAnimation(sequence);
- group.setIterationCount(2);
+ group.setLoopCount(2);
group.start();
group.pause();
@@ -864,12 +864,12 @@ void tst_QSequentialAnimationGroup::looping()
group.setCurrentTime(1750);
QCOMPARE(group.currentTime(), 1750);
QCOMPARE(sequence->currentTime(), 750);
- QCOMPARE(sequence->currentIteration(), 1);
+ QCOMPARE(sequence->currentLoop(), 1);
QCOMPARE(a1_s_o1->currentTime(), 250);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 1);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
// this animation is at the beginning because it is the current one inside sequence
- QCOMPARE(a3_s_o1->currentIteration(), 0);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
QCOMPARE(a3_s_o1->currentTime(), 0);
QCOMPARE(sequence->currentAnimation(), a3_s_o1);
@@ -898,14 +898,14 @@ void tst_QSequentialAnimationGroup::looping()
// Looping, current time = duration + 1
group.setCurrentTime(group.duration() + 1);
QCOMPARE(group.currentTime(), 1);
- QCOMPARE(group.currentIteration(), 1);
+ QCOMPARE(group.currentLoop(), 1);
QCOMPARE(sequence->currentTime(), 1);
- QCOMPARE(sequence->currentIteration(), 0);
+ QCOMPARE(sequence->currentLoop(), 0);
QCOMPARE(a1_s_o1->currentTime(), 1);
QCOMPARE(a2_s_o1->currentTime(), 250);
- QCOMPARE(a2_s_o1->currentIteration(), 1);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
// this animation is at the end because it was run on the previous loop
- QCOMPARE(a3_s_o1->currentIteration(), 0);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
QCOMPARE(a3_s_o1->currentTime(), 250);
QCOMPARE(group.state(), QAnimationGroup::Paused);
@@ -1367,7 +1367,7 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation()
group.addAnimation(anim1);
group.addAnimation(anim2);
group.addAnimation(anim3);
- group.setIterationCount(2);
+ group.setLoopCount(2);
group.start();
QCOMPARE(stateChangedSpy.count(), 2);
@@ -1401,7 +1401,7 @@ void tst_QSequentialAnimationGroup::stopUncontrolledAnimations()
loopsForever.setStartValue(0);
loopsForever.setEndValue(100);
loopsForever.setDuration(100);
- loopsForever.setIterationCount(-1);
+ loopsForever.setLoopCount(-1);
group.addAnimation(&notTimeDriven);
group.addAnimation(&loopsForever);
@@ -1592,11 +1592,11 @@ void tst_QSequentialAnimationGroup::currentAnimationWithZeroDuration()
void tst_QSequentialAnimationGroup::insertAnimation()
{
QSequentialAnimationGroup group;
- group.setIterationCount(2);
+ group.setLoopCount(2);
QPropertyAnimation *anim = new QPropertyAnimation(&group);
QCOMPARE(group.duration(), anim->duration());
group.setCurrentTime(300);
- QCOMPARE(group.currentIteration(), 1);
+ QCOMPARE(group.currentLoop(), 1);
//this will crash if the sequential group calls duration on the created animation
new QPropertyAnimation(&group);
diff --git a/tests/auto/qstate/tst_qstate.cpp b/tests/auto/qstate/tst_qstate.cpp
index c4a0050..f28c3fa 100644
--- a/tests/auto/qstate/tst_qstate.cpp
+++ b/tests/auto/qstate/tst_qstate.cpp
@@ -42,15 +42,16 @@ private slots:
#if 0
void test();
#endif
- void setPropertyOnEntry();
- void setPropertyOnEntryTwice();
- void setPropertyOnExit();
- void setPropertyOnExitTwice();
+ void assignProperty();
+ void assignPropertyTwice();
void historyInitialState();
void addEntryAction();
+
+private:
+ bool functionCalled;
};
-tst_QState::tst_QState()
+tst_QState::tst_QState() : functionCalled(false)
{
}
@@ -200,20 +201,36 @@ void tst_QState::test()
}
#endif
+class TestClass: public QObject
+{
+ Q_OBJECT
+public:
+ TestClass() : called(false) {}
+ bool called;
+
+public slots:
+ void slot() { called = true; }
+
+
+};
+
void tst_QState::addEntryAction()
{
QStateMachine sm;
+
+ TestClass testObject;
+
QState *s0 = new QState(sm.rootState());
- s0->addEntryAction(new QStateSetPropertyAction(this, "objectName", "commandTest"));
+ s0->addEntryAction(new QStateInvokeMethodAction(&testObject, "slot"));
sm.setInitialState(s0);
sm.start();
QCoreApplication::processEvents();
- QCOMPARE(this->objectName(), QString::fromLatin1("commandTest"));
+ QCOMPARE(testObject.called, true);
}
-void tst_QState::setPropertyOnEntry()
+void tst_QState::assignProperty()
{
QStateMachine machine;
@@ -221,7 +238,7 @@ void tst_QState::setPropertyOnEntry()
object->setProperty("fooBar", 10);
QState *s1 = new QState(machine.rootState());
- s1->setPropertyOnEntry(object, "fooBar", 20);
+ s1->assignProperty(object, "fooBar", 20);
machine.setInitialState(s1);
machine.start();
@@ -230,7 +247,7 @@ void tst_QState::setPropertyOnEntry()
QCOMPARE(object->property("fooBar").toInt(), 20);
}
-void tst_QState::setPropertyOnEntryTwice()
+void tst_QState::assignPropertyTwice()
{
QStateMachine machine;
@@ -238,8 +255,8 @@ void tst_QState::setPropertyOnEntryTwice()
object->setProperty("fooBar", 10);
QState *s1 = new QState(machine.rootState());
- s1->setPropertyOnEntry(object, "fooBar", 20);
- s1->setPropertyOnEntry(object, "fooBar", 30);
+ s1->assignProperty(object, "fooBar", 20);
+ s1->assignProperty(object, "fooBar", 30);
machine.setInitialState(s1);
machine.start();
@@ -248,56 +265,24 @@ void tst_QState::setPropertyOnEntryTwice()
QCOMPARE(object->property("fooBar").toInt(), 30);
}
-void tst_QState::setPropertyOnExit()
-{
- QStateMachine machine;
-
- QObject *object = new QObject();
- object->setProperty("fooBar", 10);
-
- QState *s1 = new QState(machine.rootState());
- s1->setPropertyOnExit(object, "fooBar", 20);
-
- QState *s2 = new QState(machine.rootState());
- s1->addTransition(new QTransition(QEvent::User), s2);
-
- machine.setInitialState(s1);
- machine.start();
- QCoreApplication::processEvents();
-
- QCOMPARE(object->property("fooBar").toInt(), 10);
-
- machine.postEvent(new QEvent(QEvent::User));
- QCoreApplication::processEvents();
-
- QCOMPARE(object->property("fooBar").toInt(), 20);
-}
-
-void tst_QState::setPropertyOnExitTwice()
+class EventTestTransition: public QTransition
{
- QStateMachine machine;
-
- QObject *object = new QObject();
- object->setProperty("fooBar", 10);
-
- QState *s1 = new QState(machine.rootState());
- s1->setPropertyOnExit(object, "fooBar", 20);
- s1->setPropertyOnExit(object, "fooBar", 30);
-
- QState *s2 = new QState(machine.rootState());
- s1->addTransition(new QTransition(QEvent::User), s2);
+public:
+ EventTestTransition(QEvent::Type type, QState *targetState)
+ : QTransition(QList<QAbstractState*>() << targetState), m_type(type)
+ {
+ }
+
+protected:
+ bool eventTest(QEvent *e) const
+ {
+ return e->type() == m_type;
+ }
+
+private:
+ QEvent::Type m_type;
- machine.setInitialState(s1);
- machine.start();
- QCoreApplication::processEvents();
-
- QCOMPARE(object->property("fooBar").toInt(), 10);
-
- machine.postEvent(new QEvent(QEvent::User));
- QCoreApplication::processEvents();
-
- QCOMPARE(object->property("fooBar").toInt(), 30);
-}
+};
void tst_QState::historyInitialState()
{
@@ -315,9 +300,9 @@ void tst_QState::historyInitialState()
QState *s4 = new QState(s2);
- s1->addTransition(new QTransition(QEvent::User), s2);
- s2->addTransition(new QTransition(QEvent::User), s1);
- s3->addTransition(new QTransition(QEvent::Type(QEvent::User+1)), s4);
+ s1->addTransition(new EventTestTransition(QEvent::User, s2));
+ s2->addTransition(new EventTestTransition(QEvent::User, s1));
+ s3->addTransition(new EventTestTransition(QEvent::Type(QEvent::User+1), s4));
machine.setInitialState(s1);
machine.start();
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 729581e..085d16b 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -3,6 +3,40 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
****************************************************************************/
#include <QtTest/QtTest>
@@ -11,7 +45,7 @@
#include "qstatemachine.h"
#include "qstate.h"
-#include "qtransition.h"
+#include "qactiontransition.h"
#include "qhistorystate.h"
#include "qkeyeventtransition.h"
#include "qmouseeventtransition.h"
@@ -87,7 +121,6 @@ private slots:
void setRestorePolicyToDoNotRestore();
void setGlobalRestorePolicyToGlobalRestore();
void restorePolicyOnChildState();
- void addAnimatedTransition();
void transitionWithParent();
};
@@ -161,11 +194,11 @@ void tst_QStateMachine::cleanup()
qInstallMsgHandler(s_oldHandler);
}
-class EventTransition : public QTransition
+class EventTransition : public QActionTransition
{
public:
EventTransition(QEvent::Type type, QAbstractState *target, QState *parent = 0)
- : QTransition(QList<QAbstractState*>() << target, parent), m_type(type) {}
+ : QActionTransition(QList<QAbstractState*>() << target, parent), m_type(type) {}
protected:
virtual bool eventTest(QEvent *e) const {
return (e->type() == m_type);
@@ -212,21 +245,21 @@ void tst_QStateMachine::transitionEntersParent()
QState *greatGrandParent = new QState();
greatGrandParent->setObjectName("grandParent");
- greatGrandParent->setPropertyOnEntry(entryController, "greatGrandParentEntered", true);
+ greatGrandParent->assignProperty(entryController, "greatGrandParentEntered", true);
machine.addState(greatGrandParent);
machine.setInitialState(greatGrandParent);
QState *grandParent = new QState(greatGrandParent);
grandParent->setObjectName("grandParent");
- grandParent->setPropertyOnEntry(entryController, "grandParentEntered", true);
+ grandParent->assignProperty(entryController, "grandParentEntered", true);
QState *parent = new QState(grandParent);
parent->setObjectName("parent");
- parent->setPropertyOnEntry(entryController, "parentEntered", true);
+ parent->assignProperty(entryController, "parentEntered", true);
QState *state = new QState(parent);
state->setObjectName("state");
- state->setPropertyOnEntry(entryController, "stateEntered", true);
+ state->assignProperty(entryController, "stateEntered", true);
QState *initialStateOfGreatGrandParent = new QState(greatGrandParent);
initialStateOfGreatGrandParent->setObjectName("initialStateOfGreatGrandParent");
@@ -633,21 +666,21 @@ void tst_QStateMachine::errorStateEntersParentFirst()
QState *greatGrandParent = new QState();
greatGrandParent->setObjectName("greatGrandParent");
- greatGrandParent->setPropertyOnEntry(entryController, "greatGrandParentEntered", true);
+ greatGrandParent->assignProperty(entryController, "greatGrandParentEntered", true);
machine.addState(greatGrandParent);
machine.setInitialState(greatGrandParent);
QState *grandParent = new QState(greatGrandParent);
grandParent->setObjectName("grandParent");
- grandParent->setPropertyOnEntry(entryController, "grandParentEntered", true);
+ grandParent->assignProperty(entryController, "grandParentEntered", true);
QState *parent = new QState(grandParent);
parent->setObjectName("parent");
- parent->setPropertyOnEntry(entryController, "parentEntered", true);
+ parent->assignProperty(entryController, "parentEntered", true);
QState *errorState = new QState(parent);
errorState->setObjectName("errorState");
- errorState->setPropertyOnEntry(entryController, "errorStateEntered", true);
+ errorState->assignProperty(entryController, "errorStateEntered", true);
machine.setErrorState(errorState);
QState *initialStateOfGreatGrandParent = new QState(greatGrandParent);
@@ -785,15 +818,15 @@ void tst_QStateMachine::brokenStateIsNeverEntered()
machine.setInitialState(initialState);
QState *errorState = new QState(machine.rootState());
- errorState->setPropertyOnEntry(entryController, "errorStateEntered", true);
+ errorState->assignProperty(entryController, "errorStateEntered", true);
machine.setErrorState(errorState);
QState *brokenState = new QState(machine.rootState());
- brokenState->setPropertyOnEntry(entryController, "brokenStateEntered", true);
+ brokenState->assignProperty(entryController, "brokenStateEntered", true);
brokenState->setObjectName("brokenState");
QState *childState = new QState(brokenState);
- childState->setPropertyOnEntry(entryController, "childStateEntered", true);
+ childState->assignProperty(entryController, "childStateEntered", true);
initialState->addTransition(new EventTransition(QEvent::User, brokenState));
@@ -863,13 +896,13 @@ void tst_QStateMachine::restoreProperties()
QState *S1 = new QState();
S1->setObjectName("S1");
- S1->setPropertyOnEntry(object, "a", 3);
+ S1->assignProperty(object, "a", 3);
S1->setRestorePolicy(QState::RestoreProperties);
machine.addState(S1);
QState *S2 = new QState();
S2->setObjectName("S2");
- S2->setPropertyOnEntry(object, "b", 5);
+ S2->assignProperty(object, "b", 5);
S2->setRestorePolicy(QState::RestoreProperties);
machine.addState(S2);
@@ -1584,30 +1617,6 @@ private:
void tst_QStateMachine::stateActions()
{
- {
- QStateSetPropertyAction act;
- QCOMPARE(act.targetObject(), (QObject*)0);
- QCOMPARE(act.propertyName().length(), 0);
- QCOMPARE(act.value(), QVariant());
-
- act.setTargetObject(this);
- QCOMPARE(act.targetObject(), (QObject*)this);
- QByteArray name("foo");
- act.setPropertyName(name);
- QCOMPARE(act.propertyName(), name);
- QVariant value(123);
- act.setValue(value);
- QCOMPARE(act.value(), value);
- }
- {
- QByteArray name("foo");
- QVariant value(123);
- QStateSetPropertyAction act(this, name, value);
- QCOMPARE(act.targetObject(), (QObject*)this);
- QCOMPARE(act.propertyName(), name);
- QCOMPARE(act.value(), value);
- }
-
QStateMachine machine;
QState *s1 = new QState(machine.rootState());
@@ -1623,47 +1632,15 @@ void tst_QStateMachine::stateActions()
QTest::ignoreMessage(QtWarningMsg, "QActionState::removeExitAction: cannot remove null action");
s1->removeExitAction(0);
- QStateSetPropertyAction *spa = new QStateSetPropertyAction(s1, "objectName", "foo");
- s1->addEntryAction(spa);
- QCOMPARE(s1->entryActions().size(), 1);
- QCOMPARE(s1->entryActions().at(0), (QStateAction*)spa);
- QCOMPARE(spa->parent(), (QObject*)s1);
- QVERIFY(s1->exitActions().isEmpty());
-
- s1->addEntryAction(spa); // add again
- QCOMPARE(s1->entryActions().size(), 1);
-
QFinalState *s2 = new QFinalState(machine.rootState());
s1->addTransition(s2);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
- machine.start();
- QTRY_COMPARE(finishedSpy.count(), 1);
- QCOMPARE(s1->objectName(), QString::fromLatin1("foo"));
-
- s1->removeEntryAction(spa);
- QCOMPARE(spa->parent(), (QObject*)0);
- QVERIFY(s1->entryActions().isEmpty());
-
- s1->removeEntryAction(spa); // remove again
-
- s1->setObjectName(QString::fromLatin1("bar"));
- finishedSpy.clear();
- machine.start();
- QTRY_COMPARE(finishedSpy.count(), 1);
- QCOMPARE(s1->objectName(), QString::fromLatin1("bar"));
- s1->addEntryAction(spa);
- finishedSpy.clear();
- machine.start();
- QTRY_COMPARE(finishedSpy.count(), 1);
- QCOMPARE(s1->objectName(), QString::fromLatin1("foo"));
-
- s1->removeEntryAction(spa);
- QVERIFY(s1->entryActions().isEmpty());
- QStateInvokeMethodAction *ima = new QStateInvokeMethodAction(spa, "deleteLater");
- QPointer<QStateAction> ptr(spa);
+ QObject *obj = new QObject();
+ QStateInvokeMethodAction *ima = new QStateInvokeMethodAction(obj, "deleteLater");
+ QPointer<QObject> ptr(obj);
QVERIFY(ptr != 0);
s1->addEntryAction(ima);
finishedSpy.clear();
@@ -1674,13 +1651,8 @@ void tst_QStateMachine::stateActions()
s1->removeEntryAction(ima);
- s1->setPropertyOnEntry(s1, "objectName", "bar");
- QCOMPARE(s1->entryActions().size(), 1);
- s1->setPropertyOnEntry(s1, "objectName", "bar");
- QCOMPARE(s1->entryActions().size(), 1);
-
s1->invokeMethodOnEntry(ima, "deleteLater");
- QCOMPARE(s1->entryActions().size(), 2);
+ QCOMPARE(s1->entryActions().size(), 1);
ptr = ima;
QVERIFY(ptr != 0);
@@ -1730,10 +1702,10 @@ void tst_QStateMachine::transitionActions()
QState *s1 = new QState(machine.rootState());
QFinalState *s2 = new QFinalState(machine.rootState());
- QTransition *trans = new EventTransition(QEvent::User, s2);
+ EventTransition *trans = new EventTransition(QEvent::User, s2);
s1->addTransition(trans);
QVERIFY(trans->actions().isEmpty());
- QTest::ignoreMessage(QtWarningMsg, "QTransition::addAction: cannot add null action");
+ QTest::ignoreMessage(QtWarningMsg, "QActionTransition::addAction: cannot add null action");
trans->addAction(0);
QVERIFY(trans->actions().isEmpty());
@@ -1760,7 +1732,6 @@ void tst_QStateMachine::transitionActions()
QTRY_COMPARE(finishedSpy.count(), 1);
QVERIFY(act->didExecute());
- trans->setPropertyOnTransition(s1, "objectName", "foo");
trans->invokeMethodOnTransition(act, "deleteLater");
QPointer<QStateAction> ptr(act);
@@ -1774,7 +1745,6 @@ void tst_QStateMachine::transitionActions()
QTRY_COMPARE(finishedSpy.count(), 1);
QCoreApplication::processEvents();
QVERIFY(ptr == 0);
- QCOMPARE(s1->objectName(), QString::fromLatin1("foo"));
}
void tst_QStateMachine::defaultGlobalRestorePolicy()
@@ -1786,10 +1756,10 @@ void tst_QStateMachine::defaultGlobalRestorePolicy()
propertyHolder->setProperty("b", 2);
QState *s1 = new QState(machine.rootState());
- s1->setPropertyOnEntry(propertyHolder, "a", 3);
+ s1->assignProperty(propertyHolder, "a", 3);
QState *s2 = new QState(machine.rootState());
- s2->setPropertyOnEntry(propertyHolder, "b", 4);
+ s2->assignProperty(propertyHolder, "b", 4);
QState *s3 = new QState(machine.rootState());
@@ -1830,12 +1800,12 @@ void tst_QStateMachine::restorePolicyNotInherited()
QState *s1 = new QState(parentState);
s1->setObjectName("s1");
- s1->setPropertyOnEntry(propertyHolder, "a", 3);
+ s1->assignProperty(propertyHolder, "a", 3);
parentState->setInitialState(s1);
QState *s2 = new QState(parentState);
s2->setObjectName("s2");
- s2->setPropertyOnEntry(propertyHolder, "b", 4);
+ s2->assignProperty(propertyHolder, "b", 4);
QState *s3 = new QState(parentState);
s3->setObjectName("s3");
@@ -1874,10 +1844,10 @@ void tst_QStateMachine::globalRestorePolicySetToDoNotRestore()
propertyHolder->setProperty("b", 2);
QState *s1 = new QState(machine.rootState());
- s1->setPropertyOnEntry(propertyHolder, "a", 3);
+ s1->assignProperty(propertyHolder, "a", 3);
QState *s2 = new QState(machine.rootState());
- s2->setPropertyOnEntry(propertyHolder, "b", 4);
+ s2->assignProperty(propertyHolder, "b", 4);
QState *s3 = new QState(machine.rootState());
@@ -1914,13 +1884,13 @@ void tst_QStateMachine::setRestorePolicyToDoNotRestore()
QState *S1 = new QState();
S1->setObjectName("S1");
- S1->setPropertyOnEntry(object, "a", 3);
+ S1->assignProperty(object, "a", 3);
S1->setRestorePolicy(QState::DoNotRestoreProperties);
machine.addState(S1);
QState *S2 = new QState();
S2->setObjectName("S2");
- S2->setPropertyOnEntry(object, "b", 5);
+ S2->assignProperty(object, "b", 5);
S2->setRestorePolicy(QState::DoNotRestoreProperties);
machine.addState(S2);
@@ -1987,13 +1957,13 @@ void tst_QStateMachine::restorePolicyOnChildState()
QState *s1 = new QState(parentState);
s1->setRestorePolicy(QState::RestoreProperties);
s1->setObjectName("s1");
- s1->setPropertyOnEntry(propertyHolder, "a", 3);
+ s1->assignProperty(propertyHolder, "a", 3);
parentState->setInitialState(s1);
QState *s2 = new QState(parentState);
s2->setRestorePolicy(QState::RestoreProperties);
s2->setObjectName("s2");
- s2->setPropertyOnEntry(propertyHolder, "b", 4);
+ s2->assignProperty(propertyHolder, "b", 4);
QState *s3 = new QState(parentState);
s3->setRestorePolicy(QState::RestoreProperties);
@@ -2032,10 +2002,10 @@ void tst_QStateMachine::globalRestorePolicySetToRestore()
propertyHolder->setProperty("b", 2);
QState *s1 = new QState(machine.rootState());
- s1->setPropertyOnEntry(propertyHolder, "a", 3);
+ s1->assignProperty(propertyHolder, "a", 3);
QState *s2 = new QState(machine.rootState());
- s2->setPropertyOnEntry(propertyHolder, "b", 4);
+ s2->assignProperty(propertyHolder, "b", 4);
QState *s3 = new QState(machine.rootState());
@@ -2071,19 +2041,19 @@ void tst_QStateMachine::mixedRestoreProperties()
QState *s1 = new QState(machine.rootState());
s1->setRestorePolicy(QState::RestoreProperties);
- s1->setPropertyOnEntry(propertyHolder, "a", 3);
+ s1->assignProperty(propertyHolder, "a", 3);
QState *s2 = new QState(machine.rootState());
- s2->setPropertyOnEntry(propertyHolder, "a", 4);
+ s2->assignProperty(propertyHolder, "a", 4);
QState *s3 = new QState(machine.rootState());
QState *s4 = new QState(machine.rootState());
- s4->setPropertyOnEntry(propertyHolder, "a", 5);
+ s4->assignProperty(propertyHolder, "a", 5);
QState *s5 = new QState(machine.rootState());
s5->setRestorePolicy(QState::RestoreProperties);
- s5->setPropertyOnEntry(propertyHolder, "a", 6);
+ s5->assignProperty(propertyHolder, "a", 6);
s1->addTransition(new EventTransition(QEvent::User, s2));
s2->addTransition(new EventTransition(QEvent::User, s3));
@@ -2129,38 +2099,6 @@ void tst_QStateMachine::mixedRestoreProperties()
QCOMPARE(propertyHolder->property("a").toInt(), 5);
}
-void tst_QStateMachine::addAnimatedTransition()
-{
- {
- QStateMachine machine;
- QState *s1 = new QState(machine.rootState());
- QState *s2 = new QState(machine.rootState());
- SignalEmitter emitter;
- QState *as = s1->addAnimatedTransition(&emitter, SIGNAL(signalWithNoArg()), s2);
- QVERIFY(as != 0);
- QCOMPARE(as->parentState(), s2->parentState());
- }
- {
- QStateMachine machine;
- QState *s1 = new QState(machine.rootState());
- QState *s2 = new QState(machine.rootState());
- QState *s21 = new QState(s2);
- SignalEmitter emitter;
- QState *as = s1->addAnimatedTransition(&emitter, SIGNAL(signalWithNoArg()), s21);
- QVERIFY(as != 0);
- QCOMPARE(as->parentState(), s2);
- }
- {
- QStateMachine machine;
- QState *s1 = new QState();
- QState *s2 = new QState();
- SignalEmitter emitter;
- QTest::ignoreMessage(QtWarningMsg, "QState::addAnimatedTransition: cannot add transition to target that doesn't have a parent state");
- QState *as = s1->addAnimatedTransition(&emitter, SIGNAL(signalWithNoArg()), s2);
- QCOMPARE(as, (QState*)0);
- }
-}
-
void tst_QStateMachine::transitionWithParent()
{
QStateMachine machine;