#endif
state = Running;
processingScheduled = true; // we call _q_process() below
- emit q->started();
QState *start = startState();
Q_ASSERT(start != 0);
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": initial configuration:" << configuration;
#endif
+
+ emit q->started();
+
_q_process();
}
void stopInTransitionToFinalState();
void stopInEventTest_data();
void stopInEventTest();
+
+ void initialStateIsEnteredBeforeStartedEmitted();
};
class TestState : public QState
QVERIFY(machine.configuration().contains(s1));
}
+void tst_QStateMachine::initialStateIsEnteredBeforeStartedEmitted()
+{
+ QStateMachine machine;
+ QState *s1 = new QState(&machine);
+ machine.setInitialState(s1);
+ QFinalState *s2 = new QFinalState(&machine);
+
+ // When started() is emitted, s1 should be the active state, and this
+ // transition should trigger.
+ s1->addTransition(&machine, SIGNAL(started()), s2);
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.start();
+ QTRY_COMPARE(finishedSpy.count(), 1);
+}
+
QTEST_MAIN(tst_QStateMachine)
#include "tst_qstatemachine.moc"