diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 12 | ||||
-rw-r--r-- | test/src/test-arabica-namespaces.cpp | 20 | ||||
-rw-r--r-- | test/src/test-mmi.cpp | 289 | ||||
-rw-r--r-- | test/src/test-vxml-mmi-http.cpp | 12 | ||||
-rw-r--r-- | test/uscxml/test-jvoicexml.scxml | 128 |
5 files changed, 401 insertions, 60 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b879401..718409f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -152,12 +152,12 @@ target_link_libraries(test-sockets uscxml) set_target_properties(test-sockets PROPERTIES FOLDER "Tests") -# if (NOT WIN32) -# add_executable(test-mmi src/test-mmi.cpp) -# target_link_libraries(test-mmi uscxml) -# add_test(test-url ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-mmi) -# set_target_properties(test-mmi PROPERTIES FOLDER "Tests") -# endif() +if (NOT WIN32) + add_executable(test-mmi src/test-mmi.cpp) + target_link_libraries(test-mmi uscxml) + add_test(test-mmi ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-mmi) + set_target_properties(test-mmi PROPERTIES FOLDER "Tests") +endif() # add_executable(test-curl-multi-api src/test-curl-multi-api.cpp) # target_link_libraries(test-curl-multi-api uscxml) diff --git a/test/src/test-arabica-namespaces.cpp b/test/src/test-arabica-namespaces.cpp index bc3e62f..32feacd 100644 --- a/test/src/test-arabica-namespaces.cpp +++ b/test/src/test-arabica-namespaces.cpp @@ -95,8 +95,8 @@ static void validateRootFoo(std::pair<Document<std::string>, NameSpaceInfo>& par Node<std::string> root = document.getDocumentElement(); _xpath.setNamespaceContext(*nsInfo.getNSContext()); - assert(TAGNAME(root) == nsInfo.xmlNSPrefix + "root"); - assert(LOCALNAME(root) == "root"); + assert(TAGNAME_CAST(root) == nsInfo.xmlNSPrefix + "root"); + assert(LOCALNAME_CAST(root) == "root"); NodeSet<std::string> foosFiltered = InterpreterImpl::filterChildElements(nsInfo.xmlNSPrefix + "foo", root); assert(foosFiltered.size() == 3); NodeSet<std::string> foosXPath = _xpath.evaluate("//" + nsInfo.xpathPrefix + "foo", root).asNodeSet(); @@ -104,8 +104,8 @@ static void validateRootFoo(std::pair<Document<std::string>, NameSpaceInfo>& par for (int i = 0; i < 3; i++) { assert(foosFiltered[i] == foosXPath[i]); - assert(TAGNAME(foosFiltered[i]) == nsInfo.xmlNSPrefix + "foo"); - assert(LOCALNAME(foosFiltered[i]) == "foo"); + assert(TAGNAME_CAST(foosFiltered[i]) == nsInfo.xmlNSPrefix + "foo"); + assert(LOCALNAME_CAST(foosFiltered[i]) == "foo"); } } @@ -126,8 +126,8 @@ static void validateRootFooBar(std::pair<Document<std::string>, NameSpaceInfo>& for (int i = 0; i < 3; i++) { assert(barsFiltered[i] == barsXPath[i]); - assert(TAGNAME(barsFiltered[i]) == nsInfo.xmlNSPrefix + "bar"); - assert(LOCALNAME(barsFiltered[i]) == "bar"); + assert(TAGNAME_CAST(barsFiltered[i]) == nsInfo.xmlNSPrefix + "bar"); + assert(LOCALNAME_CAST(barsFiltered[i]) == "bar"); } } @@ -141,8 +141,8 @@ static void validateRootFooBarBaz(std::pair<Document<std::string>, NameSpaceInfo Node<std::string> root = document.getDocumentElement(); _xpath.setNamespaceContext(*nsInfo.getNSContext()); - assert(TAGNAME(root) == nsInfo.xmlNSPrefix + "root"); - assert(LOCALNAME(root) == "root"); + assert(TAGNAME_CAST(root) == nsInfo.xmlNSPrefix + "root"); + assert(LOCALNAME_CAST(root) == "root"); NodeSet<std::string> bazsFiltered = InterpreterImpl::filterChildElements(nsInfo.xmlNSPrefix + "baz", root); assert(bazsFiltered.size() == 3); @@ -151,8 +151,8 @@ static void validateRootFooBarBaz(std::pair<Document<std::string>, NameSpaceInfo for (int i = 0; i < 3; i++) { assert(bazsFiltered[i] == bazsXPath[i]); - assert(TAGNAME(bazsFiltered[i]) == nsInfo.xmlNSPrefix + "baz"); - assert(LOCALNAME(bazsFiltered[i]) == "baz"); + assert(TAGNAME_CAST(bazsFiltered[i]) == nsInfo.xmlNSPrefix + "baz"); + assert(LOCALNAME_CAST(bazsFiltered[i]) == "baz"); } } diff --git a/test/src/test-mmi.cpp b/test/src/test-mmi.cpp index 0b9f5f9..eeb71ee 100644 --- a/test/src/test-mmi.cpp +++ b/test/src/test-mmi.cpp @@ -1,7 +1,7 @@ #include <iostream> #include <string> -#include "uscxml/plugins/ioprocessor/modality/MMIMessages.h" +#include "uscxml/messages/MMIMessages.h" #include <SAX/helpers/InputSourceResolver.hpp> #include <DOM/SAX2DOM/SAX2DOM.hpp> @@ -30,19 +30,30 @@ int main(int argc, char** argv) { // --- NewContextRequest std::stringstream ss; ss << "<mmi:mmi xmlns:mmi=\"http://www.w3.org/2008/04/mmi-arch\" version=\"1.0\"><mmi:NewContextRequest mmi:Source=\"someURI\" mmi:Target=\"someOtherURI\" mmi:RequestID=\"request-1\"></mmi:NewContextRequest></mmi:mmi>"; + NewContextRequest msg = NewContextRequest::fromXML(xmlToDoc(ss.str())); assert(boost::iequals(msg.tagName, "NewContextRequest")); assert(boost::iequals(msg.source, "someURI")); assert(boost::iequals(msg.target, "someOtherURI")); assert(boost::iequals(msg.requestId, "request-1")); assert(boost::iequals(msg.data, "")); - + NewContextRequest msg2 = NewContextRequest::fromXML(msg.toXML()); assert(boost::iequals(msg2.tagName, "NewContextRequest")); assert(boost::iequals(msg2.source, "someURI")); assert(boost::iequals(msg2.target, "someOtherURI")); assert(boost::iequals(msg2.requestId, "request-1")); assert(boost::iequals(msg2.data, "")); + + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.request.newcontext"); + assert(ev.origin == msg.source); } { @@ -69,10 +80,20 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.context, "URI-1")); assert(boost::iequals(msg2.data, "")); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.response.newcontext"); + assert(ev.origin == msg.source); + } { - // --- PrepareRequest + // --- PrepareRequest ContentURL std::stringstream ss; ss << "<mmi:mmi xmlns:mmi=\"http://www.w3.org/2008/04/mmi-arch\" version=\"1.0\"> <mmi:PrepareRequest mmi:Source=\"someURI\" mmi:Target=\"someOtherURI\" mmi:Context=\"URI-1\" mmi:RequestID=\"request-1\"> <mmi:ContentURL mmi:href=\"someContentURI\" mmi:max-age=\"\" mmi:fetchtimeout=\"1s\"/> </mmi:PrepareRequest></mmi:mmi>"; PrepareRequest msg = PrepareRequest::fromXML(xmlToDoc(ss.str())); @@ -99,10 +120,20 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.contentURL.maxAge, "")); assert(boost::iequals(msg2.contentURL.fetchTimeout, "1s")); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.request.prepare"); + assert(ev.origin == msg.source); + } { - // --- PrepareRequest + // --- PrepareRequest Content std::stringstream ss; ss << "<mmi:mmi xmlns:mmi=\"http://www.w3.org/2008/04/mmi-arch\" version=\"1.0\" xmlns:vxml=\"http://www.w3.org/2001/vxml\"> <mmi:PrepareRequest mmi:Source=\"someURI\" mmi:Target=\"someOtherURI\" mmi:Context=\"URI-1\" mmi:RequestID=\"request-1\" > <mmi:content> <vxml:vxml version=\"2.0\"> <vxml:form> <vxml:block>Hello World!</vxml:block> </vxml:form> </vxml:vxml> </mmi:content> </mmi:PrepareRequest></mmi:mmi>"; PrepareRequest msg = PrepareRequest::fromXML(xmlToDoc(ss.str())); @@ -111,8 +142,8 @@ int main(int argc, char** argv) { assert(boost::iequals(msg.target, "someOtherURI")); assert(boost::iequals(msg.requestId, "request-1")); assert(boost::iequals(msg.context, "URI-1")); - assert(msg.content.size() > 0); - + assert(msg.contentDOM); + PrepareRequest msg2 = PrepareRequest::fromXML(msg.toXML()); assert(boost::iequals(msg2.tagName, "PrepareRequest")); assert(boost::iequals(msg2.source, "someURI")); @@ -121,6 +152,16 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.context, "URI-1")); assert(msg2.content.size() > 0); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.request.prepare"); + assert(ev.origin == msg.source); + } { @@ -143,6 +184,16 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.context, "someURI")); assert(msg2.status == StatusResponse::SUCCESS); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.response.prepare"); + assert(ev.origin == msg.source); + } { @@ -167,6 +218,16 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.statusInfo, " NotAuthorized ")); assert(msg2.status == StatusResponse::FAILURE); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.response.prepare"); + assert(ev.origin == msg.source); + } { @@ -187,9 +248,52 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.requestId, "request-1")); assert(boost::iequals(msg2.context, "URI-1")); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.request.start"); + assert(ev.origin == msg.source); + } { + // --- StartRequest + std::stringstream ss; + ss << "<mmi:mmi xmlns:mmi=\"http://www.w3.org/2008/04/mmi-arch\" version=\"1.0\"> <mmi:StartRequest mmi:Source=\"someURI\" mmi:Target=\"someOtherURI\" mmi:Context=\"URI-1\" mmi:RequestID=\"request-1\"> <mmi:ContentURL mmi:href=\"someContentURI\" mmi:max-age=\"\" mmi:fetchtimeout=\"1s\"/> <mmi:Data> { \"foo\": 12 } </mmi:Data> </mmi:StartRequest></mmi:mmi>"; + StartRequest msg = StartRequest::fromXML(xmlToDoc(ss.str())); + assert(boost::iequals(msg.tagName, "StartRequest")); + assert(boost::iequals(msg.source, "someURI")); + assert(boost::iequals(msg.target, "someOtherURI")); + assert(boost::iequals(msg.requestId, "request-1")); + assert(boost::iequals(msg.context, "URI-1")); + + StartRequest msg2 = StartRequest::fromXML(msg.toXML()); + assert(boost::iequals(msg2.tagName, "StartRequest")); + assert(boost::iequals(msg2.source, "someURI")); + assert(boost::iequals(msg2.target, "someOtherURI")); + assert(boost::iequals(msg2.requestId, "request-1")); + assert(boost::iequals(msg2.context, "URI-1")); + + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.request.start"); + assert(ev.data.compound["foo"] == 12); + assert(ev.origin == msg.source); + + } + + + + { // --- StartResponse std::stringstream ss; ss << "<mmi:mmi xmlns:mmi=\"http://www.w3.org/2008/04/mmi-arch\" version=\"1.0\"> <mmi:StartResponse mmi:Source=\"someURI\" mmi:Target=\"someOtherURI\" mmi:Context=\"someURI\" mmi:RequestID=\"request-1\" mmi:Status=\"failure\"> <mmi:statusInfo> NotAuthorized </mmi:statusInfo> </mmi:StartResponse></mmi:mmi>"; @@ -211,6 +315,16 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.statusInfo, " NotAuthorized ")); assert(msg2.status == StatusResponse::FAILURE); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.response.start"); + assert(ev.origin == msg.source); + } { @@ -235,6 +349,16 @@ int main(int argc, char** argv) { assert(msg2.data.size() > 0); assert(msg2.status == StatusResponse::SUCCESS); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.notification.done"); + assert(ev.origin == msg.source); + } { @@ -259,6 +383,16 @@ int main(int argc, char** argv) { assert(msg2.data.size() > 0); assert(msg2.status == StatusResponse::SUCCESS); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.notification.done"); + assert(ev.origin == msg.source); + } { @@ -279,6 +413,16 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.requestId, "request-1")); assert(boost::iequals(msg2.context, "someURI")); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.request.cancel"); + assert(ev.origin == msg.source); + } { @@ -301,6 +445,16 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.context, "someURI")); assert(msg2.status == StatusResponse::SUCCESS); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.response.cancel"); + assert(ev.origin == msg.source); + } { @@ -321,6 +475,16 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.requestId, "request-1")); assert(boost::iequals(msg2.context, "someURI")); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.request.pause"); + assert(ev.origin == msg.source); + } { @@ -343,6 +507,16 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.context, "someURI")); assert(msg2.status == StatusResponse::SUCCESS); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.response.pause"); + assert(ev.origin == msg.source); + } { @@ -363,6 +537,16 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.requestId, "request-1")); assert(boost::iequals(msg2.context, "someURI")); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.request.resume"); + assert(ev.origin == msg.source); + } { @@ -385,6 +569,16 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.context, "someURI")); assert(msg2.status == StatusResponse::SUCCESS); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.response.resume"); + assert(ev.origin == msg.source); + } { @@ -407,6 +601,49 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.context, "someURI")); assert(boost::iequals(msg2.name, "appEvent")); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "appEvent"); + assert(ev.origin == msg.source); + + } + + { + // --- ExtensionNotification + std::stringstream ss; + ss << "<mmi:mmi xmlns:mmi=\"http://www.w3.org/2008/04/mmi-arch\" version=\"1.0\"> <mmi:ExtensionNotification mmi:Name=\"appEvent\" mmi:Source=\"someURI\" mmi:Target=\"someOtherURI\" mmi:Context=\"someURI\" mmi:RequestID=\"request-1\"> <mmi:Data> { \"foo\": 12 } </mmi:Data> </mmi:ExtensionNotification></mmi:mmi>"; + ExtensionNotification msg = ExtensionNotification::fromXML(xmlToDoc(ss.str())); + assert(boost::iequals(msg.tagName, "ExtensionNotification")); + assert(boost::iequals(msg.source, "someURI")); + assert(boost::iequals(msg.target, "someOtherURI")); + assert(boost::iequals(msg.requestId, "request-1")); + assert(boost::iequals(msg.context, "someURI")); + assert(boost::iequals(msg.name, "appEvent")); + + ExtensionNotification msg2 = ExtensionNotification::fromXML(msg.toXML()); + assert(boost::iequals(msg2.tagName, "ExtensionNotification")); + assert(boost::iequals(msg2.source, "someURI")); + assert(boost::iequals(msg2.target, "someOtherURI")); + assert(boost::iequals(msg2.requestId, "request-1")); + assert(boost::iequals(msg2.context, "someURI")); + assert(boost::iequals(msg2.name, "appEvent")); + + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "appEvent"); + assert(ev.data.compound["foo"] == 12); + assert(ev.origin == msg.source); + } { @@ -427,6 +664,16 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.requestId, "request-2")); assert(boost::iequals(msg2.context, "someURI")); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.request.clearcontext"); + assert(ev.origin == msg.source); + } { @@ -449,6 +696,16 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.context, "someURI")); assert(msg2.status == StatusResponse::SUCCESS); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.response.clearcontext"); + assert(ev.origin == msg.source); + } { @@ -471,6 +728,16 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.context, "aToken")); assert(msg2.automaticUpdate); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.request.status"); + assert(ev.origin == msg.source); + } { @@ -493,6 +760,16 @@ int main(int argc, char** argv) { assert(boost::iequals(msg2.context, "aToken")); assert(msg2.status == StatusResponse::ALIVE); + std::stringstream xml1SS; + std::stringstream xml2SS; + xml1SS << msg.toXML(); + xml2SS << msg2.toXML(); + assert(xml1SS.str() == xml2SS.str()); + + Event ev = msg; + assert(ev.name == "mmi.response.status"); + assert(ev.origin == msg.source); + } }
\ No newline at end of file diff --git a/test/src/test-vxml-mmi-http.cpp b/test/src/test-vxml-mmi-http.cpp index 0e4f5a9..2b2cd25 100644 --- a/test/src/test-vxml-mmi-http.cpp +++ b/test/src/test-vxml-mmi-http.cpp @@ -22,7 +22,7 @@ #include "XGetopt.h" #endif -#define ISSUE_REQUEST(name) {\ +#define ISSUE_REQUEST(name, block) {\ Arabica::DOM::Document<std::string> name##XML = name.toXML(true);\ name##XML.getDocumentElement().setPrefix("mmi");\ std::stringstream name##XMLSS;\ @@ -31,7 +31,8 @@ std::cout << "SEND:" << std::endl << name##XMLSS.str() << std::flush;\ name##URL.setOutContent(name##XMLSS.str());\ name##URL.addOutHeader("Content-type", "application/xml");\ - name##URL.download(false);\ + name##URL.download(block);\ + std::cout << "OK" << std::endl << std::flush;\ } using namespace uscxml; @@ -144,9 +145,10 @@ int main(int argc, char** argv) { newCtxReq.source = source; newCtxReq.target = target; newCtxReq.requestId = uscxml::UUID::getUUID(); - + Requests[newCtxReq.requestId] = &newCtxReq; - ISSUE_REQUEST(newCtxReq); + + ISSUE_REQUEST(newCtxReq, false); while(Replies.find(newCtxReq.requestId) == Replies.end()) Cond.wait(Mutex); @@ -160,7 +162,7 @@ int main(int argc, char** argv) { //"https://raw.githubusercontent.com/Roland-Taizun-Azhar/TaskAssistance-Project/master/WebContent/hello.vxml"; Requests[startReq.requestId] = &startReq; - ISSUE_REQUEST(startReq); + ISSUE_REQUEST(startReq, false); while(Replies.find(startReq.requestId) == Replies.end()) Cond.wait(Mutex); diff --git a/test/uscxml/test-jvoicexml.scxml b/test/uscxml/test-jvoicexml.scxml index ca423ad..2e60cf3 100644 --- a/test/uscxml/test-jvoicexml.scxml +++ b/test/uscxml/test-jvoicexml.scxml @@ -1,54 +1,116 @@ -<scxml xmlns="http://www.w3.org/2005/07/scxml" - xmlns:vxml="http://www.w3.org/2001/vxml" - datamodel="ecmascript"> - <script src="http://uscxml.tk.informatik.tu-darmstadt.de/scripts/dump.js" /> +<?xml version="1.0"?> +<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:vxml="http://www.w3.org/2001/vxml" datamodel="ecmascript"> + <!-- get dump() function into datamodel --> + <script src="http://uscxml.tk.informatik.tu-darmstadt.de/scripts/dump.js"/> + <script> + vxmlTargetURL = "http://localhost:9090/mmi"; + </script> - <state id="start"> - <invoke type="heartbeat"> - <param name="interval" expr="'5s'" /> - </invoke> - - <state id="vxmlHello"> - <invoke src="https://raw.githubusercontent.com/Roland-Taizun-Azhar/TaskAssistance-Project/master/WebContent/hello.vxml" type="vxml" id="vxml"> - <param name="target" expr="'http://localhost:9090/mmi'" /> - </invoke> - <!--invoke type="vxml" id="vxml"> - <param name="target" expr="'http://localhost:9090/mmi'" /> + <state id="prompts"> + <transition event="error" target="done"> + <log expr="'An error occured:' + _event" /> + </transition> + + <state id="vxmlPrompt1"> + <!-- Test that rendering a prompt sends start and done events --> + <invoke type="vxml" id="vxml"> + <param name="target" expr="vxmlTargetURL"/> + <content> + <vxml:prompt>Testing start and done events</vxml:prompt> + </content> <finalize> <script>dump(_event);</script> </finalize> - + </invoke> + + <state id="waitForPrompt1Start"> + <transition event="vxml.output.start" target="waitForPrompt1Done"/> + </state> + <state id="waitForPrompt1Done"> + <transition event="vxml.output.done" target="vxmlPrompt2"/> + </state> + </state> + + + <state id="vxmlPrompt2"> + <!-- Test prompts in form with goto --> + <invoke type="vxml" id="vxml"> + <param name="target" expr="vxmlTargetURL"/> <content> - <vxml:vxml version="2.1" xml:lang="en" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schematicLocation="http://www.w3.org/2001/vxml http://www.w3.org/TR/voicexml20/vxml.xsd"> + <vxml:vxml version="2.1"> <vxml:form id="say_hello"> <vxml:block> - Hello World! - <vxml:goto next="#say_goodbye" /> + Testing prompts in form + <vxml:goto next="#say_goodbye"/> </vxml:block> </vxml:form> <vxml:form id="say_goodbye"> <vxml:block> - <vxml:prompt>Goodbye!</vxml:prompt> + <vxml:prompt>with goto</vxml:prompt> </vxml:block> </vxml:form> </vxml:vxml> </content> - </invoke--> + <finalize> + <script>dump(_event);</script> + </finalize> + </invoke> - <!-- <transition event="heartbeat" target="idle" /> --> + <state id="waitForPrompt2HelloStart"> + <transition event="vxml.output.start" target="waitForPrompt2HelloDone"/> + </state> + <state id="waitForPrompt2HelloDone"> + <transition event="vxml.output.done" target="waitForPrompt2ByeStart"/> + </state> + <state id="waitForPrompt2ByeStart"> + <transition event="vxml.output.start" target="waitForPrompt2ByeDone"/> + </state> + <state id="waitForPrompt2ByeDone"> + <transition event="vxml.output.done" target="waitForPrompt2HelloDone"/> + </state> </state> + </state> + + + + <state id="forms"> + <transition event="error" target="done"> + <log expr="'An error occured:' + _event" /> + </transition> + + <invoke type="vxml" id="vxml"> + <param name="target" expr="vxmlTargetURL"/> + <content> + <vxml:vxml version="2.1"> + <vxml:form id="launch_missiles"> + <vxml:field name="user_id" type="digits"> + <vxml:prompt>What is your username</vxml:prompt> + </vxml:field> + <vxml:field name="password"> + <vxml:prompt>What is the code word?</vxml:prompt> + <vxml:grammar version="1.0" root="root"> + <vxml:rule id="root" scope="public">rutabaga</vxml:rule> + </vxml:grammar> + <vxml:help>It is the name of an obscure vegetable.</vxml:help> + <vxml:catch event="nomatch noinput" count="3"> + <vxml:prompt>Security violation!</vxml:prompt> + </vxml:catch> + </vxml:field> + </vxml:form> + </vxml:vxml> + </content> + <finalize> + <script>dump(_event);</script> + </finalize> + </invoke> - <state id="idle"> - <onentry> - <log expr="'Idling!'" /> - </onentry> - - <transition event="heartbeat" target="vxmlHello"> - <log expr="'Foo!'" /> + <state id="waitForMissileEvents"> + <transition event="vxml.input.field.user_id" target="done"> + <log expr="'Welcome ' + _event.data.value + ' please provide credentials!'" /> </transition> + <transition event="vxml.input.field.password" /> </state> - </state> -</scxml>
\ No newline at end of file + + <final id="done" /> +</scxml> |