From 28e9a602cb35fc621dec36e28e8556ca0052551e Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Sat, 7 Jul 2012 05:43:11 +0200 Subject: statemachine: Emit finished() signal when the initial state is final It's legal to set a QFinalState as the initial state. The state machine should correctly emit the finished() signal upon entering such a state in the initial transition, and don't do any further processing. Change-Id: Ica8d3fadbbde604512ea1136624af54eb3b13b11 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../corelib/statemachine/qstatemachine/tst_qstatemachine.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/auto/corelib/statemachine') diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp index b048f9c2f0..64f8d3aa9b 100644 --- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp @@ -193,6 +193,7 @@ private slots: void setPropertyAfterRestore(); void transitionWithNoTarget_data(); void transitionWithNoTarget(); + void initialStateIsFinal(); void restorePropertiesSimple(); void restoreProperties2(); @@ -4196,6 +4197,17 @@ void tst_QStateMachine::transitionWithNoTarget() delete object; } +void tst_QStateMachine::initialStateIsFinal() +{ + QStateMachine machine; + QFinalState *f = new QFinalState(&machine); + machine.setInitialState(f); + QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + machine.start(); + QTRY_VERIFY(machine.configuration().contains(f)); + QTRY_COMPARE(finishedSpy.count(), 1); +} + class PropertyObject : public QObject { Q_OBJECT -- cgit v1.2.3