From ece4622980236f1d585dce35ed0dd2ad51fe90fb Mon Sep 17 00:00:00 2001 From: Juha Vuolle Date: Mon, 8 Mar 2021 16:49:11 +0200 Subject: 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 Reviewed-by: Ivan Solovev --- tests/auto/statemachine/CMakeLists.txt | 6 ++++++ tests/auto/statemachine/submachineA.scxml | 4 ++++ tests/auto/statemachine/submachineB.scxml | 4 ++++ tests/auto/statemachine/topmachine.scxml | 19 +++++++++++++++++++ tests/auto/statemachine/tst_statemachine.cpp | 26 ++++++++++++++++++++++++-- 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 tests/auto/statemachine/submachineA.scxml create mode 100644 tests/auto/statemachine/submachineB.scxml create mode 100644 tests/auto/statemachine/topmachine.scxml (limited to 'tests') 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:: # 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 @@ + + + + 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 @@ + + + + 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 @@ + + + + + + + + + + + + + + + + + + + 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 #include +#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( *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))); + 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 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" - - -- cgit v1.2.3