diff options
author | Sebastian Sauer <sebastian.sauer.ford@kdab.com> | 2014-09-18 00:10:40 +0700 |
---|---|---|
committer | Brett Stottlemyer <bstottle@ford.com> | 2014-09-24 17:39:14 +0200 |
commit | 40f76f99469e75d7a6818306891964e5966d0fad (patch) | |
tree | e936508affedefd98ab8ec2c073ea7be9187c4f4 | |
parent | 5b21f8529ebc8e3e66ec6d057734f90b10bb7657 (diff) | |
download | qtdeclarative-40f76f99469e75d7a6818306891964e5966d0fad.tar.gz qtdeclarative-40f76f99469e75d7a6818306891964e5966d0fad.tar.bz2 qtdeclarative-40f76f99469e75d7a6818306891964e5966d0fad.zip |
QDSM: Nested statemachines are supported
* Remove wrongly printed info that nested
statemachines are not supported.
* Added autotest for nested statemachines.
* Re-enable commented out testcase in the
nestedInitalStates autotest. The reason
why the test was disabled was fixed a
while ago.
Change-Id: I921483fa49d751d14c877f8f63335fa88cf2ce7b
Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r-- | src/imports/statemachine/childrenprivate.h | 6 | ||||
-rw-r--r-- | tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml | 3 | ||||
-rw-r--r-- | tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml | 71 |
3 files changed, 72 insertions, 8 deletions
diff --git a/src/imports/statemachine/childrenprivate.h b/src/imports/statemachine/childrenprivate.h index 5e2d60e29..d66454ca1 100644 --- a/src/imports/statemachine/childrenprivate.h +++ b/src/imports/statemachine/childrenprivate.h @@ -51,9 +51,6 @@ public: { QAbstractState *state = qobject_cast<QAbstractState*>(item); if (state) { - if (qobject_cast<QStateMachine*>(item)) - qmlInfo(static_cast<T *>(prop->object)) << "StateMachines should not be nested."; - item->setParent(prop->object); } else { QAbstractTransition *trans = qobject_cast<QAbstractTransition*>(item); @@ -68,9 +65,6 @@ public: { QAbstractState *state = qobject_cast<QAbstractState*>(item); if (state) { - if (qobject_cast<QStateMachine*>(item)) - qmlInfo(static_cast<T *>(prop->object)) << "StateMachines should not be nested."; - item->setParent(prop->object); } static_cast<ChildrenPrivate<T>*>(prop->data)->children.append(item); diff --git a/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml b/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml index dc13481bf..2906de298 100644 --- a/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml +++ b/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml @@ -52,8 +52,7 @@ TestCase { name: "nestedInitalStates" function test_nestedInitalStates() { - // uncomment me after vm problems are fixed. - // compare(myStateMachine.running, false); + compare(myStateMachine.running, false); compare(parentState.active, false); compare(childState1.active, false); compare(childState2.active, false); diff --git a/tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml b/tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml new file mode 100644 index 000000000..41a2c2a85 --- /dev/null +++ b/tests/auto/qmltest/statemachine/tst_nestedstatemachine.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Ford Motor Company +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQml.StateMachine 1.0 +import QtTest 1.0 + +TestCase { + StateMachine { + id: myStateMachine + initialState: parentState + StateBase { + id: parentState + initialState: childStateMachine + StateMachine { + id: childStateMachine + initialState: childState2 + StateBase { + id: childState1 + } + StateBase { + id: childState2 + } + } + } + } + name: "nestedStateMachine" + + function test_nestedStateMachine() { + compare(myStateMachine.running, false); + compare(parentState.active, false); + compare(childStateMachine.running, false); + compare(childState1.active, false); + compare(childState2.active, false); + myStateMachine.start(); + tryCompare(myStateMachine, "running", true); + tryCompare(parentState, "active", true); + tryCompare(childStateMachine, "running", true); + tryCompare(childState1, "active", false); + tryCompare(childState2, "active", true); + } +} |