diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-07-12 03:12:06 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-12 20:38:02 +0200 |
commit | c4cef6fae9f2a55f21fc9517855dfcf659c89081 (patch) | |
tree | 6013a60155c3f949d9db4661c9bdcfff5cb4b20b /tests/auto/corelib/statemachine | |
parent | b76014b8ef3862b4168148cb20e1108d9c0df5f6 (diff) |
statemachine: Fix state entry bug for parallel state groups
The SCXML spec had a bug that would cause the initial state of a
compound state within a parallel state group to be entered even if
the transition specified another (non-initial) state of the compound
state as its target. This only happened if the transition had
multiple target states.
The bug has been fixed in recent revisions of the SCXML spec. This
commit implements the fix, which is to walk the ancestors of the
transition's target states only after all the target states
themselves have been added, so that the default initial states are
correctly overridden/ignored.
Task-number: QTBUG-25958
Change-Id: Iac532047678c483a4a3996e24dacf30e00f6bbe0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'tests/auto/corelib/statemachine')
-rw-r--r-- | tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp index 436b386a28..06d169c0e7 100644 --- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp @@ -203,6 +203,8 @@ private slots: void changeStateWhileAnimatingProperty(); void propertiesAreAssignedBeforeEntryCallbacks_data(); void propertiesAreAssignedBeforeEntryCallbacks(); + + void multiTargetTransitionInsideParallelStateGroup(); }; class TestState : public QState @@ -246,6 +248,9 @@ public: EventTransition(QEvent::Type type, QAbstractState *target, QState *parent = 0) : QAbstractTransition(parent), m_type(type) { setTargetState(target); } + EventTransition(QEvent::Type type, const QList<QAbstractState *> &targets, QState *parent = 0) + : QAbstractTransition(parent), m_type(type) + { setTargetStates(targets); } protected: virtual bool eventTest(QEvent *e) { return (e->type() == m_type); @@ -4647,5 +4652,39 @@ void tst_QStateMachine::propertiesAreAssignedBeforeEntryCallbacks() QVERIFY(s2->enteredPassed); } +// QTBUG-25958 +void tst_QStateMachine::multiTargetTransitionInsideParallelStateGroup() +{ + QStateMachine machine; + QState *s1 = new QState(&machine); + machine.setInitialState(s1); + + QState *s2 = new QState(QState::ParallelStates, &machine); + + QState *s21 = new QState(s2); + QState *s211 = new QState(s21); + QState *s212 = new QState(s21); + s21->setInitialState(s212); + + QState *s22 = new QState(s2); + QState *s221 = new QState(s22); + QState *s222 = new QState(s22); + s22->setInitialState(s222); + + QAbstractTransition *t1 = new EventTransition(QEvent::User, QList<QAbstractState *>() << s211 << s221); + s1->addTransition(t1); + + machine.start(); + QTRY_VERIFY(machine.configuration().contains(s1)); + + machine.postEvent(new QEvent(QEvent::User)); + QTRY_VERIFY(machine.configuration().contains(s2)); + QCOMPARE(machine.configuration().size(), 5); + QVERIFY(machine.configuration().contains(s21)); + QVERIFY(machine.configuration().contains(s211)); + QVERIFY(machine.configuration().contains(s22)); + QVERIFY(machine.configuration().contains(s221)); +} + QTEST_MAIN(tst_QStateMachine) #include "tst_qstatemachine.moc" |