summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2012-11-07 22:20:09 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2012-11-07 22:20:09 (GMT)
commitda08a1d3c3bca8070c9b029cfc1f8faf9e34dd25 (patch)
treeb285148ab6ca415814d9370148f91736f83c852c /test
parent0ae6c27d9322208053033d9b19c0ffffed3d99eb (diff)
downloaduscxml-da08a1d3c3bca8070c9b029cfc1f8faf9e34dd25.zip
uscxml-da08a1d3c3bca8070c9b029cfc1f8faf9e34dd25.tar.gz
uscxml-da08a1d3c3bca8070c9b029cfc1f8faf9e34dd25.tar.bz2
Committing local version again
Diffstat (limited to 'test')
-rw-r--r--test/samples/uscxml/audio/click.wav (renamed from test/src/audio/click.wav)bin5058 -> 5058 bytes
-rw-r--r--test/samples/uscxml/proto/Dependee.proto3
-rw-r--r--test/samples/uscxml/proto/Depender.proto5
-rw-r--r--test/samples/uscxml/proto/Test.proto37
-rw-r--r--test/samples/uscxml/proto/TestServices.proto23
-rw-r--r--test/samples/uscxml/scripts/GreatCircle.js46
-rw-r--r--test/samples/uscxml/scxml-gui-test.scxml (renamed from test/src/scxml-gui-test.scxml)0
-rw-r--r--test/samples/uscxml/test-communication.scxml (renamed from test/src/test-communication.scxml)0
-rw-r--r--test/samples/uscxml/test-dom.scxml (renamed from test/src/test-dom.scxml)1
-rw-r--r--test/samples/uscxml/test-donedata.scxml (renamed from test/src/test-donedata.scxml)0
-rw-r--r--test/samples/uscxml/test-ecmascript.scxml (renamed from test/src/test-ecmascript.scxml)0
-rw-r--r--test/samples/uscxml/test-execution.scxml (renamed from test/src/test-execution.scxml)0
-rw-r--r--test/samples/uscxml/test-invoked.scxml (renamed from test/src/test-invoked.scxml)0
-rw-r--r--test/samples/uscxml/test-predicates.scxml (renamed from test/src/test-predicates.scxml)0
-rw-r--r--test/samples/uscxml/test-spatial-audio.scxml (renamed from test/src/test-spatial-audio.scxml)2
-rw-r--r--test/samples/uscxml/test-umundo-map-demo.scxml71
-rw-r--r--test/samples/uscxml/test-umundo-rpc.scxml60
-rw-r--r--test/samples/uscxml/test-umundo-s11n.scxml115
-rw-r--r--test/src/test-completion.cpp2
19 files changed, 363 insertions, 2 deletions
diff --git a/test/src/audio/click.wav b/test/samples/uscxml/audio/click.wav
index e11b0b7..e11b0b7 100644
--- a/test/src/audio/click.wav
+++ b/test/samples/uscxml/audio/click.wav
Binary files differ
diff --git a/test/samples/uscxml/proto/Dependee.proto b/test/samples/uscxml/proto/Dependee.proto
new file mode 100644
index 0000000..bbd19fd
--- /dev/null
+++ b/test/samples/uscxml/proto/Dependee.proto
@@ -0,0 +1,3 @@
+message DependeeMsg {
+ required string stringType = 1;
+} \ No newline at end of file
diff --git a/test/samples/uscxml/proto/Depender.proto b/test/samples/uscxml/proto/Depender.proto
new file mode 100644
index 0000000..5fa9952
--- /dev/null
+++ b/test/samples/uscxml/proto/Depender.proto
@@ -0,0 +1,5 @@
+import "Dependee.proto";
+
+message DependerMsg {
+ required DependeeMsg dependeeType = 1;
+} \ No newline at end of file
diff --git a/test/samples/uscxml/proto/Test.proto b/test/samples/uscxml/proto/Test.proto
new file mode 100644
index 0000000..4e7ab6a
--- /dev/null
+++ b/test/samples/uscxml/proto/Test.proto
@@ -0,0 +1,37 @@
+message AllTypes {
+ required double doubleType = 1;
+ required float floatType = 2;
+ required int32 int32Type = 3;
+ required int64 int64Type = 4;
+ required uint32 uint32Type = 5;
+ required uint64 uint64Type = 6;
+ required sint32 sint32Type = 7;
+ required sint64 sint64Type = 8;
+ required fixed32 fixed32Type = 9;
+ required fixed64 fixed64Type = 10;
+ required sfixed32 sfixed32Type = 11;
+ required sfixed64 sfixed64Type = 12;
+ required bool boolType = 13;
+ required string stringType = 14;
+ required bytes bytesType = 15;
+ optional AllTypes allTypes = 16;
+}
+
+message RepeatedTypes {
+ repeated double doubleType = 1;
+ repeated float floatType = 2;
+ repeated int32 int32Type = 3;
+ repeated int64 int64Type = 4;
+ repeated uint32 uint32Type = 5;
+ repeated uint64 uint64Type = 6;
+ repeated sint32 sint32Type = 7;
+ repeated sint64 sint64Type = 8;
+ repeated fixed32 fixed32Type = 9;
+ repeated fixed64 fixed64Type = 10;
+ repeated sfixed32 sfixed32Type = 11;
+ repeated sfixed64 sfixed64Type = 12;
+ repeated bool boolType = 13;
+ repeated string stringType = 14;
+ repeated bytes bytesType = 15;
+ repeated RepeatedTypes repeatedMessage = 16;
+}
diff --git a/test/samples/uscxml/proto/TestServices.proto b/test/samples/uscxml/proto/TestServices.proto
new file mode 100644
index 0000000..c96c34f
--- /dev/null
+++ b/test/samples/uscxml/proto/TestServices.proto
@@ -0,0 +1,23 @@
+option java_package = "org.umundo.protobuf.tests";
+
+message EchoRequest {
+ required string name = 1;
+ optional bytes buffer = 2;
+}
+message EchoReply {
+ required string name = 1;
+ optional bytes buffer = 2;
+}
+service EchoService {
+ rpc echo (EchoRequest) returns (EchoReply);
+}
+
+message PingRequest {
+ required string name = 1;
+}
+message PingReply {
+ required string name = 1;
+}
+service PingService {
+ rpc ping (PingRequest) returns (PingReply);
+}
diff --git a/test/samples/uscxml/scripts/GreatCircle.js b/test/samples/uscxml/scripts/GreatCircle.js
new file mode 100644
index 0000000..7a866d9
--- /dev/null
+++ b/test/samples/uscxml/scripts/GreatCircle.js
@@ -0,0 +1,46 @@
+// taken from http://trac.osgeo.org/openlayers/wiki/GreatCircleAlgorithms
+var EARTH_RADIUS = 3958.75;
+var PI = 3.1415926535897932384626433832795;
+var DEG2RAD = 0.01745329252;
+var RAD2DEG = 57.29577951308;
+
+function WGS84Distance(x1, y1, x2, y2) {
+ x1 = x1 * DEG2RAD;
+ y1 = y1 * DEG2RAD;
+ x2 = x2 * DEG2RAD;
+ y2 = y2 * DEG2RAD;
+
+ var a = sin(( y2-y1 ) / 2.0 )^2;
+ var b = sin(( x2-x1 ) / 2.0 )^2;
+ var c = sqrt( a + cos( y2 ) * cos( y1 ) * b );
+
+ return 2 * asin( c ) * EARTH_RADIUS;
+}
+
+function WGS84Bearing(x1, y1, x2, y2) {
+ x1 = x1 * DEG2RAD;
+ y1 = y1 * DEG2RAD;
+ x2 = x2 * DEG2RAD;
+ y2 = y2 * DEG2RAD;
+
+ var a = cos(y2) * sin(x2 - x1);
+ var b = cos(y1) * sin(y2) - sin(y1) * cos(y2) * cos(x2 - x1);
+ var adjust = 0;
+
+ if((a == 0) && (b == 0)) {
+ bearing = 0;
+ } else if( b == 0) {
+ if( a < 0)
+ bearing = 3 * PI / 2;
+ else
+ bearing = PI / 2;
+ } else if( b < 0)
+ adjust = PI;
+ else {
+ if( a < 0)
+ adjust = 2 * PI;
+ else
+ adjust = 0;
+ }
+ return (atan(a/b) + adjust) * RAD2DEG;
+}
diff --git a/test/src/scxml-gui-test.scxml b/test/samples/uscxml/scxml-gui-test.scxml
index adf93b8..adf93b8 100644
--- a/test/src/scxml-gui-test.scxml
+++ b/test/samples/uscxml/scxml-gui-test.scxml
diff --git a/test/src/test-communication.scxml b/test/samples/uscxml/test-communication.scxml
index 610f8cc..610f8cc 100644
--- a/test/src/test-communication.scxml
+++ b/test/samples/uscxml/test-communication.scxml
diff --git a/test/src/test-dom.scxml b/test/samples/uscxml/test-dom.scxml
index 4624209..73b449c 100644
--- a/test/src/test-dom.scxml
+++ b/test/samples/uscxml/test-dom.scxml
@@ -2,7 +2,6 @@
<state id="start">
<onentry>
<script>
- <!-- Add the missing transition to final -->
var transition = document.createElement("transition");
transition.setAttribute("target", "final");
transition.setAttribute("event", "quit");
diff --git a/test/src/test-donedata.scxml b/test/samples/uscxml/test-donedata.scxml
index c48b6de..c48b6de 100644
--- a/test/src/test-donedata.scxml
+++ b/test/samples/uscxml/test-donedata.scxml
diff --git a/test/src/test-ecmascript.scxml b/test/samples/uscxml/test-ecmascript.scxml
index aa88f17..aa88f17 100644
--- a/test/src/test-ecmascript.scxml
+++ b/test/samples/uscxml/test-ecmascript.scxml
diff --git a/test/src/test-execution.scxml b/test/samples/uscxml/test-execution.scxml
index ada1a17..ada1a17 100644
--- a/test/src/test-execution.scxml
+++ b/test/samples/uscxml/test-execution.scxml
diff --git a/test/src/test-invoked.scxml b/test/samples/uscxml/test-invoked.scxml
index 7cd0d72..7cd0d72 100644
--- a/test/src/test-invoked.scxml
+++ b/test/samples/uscxml/test-invoked.scxml
diff --git a/test/src/test-predicates.scxml b/test/samples/uscxml/test-predicates.scxml
index 98848a2..98848a2 100644
--- a/test/src/test-predicates.scxml
+++ b/test/samples/uscxml/test-predicates.scxml
diff --git a/test/src/test-spatial-audio.scxml b/test/samples/uscxml/test-spatial-audio.scxml
index f800c82..d960533 100644
--- a/test/src/test-spatial-audio.scxml
+++ b/test/samples/uscxml/test-spatial-audio.scxml
@@ -45,6 +45,7 @@
<onentry>
<!-- trigger transition in 1 second -->
<send event="spatial-audio.play" delay="1s" />
+ <log expr="'Ready'" />
</onentry>
<transition target="click" event="spatial-audio.play" />
<transition target="final" event="quit" />
@@ -58,6 +59,7 @@
<send target="#_spatial-audio.id2" event="play" delay="200ms">
<param name="circle" expr="spatialAudio.id2.degree + 'deg'" />
</send>
+ <log expr="'Clicking'" />
<script>spatialAudio.id2.degree += 10;</script>
</onentry>
<transition target="ready" />
diff --git a/test/samples/uscxml/test-umundo-map-demo.scxml b/test/samples/uscxml/test-umundo-map-demo.scxml
new file mode 100644
index 0000000..8ee91f1
--- /dev/null
+++ b/test/samples/uscxml/test-umundo-map-demo.scxml
@@ -0,0 +1,71 @@
+<scxml datamodel="ecmascript">
+ <script src="scripts/GreatCircle.js" />
+ <data id="audioSources">
+ {
+ }
+ </data>
+ <script>
+ function dump(thingy) {
+ if (typeof(thingy) == 'object') {
+ for (var key in thingy) {
+ print(key + ": ")
+ dump(thingy[key]);
+ }
+ } else {
+ print(thingy + "\n");
+ }
+ };
+ var listener = { x: 0, y: 0, z: 0 };
+ </script>
+ <state id="start">
+ <!-- start listening for drag events on umundo map channel -->
+ <invoke type="umundo" id="map.drag">
+ <param name="channel" expr="'map/center'" />
+ <!-- update position of listener for every audio source when map was dragged -->
+ <finalize>
+ <send event="move.listener" target="#_audioSources.id1">
+ <param name="x" expr="_event.data.lon" />
+ <param name="y" expr="40 - (_event.data.zoom * 2)" />
+ <param name="z" expr="_event.data.lat" />
+ </send>
+ </finalize>
+ </invoke>
+
+ <!-- start two spatial audio invokers -->
+ <invoke type="spatial-audio" src="audio/click.wav" id="audioSources.id1">
+ <param name="x" expr="18.08" />
+ <param name="y" expr="0" />
+ <param name="z" expr="59.32" />
+ </invoke>
+
+ <invoke type="umundo" id="map.fault">
+ <param name="channel" expr="'map/tick'" />
+ <finalize>
+ <send target="#_audioSources.id1" event="play">
+ <param name="x" expr="_event.data.lon" />
+ <param name="y" expr="0" />
+ <param name="z" expr="_event.data.lat" />
+ </send>
+ </finalize>
+ </invoke>
+
+ <!-- this is the state where we wait for events -->
+ <state id="idle">
+ <!-- onentry>
+ <log expr="'== Idleing ====='" />
+ </onentry -->
+ <transition target="dump" event="*" />
+ </state>
+
+ <state id="dump">
+ <!-- onentry>
+ <log expr="'== Dumping Event ====='" />
+ <script>
+ dump(_event);
+ </script>
+ </onentry -->
+ <transition target="idle" />
+ </state>
+
+ </state>
+</scxml> \ No newline at end of file
diff --git a/test/samples/uscxml/test-umundo-rpc.scxml b/test/samples/uscxml/test-umundo-rpc.scxml
new file mode 100644
index 0000000..f6e0f70
--- /dev/null
+++ b/test/samples/uscxml/test-umundo-rpc.scxml
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<scxml datamodel="ecmascript">
+ <script>
+ function dump(thingy) {
+ if (typeof(thingy) == 'object') {
+ for (var key in thingy) {
+ print(key + ": ")
+ dump(thingy[key]);
+ }
+ } else {
+ print(thingy + "\n");
+ }
+ };
+ </script>
+ <state id="start">
+ <!-- Invoke umundo with a service query -->
+ <invoke type="umundo" id="umundo.eventSvc">
+ <param name="types" expr="'proto'"/>
+ <param name="service" expr="'EchoService'"/>
+ <finalize>
+ <log expr="'Calling finalize on returned event'"/>
+ </finalize>
+ </invoke>
+ <state id="idle">
+ <transition target="service.added" event="umundo.eventSvc.added"/>
+ <transition target="service.removed" event="umundo.eventSvc.removed"/>
+ <transition target="service.reply" event="umundo.eventSvc.reply.echo"/>
+ </state>
+ <state id="service.reply">
+ <onentry>
+ <log expr="'RPC Reply:'"/>
+ <script>dump(_event);</script>
+ </onentry>
+ <transition target="idle"/>
+ </state>
+
+ <state id="service.added">
+ <onentry>
+ <log expr="'Log Service found:'"/>
+ <script>dump(_event);</script>
+ <send target="#_umundo.eventSvc" event="echo">
+ <param name="type" expr="'EchoRequest'"/>
+ <content>
+ ({
+ "name": "This is foo!"
+ })
+ </content>
+ </send>
+ </onentry>
+ <transition target="idle"/>
+ </state>
+ <state id="service.removed">
+ <onentry>
+ <log expr="'Log Service lost:'"/>
+ <script>dump(_event);</script>
+ </onentry>
+ <transition target="idle"/>
+ </state>
+ </state>
+</scxml>
diff --git a/test/samples/uscxml/test-umundo-s11n.scxml b/test/samples/uscxml/test-umundo-s11n.scxml
new file mode 100644
index 0000000..001d72e
--- /dev/null
+++ b/test/samples/uscxml/test-umundo-s11n.scxml
@@ -0,0 +1,115 @@
+<scxml datamodel="ecmascript">
+ <script>
+ <![CDATA[
+ function dump(arr,level) {
+ if(!level) level = 0;
+
+ var level_padding = "";
+ for(var j=0;j < level+1;j++) level_padding += " ";
+
+ if(typeof(arr) == 'object') {
+ for(var item in arr) {
+ var value = arr[item];
+
+ if(typeof(value) == 'object') {
+ print(level_padding + "'" + item + "' ...\n");
+ print(dump(value,level+1));
+ } else {
+ print(level_padding + "'" + item + "' => \"" + value + "\"\n");
+ }
+ }
+ } else {
+ print("===> "+arr+" <===("+typeof(arr)+")");
+ }
+ }
+ ]]>
+ </script>
+ <state id="start">
+ <invoke type="umundo" id="scxml.umundo">
+ <param name="types" expr="'proto/Test.proto'" />
+ <param name="channel" expr="'types'" />
+ <finalize>
+ <script>
+ dump(_event);
+ </script>
+ <send target="#_scxml.umundo" delay="0s" event="dump.event">
+ <param name="type" expr="_event.data.type" />
+ <content>_event.data</content>
+ </send>
+ </finalize>
+ </invoke>
+ <onentry-off>
+ <!-- The round brackets are needed to evaluate the JSON object as an expression! -->
+ <send target="#_scxml.umundo" delay="3s" event="dump.event">
+ <param name="type" expr="'AllTypes'" />
+ <content>
+ ({
+ "doubleType": 1.0,
+ "floatType": 2.0,
+ "int32Type": -3,
+ "int64Type": -4,
+ "uint32Type": 5,
+ "uint64Type": 6,
+ "sint32Type": -7,
+ "sint64Type": -8,
+ "fixed32Type": 9,
+ "fixed64Type": 10,
+ "sfixed32Type": -11,
+ "sfixed64Type": -12,
+ "boolType": false,
+ "stringType": 'string',
+ "bytesType": 'bytes',
+ })
+ </content>
+ </send>
+ <send target="#_scxml.umundo" delay="3s" event="dump.event">
+ <param name="type" expr="'RepeatedTypes'" />
+ <content>
+ ({
+ "doubleType": [ 1.0, 2.0 ],
+ "floatType": [ 2.0, 3.0 ],
+ "int32Type": [ -3, -4 ],
+ "int64Type": [ -4, -5 ],
+ "uint32Type": [ 5, 6 ],
+ "uint64Type": [ 6, 7 ],
+ "sint32Type": [ -7, -8 ],
+ "sint64Type": [ -8, -9 ],
+ "fixed32Type": [ 9, 10 ],
+ "fixed64Type": [ 10, 11 ],
+ "sfixed32Type": [ -11, -12 ],
+ "sfixed64Type": [ -12, -13 ],
+ "boolType": [ false, true ],
+ "stringType": [ '1st string', '2nd string' ],
+ "bytesType": [ '1st bytes', '2nd bytes' ],
+ "repeatedMessage": [{
+ "doubleType": [ 1.0, 2.0 ],
+ "floatType": [ 2.0, 3.0 ],
+ "int32Type": [ -3, -4 ],
+ "int64Type": [ -4, -5 ],
+ "uint32Type": [ 5, 6 ],
+ "uint64Type": [ 6, 7 ],
+ "sint32Type": [ -7, -8 ],
+ "sint64Type": [ -8, -9 ],
+ "fixed32Type": [ 9, 10 ],
+ "fixed64Type": [ 10, 11 ],
+ "sfixed32Type": [ -11, -12 ],
+ "sfixed64Type": [ -12, -13 ],
+ "boolType": [ false, true ],
+ "stringType": [ '1st string', '2nd string' ],
+ "bytesType": [ '1st bytes', '2nd bytes' ],
+ }],
+ })
+ </content>
+ </send>
+ </onentry-off>
+ <transition target="dump" event="dump.event" />
+ </state>
+ <state id="dump">
+ <onentry>
+ <script>
+ dump(_event);
+ </script>
+ </onentry>
+ <transition target="dump" event="dump.event" />
+ </state>
+</scxml> \ No newline at end of file
diff --git a/test/src/test-completion.cpp b/test/src/test-completion.cpp
index 619bdef..b75baf6 100644
--- a/test/src/test-completion.cpp
+++ b/test/src/test-completion.cpp
@@ -11,7 +11,7 @@ int main(int argc, char** argv) {
using namespace uscxml;
Interpreter* interpreter = Interpreter::fromURI(argv[1]);
- SCXMLDotWriter::toDot("output.dot", interpreter);
+ //SCXMLDotWriter::toDot("output.dot", interpreter);
interpreter->interpret();