diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-05-08 11:34:22 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-05-08 11:34:22 (GMT) |
commit | a70e9bc07f2252a49060132fc88ddd4c5963d456 (patch) | |
tree | 3f35f4698dbd476008ed49cb1253f31f2bef7496 /tests | |
parent | f64170262441cce51b52d05a2f2ba2f0021ba8e4 (diff) | |
download | Qt-a70e9bc07f2252a49060132fc88ddd4c5963d456.zip Qt-a70e9bc07f2252a49060132fc88ddd4c5963d456.tar.gz Qt-a70e9bc07f2252a49060132fc88ddd4c5963d456.tar.bz2 |
Test what happens when target state doesn't have a parent
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qstatemachine/tst_qstatemachine.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 288cbec..fa49ecb 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -105,6 +105,7 @@ private slots: void eventTransitions(); void historyStates(); void startAndStop(); + void targetStateWithNoParent(); void transitionToRootState(); void transitionEntersParent(); @@ -1490,6 +1491,8 @@ void tst_QStateMachine::parallelStates() QSignalSpy finishedSpy(&machine, SIGNAL(finished())); machine.start(); QTRY_COMPARE(finishedSpy.count(), 1); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s2)); } void tst_QStateMachine::allSourceToTargetConfigurations() @@ -1915,6 +1918,28 @@ void tst_QStateMachine::startAndStop() QVERIFY(machine.configuration().contains(s1)); } +void tst_QStateMachine::targetStateWithNoParent() +{ + QStateMachine machine; + QState *s1 = new QState(machine.rootState()); + s1->setObjectName("s1"); + QState *s2 = new QState(); + s1->addTransition(s2); + machine.setInitialState(s1); + QSignalSpy startedSpy(&machine, SIGNAL(started())); + QSignalSpy stoppedSpy(&machine, SIGNAL(stopped())); + QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + machine.start(); + QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: No common ancestor for targets and source of transition from state 's1'"); + QTRY_COMPARE(machine.isRunning(), true); + QTRY_COMPARE(startedSpy.count(), 1); + QCOMPARE(stoppedSpy.count(), 0); + QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(machine.errorState())); + QCOMPARE(machine.error(), QStateMachine::NoCommonAncestorForTransitionError); +} + void tst_QStateMachine::defaultGlobalRestorePolicy() { QStateMachine machine; |