<?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-05
FIXED:
ISSUE-677: TA 798 

-->
	
	<conf:docsetup/>	
	<var name="assert_799_appObjType" expr="typeof(application)"/>
	<var name="chld_reason"/>
	<var name="send_id_1"/>
	<var name="cur_event_ID"/>
	<script><![CDATA[
	   function GetMilliseconds() {
     var d = new Date();
     return d.getTime();  // ms from midnight on Jan 1, 2000.application)"/>

   }

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('795');
assertions[i++] = init_assertion('798');
assertions[i++] = init_assertion('1035');

add_2_assert_trace('795');
add_2_assert_trace('796');
add_2_assert_trace('797');
// add_2_assert_trace('798');
add_2_assert_trace('799');
add_2_assert_trace('1035');

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>
	<var name="i_798" expr="0"/>
	<var name="r_798" expr="''"/>
	<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">
			<conf:comment expr="'Event: ' + event$.name"/>
			<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">
				<!-- 800 	
8.4 Application Variables 	Application variables are visible within all documents which form the CCXML application. 	emily.candell@comverse.com 	Accepted 	
-->
				<log label="s_TA" expr="'Testing assertion 800, moving to another file...'"/>
				<assign name="application.signal" expr="'set'"/>
				<!--This needs to be the last thing executed; after the goto, control will not return to this file. -->
				<fetch next="'8_4_A_800.ccxml'" type="'application/ccxml+xml'"/>
				<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_795" state="ASSERTION_NMBR_795">
			<conf:comment expr="'Event: ' + event$.name"/>
<!--
795 	
8.4 Application Variables 	
Application variables can be modified by CCXML programs. 	emily.candell@comverse.com 	Accepted 	
-->
			<assign name="application.userid" expr="'modified'"/>
			<if cond="application.userid=='modified'">
				<script>assertions[assert_index].P_F = s_PASS;</script>
				<conf:pass/>
				<else/>
				<script>
			assertions[assert_index].P_F = s_FAIL;
			assertions[assert_index].reason = 'assigned value of application variable=' + application.assert_795 + ' expected=modified';
			 </script> 
			</if>

<!--			
796 	
8.4 Application Variables 	
Application variables that are properties of the application object are not explicitly declared. 	emily.candell@comverse.com 	Accepted 		
-->					
			<assign name="ASSERTION_NUM" expr="'796'"/>
			<assign name="application.anything" expr="'42'"/>
			<if cond="typeof application.anything != 'undefined'">
				<conf:pass/>
				<else/>
				<assign name="chld_reason" expr="'application.anything was set to a value without being declared, but still had a type of undefined.'"/>
				<conf:fail reason="chld_reason"/>
			</if>
			
<!--
797 	
8.4 Application Variables 	
By default, application variables have the value ECMAScript undefined. 	emily.candell@comverse.com 	Accepted 	-->

			
			<assign name="ASSERTION_NUM" expr="'797'"/>			
			<if cond="application.nonExistent == undefined">				
				<conf:pass/>
				<else/>
				<assign name="chld_reason" expr="'Unassigned variable application.nonExistent != undefined.'"/>
				<conf:fail reason="chld_reason"/>
			</if>




<!--
799 	
8.4 Application Variables 	
The application object is initialized by the CCXML implementation 	emily.candell@comverse.com 	Accepted
-->			

			<assign name="ASSERTION_NUM" expr="'799'"/>
			<if cond="assert_799_appObjType == 'object'">
				<conf:pass/>
				<else/>
				<assign name="chld_reason" expr="'Application Object was not initialized by CCMXML app.'"/>
				<conf:fail reason="chld_reason"/>
			</if>

			<assign name="current_state" expr="'GEN'"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
<!--
798 	
8.4 Application Variables 	
Variables in the application scope are subject to the parent scope chain delegation model and have session as their parent scope. 
-->		
    <transition event="user.START_ASSERTION_798" state="ASSERTION_NMBR_798">
			<conf:comment expr="'Event: ' + event$.name"/>
			<!-- FIXED ISSUE-677:  test assertion structure changed -->
		<script>
			assertions[assert_index].P_F = s_FAIL;
			assertions[assert_index].reason = 'Unknown: check for errors.';
		</script>
			<conf:comment expr="'id  resolved to  session.id=' + id"/>

		<if cond="id != session.id">
			<assign name="i_798" expr="i_798 + 1"/>
			<assign name="r_798" expr="r_798 + ' id was not resolved to session.id variable '"/>	
		</if>
		<send targettype="'ccxml'" target="session.id" name="'user.START_ASSERTION_798_a'"/>
	</transition>
    <transition event="user.START_ASSERTION_798_a" state="ASSERTION_NMBR_798">
		<conf:comment expr="'Event: ' + event$.name"/>
 		<assign name="application.id" expr="'1'"/>
		<conf:comment expr="'id  resolved to  application.id=' + id"/>
		<if cond="id != '1'">
			<assign name="i_798" expr="i_798 + 1"/>
			<assign name="r_798" expr="r_798 + ' id was not resolved to application.id variable.'"/>	
		</if>
		<send targettype="'ccxml'" target="session.id" name="'user.START_ASSERTION_798_b'"/>
	</transition>
    <transition event="user.START_ASSERTION_798_b" state="ASSERTION_NMBR_798">
		<conf:comment expr="'Event: ' + event$.name"/>
		<var name="id" expr="'2'"/>
		<conf:comment expr="'id  resolved to  transition.id=' + id"/>
		<if cond="id!='2'">	
			<assign name="i_798" expr="i_798 + 1"/>
			<assign name="r_798" expr="r_798 + ' id was not resolved to transition.id variable.'"/>	
		</if>
		<if cond="i_798==0">	
			<script>
				assertions[assert_index].P_F = s_PASS;
				assertions[assert_index].reason = '';
			</script>		
			<else/>
			<script>
			assertions[assert_index].P_F = s_FAIL;
			assertions[assert_index].reason = r_798;
			</script>
		</if>
		
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>

	</transition>
		
    <transition event="user.START_ASSERTION_1035" state="ASSERTION_NMBR_1035">
<!--
1035 	
8_4_A_800
8.4 Application Variables 	Application variables that are not properties, e.g. objects, must be declared 	emily.candell@comverse.com 	Accepted 	
-->
			<conf:comment expr="'Event: ' + event$.name"/>
			<assign name="application.invalid.string" expr="'a_string'"/>
			<send targettype="'ccxml'" target="session.id" name="'user.1035_failed'"/>
		</transition>
		
		<transition event="error.semantic" state="ASSERTION_NMBR_1035">
			<conf:comment expr="'Event: ' + event$.name"/>
			<script>assertions[assert_index].P_F = s_PASS;</script>
			<assign name="current_state" expr="'GEN'"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</transition>
		
		<transition event="user.1035_failed" state="ASSERTION_NMBR_1035">
			<conf:comment expr="'Event: ' + event$.name"/>
			<script>
			assertions[assert_index].P_F = s_FAIL;
			assertions[assert_index].reason = 'error.semantic should have been thrown.';
			 </script>
			<assign name="current_state" expr="'GEN'"/>
			<send targettype="'ccxml'" target="session.id" name="name_prepare_new"/>
		</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>
		<!-- transfers to a separate test file for assertions 800 and 1177 -->
		<transition event="fetch.done">
			<conf:comment expr="'Event: ' + event$.name"/>
			<goto fetchid="event$.fetchid"/> 
		</transition>
		<transition event="*">
			<assign name="t_ASSERT_REASON" expr="'UNEXPECTED EVENT ' + event$.name + ' IN STATE ' + current_state"/>
			<conf:comment expr="t_ASSERT_REASON"/>
			<conf:uncond_exit/>
			<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>
