summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2012-09-16 22:09:30 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2012-09-16 22:09:30 (GMT)
commit30576421dd507170a96e31cd56daacc02db46e14 (patch)
treeb12f0fa2ee71d8dc37e339f73490fdcbb9c80fb8 /test
parentd7211d570f8b78442f35bd9c55808053eb18ecc2 (diff)
downloaduscxml-30576421dd507170a96e31cd56daacc02db46e14.zip
uscxml-30576421dd507170a96e31cd56daacc02db46e14.tar.gz
uscxml-30576421dd507170a96e31cd56daacc02db46e14.tar.bz2
Fixed done.state events
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt5
-rw-r--r--test/src/test-communication.scxml13
-rw-r--r--test/src/test-completion.cpp16
-rw-r--r--test/src/test-donedata.scxml37
4 files changed, 68 insertions, 3 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 297428c..bea3b53 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -27,3 +27,8 @@ add_executable(test-eventdelay src/test-eventdelay.cpp)
target_link_libraries(test-eventdelay uscxml)
add_test(test-eventdelay test-eventdelay)
set_target_properties(test-eventdelay PROPERTIES FOLDER "Tests")
+
+add_executable(test-completion src/test-completion.cpp)
+target_link_libraries(test-completion uscxml)
+add_test(test-completion ${CMAKE_SOURCE_DIR}/test/src/test-donedata.scxml)
+set_target_properties(test-completion PROPERTIES FOLDER "Tests")
diff --git a/test/src/test-communication.scxml b/test/src/test-communication.scxml
index bd3c00d..c1c1f65 100644
--- a/test/src/test-communication.scxml
+++ b/test/src/test-communication.scxml
@@ -1,5 +1,8 @@
<scxml datamodel="ecmascript" initial="start" binding="late" name="foo">
<state id="start">
+
+ <!-- Setup datamodel, print environment and send ourself an event to transition to next state -->
+
<datamodel>
<data id="invokeconfig">
<invoker id="scxml" name="http://www.w3.org/TR/scxml/" location="_runtime" />
@@ -10,7 +13,7 @@
<onentry>
<log expr="'basichttp listening as ' + _ioprocessors['basichttp'].location" />
<log expr="'Entered step1'" />
- <log expr="'Sending ourself an event'" />
+ <log expr="'Sending ourself an event with data via basichttp'" />
<send targetexpr="_ioprocessors['basichttp'].location" namelist="foo" type="basichttp" event="transitionToNext">
<param name="bar" expr="'b' + 'ar'" />
<content>
@@ -20,7 +23,7 @@ This is some content you got there dude!
</content>
</send>
</onentry>
- <transition event="transitionToNext" target="step1" />
+ <transition event="transitionToNext" target="step1" cond="_event.data.bar == 'this is the bar data'" />
</state>
<state id="step1">
<onentry>
@@ -35,7 +38,11 @@ This is some content you got there dude!
<log expr="'Entered step2'" />
<log expr="'Invoking scxml interpreter'" />
</onentry>
- <invoke type="http://www.w3.org/TR/scxml/" src="test-invoked.scxml" />
+ <invoke type="http://www.w3.org/TR/scxml/" src="test-invoked.scxml">
+ <finalize>
+ <log expr="'Calling finalize on returned event'" />
+ </finalize>
+ </invoke>
<transition event="transitionToNext" target="step2" />
</state>
<final id="final">
diff --git a/test/src/test-completion.cpp b/test/src/test-completion.cpp
new file mode 100644
index 0000000..33056f3
--- /dev/null
+++ b/test/src/test-completion.cpp
@@ -0,0 +1,16 @@
+#include "uscxml/Interpreter.h"
+#include <DOM/io/Stream.hpp>
+
+int main(int argc, char** argv) {
+ if (argc != 2) {
+ std::cerr << "Expected path to scxml document" << std::endl;
+ exit(EXIT_FAILURE);
+ }
+
+ using namespace uscxml;
+
+ Interpreter* interpreter = Interpreter::fromURI(argv[1]);
+ interpreter->interpret();
+
+ return EXIT_SUCCESS;
+} \ No newline at end of file
diff --git a/test/src/test-donedata.scxml b/test/src/test-donedata.scxml
new file mode 100644
index 0000000..c48b6de
--- /dev/null
+++ b/test/src/test-donedata.scxml
@@ -0,0 +1,37 @@
+<scxml datamodel="ecmascript" initial="start" binding="late" name="test-donedata">
+ <parallel id="start">
+ <onentry>
+ <raise event="e1" />
+ <raise event="e2" />
+ <raise event="e4" />
+ <raise event="e1" />
+ </onentry>
+ <transition event="done.state.start" target="final"/>
+
+ <state id="S1" initial="S11">
+ <state id="S11">
+ <transition event="e4" target="S12"/>
+ </state>
+ <state id="S12">
+ <transition event="e1" target="S1Final"/>
+ </state>
+ <final id="S1Final"/>
+ </state>
+
+ <state id="S2" initial="S21">
+ <state id="S21">
+ <transition event="e1" target="S22"/>
+ </state>
+ <state id="S22">
+ <transition event="e2" target="S2Final" />
+ </state>
+ <final id="S2Final"/>
+ </state>
+ </parallel>
+
+ <state id="final" final="true">
+ <onentry>
+ <log expr="'Finished!'"/>
+ </onentry>
+ </state>
+</scxml> \ No newline at end of file