diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/statemachine/historystate.scxml | 13 | ||||
-rw-r--r-- | tests/auto/statemachine/tst_statemachine.cpp | 19 | ||||
-rw-r--r-- | tests/auto/statemachine/tst_statemachine.qrc | 1 |
3 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/statemachine/historystate.scxml b/tests/auto/statemachine/historystate.scxml new file mode 100644 index 0000000..4b3a5e4 --- /dev/null +++ b/tests/auto/statemachine/historystate.scxml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" binding="early" name="HistoryState"> + <state id="Working"> + <state id="State1"> + <onentry> + <send event="timeout" delay="1s"/> + </onentry> + </state> + <history type="shallow" id="HistoryState"/> + <transition type="external" event="timeout" target="State2"/> + </state> + <state id="State2"/> +</scxml> diff --git a/tests/auto/statemachine/tst_statemachine.cpp b/tests/auto/statemachine/tst_statemachine.cpp index ed1f424..69d38b6 100644 --- a/tests/auto/statemachine/tst_statemachine.cpp +++ b/tests/auto/statemachine/tst_statemachine.cpp @@ -48,6 +48,7 @@ private Q_SLOTS: void activeStateNames_data(); void activeStateNames(); void connections(); + void historyState(); void onExit(); void eventOccurred(); @@ -251,6 +252,24 @@ void tst_StateMachine::connections() #endif } +void tst_StateMachine::historyState() +{ + QScopedPointer<QScxmlStateMachine> stateMachine( + QScxmlStateMachine::fromFile(QString(":/tst_statemachine/historystate.scxml"))); + QVERIFY(!stateMachine.isNull()); + + bool state2Reached = false; + QMetaObject::Connection state2Connection = stateMachine->connectToState("State2", + [&state2Reached](bool enabled) { + state2Reached = state2Reached || enabled; + }); + QVERIFY(state2Connection); + + stateMachine->start(); + + QTRY_VERIFY(state2Reached); +} + void tst_StateMachine::onExit() { #if defined(__cpp_return_type_deduction) && __cpp_return_type_deduction == 201304 diff --git a/tests/auto/statemachine/tst_statemachine.qrc b/tests/auto/statemachine/tst_statemachine.qrc index c31fe4c..78c1f00 100644 --- a/tests/auto/statemachine/tst_statemachine.qrc +++ b/tests/auto/statemachine/tst_statemachine.qrc @@ -6,5 +6,6 @@ <file>ids1.scxml</file> <file>stateDotDoneEvent.scxml</file> <file>invoke.scxml</file> + <file>historystate.scxml</file> </qresource> </RCC> |