summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@theqtcompany.com>2016-04-22 15:15:14 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2016-05-03 12:07:39 +0000
commitaad2bc876b71c1c3a0a104f00862facad6ff2640 (patch)
tree4e05c2874a2954bd1f2a8a75558585b44d88fee2 /tests
parent0b7ef02b4a6d99b3b909478036fd18cac9b3f211 (diff)
Set the event type of done.state events to internal.
Change-Id: If874a2aa4a47ea1ebe2dd539c09ff19243dd5558 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/statemachine/eventoccurred.scxml8
-rw-r--r--tests/auto/statemachine/stateDotDoneEvent.scxml53
-rw-r--r--tests/auto/statemachine/tst_statemachine.cpp17
-rw-r--r--tests/auto/statemachine/tst_statemachine.qrc1
4 files changed, 79 insertions, 0 deletions
diff --git a/tests/auto/statemachine/eventoccurred.scxml b/tests/auto/statemachine/eventoccurred.scxml
index 6c164c2..87aaf41 100644
--- a/tests/auto/statemachine/eventoccurred.scxml
+++ b/tests/auto/statemachine/eventoccurred.scxml
@@ -42,4 +42,12 @@
</state>
<final id="final"/>
</state>
+
+ <!--
+ The done.state.* events are internal, so expose them to the spy too by re-sending them as
+ external events:
+ -->
+ <transition event="done.state.*" cond="_event.type === 'internal'">
+ <send eventexpr="_event.name"/>
+ </transition>
</scxml>
diff --git a/tests/auto/statemachine/stateDotDoneEvent.scxml b/tests/auto/statemachine/stateDotDoneEvent.scxml
new file mode 100644
index 0000000..82e68ee
--- /dev/null
+++ b/tests/auto/statemachine/stateDotDoneEvent.scxml
@@ -0,0 +1,53 @@
+<?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="EventOccurred" datamodel="ecmascript">
+ <parallel id="top">
+ <state id="a">
+ <state id="a1">
+ <transition event="terminate" target="a2"/>
+ </state>
+ <final id="a2"/>
+
+ <onentry>
+ <send event="terminate"/>
+ <send event="timeout" delay="1s"/>
+ </onentry>
+ <transition event="timeout" target="failure"/>
+ <transition event="done.state.a" target="success"
+ cond="_event.type === 'internal'"
+ />
+ </state>
+ <state id="b"/>
+ </parallel>
+ <final id="success"/>
+ <final id="failure"/>
+</scxml>
diff --git a/tests/auto/statemachine/tst_statemachine.cpp b/tests/auto/statemachine/tst_statemachine.cpp
index 14628d3..fc20118 100644
--- a/tests/auto/statemachine/tst_statemachine.cpp
+++ b/tests/auto/statemachine/tst_statemachine.cpp
@@ -47,6 +47,8 @@ private Q_SLOTS:
void activeStateNames();
void connectToFinal();
void eventOccurred();
+
+ void doneDotStateEvent();
};
void tst_StateMachine::stateNames_data()
@@ -159,6 +161,21 @@ void tst_StateMachine::eventOccurred()
QCOMPARE(qvariant_cast<QScxmlEvent>(externalEventOccurredSpy.at(0).at(0)).name(), QLatin1String("externalEvent"));
}
+void tst_StateMachine::doneDotStateEvent()
+{
+ QScopedPointer<QScxmlStateMachine> stateMachine(QScxmlStateMachine::fromFile(QString(":/tst_statemachine/stateDotDoneEvent.scxml")));
+ QVERIFY(!stateMachine.isNull());
+
+ QSignalSpy finishedSpy(stateMachine.data(), SIGNAL(finished()));
+
+ stateMachine->start();
+ finishedSpy.wait(5000);
+ QCOMPARE(finishedSpy.count(), 1);
+ QCOMPARE(stateMachine->activeStateNames(true).size(), 1);
+ qDebug() << stateMachine->activeStateNames(true);
+ QVERIFY(stateMachine->activeStateNames(true).contains(QLatin1String("success")));
+}
+
QTEST_MAIN(tst_StateMachine)
diff --git a/tests/auto/statemachine/tst_statemachine.qrc b/tests/auto/statemachine/tst_statemachine.qrc
index 59c39af..9ded2d0 100644
--- a/tests/auto/statemachine/tst_statemachine.qrc
+++ b/tests/auto/statemachine/tst_statemachine.qrc
@@ -4,5 +4,6 @@
<file>statenames.scxml</file>
<file>statenamesnested.scxml</file>
<file>ids1.scxml</file>
+ <file>stateDotDoneEvent.scxml</file>
</qresource>
</RCC>