diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2010-03-22 14:17:26 (GMT) |
---|---|---|
committer | Kent Hansen <kent.hansen@nokia.com> | 2010-03-22 14:58:30 (GMT) |
commit | 1ad46d8cc9fa30ef26c3eb109c5d75937ec78aac (patch) | |
tree | ac1c48d07e211f2baf729e1856ca0a03535fb3bc /tests/auto/qstate | |
parent | 9cfda3493ce4086313072a216d6a5b4f796c40d3 (diff) | |
download | Qt-1ad46d8cc9fa30ef26c3eb109c5d75937ec78aac.zip Qt-1ad46d8cc9fa30ef26c3eb109c5d75937ec78aac.tar.gz Qt-1ad46d8cc9fa30ef26c3eb109c5d75937ec78aac.tar.bz2 |
Add a function to get the transitions available from a state
For introspection purposes. It's nicer than having to qobject_cast
the state's children().
Task-number: QTBUG-7741
Reviewed-by: Eskil Abrahamsen Blomfeldt
Diffstat (limited to 'tests/auto/qstate')
-rw-r--r-- | tests/auto/qstate/tst_qstate.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qstate/tst_qstate.cpp b/tests/auto/qstate/tst_qstate.cpp index b05aaa0..0d39c72 100644 --- a/tests/auto/qstate/tst_qstate.cpp +++ b/tests/auto/qstate/tst_qstate.cpp @@ -77,6 +77,7 @@ private slots: void assignProperty(); void assignPropertyTwice(); void historyInitialState(); + void transitions(); private: bool functionCalled; @@ -370,6 +371,38 @@ void tst_QState::historyInitialState() QVERIFY(machine.configuration().contains(s4)); } +void tst_QState::transitions() +{ + QState s1; + QState s2; + + QVERIFY(s1.transitions().isEmpty()); + + QAbstractTransition *t1 = s1.addTransition(this, SIGNAL(destroyed()), &s2); + QVERIFY(t1 != 0); + QCOMPARE(s1.transitions().count(), 1); + QCOMPARE(s1.transitions().first(), t1); + QVERIFY(s2.transitions().isEmpty()); + + s1.removeTransition(t1); + QVERIFY(s1.transitions().isEmpty()); + + s1.addTransition(t1); + QCOMPARE(s1.transitions().count(), 1); + QCOMPARE(s1.transitions().first(), t1); + + QAbstractTransition *t2 = new QEventTransition(&s1); + QCOMPARE(s1.transitions().count(), 2); + QVERIFY(s1.transitions().contains(t1)); + QVERIFY(s1.transitions().contains(t2)); + + // Transitions from child states should not be reported. + QState *s21 = new QState(&s2); + QAbstractTransition *t3 = s21->addTransition(this, SIGNAL(destroyed()), &s2); + QVERIFY(s2.transitions().isEmpty()); + QCOMPARE(s21->transitions().count(), 1); + QCOMPARE(s21->transitions().first(), t3); +} QTEST_MAIN(tst_QState) #include "tst_qstate.moc" |