diff options
author | Juha Vuolle <juha.vuolle@insta.fi> | 2021-03-08 16:49:11 +0200 |
---|---|---|
committer | Juha Vuolle <juha.vuolle@insta.fi> | 2021-05-03 13:52:05 +0300 |
commit | ece4622980236f1d585dce35ed0dd2ad51fe90fb (patch) | |
tree | 95679a1983b3a297bfecd816180cc1cb15b809a3 /tests | |
parent | 61dbf282ba718771e432dfbbd618cad2dc728c5b (diff) |
QtScxml QML-facing properties bindable support additions part 2
This commit adds the bindable support to following QScxmlStateMachine
properties: invokedServices
Task-number: QTBUG-89895
Change-Id: Ib9806e295f8aa7c1d3eb123cd3a151796a3a7c80
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/statemachine/CMakeLists.txt | 6 | ||||
-rw-r--r-- | tests/auto/statemachine/submachineA.scxml | 4 | ||||
-rw-r--r-- | tests/auto/statemachine/submachineB.scxml | 4 | ||||
-rw-r--r-- | tests/auto/statemachine/topmachine.scxml | 19 | ||||
-rw-r--r-- | tests/auto/statemachine/tst_statemachine.cpp | 26 |
5 files changed, 57 insertions, 2 deletions
diff --git a/tests/auto/statemachine/CMakeLists.txt b/tests/auto/statemachine/CMakeLists.txt index 8a24651..d23dc7f 100644 --- a/tests/auto/statemachine/CMakeLists.txt +++ b/tests/auto/statemachine/CMakeLists.txt @@ -17,6 +17,9 @@ qt_internal_add_test(tst_statemachine # Resources: set(tst_statemachine_resource_files + "topmachine.scxml" + "submachineA.scxml" + "submachineB.scxml" "emptylog.scxml" "eventoccurred.scxml" "historystate.scxml" @@ -35,6 +38,9 @@ qt_internal_add_resource(tst_statemachine "tst_statemachine" ${tst_statemachine_resource_files} ) +qt6_add_statecharts(tst_statemachine + topmachine.scxml +) #### Keys ignored in scope 1:.:.:statemachine.pro:<TRUE>: # TEMPLATE = "app" diff --git a/tests/auto/statemachine/submachineA.scxml b/tests/auto/statemachine/submachineA.scxml new file mode 100644 index 0000000..0924b2e --- /dev/null +++ b/tests/auto/statemachine/submachineA.scxml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="SubMachine"> + <final id="topState"/> +</scxml> diff --git a/tests/auto/statemachine/submachineB.scxml b/tests/auto/statemachine/submachineB.scxml new file mode 100644 index 0000000..0924b2e --- /dev/null +++ b/tests/auto/statemachine/submachineB.scxml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="SubMachine"> + <final id="topState"/> +</scxml> diff --git a/tests/auto/statemachine/topmachine.scxml b/tests/auto/statemachine/topmachine.scxml new file mode 100644 index 0000000..b733c6a --- /dev/null +++ b/tests/auto/statemachine/topmachine.scxml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="TopMachine" datamodel="ecmascript"> + <datamodel> + <data id="doneCounter" expr="0"/> + </datamodel> + <state id="topState"> + <invoke type="scxml" id="submachine.1" src="file:submachineA.scxml"/> + <invoke type="scxml" id="submachine.2" src="file:submachineA.scxml"/> + <invoke type="scxml" id="submachine.3" src="file:submachineB.scxml"/> + <transition event="done.invoke"> + <assign location="doneCounter" expr="doneCounter + 1"/> + <if cond="doneCounter === 3"> + <send event="goToFinal" delay="1s"/> + </if> + </transition> + <transition event="goToFinal" target="finalState"/> + </state> + <final id="finalState"/> +</scxml> diff --git a/tests/auto/statemachine/tst_statemachine.cpp b/tests/auto/statemachine/tst_statemachine.cpp index 03b30d6..c43a03f 100644 --- a/tests/auto/statemachine/tst_statemachine.cpp +++ b/tests/auto/statemachine/tst_statemachine.cpp @@ -35,6 +35,7 @@ #include <QtScxml/private/qscxmlstatemachine_p.h> #include <QtScxml/QScxmlNullDataModel> +#include "topmachine.h" #include "../shared/bindableutils.h" enum { SpyWaitTime = 8000 }; @@ -513,10 +514,31 @@ void tst_StateMachine::bindings() QScxmlStateMachine::fromFile(QString(":/tst_statemachine/invoke.scxml"))); testWritableBindableBasics<QScxmlStateMachine, QScxmlTableData*>( *stateMachine2, stateMachine1.get()->tableData(), stateMachine4.get()->tableData(), "tableData"); + + // -- QScxmlStateMachine::invokedServices + // Test executes statemachine and observes as the invoked services change + TopMachine topSm; + QSignalSpy invokedSpy(&topSm, SIGNAL(invokedServicesChanged(const QList<QScxmlInvokableService *>))); + QCOMPARE(topSm.invokedServices().count(), 0); + // at some point during the topSm execution there are 3 invoked services + topSm.start(); + QTRY_COMPARE(topSm.invokedServices().count(), 3); + QCOMPARE(invokedSpy.count(), 1); + // after completion invoked services drop back to 0 + QTRY_COMPARE(topSm.isRunning(), false); + QCOMPARE(topSm.invokedServices().count(), 0); + QCOMPARE(invokedSpy.count(), 2); + // bind *to* the invokedservices property and check that we observe same changes + // during the topSm execution + QProperty<qsizetype> invokedServicesObserver; + invokedServicesObserver.setBinding([&](){ return topSm.invokedServices().count(); }); + QCOMPARE(invokedServicesObserver, 0); + topSm.start(); + QTRY_COMPARE(invokedServicesObserver, 3); + QCOMPARE(topSm.invokedServices().count(), 3); + QCOMPARE(invokedSpy.count(), 3); } QTEST_MAIN(tst_StateMachine) #include "tst_statemachine.moc" - - |