diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-05-13 11:56:44 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-05-13 11:56:44 (GMT) |
commit | 3cd4b6e00e3448d880ae2335bd50f70d9a5d0fca (patch) | |
tree | 019c7150eb761c0f3463734a4ccdef1147fd8feb /tests/auto | |
parent | b75c6210c7fa225e86d2c4bff239bb050321998d (diff) | |
download | Qt-3cd4b6e00e3448d880ae2335bd50f70d9a5d0fca.zip Qt-3cd4b6e00e3448d880ae2335bd50f70d9a5d0fca.tar.gz Qt-3cd4b6e00e3448d880ae2335bd50f70d9a5d0fca.tar.bz2 |
correctly handle multiple event transitions for same (object,event)
The event filter was not removed at the right time. We now store the
number of active event transitions for a particular (object,event)
and only remove the filtering when the count drops to zero.
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qstatemachine/tst_qstatemachine.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 3f94ad9..f8a778a 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -1881,6 +1881,54 @@ void tst_QStateMachine::eventTransitions() QTRY_COMPARE(finishedSpy.count(), 1); } + // Multiple transitions for same (object,event) + { + QStateMachine machine; + QState *s0 = new QState(machine.rootState()); + QState *s1 = new QState(machine.rootState()); + QEventTransition *t0 = new QEventTransition(&button, QEvent::MouseButtonPress); + t0->setTargetState(s1); + s0->addTransition(t0); + QEventTransition *t1 = new QEventTransition(&button, QEvent::MouseButtonPress); + t1->setTargetState(s0); + s1->addTransition(t1); + + QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + machine.setInitialState(s0); + machine.start(); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s0)); + + QTest::mousePress(&button, Qt::LeftButton); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); + + s0->removeTransition(t0); + QTest::mousePress(&button, Qt::LeftButton); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s0)); + + QTest::mousePress(&button, Qt::LeftButton); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s0)); + + s1->removeTransition(t1); + QTest::mousePress(&button, Qt::LeftButton); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s0)); + + s0->addTransition(t0); + s1->addTransition(t1); + QTest::mousePress(&button, Qt::LeftButton); + QCoreApplication::processEvents(); + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); + } } void tst_QStateMachine::historyStates() |