<?xml version="1.0" encoding="UTF-8"?>
<ccxml xmlns="http://www.w3.org/2002/09/ccxml" xmlns:conf="http://www.w3.org/2005/ccxml-conformance" version="1.0">
<!--
Release 1.1 - 2010-07-09
FIXED: 
- catch for conference.unjoined event added at bottom (no specific ISSUE)

-->
	<conf:docsetup/>
	
	<var name="general_connid"/>
	
	<var name="A841_dialogid"/>
	<var name="A844_dialogid"/>
	<var name="A844_part_one_passed"/>
	<var name="A845_confid"/>
	<var name="A845_dialogid"/>
	<var name="A845_part_one_passed"/>
	<var name="A848_dialogid"/>
	<var name="A848_timer"/>
	<var name="A849_timer"/>
	<var name="A850_dialogid"/>
	<var name="A850_timer"/>
	
	<script><![CDATA[
	   function GetMilliseconds() {
     var d = new Date();
     return d.getTime();  // ms from midnight on Jan 1, 2000.
   }

var t_start, t_end, t_delay = 2000, t_delta, t_delta_e = 0.05 * t_delay;
		   ]]></script>
	<script><![CDATA[
var i=0;
assertions[i++] = init_assertion('841');
assertions[i++] = init_assertion('844');
assertions[i++] = init_assertion('848');
assertions[i++] = init_assertion('849');
assertions[i++] = init_assertion('850');



//children of 841
add_2_assert_trace('842');
add_2_assert_trace('843');
add_2_assert_trace('847');

//children of 844
add_2_assert_trace('845');

var assert_last = i - 1;
var assert_index = -1;
//
// out of the loop assertions (children?)
//
//
s_ASSERTIONS_LEFT = show_remained_assertions();
var b_in_test = false;


]]></script>
	<eventprocessor statevariable="current_state">
		<conf:setup type="alerting"/>
		<transition event="connection.alerting" state="init">
			<send targettype="'ccxml'" target="session.id" name="'user.timeout'" delay="TEST_LONG_TIMEOUT"/>
			<accept connectionid="event$.connectionid"/>
		</transition>
		<transition event="connection.connected" state="init">
			<assign name="general_connid" expr="event$.connectionid"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		<transition event="user.PREPARE_NEW">
			<conf:comment expr="'Event: ' + event$.name"/>
			<if cond="assert_index &gt;= 0">
				<assign name="ASSERTION_NUM" expr="assertions[assert_index].number"/>
				<assign name="t_ASSERT_RESULT" expr="assertions[assert_index].P_F"/>
				<script>t_ASSERT_REASON = assertions[assert_index].reason</script>
				<if cond="t_ASSERT_RESULT == s_PASS">
					<conf:pass reason="t_ASSERT_REASON"/>
					<elseif cond="t_ASSERT_RESULT == s_FAIL"/>
					<conf:fail reason="t_ASSERT_REASON"/>
					<else/>
					<conf:not_exec reason="t_ASSERT_REASON"/>
				</if>
			</if>
			<assign name="assert_index" expr="assert_index + 1"/>
			<if cond="assert_index &gt; assert_last">
				<log label="s_TA" expr="s_ASSERTIONS_LEFT"/>
				<conf:uncond_exit expr="'DONE'"/>
				<else/>
				<log label="s_TA" expr="s_ASSERTIONS_LEFT"/>
				<assign name="ASSERTION_NUM" expr=" assertions[assert_index].number"/>
				<assign name="t_ASSERT_REASON" expr="''"/>
				<script>assertions[assert_index].P_F = s_FAIL;</script>
				<assign name="current_state" expr="state_prefix + ASSERTION_NUM"/>
				<send targettype="'ccxml'" target="session.id" name="start_name_prefix + ASSERTION_NUM" sendid="cur_event_ID"/>
				<log label="s_TA" expr="'Loop event: SendID=' + cur_event_ID"/>
			</if>
		</transition>




		<transition event="user.START_ASSERTION_841" state="ASSERTION_NMBR_841">
<!--
841  	
Appendix D: VoiceXML 2.0 Integration Details  	
CCXML defines an additional read-only VoiceXML session variable, also populated when the dialog is bridged to a connection, called session.connection.ccxml  	
rachel.muller@aspect.com  	Accepted	
-->
			<var name="foo" expr="'bar'"/>
			<dialogstart src="'A841_dialog.vxml'" dialogid="A841_dialogid" connectionid="general_connid" parameters="foo"/>
		</transition>

		<transition event="dialog.exit" state="ASSERTION_NMBR_841">
			<conf:comment expr="'Event: ' + event$.name"/>
			<if cond="event$.values.session_connection_ccxml != undefined">
				<script>assertions[assert_index].P_F = s_PASS;</script>
			<else/>
				<script>assertions[assert_index].P_F = s_FAIL;
						assertions[assert_index].reason = 'session.connection.ccxml was not defined in the vxml session.';</script>
			</if>
<!--
842  	
Appendix D: VoiceXML 2.0 Integration Details  	
The session.connection.ccxml must have a read-only subproperty called sessionid which evaluates to the CCXML Session ID to which the VoiceXML dialog is currently associated.  	
rachel.muller@aspect.com  	Accepted	
-->			
			<assign name="ASSERTION_NUM" expr="'842'"/>
			<if cond="event$.values.session_connection_ccxml_sessionid == session.id">
				<conf:pass/>
			<else/>
				<conf:fail/>
			</if>
<!--			
843  	
Appendix D: VoiceXML 2.0 Integration Details  	
The session.connection.ccxml must have a read-only subproperty called dialogid which evaluates to the CCXML Dialog ID for the current dialog.  rachel.muller@aspect.com  	Accepted
-->
			<assign name="ASSERTION_NUM" expr="'843'"/>
			<if cond="event$.values.session_connection_ccxml_dialogid == A841_dialogid">
				<conf:pass/>
			<else/>
				<conf:fail/>
			</if>	

<!--
847  	
Appendix D: VoiceXML 2.0 Integration Details  	
The session.connection.ccxml must have a read-only subproperty called values. This associative array contains the names and values of the parameters attribute supplied in a CCXML <dialogprepare> or <dialogstart> invocation.  	
rachel.muller@aspect.com  	Accepted	
-->
			<assign name="ASSERTION_NUM" expr="'847'"/>
			<if cond="event$.values.session_connection_ccxml_values_foo == 'bar'">
				<conf:pass/>
			<else/>
				<conf:fail/>
			</if>
			
			<send name="name_prepare_new" targettype="'ccxml'" target="session.id"/>
		</transition>

		<transition event="user.START_ASSERTION_844" state="ASSERTION_NMBR_844">
<!--
844  	
Appendix D: VoiceXML 2.0 Integration Details  	
The session.connection.ccxml must have a read-only subproperty called connectionid which evaluates to the CCXML Connection ID to which the VoiceXML dialog is currently bridged. This variable is undefined if the dialog is not bridged to a connection.  	
rachel.muller@aspect.com  	Accepted	
-->
			<dialogstart src="'A844_dialog.vxml'" dialogid="A844_dialogid" connectionid="general_connid"/>
		</transition>

		<transition event="dialog.exit" state="ASSERTION_NMBR_844">
			<conf:comment expr="'Event: ' + event$.name"/>
			
			<if cond="event$.values.session_connection_ccxml_connectionid == general_connid">
				<assign name="A844_part_one_passed" expr="true"/>
			<else/>
				<assign name="A844_part_one_passed" expr="false"/>
			</if>
			
			<if cond="event$.values.session_connection_ccxml_conferenceid == undefined">
				<assign name="A845_part_one_passed" expr="true"/> 
			<else/>
				<assign name="A845_part_one_passed" expr="false"/>
			</if>
			
			<assign name="current_state" expr="'ASSERTION_NMBR_844_PART_TWO'"/>
			
			<createconference conferenceid="A845_confid"/>
		</transition>

		<transition event="conference.created" state="ASSERTION_NMBR_844_PART_TWO">
			<conf:comment expr="'Event: ' + event$.name"/>
			<dialogstart src="'A844_dialog.vxml'" dialogid="A845_dialogid" conferenceid="A845_confid"/>
		</transition>

		<transition event="dialog.exit" state="ASSERTION_NMBR_844_PART_TWO">
			<conf:comment expr="'Event: ' + event$.name"/>
			
			<if cond="event$.values.session_connection_ccxml_connectionid == undefined &amp;&amp; A844_part_one_passed">
				<script>assertions[assert_index].P_F = s_PASS;</script>
			<else/>
				<script>assertions[assert_index].P_F = s_FAIL;</script>
			</if>
<!--
845  	
Appendix D: VoiceXML 2.0 Integration Details  	
The session.connection.ccxml must have a read-only subproperty called conferenceid which evaluates to the CCXML Conference ID to which the VoiceXML dialog is currently bridged. This variable is undefined if the dialog is not bridged to a conference.  	
rachel.muller@aspect.com  	Accepted
-->			
			<assign name="ASSERTION_NUM" expr="'845'"/>

			<if cond="event$.values.session_connection_ccxml_conferenceid == A845_confid &amp;&amp; A845_part_one_passed">
				<conf:pass/>
			<else/>
				<conf:fail/>
			</if>
			
			<send name="name_prepare_new" targettype="'ccxml'" target="session.id"/>
		</transition>

		<transition event="user.START_ASSERTION_848" state="ASSERTION_NMBR_848">
<!--
848  	
Appendix D: VoiceXML 2.0 Integration Details  	
When a CCXML application processes a <dialogterminate> it causes a "connection.disconnect.hangup" event to be thrown to the VoiceXML application.  	
rachel.muller@aspect.com  	Accepted
-->
			<dialogstart src="'A848_dialog.vxml'" dialogid="A848_dialogid" connectionid="general_connid"/>
		</transition>
		
		<transition event="dialog.started" state="ASSERTION_NMBR_848">
			<conf:comment expr="'Event: ' + event$.name"/>
			<send name="'user.fail_A848'" targettype="'ccxml'" target="session.id" delay="'5s'" sendid="A848_timer"/>	
			<dialogterminate dialogid="A848_dialogid"/>
		</transition>
		
		<transition event="dialog.exit" state="ASSERTION_NMBR_848">
			<conf:comment expr="'Event: ' + event$.name"/>
			<cancel sendid="A848_timer"/>
			<if cond="event$.values.A848_pass_fail=='pass'">
				<script>assertions[assert_index].P_F = s_PASS;</script>
			<else/>
				<script>assertions[assert_index].P_F = s_FAIL;
						assertions[assert_index].reason = 'dialogterminate element did not correctly send a connection.disconnect.hangup event to the target vxml session.';</script>
			</if>
			<send name="name_prepare_new" targettype="'ccxml'" target="session.id"/>
		</transition>
		
		<transition event="user.fail_A848">
			<conf:comment expr="'Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_FAIL;
					assertions[assert_index].reason = 'dialog did not exit when terminated with a dialogterminate element.';</script>
			<send name="name_prepare_new" targettype="'ccxml'" target="session.id"/>
		</transition>
		
		<transition event="user.START_ASSERTION_849" state="ASSERTION_NMBR_849">
<!--
849  	
Appendix D: VoiceXML 2.0 Integration Details  	
When a VoiceXML application processes a VoiceXML <exit> it will cause the VoiceXML application to exit and return the contents of the namelist attribute to the CCXML application in the "dialog.exit" event.  	rachel.muller@aspect.com  	Accepted	
-->

			<send name="'user.fail_A849'" targettype="'ccxml'" target="session.id" delay="'5s'" sendid="A849_timer"/>
			<dialogstart src="'A849_dialog.vxml'" connectionid="general_connid"/>
		</transition>
		
		<transition event="dialog.exit" state="ASSERTION_NMBR_849">
			<conf:comment expr="'Event: ' + event$.name"/>
			<cancel sendid="A849_timer"/>
			<if cond="event$.values.A849_pass_fail=='pass'">
				<script>assertions[assert_index].P_F = s_PASS;</script>
			<else/>
				<script>assertions[assert_index].P_F = s_FAIL;
						assertions[assert_index].reason = 'dialog did not send namelist values to parent session when exiting.';</script>
			</if>
			<send name="name_prepare_new" targettype="'ccxml'" target="session.id"/>
		</transition>

		<transition event="user.fail_A849" state="ASSERTION_NMBR_849">
			<conf:comment expr="'Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_FAIL;
					assertions[assert_index].reason = 'dialog did not exit when it got to an exit element.';</script>
			<send name="name_prepare_new" targettype="'ccxml'" target="session.id"/>
		</transition>
		
		<transition event="user.START_ASSERTION_850" state="ASSERTION_NMBR_850">
<!--
850  	
Appendix D: VoiceXML 2.0 Integration Details  	
When the VoiceXML application processes a <disconnect> element it causes a "dialog.disconnect" event to be thrown in the CCXML application. It is then up to the CCXML application to disconnect the call and send back a "connection.disconnect.hangup" event by using the <dialogterminate> element.  	
rachel.muller@aspect.com  	Accepted
-->
			
			<send name="'user.fail_A850'" targettype="'ccxml'" target="session.id" delay="'5s'" sendid="A850_timer"/>
			<dialogstart src="'A850_dialog.vxml'" dialogid="A850_dialogid" connectionid="general_connid"/>
		</transition>
		
		<transition event="dialog.disconnect" state="ASSERTION_NMBR_850">
			<dialogterminate dialogid="A850_dialogid"/>
		</transition>
		
		<transition event="dialog.exit" state="ASSERTION_NMBR_850">
			<cancel sendid="A850_timer"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send name="name_prepare_new" targettype="'ccxml'" target="session.id"/>
		</transition>
		
		<transition event="user.fail_850" state="ASSERTION_NMBR_850">
			<script>assertions[assert_index].P_F = s_FAIL;
					assertions[assert_index].reason = 'dialog did not handle a disconnect exchange with the parent CCXML session correctly';</script>
			<send name="name_prepare_new" targettype="'ccxml'" target="session.id"/>		
		</transition>
		


<!-- ============================================================ All-purpose handlers ============================================================ -->

		<transition event="conference.unjoined">
			<conf:comment expr="'Event: ' + event$.name"/>
		</transition>
		
		<transition event="dialog.exit">
			<conf:comment expr="'Event: ' + event$.name"/>
		</transition>

		<transition event="">
			<conf:comment expr="'Event: ' + event$.name"/>
		</transition>

		<transition event="cancel.successful">
			<conf:comment expr="'Event: ' + event$.name"/>
		</transition>

		<transition event="dialog.started">
			<conf:comment expr="'Event: ' + event$.name"/>
		</transition>
		
		<transition event="user.timeout">
			<assign name="current_state" expr="'GEN'"/>
			<conf:uncond_exit expr="'TEST-TIMEOUT.' + show_remained_assertions()"/>
		</transition>
		
		<transition event="send.successful">
			<conf:comment expr="'Event: ' + event$.name + ' (generic handler) state=' + current_state"/>
		</transition>
		
		<transition event="*">
			<assign name="t_ASSERT_REASON" expr="'UNEXPECTED EVENT ' + event$.name + ' IN STATE ' + current_state"/>
			<conf:comment expr="t_ASSERT_REASON"/>
			<if cond="current_state == 'init'">
				<conf:uncond_exit expr="'Did not come out from init state.'"/>
				<else/>
				<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
			</if>
		</transition>
	</eventprocessor>
</ccxml>
