diff options
author | Jarek Kobus <jaroslaw.kobus@theqtcompany.com> | 2016-01-12 12:44:02 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@theqtcompany.com> | 2016-02-10 15:35:20 +0000 |
commit | a69dfbcbb1cdfe8da6e8f78645582169e948ca58 (patch) | |
tree | 7154d3368d16a3c3ebede3e6211f15adb8d4a6d3 /tests/auto/statemachine | |
parent | 3c02e20707d77ca2562742711053b5a356ab36b6 (diff) |
Add a test for nested state machine
Change-Id: I4f63ebc3650928dfe9097ff61b851ebe22e6f216
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Diffstat (limited to 'tests/auto/statemachine')
-rw-r--r-- | tests/auto/statemachine/statenames.scxml (renamed from tests/auto/statemachine/test1.scxml) | 2 | ||||
-rw-r--r-- | tests/auto/statemachine/statenamesnested.scxml | 46 | ||||
-rw-r--r-- | tests/auto/statemachine/tst_statemachine.cpp | 23 | ||||
-rw-r--r-- | tests/auto/statemachine/tst_statemachine.qrc | 3 |
4 files changed, 67 insertions, 7 deletions
diff --git a/tests/auto/statemachine/test1.scxml b/tests/auto/statemachine/statenames.scxml index 3f282f1..4cacd15 100644 --- a/tests/auto/statemachine/test1.scxml +++ b/tests/auto/statemachine/statenames.scxml @@ -29,7 +29,7 @@ ****************************************************************************/ --> <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" - name="test1"> + name="statenames"> <parallel id="top"> <state id="a"> <state id="a1"/> diff --git a/tests/auto/statemachine/statenamesnested.scxml b/tests/auto/statemachine/statenamesnested.scxml new file mode 100644 index 0000000..64380e3 --- /dev/null +++ b/tests/auto/statemachine/statenamesnested.scxml @@ -0,0 +1,46 @@ +<?xml version="1.0" ?> +<!-- +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtScxml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +--> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + name="super_state_machine"> + <parallel id="super_top"> + <state id="a"> + <invoke> + <content> + <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + name="sub_state_machine"> + <state id="sub_top"/> + </scxml> + </content> + </invoke> + </state> + <state id="b"/> + </parallel> +</scxml> diff --git a/tests/auto/statemachine/tst_statemachine.cpp b/tests/auto/statemachine/tst_statemachine.cpp index 60c9260..9ee9aa4 100644 --- a/tests/auto/statemachine/tst_statemachine.cpp +++ b/tests/auto/statemachine/tst_statemachine.cpp @@ -54,12 +54,18 @@ void tst_StateMachine::stateNames_data() QTest::addColumn<bool>("compressed"); QTest::addColumn<QStringList>("expectedStates"); - QTest::newRow("test1-compressed") << QString(":/tst_statemachine/test1.scxml") + QTest::newRow("stateNames-compressed") << QString(":/tst_statemachine/statenames.scxml") << true << (QStringList() << QString("a1") << QString("a2") << QString("final")); - QTest::newRow("test1-not-compressed") << QString(":/tst_statemachine/test1.scxml") + QTest::newRow("stateNames-notCompressed") << QString(":/tst_statemachine/statenames.scxml") << false << (QStringList() << QString("a") << QString("a1") << QString("a2") << QString("b") << QString("final") << QString("top")); + QTest::newRow("stateNamesNested-compressed") << QString(":/tst_statemachine/statenamesnested.scxml") + << true + << (QStringList() << QString("a") << QString("b")); + QTest::newRow("stateNamesNested-notCompressed") << QString(":/tst_statemachine/statenamesnested.scxml") + << false + << (QStringList() << QString("a") << QString("b") << QString("super_top")); } void tst_StateMachine::stateNames() @@ -70,6 +76,7 @@ void tst_StateMachine::stateNames() QScopedPointer<QScxmlStateMachine> stateMachine(QScxmlStateMachine::fromFile(scxmlFileName)); QVERIFY(!stateMachine.isNull()); + QVERIFY(!stateMachine->parseErrors().count()); QCOMPARE(stateMachine->stateNames(compressed), expectedStates); } @@ -80,12 +87,18 @@ void tst_StateMachine::activeStateNames_data() QTest::addColumn<bool>("compressed"); QTest::addColumn<QStringList>("expectedStates"); - QTest::newRow("test1-compressed") << QString(":/tst_statemachine/test1.scxml") + QTest::newRow("stateNames-compressed") << QString(":/tst_statemachine/statenames.scxml") << true << (QStringList() << QString("a1") << QString("final")); - QTest::newRow("test1-not-compressed") << QString(":/tst_statemachine/test1.scxml") + QTest::newRow("stateNames-notCompressed") << QString(":/tst_statemachine/statenames.scxml") << false << (QStringList() << QString("a") << QString("a1") << QString("b") << QString("final") << QString("top")); + QTest::newRow("stateNamesNested-compressed") << QString(":/tst_statemachine/statenamesnested.scxml") + << true + << (QStringList() << QString("a")<< QString("b")); + QTest::newRow("stateNamesNested-notCompressed") << QString(":/tst_statemachine/statenamesnested.scxml") + << false + << (QStringList() << QString("a") << QString("b") << QString("super_top")); } void tst_StateMachine::activeStateNames() @@ -109,7 +122,7 @@ void tst_StateMachine::activeStateNames() void tst_StateMachine::connectToFinal() { - QScopedPointer<QScxmlStateMachine> stateMachine(QScxmlStateMachine::fromFile(QString(":/tst_statemachine/test1.scxml"))); + QScopedPointer<QScxmlStateMachine> stateMachine(QScxmlStateMachine::fromFile(QString(":/tst_statemachine/statenames.scxml"))); QVERIFY(!stateMachine.isNull()); QState dummy; diff --git a/tests/auto/statemachine/tst_statemachine.qrc b/tests/auto/statemachine/tst_statemachine.qrc index 1210ef3..69c96ae 100644 --- a/tests/auto/statemachine/tst_statemachine.qrc +++ b/tests/auto/statemachine/tst_statemachine.qrc @@ -1,5 +1,6 @@ <RCC> <qresource prefix="/tst_statemachine"> - <file>test1.scxml</file> + <file>statenames.scxml</file> + <file>statenamesnested.scxml</file> </qresource> </RCC> |