summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-09-29 09:59:01 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-09-29 10:02:09 (GMT)
commit39604894946c3c0d623c0073ccf027a8e6df120a (patch)
treecb6fa13f922365d151cbc5597343560a56f19037 /tests
parentd557d6e5dc73c88f9de26bf2e3dd2c6955400467 (diff)
downloadQt-39604894946c3c0d623c0073ccf027a8e6df120a.zip
Qt-39604894946c3c0d623c0073ccf027a8e6df120a.tar.gz
Qt-39604894946c3c0d623c0073ccf027a8e6df120a.tar.bz2
Do synchronous processing of events in state machine if possible
Avoid delayed scheduling in the cases where there's no need to delay it (e.g. when the state machine intercepts a signal or event). Task-number: QTBUG-4491 Reviewed-by: Eskil Abrahamsen Blomfeldt
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 7244d72..37b34bf 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -176,6 +176,7 @@ private slots:
void twoAnimatedTransitions();
void playAnimationTwice();
void nestedTargetStateForAnimation();
+ void polishedSignalTransitionsReuseAnimationGroup();
void animatedGlobalRestoreProperty();
void specificTargetValueOfAnimation();
@@ -3115,6 +3116,38 @@ void tst_QStateMachine::nestedTargetStateForAnimation()
QCOMPARE(counter.counter, 2);
}
+void tst_QStateMachine::polishedSignalTransitionsReuseAnimationGroup()
+{
+ QStateMachine machine;
+ QObject *object = new QObject(&machine);
+ object->setProperty("foo", 0);
+
+ QState *s1 = new QState(&machine);
+ s1->assignProperty(object, "foo", 123);
+ QState *s2 = new QState(&machine);
+ s2->assignProperty(object, "foo", 456);
+ QState *s3 = new QState(&machine);
+ s3->assignProperty(object, "foo", 789);
+ QFinalState *s4 = new QFinalState(&machine);
+
+ QParallelAnimationGroup animationGroup;
+ animationGroup.addAnimation(new QPropertyAnimation(object, "foo"));
+ QSignalSpy animationFinishedSpy(&animationGroup, SIGNAL(finished()));
+ s1->addTransition(s1, SIGNAL(polished()), s2)->addAnimation(&animationGroup);
+ s2->addTransition(s2, SIGNAL(polished()), s3)->addAnimation(&animationGroup);
+ s3->addTransition(s3, SIGNAL(polished()), s4);
+
+ machine.setInitialState(s1);
+ QSignalSpy machineFinishedSpy(&machine, SIGNAL(finished()));
+ machine.start();
+ QTRY_COMPARE(machineFinishedSpy.count(), 1);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s4));
+ QCOMPARE(object->property("foo").toInt(), 789);
+
+ QCOMPARE(animationFinishedSpy.count(), 2);
+}
+
void tst_QStateMachine::animatedGlobalRestoreProperty()
{
QStateMachine machine;