Commit dc65d650 authored by schulzs's avatar schulzs
Browse files

No commit message

No commit message
parent 1951943a
Loading
Loading
Loading
Loading
+201 −0
Original line number Diff line number Diff line
/**
 *	@author 	STF 370
 *  @version    $Id: $
 *	@desc		This module provides common functions which describes behavior for each TP reference.
 */
module AtsImsIot_Behavior {
	
	import from LibIot_TypesAndValues {
		type DefaultList, SipMessageList, SipMessage; 
	}
	import from LibIot_Templates {
		template all;
	}
	import from LibIot_TestInterface {
		type TestCoordinator, InterfaceMonitor; 
	}

	import from LibSip_SIPTypesAndValues {type Request, Response;}
	
	import from LibSip_Templates {
		template mw_ACK_Request_Base,
			mw_INVITE_Request_Base,
			mw_MESSAGE_Request_Base,
			mw_NOTIFY_Request_Base,
			mw_REGISTER_Request_Base,
			mw_SUBSCRIBE_Request_Base,
			mw_Response_Base;
	}
	
	//TODO move group to Function module
	group general_td_functions {
		/**
         * @desc Receive the expected messages on the interfaces.
         * @param p_passCriteria Expected massages which leads to pass
         * @param p_failCriteria Expected message which leads to fail
         * @param p_tpId The Test Purpose ID
         * @param p_msgCount Indicate how many messages should be irgnored
         * @param p_forword Indicate if the received message should be forwarded to the MTC
         */     
        function f_receive( 
          in template SipMessageList p_passCriteria,
          in template SipMessageList p_failCriteria,
          in charstring p_tpId,
          in charstring p_log,
          in integer p_msgCount,
          in boolean p_forward
        ) runs on InterfaceMonitor {
            var integer v_size := sizeof(valueof(p_failCriteria));
            var DefaultList v_defaultArray;

            v_defaultArray[0] := activate(a_default(p_tpId));
            f_activateDefaults(v_defaultArray, 1, p_failCriteria, fail, p_tpId, p_log, p_forward);
            f_activateDefaults(v_defaultArray, v_size + 1, p_passCriteria, pass, p_tpId, p_log, p_forward);
            
			tc_wait.start;
            
            alt {
            	// preamble (consume prior messesages)
            	[p_msgCount > 0] mPort.receive {
            		p_msgCount := p_msgCount - 1;
            		log("***f_Mw_recieve: message skipped****");
            		repeat;
            	}
	            [] tc_wait.timeout {
	                setverdict(fail, self, "***" & p_tpId & ": timer expired. " & p_log & " not received***"); 
	            }
            }
            
            for (var integer i := 0; i < sizeof(v_defaultArray); i := i + 1) {
                deactivate(v_defaultArray[i]);
            }
        }
        
		/**
		* @desc Activate alternatives for the interfaces.
		* @param p_default Record of alternatives.
		* @param p_startIdx Start index where alternatives should be added
		* @param p_list Message List to add
		* @param p_verdict expected verdict
		* @param p_tpId Test Purpose ID
		* @param p_forward Indicate if the recieved message should be forwarded to MTC
		*/
		function f_activateDefaults(
			inout DefaultList p_default,
			in integer p_startIdx,
			in template SipMessageList p_list,
			in verdicttype p_verdict,
			in charstring p_tpId,
			in charstring p_log,
			in boolean p_forward
		) runs on InterfaceMonitor {
			var integer v_size := sizeof(valueof(p_list));
			var integer v_idx := p_startIdx;

			for (var integer i := 0; i < v_size; i := i + 1) {
				if (ischosen(p_list[i].request)) {
					p_default[v_idx] := activate(
						a_receive_request(p_list[i].request,p_verdict, p_tpId, p_log, p_forward)
					);
				} else {
					p_default[v_idx] := activate(
						a_receive_response(p_list[i].response,p_verdict, p_tpId, p_log, p_forward)
					);
				}
				v_idx := v_idx + 1;
			}
		}
        
	}//end group
		
	group altsteps {
		
		altstep a_default(in charstring p_TP) runs on InterfaceMonitor {
			[] mPort.receive {
				log(self, "***" & p_TP & ": message received");
				repeat; 
			}
		}
        
		/**
		* @desc Receiving SIP request alternative for interfaces.
		* @param p_message the SIP repsonse
		* @param p_verdict the expected verdict
		* @param p_tpId the test purpose ID
		*/
		altstep a_receive_request(
			in template Request p_message,
			in verdicttype p_verdict,
			in charstring p_tpId,
			in charstring p_log,
			in boolean p_forward
		) runs on InterfaceMonitor {
			var Request v_message;
			[] mPort.receive(p_message) -> value v_message {
				var charstring v_token := ": unexpected ";
				if(p_verdict == pass) {
					v_token := ": expected ";
				}
				setverdict(p_verdict, self, "***" & p_tpId & v_token & p_log & " received***");
				if(p_forward) {
					vPort.send(v_message);
				}
			}
		}
        
		/**
		* @desc Receiving SIP response alternative for interfaces.
		* @param p_message the SIP repsonse
		* @param p_verdict the expected verdict
		* @param p_tpId the test purpose ID
		*/
		altstep a_receive_response(
    		in template Response p_message,
    		in verdicttype p_verdict,
    		in charstring p_tpId,
    		in charstring p_log,
    		in boolean p_forward
		) runs on InterfaceMonitor {
			var Response v_message;
			[] mPort.receive(p_message) -> value v_message {
				var charstring v_token := ": unexpected ";
				if(p_verdict == pass) {
					v_token := ": expected ";
				}
				setverdict(p_verdict, self, "***" & p_tpId & v_token & p_log & " received***");
				if(p_forward) {
					vPort.send(v_message);
				}
			}
		}
        
	}// end group
	
	group td_IMS_0001 {
		
		 /**
          * @desc
          *     TP_IMS_4002_01 in CFW step 3 (MESSAGE)<br> ensure that {<br>
          *     when { UE_A sends a MESSAGE to UE_B containing a Message_Body
          *     greater than 1300 bytes }<br> then { IMS_B receives the MESSAGE
          *     containing the Message_Body greater than 1300 bytes }<br> }
          */
	    function f_check_TP_IMS_4002_01(InterfaceMonitor p_interfaceRef, charstring p_interfaceName) runs on TestCoordinator {
		   	    		
           p_interfaceRef.start(
            f_receive(
                {mw_SipRequest(mdw_TP_IMS_4002_01(?))},//? CallId can be checked
                {mw_SipRequest(mw_MESSAGE_Request_Base(?))},
                "TP_IMS_4002_01 @ " & p_interfaceName,
                "MESSAGE request",
                0,
                false
            )
           );
           p_interfaceRef.done;
	    }
	}


 	
}// end module
 No newline at end of file