summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/statemachine
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-11-04 20:18:14 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2015-11-04 20:18:14 +0100
commit4159ee840549df11287294f0928e90f35f3e06ff (patch)
tree4a3947e37d54bdb78b4042e9ced20dbf181b5a2c /tests/auto/corelib/statemachine
parent59dbf1786f22ec4ac88d8f9d38cac5cfb82acaea (diff)
parentc8c39ecc37c156ac2677de09a26548dfc274b564 (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: config.tests/unix/ptrsize.test configure src/corelib/global/qnamespace.h src/network/socket/qabstractsocket.cpp tests/auto/other/networkselftest/networkselftest.pro Change-Id: Ic78abb4a34f9068567cea876861d4220f5a07672
Diffstat (limited to 'tests/auto/corelib/statemachine')
-rw-r--r--tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
index a46d42d91f..1ae4057049 100644
--- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp
@@ -249,6 +249,7 @@ private slots:
void qtbug_44783();
void internalTransition();
void conflictingTransition();
+ void conflictingTransition2();
void qtbug_46059();
void qtbug_46703();
};
@@ -6448,6 +6449,71 @@ void tst_QStateMachine::conflictingTransition()
QVERIFY(machine.isRunning());
}
+void tst_QStateMachine::conflictingTransition2()
+{
+ SignalEmitter emitter;
+
+ QStateMachine machine;
+ QState s0(&machine);
+ QState p0(QState::ParallelStates, &s0);
+ QState p0s1(&p0);
+ QState p0s2(&p0);
+ QState p0s3(&p0);
+ QState s1(&machine);
+
+ machine.setInitialState(&s0);
+ s0.setInitialState(&p0);
+
+ QSignalTransition *t1 = new QSignalTransition(&emitter, SIGNAL(signalWithNoArg()));
+ p0s1.addTransition(t1);
+ QSignalTransition *t2 = p0s2.addTransition(&emitter, SIGNAL(signalWithNoArg()), &p0s1);
+ QSignalTransition *t3 = p0s3.addTransition(&emitter, SIGNAL(signalWithNoArg()), &s1);
+ QSignalSpy t1Spy(t1, &QAbstractTransition::triggered);
+ QSignalSpy t2Spy(t2, &QAbstractTransition::triggered);
+ QSignalSpy t3Spy(t3, &QAbstractTransition::triggered);
+ QVERIFY(t1Spy.isValid());
+ QVERIFY(t2Spy.isValid());
+ QVERIFY(t3Spy.isValid());
+
+ s0.setObjectName("s0");
+ p0.setObjectName("p0");
+ p0s1.setObjectName("p0s1");
+ p0s2.setObjectName("p0s2");
+ p0s3.setObjectName("p0s3");
+ s1.setObjectName("s1");
+ t1->setObjectName("p0s1->p0s1");
+ t2->setObjectName("p0s2->p0s1");
+ t3->setObjectName("p0s3->s1");
+
+ machine.start();
+
+ QTRY_COMPARE(machine.configuration().contains(&s0), true);
+ QTRY_COMPARE(machine.configuration().contains(&p0), true);
+ QTRY_COMPARE(machine.configuration().contains(&p0s1), true);
+ QTRY_COMPARE(machine.configuration().contains(&p0s2), true);
+ QTRY_COMPARE(machine.configuration().contains(&p0s3), true);
+ QTRY_COMPARE(machine.configuration().contains(&s1), false);
+
+ QCOMPARE(t1Spy.count(), 0);
+ QCOMPARE(t2Spy.count(), 0);
+ QCOMPARE(t3Spy.count(), 0);
+
+ emitter.emitSignalWithNoArg();
+
+ QTRY_COMPARE(machine.configuration().contains(&s0), true);
+ QTRY_COMPARE(machine.configuration().contains(&p0), true);
+ QTRY_COMPARE(machine.configuration().contains(&p0s1), true);
+ QTRY_COMPARE(machine.configuration().contains(&p0s2), true);
+ QTRY_COMPARE(machine.configuration().contains(&p0s3), true);
+ QTRY_COMPARE(machine.configuration().contains(&s1), false);
+
+ QCOMPARE(t1Spy.count(), 1);
+ QCOMPARE(t2Spy.count(), 1);
+ QCOMPARE(t3Spy.count(), 0); // t3 got preempted by t2
+
+ QVERIFY(machine.isRunning());
+}
+
void tst_QStateMachine::qtbug_46059()
{
QStateMachine machine;