telephonyserverplugins/multimodetsy/test/Te_LoopBack/Te_LoopBackScriptEng.h
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This file contains the classes and enumerations necessary to drive the scripting engine.  The
       
    15 // allowed scripting commands, events, and actual script line structure are defined in this file.
       
    16 // Note that the actual scripts are NOT defined in this file.
       
    17 // See ScriptLanguage.htm for more information.
       
    18 // Scripting Engine to execute command scripts
       
    19 // 
       
    20 //
       
    21 
       
    22 /**
       
    23  @file
       
    24  @internalComponent
       
    25 */
       
    26 
       
    27 #ifndef __SCRIPTENG_H__
       
    28 #define __SCRIPTENG_H__
       
    29 
       
    30 #include "Te_LoopBackSLOGGER.H"
       
    31 #include "Te_LoopBackATBASE.H"
       
    32 #include "Te_LoopBackATIO.H"
       
    33 
       
    34 // Valid commands for the ETel Regression Test scripting "Language"
       
    35 enum TScriptCommands
       
    36 	{
       
    37 	ETxString,				//< Transmit ASCII String; CR/LF automatically appended
       
    38 	ETxStringWithoutCrLf,	//< Transmit ASCII String; No CR or LF.
       
    39 	ETxStringOK,			//< Transmit the string "OK" including CR/LF.
       
    40 	ERxString,				//< Expect String which the script engine will wait for
       
    41 	EIfRxStringJmp,			//< A Conditional Branch, if the specified string is received, it branches.
       
    42 	EIfRxStringRelativeJmp,	//< A Conditional Branch, if the specified string is received, it branches.
       
    43 	EWait,					//< Delay specified time before continuing script; care must be used because of timing considerations
       
    44 							//< NOTE: failures can occur if an EWait command is used before ERxEvent events.
       
    45 							//< NOTE: safest place to use an EWait command is between ETxEvent events.
       
    46 	EExecuteSpecial,		//< Asks script engine to call an algorithm specific to test scenario
       
    47 	EComplete,				//< Informs script engine the script is complete
       
    48 	ESignalMark,			//< Sets signal(s)
       
    49 	ESignalSpace			//< Clears signal(s)
       
    50 	};
       
    51 
       
    52 // The completion event codes here drive when the script engine can proceed to the next line
       
    53 // of the script.  Note that these values are bit flags and thus can be combined.  For example,
       
    54 // the combination of ETxEvent | EFailIfTimeOut means that if a tx event complete is received go
       
    55 // to the next step in the script.  If a time-out occurs, fail the script.
       
    56 enum TCompletionEvent
       
    57 	{
       
    58 	ETxEvent=		0x1,	//< Progress to next script element if tx complete event is received
       
    59 	ERxEvent=		0x2,	//< Progress to next script element if rx complete event is received
       
    60 	ETimeOutEvent=	0x4,	//< Progress to next script element if time-out event occurs
       
    61 	EFailIfTimeOut=	0x8,	//< If a time-out event occurs, fail the script
       
    62 	EKeepExpectStrings =0x10	//< Allow expect string to be persistent even after it has been received
       
    63 	};
       
    64 
       
    65 // The TScript structure represents one line of a script.  Note that the iParam member has
       
    66 // specific meaning depending on the command.
       
    67 struct TScript
       
    68 	{
       
    69 	TInt iCommand;			//< Command
       
    70 	TText8* iText;			//< Text related to Command
       
    71 	TInt iParam;			//< Parameter related to Command, often a time-out.
       
    72 							//< NOTE: for an EWait, an iParam value of -1 is only applicable to specific test scripts. 
       
    73 							//< This indicates the timeout is specified by the delay parameter entered by the operator 
       
    74 							//< or a test specific default value.
       
    75 	TInt iCompletionEvent;	//< Flags to indicate the conditions for moving onto the
       
    76 							//< next state.
       
    77 	};
       
    78 
       
    79 /**
       
    80  * The CATScriptEng base derives from the CATBase.  In turn, the emulator side of the specific
       
    81  * tests all derive from CATScriptEng.  This class drives the scripting engine for the Modem
       
    82  * emulator.  It is used to implement the ETel Regression Test Harness "Language".
       
    83  */
       
    84 class CRestartSignal;
       
    85 class CATScriptEng : public CATBase
       
    86 	{
       
    87 public:
       
    88 	// Called in StartScriptL in the Responder Thread.  Implemented by each specific test case.
       
    89 	virtual TInt Start()=0;
       
    90 
       
    91 	// Called in ProcessScriptLine in the Responder Thread when an EExecuteSpecial 
       
    92 	// command is in the script.  Implemented by each specific test case. 
       
    93 
       
    94 	virtual void SpecificAlgorithmL(TInt aParam)=0;
       
    95 	// Called in the Responder Thread for various reasons.  It is called when the script 
       
    96 	// completes either by running to completion, timeout (if timeouts
       
    97 	// force a failure), or because of another error.
       
    98 
       
    99 	virtual void Complete(TInt aError)=0;
       
   100 	void StartRestart(TRequestStatus** aStatus);
       
   101 	void Restart();
       
   102 	TInt iReturnValue;
       
   103 protected:
       
   104 	CATScriptEng();
       
   105 	CATScriptEng(TInt aVarDelay);
       
   106 	~CATScriptEng();
       
   107 	void ConstructL();
       
   108 	TInt StartScript(const TScript* aScript);
       
   109 	// virtual function inherited from CATBase
       
   110 	virtual void EventSignal(TEventSource aEventSource); 
       
   111 
       
   112 private:
       
   113 	void ProcessMultipleScriptLines();
       
   114 	TInt ProcessScriptLine();
       
   115 
       
   116 	const TScript* iStartScriptPnt;		//< Pointer to the beginning of the script in memory.
       
   117 	const TScript* iScriptPnt;			//< Pointer into the current script being executed used
       
   118 										//< to increment through script.
       
   119 	TScript iCurrentScriptLine;			//< A copy of the current script line be processed.
       
   120 										//< Used by line processing code.
       
   121 	TInt     iDelay;					//< Variable delay value to be used as timeout by script 
       
   122 										//< processing engine when iParam value is -1 in a TScript 
       
   123 										//< script whose iCommand is an EWait.
       
   124 // Variables to handle conditional Jump
       
   125 	CCommChatString* iJmpChatString;	//< Used to compare incoming string vs. expected for 
       
   126 										//< conditional jump
       
   127 	TUint iJmpAbsolute;					//< Used to store the target absolute script line number
       
   128 										//< for conditional jumping
       
   129 	CRestartSignal* iRestartSignal;		//< Pointer to the Restart Signal class.
       
   130 	};
       
   131 
       
   132 #endif