<?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="false" or exittone="false" are substituted with entertone="'false'" or exittone="'false'"
2) fixed
-->

<!--
Release 1.2 - 2011-03-30
FIXED: 
- added 2s delay to listen exit tone
-->
    <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('110');



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 110
		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 the application produces the sound of a voice in the process of 
		saying "At the tone, say and spell your first name...", the assertion passes.
		Condition for Failure: If the application terminates without making a sound, or if the application makes a beeping sound, the
		assertion fails.
		==================================================================================================================================
		-->
        <transition event="user.START_ASSERTION_110" state="ASSERTION_NMBR_110">
<!--
110
If the exittone value is a URL which points to a user-defined wav file, that wav file will be played instead of the default system beep.
-->      
            <createconference confname="'conf1'" conferenceid="conf_id"/>
		</transition>
		
        <transition event="conference.created" state="ASSERTION_NMBR_110">
            <conf:comment expr="'Event: ' + event$.name"/>	
						<join id1="general_connid" id2="conf_id" entertone="'false'"/>
        </transition>
        
    <transition event="conference.joined" state="ASSERTION_NMBR_110"   cond="join_index == 0">
			<!-- FIXED ISSUE-702 2):  changed exittone="'manual_tests/voice.wav'" into exittone="'voice.wav'" -->
    
			<assign name="join_index" expr="1"/>
      <conf:comment expr="'Event: ' + event$.name"/>	    
			<join id1="general_connid2" id2="conf_id" entertone="'false'" exittone="'voice.wav'"/>
			
		</transition>

    <transition event="conference.joined" state="ASSERTION_NMBR_110"  cond="join_index == 1">
      <conf:comment expr="'Event: ' + event$.name"/>	    
			<send targettype="'ccxml'" target="session.id" name="'user.finish'" delay="'2000ms'"/>
		</transition>

    <!-- wait a little bit before exiting so the audio of the exit tone has a chance to make it to the caller -->
    <transition event="conference.unjoined" state="ASSERTION_NMBR_110">
      <conf:comment expr="'Event: ' + event$.name"/>	
			<send targettype="'ccxml'" target="session.id" name="'user.exit'" delay="'2000ms'"/>
		</transition>
    <transition event="user.exit" state="ASSERTION_NMBR_110">
      <conf:comment expr="'Event: ' + event$.name"/>	
			<conf:uncond_exit expr="'Done with manual test 110'"/>
		</transition>
	
		<transition event="user.finish" state="ASSERTION_NMBR_110">
			<conf:comment expr="'Event: ' + event$.name"/>
      <unjoin id1="general_connid2" id2="conf_id"/>    
        </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>
