summaryrefslogtreecommitdiffstats
path: root/tests/auto/qstatemachine
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-06-03 11:17:37 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-06-03 11:17:37 (GMT)
commite72285b0108f7649366a106f1c16ea73611dbcd4 (patch)
treead1abc0554c9330737879805081589c0dec10559 /tests/auto/qstatemachine
parentf9aa7cbaea69168a4e7b9411cfdceb9e27cf75a9 (diff)
downloadQt-e72285b0108f7649366a106f1c16ea73611dbcd4.zip
Qt-e72285b0108f7649366a106f1c16ea73611dbcd4.tar.gz
Qt-e72285b0108f7649366a106f1c16ea73611dbcd4.tar.bz2
don't require use of SIGNAL macro in calls to addTransition()
Just as with the QSignalTransition::signal property, this makes it possible to use the function from language bindings (e.g. QtScript).
Diffstat (limited to 'tests/auto/qstatemachine')
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 768a683..66e50ba 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -1768,6 +1768,34 @@ void tst_QStateMachine::signalTransitions()
QState *s0 = new QState(machine.rootState());
QFinalState *s1 = new QFinalState(machine.rootState());
SignalEmitter emitter;
+ QSignalTransition *trans = s0->addTransition(&emitter, "signalWithNoArg()", s1);
+ QVERIFY(trans != 0);
+ QCOMPARE(trans->sourceState(), s0);
+ QCOMPARE(trans->targetState(), (QAbstractState*)s1);
+ QCOMPARE(trans->senderObject(), (QObject*)&emitter);
+ QCOMPARE(trans->signal(), QByteArray("signalWithNoArg()"));
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.setInitialState(s0);
+ machine.start();
+ QCoreApplication::processEvents();
+
+ emitter.emitSignalWithNoArg();
+
+ QTRY_COMPARE(finishedSpy.count(), 1);
+
+ trans->setSignal("signalWithIntArg(int)");
+ QCOMPARE(trans->signal(), QByteArray("signalWithIntArg(int)"));
+ machine.start();
+ QCoreApplication::processEvents();
+ emitter.emitSignalWithIntArg(123);
+ QTRY_COMPARE(finishedSpy.count(), 2);
+ }
+ {
+ QStateMachine machine;
+ QState *s0 = new QState(machine.rootState());
+ QFinalState *s1 = new QFinalState(machine.rootState());
+ SignalEmitter emitter;
TestSignalTransition *trans = new TestSignalTransition(&emitter, SIGNAL(signalWithIntArg(int)), s1);
s0->addTransition(trans);