diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-06-23 05:53:53 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-06-23 05:53:53 (GMT) |
commit | fbe44b843194f3892e163ecec1be52fb498e2ddd (patch) | |
tree | 857c749710a71e2d485bd134d6542c62ac51c4e5 /tests/auto/qstatemachine | |
parent | 6fc3873707ae9e8c002b14800bac9fd64faca42b (diff) | |
parent | 3647de5291db9e359e7844f80202251f47e83a97 (diff) | |
download | Qt-fbe44b843194f3892e163ecec1be52fb498e2ddd.zip Qt-fbe44b843194f3892e163ecec1be52fb498e2ddd.tar.gz Qt-fbe44b843194f3892e163ecec1be52fb498e2ddd.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'tests/auto/qstatemachine')
-rw-r--r-- | tests/auto/qstatemachine/tst_qstatemachine.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index b39f0a1..553833c 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -118,6 +118,7 @@ private slots: void postEvent(); void stateFinished(); void parallelStates(); + void parallelRootState(); void allSourceToTargetConfigurations(); void signalTransitions(); void eventTransitions(); @@ -1633,6 +1634,29 @@ void tst_QStateMachine::parallelStates() QVERIFY(machine.configuration().contains(s2)); } +void tst_QStateMachine::parallelRootState() +{ + QStateMachine machine; + QState *root = machine.rootState(); + QCOMPARE(root->childMode(), QState::ExclusiveStates); + root->setChildMode(QState::ParallelStates); + QCOMPARE(root->childMode(), QState::ParallelStates); + + QState *s1 = new QState(root); + QFinalState *s1_f = new QFinalState(s1); + s1->setInitialState(s1_f); + QState *s2 = new QState(root); + QFinalState *s2_f = new QFinalState(s2); + s2->setInitialState(s2_f); + + QSignalSpy startedSpy(&machine, SIGNAL(started())); + QTest::ignoreMessage(QtWarningMsg, "QStateMachine::start: No initial state set for machine. Refusing to start."); + machine.start(); + QCoreApplication::processEvents(); + QEXPECT_FAIL("", "parallel root state is not supported (task 256587)", Continue); + QCOMPARE(startedSpy.count(), 1); +} + void tst_QStateMachine::allSourceToTargetConfigurations() { QStateMachine machine; @@ -1957,6 +1981,31 @@ void tst_QStateMachine::signalTransitions() QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s3)); } + // signature normalization + { + QStateMachine machine; + SignalEmitter emitter; + QState *s0 = new QState(machine.rootState()); + QFinalState *s1 = new QFinalState(machine.rootState()); + QSignalTransition *t0 = s0->addTransition(&emitter, SIGNAL( signalWithNoArg( ) ), s1); + QVERIFY(t0 != 0); + QCOMPARE(t0->signal(), QByteArray(SIGNAL( signalWithNoArg( ) ))); + + QSignalTransition *t1 = s0->addTransition(&emitter, SIGNAL( signalWithStringArg( const QString & ) ), s1); + QVERIFY(t1 != 0); + QCOMPARE(t1->signal(), QByteArray(SIGNAL( signalWithStringArg( const QString & ) ))); + + QSignalSpy startedSpy(&machine, SIGNAL(started())); + QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + machine.setInitialState(s0); + machine.start(); + QTRY_COMPARE(startedSpy.count(), 1); + QCOMPARE(finishedSpy.count(), 0); + + emitter.emitSignalWithNoArg(); + + QTRY_COMPARE(finishedSpy.count(), 1); + } } void tst_QStateMachine::eventTransitions() |