<?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">
<!--
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="loadedReceived" expr="false"/>
 	

	<script><![CDATA[
		var i=0;
		
		assertions[i++] = init_assertion('704');		
		assertions[i++] = init_assertion('655');		
			
				
		var assert_last = i - 1;
		var assert_index = -1;
		//
		// out of the loop assertions (children)

		// Children of ccxml.loaded
		add_2_assert_trace('656');		
		add_2_assert_trace('705');
		add_2_assert_trace('707');
		add_2_assert_trace('709');
		add_2_assert_trace('651');
		add_2_assert_trace('654');

		// children of 704
		add_2_assert_trace('702');
		add_2_assert_trace('599');


		
		s_ASSERTIONS_LEFT = show_remained_assertions();
		var b_in_test = false;
	]]></script>
	
	
	<eventprocessor statevariable="current_state">
		<conf:setup type="noconnection"/>

		<transition event="ccxml.loaded" state="init">
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event.toSource(): ' + event$.toSource()"/>			

			<assign name="ASSERTION_NUM" expr="'656'"/>		
			<conf:comment expr="'application.var656=' + application.var656 "/>
			
			<if cond="application.var656 == 'ok656'">				
				<conf:pass/>
			<else/>
				<conf:fail/>
			</if>			

			<assign name="ASSERTION_NUM" expr="'705'"/>		
			<if cond="loadedReceived != undefined">				
				<conf:pass/>
			<else/>
				<conf:fail/>
			</if>
			
			<assign name="ASSERTION_NUM" expr="'707'"/>		
			<if cond="event$.sessionid == session.id">				
				<conf:pass/>
			<else/>
				<conf:fail/>
			</if>

			<assign name="ASSERTION_NUM" expr="'709'"/>		
			
			<if cond="event$.parent == undefined">				
				<conf:pass/>
			<else/>
				<conf:fail/>
			</if>

			<assign name="ASSERTION_NUM" expr="'651'"/>		
			<conf:pass/>

			<assign name="ASSERTION_NUM" expr="'654'"/>		
			
			<if cond="application.oldsessID == session.id">				
				<conf:pass/>
			<else/>
				<conf:fail/>
			</if>

						
			<assign name="loadedReceived" expr="true"/>			
			<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>

    	      			

		<transition event="user.START_ASSERTION_704" state="ASSERTION_NMBR_704">		
			<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>	
		
			<if cond="loadedReceived == true">
			 	<script>assertions[assert_index].P_F = s_PASS;</script>			
				
				<!-- Begin Related Tests -->
				<assign name="ASSERTION_NUM" expr="'702'"/>		
				<conf:pass/>
				
				<assign name="ASSERTION_NUM" expr="'599'"/>		
				<conf:pass/>
			 	<!-- End Related Tests -->
			 	
			<else/>
			 	<script>assertions[assert_index].P_F = s_FAIL;</script>						
			 	
				<!-- Begin Related Tests -->
				<assign name="ASSERTION_NUM" expr="'702'"/>		
				<conf:fail/>
				
				<assign name="ASSERTION_NUM" expr="'599'"/>		
				<conf:fail/>
			 	<!-- End Related Tests -->
			 	
			</if>

			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
    	  		    	
    </transition>

		<transition event="user.START_ASSERTION_655" state="ASSERTION_NMBR_655">		
  		<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>	
			<send target="session.id" name="'stop_655'" delay="'15s'"/>
    </transition>

		<transition event="goto_655" state="ASSERTION_NMBR_655">		
  		<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="stop_655" state="ASSERTION_NMBR_655">		
  		<conf:comment expr=" 'Current state : ' + current_state + ' , Event: ' + event$.name"/>	
		 	<script>assertions[assert_index].P_F = s_FAIL;</script>						  		
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
    </transition>


    
	<!--  ***************** COMMON ******************************** -->
		<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>
