diff options
author | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2015-03-17 13:23:51 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2015-04-10 12:59:20 +0000 |
commit | e616bd2641b9cf6a18cabeae3f9c425f91bfc4b3 (patch) | |
tree | dc7b8f60ec453f4ef93313b73090e6dd9779d6d2 /tests | |
parent | ab8d20532039674ac749186c1773bc0d33cf19cf (diff) |
QStateMachine: fix history state restoration.
When a history state is entered that has an actual saved history (so not
the initial state), the entry set was calculated wrongly in some cases.
See the bug report for the specific case.
The fix is to fully implement the standard, so method names in the
private class are updated to reflect the names as used in the standard.
Note that, as mentioned in the bug report, the algorithm as described in
http://www.w3.org/TR/2014/WD-scxml-20140529/ has a bug. What is
implemented is the fixed algorithm as described in the current working
draft as of Friday March 13, 2015. This draft can be found at:
http://www.w3.org/Voice/2013/scxml-irp/SCXML.htm
[ChangeLog][QtCore] Fixed an issue where a history state restore would
activate too many states, possibly putting the state machine in an
invalid state.
Change-Id: Ibb5491b2fdcf3a167c223fa8c9c4aad302dbb795
Task-number: QTBUG-44963
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp index 6e51f8f0ed..605d1e7393 100644 --- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp @@ -244,6 +244,8 @@ private slots: void signalTransitionSenderInDifferentThread2(); void signalTransitionRegistrationThreadSafety(); void childModeConstructor(); + + void qtbug_44963(); }; class TestState : public QState @@ -6169,5 +6171,90 @@ void tst_QStateMachine::childModeConstructor() } } +void tst_QStateMachine::qtbug_44963() +{ + SignalEmitter emitter; + + QStateMachine machine; + QState a(QState::ParallelStates, &machine); + QHistoryState ha(QHistoryState::DeepHistory, &a); + QState b(QState::ParallelStates, &a); + QState c(QState::ParallelStates, &b); + QState d(QState::ParallelStates, &c); + QState e(QState::ParallelStates, &d); + QState i(&e); + QState i1(&i); + QState i2(&i); + QState j(&e); + QState h(&d); + QState g(&c); + QState k(&a); + QState l(&machine); + + machine.setInitialState(&a); + ha.setDefaultState(&b); + i.setInitialState(&i1); + i1.addTransition(&emitter, SIGNAL(signalWithIntArg(int)), &i2)->setObjectName("i1->i2"); + i2.addTransition(&emitter, SIGNAL(signalWithDefaultArg(int)), &l)->setObjectName("i2->l"); + l.addTransition(&emitter, SIGNAL(signalWithNoArg()), &ha)->setObjectName("l->ha"); + + a.setObjectName("a"); + ha.setObjectName("ha"); + b.setObjectName("b"); + c.setObjectName("c"); + d.setObjectName("d"); + e.setObjectName("e"); + i.setObjectName("i"); + i1.setObjectName("i1"); + i2.setObjectName("i2"); + j.setObjectName("j"); + h.setObjectName("h"); + g.setObjectName("g"); + k.setObjectName("k"); + l.setObjectName("l"); + + machine.start(); + + QTRY_COMPARE(machine.configuration().contains(&i1), true); + QTRY_COMPARE(machine.configuration().contains(&i2), false); + QTRY_COMPARE(machine.configuration().contains(&j), true); + QTRY_COMPARE(machine.configuration().contains(&h), true); + QTRY_COMPARE(machine.configuration().contains(&g), true); + QTRY_COMPARE(machine.configuration().contains(&k), true); + QTRY_COMPARE(machine.configuration().contains(&l), false); + + emitter.emitSignalWithIntArg(0); + + QTRY_COMPARE(machine.configuration().contains(&i1), false); + QTRY_COMPARE(machine.configuration().contains(&i2), true); + QTRY_COMPARE(machine.configuration().contains(&j), true); + QTRY_COMPARE(machine.configuration().contains(&h), true); + QTRY_COMPARE(machine.configuration().contains(&g), true); + QTRY_COMPARE(machine.configuration().contains(&k), true); + QTRY_COMPARE(machine.configuration().contains(&l), false); + + emitter.emitSignalWithDefaultArg(); + + QTRY_COMPARE(machine.configuration().contains(&i1), false); + QTRY_COMPARE(machine.configuration().contains(&i2), false); + QTRY_COMPARE(machine.configuration().contains(&j), false); + QTRY_COMPARE(machine.configuration().contains(&h), false); + QTRY_COMPARE(machine.configuration().contains(&g), false); + QTRY_COMPARE(machine.configuration().contains(&k), false); + QTRY_COMPARE(machine.configuration().contains(&l), true); + + emitter.emitSignalWithNoArg(); + + QTRY_COMPARE(machine.configuration().contains(&i1), false); + QTRY_COMPARE(machine.configuration().contains(&i2), true); + QTRY_COMPARE(machine.configuration().contains(&j), true); + QTRY_COMPARE(machine.configuration().contains(&h), true); + QTRY_COMPARE(machine.configuration().contains(&g), true); + QTRY_COMPARE(machine.configuration().contains(&k), true); + QTRY_COMPARE(machine.configuration().contains(&l), false); + + QVERIFY(machine.isRunning()); +} + QTEST_MAIN(tst_QStateMachine) #include "tst_qstatemachine.moc" |