summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@insta.fi>2021-03-11 14:28:22 +0200
committerJuha Vuolle <juha.vuolle@insta.fi>2021-05-03 13:52:17 +0300
commit325d27bf651441f5252e727b24ab8d1c673e8137 (patch)
tree9ed6bdbbae31b8b86663957faeadd8940b43fb2d /tests
parent26d9862c83d7f18eb4a23da342b6d3130494c4cb (diff)
QtScxml bindable support to QScxmlDataModel::stateMachine
Task-number: QTBUG-89895 Change-Id: I11f1caec9eee9b9767691c93e4deb0dbf57be496 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/statemachine/tst_statemachine.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/statemachine/tst_statemachine.cpp b/tests/auto/statemachine/tst_statemachine.cpp
index c43a03f..404243d 100644
--- a/tests/auto/statemachine/tst_statemachine.cpp
+++ b/tests/auto/statemachine/tst_statemachine.cpp
@@ -537,6 +537,27 @@ void tst_StateMachine::bindings()
QTRY_COMPARE(invokedServicesObserver, 3);
QCOMPARE(topSm.invokedServices().count(), 3);
QCOMPARE(invokedSpy.count(), 3);
+
+ // -- QScxmlDataModel::stateMachine
+ QScxmlNullDataModel dataModel1;
+ QScxmlNullDataModel dataModel2;
+ std::unique_ptr<QScxmlStateMachine> stateMachine5(
+ QScxmlStateMachine::fromFile(QString("not_a_real_file")));
+ std::unique_ptr<QScxmlStateMachine> stateMachine6(
+ QScxmlStateMachine::fromFile(QString("not_a_real_file")));
+ // Use the "readable" test helper as the data can only change once
+ testReadableBindableBasics<QScxmlDataModel, QScxmlStateMachine*>(
+ dataModel1, nullptr, stateMachine5.get(), "stateMachine",
+ [&](){ dataModel1.setStateMachine(stateMachine5.get()); });
+ // verify that setting the model twice will not break the binding (setting is ignored)
+ QProperty<QScxmlStateMachine*> stateMachineProperty(stateMachine6.get());
+ dataModel2.bindableStateMachine().setBinding(Qt::makePropertyBinding(stateMachineProperty));
+ QVERIFY(dataModel2.bindableStateMachine().hasBinding());
+ QVERIFY(dataModel2.stateMachine() == stateMachine6.get());
+ dataModel2.setStateMachine(stateMachine5.get()); // should be ignored
+ QVERIFY(dataModel2.stateMachine() == stateMachine6.get());
+ QVERIFY(dataModel2.bindableStateMachine().hasBinding());
+
}
QTEST_MAIN(tst_StateMachine)