<?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: 
- reason added to ccxml.kill.* TAs 666, 667(no specific ISSUE)

-->
	<!--
Serguei's infrastructure performs a loop on the 'assertions' Ecma array, based on "name_prepare_new" event for doing the "loop".

Mainly we have to different levels of assertions: 

- Main assertions, stored in 'assertions' array
- Children assertions, stored into 'assert_trace'

An assertion is a child assertion if it does not need to perform any action, but it is sufficient to test its father assertion result to determine if it passes or fails.

The test finishes when all the main assertions have been tested. Children assertions are tested after the father itself.

If an unexpected event is caught by the <transition event"*"/> a comment is printed and the loop continues with the next iteration.

An hang up event causes the interruption of test: session exits.

All the send.successful events are caught and ignored (they are generated by the loop mechanism).
-->
	<conf:docsetup/>
	<var name="DialogID" expr="undefined"/>
	<var name="ConferenceID" expr="undefined"/>
	<var name="ConnectionID" expr="undefined"/>
	<var name="childSessionId" expr="undefined"/>
	<var name="mySendId" expr="undefined"/> 
 
	<var name="var666_1" expr="1"/>  
	<var name="var666_2" expr="'hallo'"/>  
	<var name="var666_3" expr="100 + 100"/>  
	
	<var name="ecmaNumber" expr="3"/>  
	<var name="ecmaString" expr="'Happy Birthday'"/>  
	
	<script><![CDATA[
		var i=0;
		assertions[i++] = init_assertion('666');
		assertions[i++] = init_assertion('667');
		assertions[i++] = init_assertion('670');
		
		assertions[i++] = init_assertion('1160');
		assertions[i++] = init_assertion('1161');
		assertions[i++] = init_assertion('1162');
		
		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="connected"/>
		<transition event="connection.connected" state="init">
			<assign name="ConnectionID" expr="event$.connectionid"/>
			<send targettype="'ccxml'" target="session.id" name="'user.timeout'" delay="TEST_LONG_TIMEOUT"/>
			<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>assertions[assert_index].reason = t_ASSERT_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"/>
			</if>
		</transition>

<!--
666.
The namelist attribute is optional. A list of zero or more whitespace separated CCXML variable names. These variables must be submitted to the server, with the same qualification as used in the namelist. When an ECMAscript variable is submitted to the server, its value must be first converted into a string before being submitted.
-->
		<transition event="user.START_ASSERTION_666" state="ASSERTION_NMBR_666">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<createccxml next="'cgi-bin/666.ircgi'" sessionid="childSessionId" namelist="var666_1 var666_2 var666_3"/>
		</transition>
		<transition event="ccxml.created" state="ASSERTION_NMBR_666">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
		</transition>

		<transition event="ccxml.PASSFromChildEvent" state="ASSERTION_NMBR_666">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<!--We dont need child session anymore -->
			<send target="session.id" targettype="'ccxml'" name="'ccxml.UnconditionallyKillChildSession'" sendid="mySendId"/>
		</transition>
				
		<transition event="ccxml.FAILFromChildEvent" state="ASSERTION_NMBR_666">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="t_ASSERT_REASON" expr="'FAIL on namelist submitted on child session in ' +  event$.name + ' event , STATE ' + current_state"/>
			<script>
				assertions[assert_index].P_F = s_FAIL;
				assertions[assert_index].reason = t_ASSERT_REASON;  
			</script>
			<!-- We dont need child session anymore -->
			<send target="session.id" targettype="'ccxml'" name="'ccxml.UnconditionallyKillChildSession'" sendid="mySendId"/>
		</transition>
		
		<transition event="ccxml.exit" state="ASSERTION_NMBR_666">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>	


<!--
The method attribute is optional. It is An ECMAScript expression which returns a character string that indicates the HTTP method to use.
-->
		<!-- TA 667 on method attribute of createccxml element -->
		<transition event="user.START_ASSERTION_667" state="ASSERTION_NMBR_667">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<createccxml next="'cgi-bin/667.ircgi'" sessionid="childSessionId" method="'get'"/>
		</transition>

		<transition event="ccxml.created" state="ASSERTION_NMBR_667">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
		</transition>
		
		<transition event="ccxml.PASSFromChildEvent" state="ASSERTION_NMBR_667">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<!--We dont need child session anymore -->
			<send target="session.id" targettype="'ccxml'" name="'ccxml.UnconditionallyKillChildSession'" sendid="mySendId"/>
		</transition>
				
		<transition event="ccxml.FAILFromChildEvent" state="ASSERTION_NMBR_667">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="t_ASSERT_REASON" expr="'FAIL on method set on child session in ' +  event$.name + ' event , STATE ' + current_state"/>
			<script>
				assertions[assert_index].P_F = s_FAIL;
				assertions[assert_index].reason = t_ASSERT_REASON;  
			</script>
			<!-- We dont need child session anymore -->
			<send target="session.id" targettype="'ccxml'" name="'ccxml.UnconditionallyKillChildSession'" sendid="mySendId"/>
		</transition>

		<transition event="ccxml.exit" state="ASSERTION_NMBR_667">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>	
				
		<!-- Shared by Ta 666 and TA 667-->		
		<transition event="ccxml.UnconditionallyKillChildSession">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name + ', so now kill the child session '"/>
			<!-- FIXED: reason added to ccxml.kill.*  -->
			<var name="reason" expr="'kill done'"/>
			<send target="childSessionId" targettype="'ccxml'" name="'ccxml.kill.unconditional'" sendid="mySendId" namelist="reason"/>
		</transition>
		
<!-- 
670.
The timeout attribute is optional. It is an ECMAScript expression. The character string returned must be interpreted as a time interval. This time interval must be interpreted by the new CCXML session as the maximum time it may wait for the completion of the fetch for the initial document specified by the next attribute. If the new CCXML session is unable to fetch the initial document within the timeout interval, an error.createccxml event must be thrown
-->
		<transition event="user.START_ASSERTION_670" state="ASSERTION_NMBR_670">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<createccxml next="'cgi-bin/670.ircgi'" sessionid="childSessionId" timeout="'5s'"/>
		</transition>
		
		<transition event="error.createccxml" state="ASSERTION_NMBR_670">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		
		<transition event="ccxml.created" state="ASSERTION_NMBR_670">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="t_ASSERT_REASON" expr="'FAIL on timeout set on child session in ' +  event$.name + ' event , STATE ' + current_state"/>
			<script>
				assertions[assert_index].P_F = s_FAIL;
				assertions[assert_index].reason = t_ASSERT_REASON;  
			</script>
			<!-- We dont need child session so we kill it  -->
			<send target="session.id" targettype="'ccxml'" name="'ccxml.UnconditionallyKillChildSession'" sendid="mySendId"/>
		</transition>
		
		<transition event="ccxml.exit" state="ASSERTION_NMBR_670">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>	
		
		
<!-- 
1160.
If the value of the fetchparam attribute is 'none', then no additional parameters may be passed with the fetch
-->
		<transition event="user.START_ASSERTION_1160" state="ASSERTION_NMBR_1160">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<createccxml next="'cgi-bin/1160.ircgi'" sessionid="childSessionId" fetchparam="'none'" parameters="ecmaNumber ecmaString"/>
		</transition>
		
		<transition event="ccxml.created" state="ASSERTION_NMBR_1160">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
		</transition>
		
		<transition event="ccxml.PASSFromChildEvent" state="ASSERTION_NMBR_1160">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<!--We dont need child session anymore -->
			<send target="session.id" targettype="'ccxml'" name="'ccxml.UnconditionallyKillChildSession'" sendid="mySendId"/>
		</transition>
				
		<transition event="ccxml.FAILFromChildEvent" state="ASSERTION_NMBR_1160">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="t_ASSERT_REASON" expr="'FAIL because no parameters must be sent to the child session, ' +  event$.name + ' event , STATE ' + current_state"/>
			<script>
				assertions[assert_index].P_F = s_FAIL;
				assertions[assert_index].reason = t_ASSERT_REASON;  
			</script>
			<!-- We dont need child session anymore -->
			<send target="session.id" targettype="'ccxml'" name="'ccxml.UnconditionallyKillChildSession'" sendid="mySendId"/>
		</transition>
			
		<transition event="ccxml.exit" state="ASSERTION_NMBR_1160">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>	

<!-- 
1161.
If the value of the fetch param attribute is 'session.id', then the 'session.id' property of the newly created session must be included when fetching the initial document
-->
		<transition event="user.START_ASSERTION_1161" state="ASSERTION_NMBR_1161">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<createccxml next="'cgi-bin/1161.ircgi'" sessionid="childSessionId" fetchparam="'session-id'" parameters="ecmaNumber ecmaString"/>
		</transition>
		
		<transition event="ccxml.created" state="ASSERTION_NMBR_1161">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
		</transition>
		
		<transition event="ccxml.PASSFromChildEvent" state="ASSERTION_NMBR_1161">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<!--We dont need child session anymore -->
			<send target="session.id" targettype="'ccxml'" name="'ccxml.UnconditionallyKillChildSession'" sendid="mySendId"/>
		</transition>
				
		<transition event="ccxml.FAILFromChildEvent" state="ASSERTION_NMBR_1161">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="t_ASSERT_REASON" expr="'FAIL because ONLY session.id parameter must be sent to the child session, ' +  event$.name + ' event , STATE ' + current_state"/>
			<script>
				assertions[assert_index].P_F = s_FAIL;
				assertions[assert_index].reason = t_ASSERT_REASON;  
			</script>
			<!-- We dont need child session anymore -->
			<send target="session.id" targettype="'ccxml'" name="'ccxml.UnconditionallyKillChildSession'" sendid="mySendId"/>
		</transition>
			
		<transition event="ccxml.exit" state="ASSERTION_NMBR_1161">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>	

<!-- 
1162.
If the value of the fetchparam attribute is 'session', then the 'session.id' property and all properties of 'session.values' will be included when fetching the initial document.
-->
		<transition event="user.START_ASSERTION_1162" state="ASSERTION_NMBR_1162">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<createccxml next="'cgi-bin/1162.ircgi'" sessionid="childSessionId" fetchparam="'session'" parameters="ecmaNumber ecmaString"/>
		</transition>
		
		<transition event="ccxml.created" state="ASSERTION_NMBR_1162">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
		</transition>
		
		<transition event="ccxml.PASSFromChildEvent" state="ASSERTION_NMBR_1162">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<!--We dont need child session anymore -->
			<send target="session.id" targettype="'ccxml'" name="'ccxml.UnconditionallyKillChildSession'" sendid="mySendId"/>
		</transition>
				
		<transition event="ccxml.FAILFromChildEvent" state="ASSERTION_NMBR_1162">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<assign name="t_ASSERT_REASON" expr="'FAIL because both session.id and session.values must be sent to the child session, ' +  event$.name + ' event , STATE ' + current_state"/>
			<script>
				assertions[assert_index].P_F = s_FAIL;
				assertions[assert_index].reason = t_ASSERT_REASON;  
			</script>
			<!-- We dont need child session anymore -->
			<send target="session.id" targettype="'ccxml'" name="'ccxml.UnconditionallyKillChildSession'" sendid="mySendId"/>
		</transition>
			
		<transition event="ccxml.exit" state="ASSERTION_NMBR_1162">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>	

	
		<!-- Safety timeout -->					
		 <transition event="user.timeout">
			<assign name="current_state" expr="'GEN'"/>
			<conf:uncond_exit expr="'TEST-TIMEOUT.' + show_remained_assertions()"/>
        </transition>
        
		<transition event="send.successful">
		</transition>
		<transition event="connection.disconnected">
			<conf:uncond_exit expr="'CONNECTION-DISCONNECTED'"/>
		</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>
