diff options
author | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2015-05-12 13:06:46 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2015-05-19 08:03:46 +0000 |
commit | 67d255f18343d74bbc9a0eec460995ca615473be (patch) | |
tree | a935d1dd031845cfaecea5e421ab9a3ff605bcaa /tests | |
parent | 009b11c30086f2ab40d3e86691f34cad31999a8f (diff) | |
download | qtbase-67d255f18343d74bbc9a0eec460995ca615473be.tar.gz |
QStateMachine: empty the whole internal queue before external queue
If the internal queue contained multiple events, but the first one did
not select any transitions, the external event queue would be checked
before the remaining events in the internal queue.
Change-Id: I1a7f49afdefaaf2b4330bf13b079b61344385ea0
Task-number: QTBUG-46059
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp index 3718b07b33..1292c3b98f 100644 --- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp @@ -249,6 +249,7 @@ private slots: void qtbug_44783(); void internalTransition(); void conflictingTransition(); + void qtbug_46059(); }; class TestState : public QState @@ -6446,5 +6447,43 @@ void tst_QStateMachine::conflictingTransition() QVERIFY(machine.isRunning()); } +void tst_QStateMachine::qtbug_46059() +{ + QStateMachine machine; + QState a(&machine); + QState b(&a); + QState c(&a); + QState success(&a); + QState failure(&machine); + + machine.setInitialState(&a); + a.setInitialState(&b); + b.addTransition(new EventTransition(QEvent::Type(QEvent::User + 1), &c)); + c.addTransition(new EventTransition(QEvent::Type(QEvent::User + 2), &success)); + b.addTransition(new EventTransition(QEvent::Type(QEvent::User + 2), &failure)); + + machine.start(); + QCoreApplication::processEvents(); + + QTRY_COMPARE(machine.configuration().contains(&a), true); + QTRY_COMPARE(machine.configuration().contains(&b), true); + QTRY_COMPARE(machine.configuration().contains(&c), false); + QTRY_COMPARE(machine.configuration().contains(&failure), false); + QTRY_COMPARE(machine.configuration().contains(&success), false); + + machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 0)), QStateMachine::HighPriority); + machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 1)), QStateMachine::HighPriority); + machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 2)), QStateMachine::NormalPriority); + QCoreApplication::processEvents(); + + QTRY_COMPARE(machine.configuration().contains(&a), true); + QTRY_COMPARE(machine.configuration().contains(&b), false); + QTRY_COMPARE(machine.configuration().contains(&c), false); + QTRY_COMPARE(machine.configuration().contains(&failure), false); + QTRY_COMPARE(machine.configuration().contains(&success), true); + + QVERIFY(machine.isRunning()); +} + QTEST_MAIN(tst_QStateMachine) #include "tst_qstatemachine.moc" |