| /////////////////////////////////////////////////////////////////////////////// |
| // |
| // Copyright (c) 2000-2018 Ericsson Telecom AB |
| // |
| // All rights reserved. This program and the accompanying materials |
| // are made available under the terms of the Eclipse Public License v2.0 |
| // which accompanies this distribution, and is available at |
| // https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html |
| /////////////////////////////////////////////////////////////////////////////// |
| // |
| // File: XTDP_Demo.ttcn |
| // Rev: <RnXnn> |
| // Prodnr: CNL 11 |
| // Updated: 2009-10-16 |
| // Contact: http://ttcn.ericsson.se |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| /////////////////////////////////////////////////////////// |
| // Module: XTDP_Demo |
| // |
| // Purpose: |
| // This module provides |
| // |
| // Module depends on: |
| // - |
| // |
| // Current Owner: |
| // Laszlo Skumat (ELSZSKU) |
| // |
| // Last Review Date: |
| // - |
| // |
| /////////////////////////////////////////////////////////////// |
| module XTDP_Demo |
| { |
| import from XTDP_EncDecFunctions all |
| //import from www_mozilla_org_keymaster_gatekeeper_there_is_only_xul all; |
| import from ttcn_ericsson_se_protocolModules_xtdp_xtdl all |
| import from ttcn_ericsson_se_protocolModules_xtdp_xtdp all |
| //import from ttcn_ericsson_se_xtdp_xul_1_0 all |
| //import from NoTargetNamespace all; |
| import from IPL4asp_PortType all; |
| import from IPL4asp_Types all; |
| //import from IPL4asp_Functions all; |
| //import from XTDP_Templates all; |
| import from Socket_API_Definitions all; |
| |
| modulepar boolean tsp_debug_GuiTest :=false; //from XTDP_TP:RunTimeGuiTest.ttcn |
| modulepar boolean tsp_debugVerbose_GuiTest :=false;//from XTDP_TP:RunTimeGuiTest.ttcn |
| modulepar integer tsp_callGrpsNo := 80;//from XTDP_TP:RunTimeGuiTest.ttcn |
| modulepar integer tsp_sigLinksNo := 80//from XTDP_TP:RunTimeGuiTest.ttcn |
| |
| const Hbox c_MainWidget := { |
| disabled := omit, |
| fixedposition := omit, |
| flex := omit, |
| id := "EPTF_Main_hbox", |
| orientation := horizontal, |
| scrollable := omit, |
| embeddedwidgets := { |
| embeddedwidget_list := { |
| { |
| hbox := { |
| disabled := omit, |
| fixedposition := omit, |
| flex := omit, |
| id := "EPTF_Main_hbox_labels", |
| orientation := vertical, |
| scrollable := omit, |
| embeddedwidgets := { |
| embeddedwidget_list := { |
| { |
| label_ := { |
| disabled := omit, |
| flex := omit, |
| id := "refreshClock", |
| style := omit, |
| tooltiptext := omit, |
| value_ := "Time elapsed since Test was started: 0.0", |
| externaldata := omit |
| } |
| }, |
| { |
| label_ := { |
| disabled := omit, |
| flex := omit, |
| id := "status", |
| style := omit, |
| tooltiptext := omit, |
| value_ := "This text will be replaced runtime.", |
| externaldata := omit |
| } |
| } |
| } |
| } |
| } |
| }, |
| { |
| hbox := { |
| disabled := omit, |
| fixedposition := omit, |
| flex := omit, |
| id := "EPTF_Main_hbox_buttons", |
| orientation := horizontal, |
| scrollable := omit, |
| embeddedwidgets := { |
| embeddedwidget_list := { |
| { |
| spacer := { |
| flex := 1.0, |
| id := omit |
| } |
| }, |
| { |
| button := { |
| checked := omit,//BOOLEAN OPTIONAL, |
| disabled := true, |
| flex := omit, |
| id := "button1", |
| imageid := omit, |
| label_ := "Snapshot", |
| tooltiptext := omit, |
| type_ := omit, //XSD.String OPTIONAL, |
| externaldata := omit |
| //image := omit, |
| } |
| }, |
| { |
| spacer := { |
| flex := 0.0, |
| id := omit |
| } |
| }, |
| { |
| button := { |
| checked := omit,//BOOLEAN OPTIONAL, |
| disabled := true, |
| flex := omit, |
| id := "button2", |
| imageid := omit, |
| label_ := "Exit TTCN", |
| tooltiptext := omit, |
| type_ := omit, //XSD.String OPTIONAL, |
| externaldata := omit |
| //image := omit, |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| type component MTC { |
| port IPL4asp_PT IPL4; |
| var integer v_reqId := 1; |
| var integer v_plainRequest:= 0; |
| } |
| function f_getNextReqId() runs on MTC return integer { |
| var integer vl_retVal := v_reqId; |
| v_reqId := v_reqId+1; |
| return vl_retVal; |
| } |
| modulepar{ |
| charstring tsp_xtdp_listen_addr := "127.0.0.1"; |
| integer tsp_xtdp_listen_port := 11420; |
| } |
| |
| template ASP_RecvFrom t_recvfrom(template integer pl_connId) := { |
| connId := pl_connId, |
| remName := ?, |
| remPort := ?, |
| locName := ?, |
| locPort := ?, |
| proto := ?, |
| userData := ?, |
| msg := ? |
| } |
| |
| template ASP_Event t_res := { |
| result := ? |
| } |
| |
| template ASP_Event t_open := { |
| connOpened := ? |
| } |
| |
| template ASP_Event t_sctpEvent := { |
| sctpEvent := ? |
| } |
| |
| template ASP_Event t_close := { |
| connClosed := ? |
| } |
| |
| testcase tc_XTDP_GUI() runs on MTC{ |
| var XTDP_Message vl_msg |
| vl_msg.transactionID := omit |
| vl_msg.choice.xTDP_AddRequests.xTDP_AddRequest_list[0].parentWidgetId := omit |
| vl_msg.choice.xTDP_AddRequests.xTDP_AddRequest_list[0].requestId := 1 |
| vl_msg.choice.xTDP_AddRequests.xTDP_AddRequest_list[0].widgets.hbox := c_MainWidget |
| |
| map(self:IPL4, system:IPL4); |
| var integer vl_connId := 0 |
| var IPL4asp_Types.Result result:= IPL4asp_PortType.f_IPL4_connect( |
| IPL4, |
| tsp_xtdp_listen_addr, tsp_xtdp_listen_port, |
| c_ipv4AnyAddr, c_anyPort, |
| vl_connId, {tcp := {}}) |
| if (ispresent(result.errorCode)) { |
| setverdict(fail,"Connection failed: ",result.errorCode); |
| stop; |
| } |
| vl_connId := result.connId |
| setverdict(pass,"Connection open: ",result); |
| var octetstring vl_msgOct := enc_XTDP_Message(vl_msg) |
| var ASP_SendTo asp := { |
| connId := vl_connId, |
| remName := tsp_xtdp_listen_addr, |
| remPort := tsp_xtdp_listen_port, |
| proto := omit, |
| msg := int2oct(lengthof(vl_msgOct)+4,4) & vl_msgOct |
| }; |
| IPL4.send(asp); |
| timer T |
| T.start(10.0); |
| var ASP_RecvFrom vl_recv |
| var ASP_Event vl_event |
| alt { |
| [] IPL4.receive(t_recvfrom(vl_connId)) -> value vl_recv { |
| log("Communication ASP received: ",vl_recv) |
| setverdict(pass); |
| T.stop; |
| } |
| [] IPL4.receive(t_res) -> value vl_event{ |
| log("Event: Result ASP received:", vl_event) |
| setverdict(fail); |
| T.stop; |
| } |
| [] IPL4.receive(t_open) -> value vl_event { |
| log("Event: Connection opened: ",vl_event) |
| setverdict(fail); |
| T.stop; |
| } |
| [] IPL4.receive(t_close) -> value vl_event { |
| log("Event: Connection closed: ",vl_event) |
| setverdict(fail); |
| T.stop; |
| } |
| [] IPL4.receive(t_sctpEvent) -> value vl_event { |
| log("Event: SCTP event arrived: ",vl_event) |
| repeat; |
| } |
| [] T.timeout { |
| log("timeout"); |
| setverdict(fail); |
| } |
| } // alt |
| IPL4asp_PortType.f_IPL4_close(IPL4, vl_connId, {tcp := {}}) |
| unmap(self:IPL4, system:IPL4); |
| } |
| /* |
| external function dec_XTDP_Message_sliding (inout octetstring p_oct,out XTDP_Message p_message) return integer |
| with {extension "prototype(sliding) decode (XER:XER_EXTENDED) errorbehavior(ALL:ERROR)"} |
| |
| testcase tc_XTDP_sliding() runs on MTC{ |
| var XTDP_Message vl_msg, vl_msg2 |
| vl_msg.noNamespaceSchemaLocation := omit |
| vl_msg.choice.xTDP_AddRequests_list[0].xTDP_AddRequest_list[0].parentWidgetId := omit |
| vl_msg.choice.xTDP_AddRequests_list[0].xTDP_AddRequest_list[0].requestId := 1 |
| vl_msg.choice.xTDP_AddRequests_list[0].xTDP_AddRequest_list[0].xul.hbox := c_MainWidget |
| var octetstring vl_ret := enc_XTDP_Message(vl_msg) |
| action(vl_ret) |
| dec_XTDP_Message_sliding(vl_ret, vl_msg2) |
| if(match(vl_msg,vl_msg2)){ |
| setverdict(pass) |
| }else{ |
| setverdict(fail, match(vl_msg,vl_msg2)) |
| } |
| if(''O == vl_ret){ |
| setverdict(pass) |
| }else{ |
| setverdict(fail, "vl_ret should be empty instead of ",vl_ret) |
| } |
| } |
| */ |
| } // end of module |