diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-10-28 17:21:05 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-10-29 11:48:20 (GMT) |
commit | 414d5550f9ffe46faf1ee81b1a364683f2b2f066 (patch) | |
tree | 14947745f5bdf6afb030efe3de487365433db22e /tests | |
parent | 093ededb85c73f30ce3abf43bc6da0fff55323c2 (diff) | |
download | Qt-414d5550f9ffe46faf1ee81b1a364683f2b2f066.zip Qt-414d5550f9ffe46faf1ee81b1a364683f2b2f066.tar.gz Qt-414d5550f9ffe46faf1ee81b1a364683f2b2f066.tar.bz2 |
Test that we gracefully handle event posting after the state machine is stopped
The internal slot _q_process() should never be called if the machine is
not in the Running state.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qstatemachine/tst_qstatemachine.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 1516346..346afc9 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -124,6 +124,7 @@ private slots: void postEvent(); void cancelDelayedEvent(); void postDelayedEventAndStop(); + void stopAndPostEvent(); void stateFinished(); void parallelStates(); void parallelRootState(); @@ -1681,6 +1682,22 @@ void tst_QStateMachine::postDelayedEventAndStop() QVERIFY(machine.configuration().contains(s1)); } +void tst_QStateMachine::stopAndPostEvent() +{ + QStateMachine machine; + QState *s1 = new QState(&machine); + machine.setInitialState(s1); + QSignalSpy startedSpy(&machine, SIGNAL(started())); + machine.start(); + QTRY_COMPARE(startedSpy.count(), 1); + QSignalSpy stoppedSpy(&machine, SIGNAL(stopped())); + machine.stop(); + QCOMPARE(stoppedSpy.count(), 0); + machine.postEvent(new QEvent(QEvent::User)); + QTRY_COMPARE(stoppedSpy.count(), 1); + QCoreApplication::processEvents(); +} + void tst_QStateMachine::stateFinished() { QStateMachine machine; |