summaryrefslogtreecommitdiffstats
path: root/tests/auto/qstatemachine
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-10-06 10:09:14 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-10-06 10:11:49 (GMT)
commitcadad3fdc7f6de95979f5b5be070da0853c46ba4 (patch)
tree84aafa053e7aa67b061bced2d15ee38bebc85ee9 /tests/auto/qstatemachine
parent1f47353f90f6e1a3122eee14b9011bdeb7c7a93f (diff)
downloadQt-cadad3fdc7f6de95979f5b5be070da0853c46ba4.zip
Qt-cadad3fdc7f6de95979f5b5be070da0853c46ba4.tar.gz
Qt-cadad3fdc7f6de95979f5b5be070da0853c46ba4.tar.bz2
statemachine: implement cloning of a whole bunch more GUI events
Now using QEventTransition with almost any type of event will actually work, instead of causing an assert.
Diffstat (limited to 'tests/auto/qstatemachine')
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index b808f7f..1516346 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -42,6 +42,9 @@
#include <QtTest/QtTest>
#include <QtCore/QCoreApplication>
#include <QtGui/QPushButton>
+#include <QtGui/QGraphicsScene>
+#include <QtGui/QGraphicsSceneEvent>
+#include <QtGui/QGraphicsTextItem>
#include "qstatemachine.h"
#include "qstate.h"
@@ -127,6 +130,7 @@ private slots:
void allSourceToTargetConfigurations();
void signalTransitions();
void eventTransitions();
+ void graphicsSceneEventTransitions();
void historyStates();
void startAndStop();
void targetStateWithNoParent();
@@ -2426,6 +2430,29 @@ void tst_QStateMachine::eventTransitions()
}
}
+void tst_QStateMachine::graphicsSceneEventTransitions()
+{
+ QGraphicsScene scene;
+ QGraphicsTextItem *textItem = scene.addText("foo");
+
+ QStateMachine machine;
+ QState *s1 = new QState(&machine);
+ QFinalState *s2 = new QFinalState(&machine);
+ QEventTransition *t = new QEventTransition(textItem, QEvent::GraphicsSceneMouseMove);
+ t->setTargetState(s2);
+ s1->addTransition(t);
+ machine.setInitialState(s1);
+
+ QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ machine.start();
+ QTRY_COMPARE(startedSpy.count(), 1);
+ QVERIFY(finishedSpy.count() == 0);
+ QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove);
+ scene.sendEvent(textItem, &mouseEvent);
+ QTRY_COMPARE(finishedSpy.count(), 1);
+}
+
void tst_QStateMachine::historyStates()
{
for (int x = 0; x < 2; ++x) {