<?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-06-09
FIXED: 
ISSUE-702: 
1) all occurrencies of entertone or exittone ="false" or "true" are substituted with "'false'" or "'true'"
-->

    <conf:docsetup/>
    <var name="chld_reason"/>

  <var name="general_connid"/>
	<var name="general_connid2"/>
  <var name="conf_id"/>
  <var name="join_index" expr="0"/>
    <script>
	   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>

var i=0;
assertions[i++] = init_assertion('101');

// 
//add_2_assert_trace('101');


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"/>
			<assign name="current_state" expr="'setup'"/>
			<createcall dest="TEST_CREATECALL_DEST_ANSWER_AND_STAY_ACTIVE[2]" connectionid="general_connid2"/>
		</transition>	
		
		<transition event="connection.connected" state="setup">
            <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 >= 0">
                <assign name="ASSERTION_NUM" expr="assertions[assert_index].number"/>
            </if>
            <assign name="assert_index" expr="assert_index + 1"/>
            <if cond="assert_index > 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>

        <!--
		==================================================================================================================================
		Manual Test: Assertion 101
		To run: Use the jumbo_tests XSLT stylesheet to transform this test file into a CCXML document, and then run the CCXML.
		Condition for Success: If you hear a beep over the connection, the assertion passes.
		Condition for Failure: If the application terminates and you haven't heard a beep, the assertion fails.
		==================================================================================================================================
		-->
        <transition event="user.START_ASSERTION_101" state="ASSERTION_NMBR_101">
<!--
101  	
10.5.7.2  	
The default value of entertone is "true"
-->      
            <createconference confname="'conf1'" conferenceid="conf_id"/>
		</transition>
		
        <transition event="conference.created" state="ASSERTION_NMBR_101">
            <conf:comment expr="'Event: ' + event$.name"/>	
						<join id1="general_connid" id2="conf_id" entertone="'false'"/>
        </transition>
        
 <transition event="conference.joined" state="ASSERTION_NMBR_101" cond="join_index == 0">
			<assign name="join_index" expr="1"/>
			<conf:comment expr="'Event: ' + event$.name"/>	    
			<join id1="general_connid2" id2="conf_id" exittone="'false'"/>
		</transition>

    <transition event="conference.joined" state="ASSERTION_NMBR_101"  cond="join_index == 1">

      <conf:comment expr="'Event: ' + event$.name"/>	    
			<send targettype="'ccxml'" target="session.id" name="'user.finish'" delay="'2000ms'"/>
		</transition>
	
		<transition event="user.finish" state="ASSERTION_NMBR_101">
			<conf:comment expr="'Event: ' + event$.name"/>
			<conf:uncond_exit expr="'Done with manual test 101'"/>
        </transition>
<!--======================================================== All-purpose handlers ========================================================-->		
		<transition event="connection.alerting">
    		<conf:comment expr="'Event: ' + event$.name"/>
		</transition>
		
		<transition event="connection.progressing">
    		<conf:comment expr="'Event: ' + event$.name"/>
		</transition>
		

        <transition event="conference.destroyed">
            <conf:comment expr="'Event: ' + event$.name"/>
        </transition>

        <transition event="conference.unjoined">
            <conf:comment expr="'Event: ' + event$.name"/>
        </transition>

        <transition event="error.conference.destroy">
            <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="cancel.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 + ' : ' + event$.reason"/>
            <if cond="current_state == 'init'">
                <conf:uncond_exit expr="'Did not come out from init state.'"/>
                <else/>
                <if cond="current_state != 'GEN'">
                    <send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
                </if>
            </if>
        </transition>
    </eventprocessor>
    
</ccxml>
