summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/statemachine/qstate/tst_qstate.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp b/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp
index ac3374b6a3..c64d55671a 100644
--- a/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp
+++ b/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp
@@ -47,6 +47,7 @@ private slots:
void historyInitialState();
void transitions();
void privateSignals();
+ void parallelStateAndInitialState();
};
class TestClass: public QObject
@@ -344,5 +345,35 @@ void tst_QState::privateSignals()
}
+void tst_QState::parallelStateAndInitialState()
+{
+ QStateMachine machine;
+
+ { // setting an initial state on a parallel state:
+ QState a(QState::ParallelStates, &machine);
+ QState b(&a);
+ QVERIFY(!a.initialState());
+ const QString warning
+ = QString::asprintf("QState::setInitialState: ignoring attempt to set initial state of parallel state group %p", &a);
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ a.setInitialState(&b); // should produce a warning and do nothing.
+ QVERIFY(!a.initialState());
+ }
+
+ { // setting the child-mode from ExclusiveStates to ParallelStates should remove the initial state:
+ QState a(QState::ExclusiveStates, &machine);
+ QState b(&a);
+ a.setInitialState(&b);
+ QCOMPARE(a.initialState(), &b);
+ const QString warning
+ = QString::asprintf("QState::setChildMode: setting the child-mode of state %p to "
+ "parallel removes the initial state", &a);
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ a.setChildMode(QState::ParallelStates); // should produce a warning and remove the initial state
+ QVERIFY(!a.initialState());
+ QCOMPARE(a.childMode(), QState::ParallelStates);
+ }
+}
+
QTEST_MAIN(tst_QState)
#include "tst_qstate.moc"