summaryrefslogtreecommitdiffstats
path: root/tests/auto/qstatemachine/tst_qstatemachine.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-04-29 08:56:47 (GMT)
committerEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-04-29 09:10:28 (GMT)
commite06c2e150f3607daf45b2ecd14bdcca9aba6208d (patch)
tree894a7f7b8d1628820646652a83a9f8a3ff6559e1 /tests/auto/qstatemachine/tst_qstatemachine.cpp
parenta7c2eff47c5ad3e98ca5505b64cdbba716cbedbd (diff)
downloadQt-e06c2e150f3607daf45b2ecd14bdcca9aba6208d.zip
Qt-e06c2e150f3607daf45b2ecd14bdcca9aba6208d.tar.gz
Qt-e06c2e150f3607daf45b2ecd14bdcca9aba6208d.tar.bz2
Merge the two queries for entry states to support having history states as
the initial state. Done by No'am, integrated by me.
Diffstat (limited to 'tests/auto/qstatemachine/tst_qstatemachine.cpp')
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 89cb51a..e42adde 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -117,6 +117,7 @@ private slots:
void customErrorStateIsNull();
void clearError();
void historyStateHasNowhereToGo();
+ void historyStateAsInitialState();
void brokenStateIsNeverEntered();
void customErrorStateNotInGraph();
void transitionToStateNotInGraph();
@@ -811,6 +812,40 @@ void tst_QStateMachine::clearError()
QVERIFY(machine.errorString().isEmpty());
}
+void tst_QStateMachine::historyStateAsInitialState()
+{
+ QStateMachine machine;
+
+ QHistoryState *hs = machine.rootState()->addHistoryState();
+ machine.setInitialState(hs);
+
+ QState *s1 = new QState(machine.rootState());
+ hs->setDefaultState(s1);
+
+ QState *s2 = new QState(machine.rootState());
+
+ QHistoryState *s2h = s2->addHistoryState();
+ s2->setInitialState(s2h);
+
+ QState *s21 = new QState(s2);
+ s2h->setDefaultState(s21);
+
+ s1->addTransition(new EventTransition(QEvent::User, s2));
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ machine.postEvent(new QEvent(QEvent::User));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 2);
+ QVERIFY(machine.configuration().contains(s2));
+ QVERIFY(machine.configuration().contains(s21));
+}
+
void tst_QStateMachine::historyStateHasNowhereToGo()
{
QStateMachine machine;