telephonyserverplugins/multimodetsy/test/Te_LoopBack/Te_LoopBackCDataCallCallBack.cpp
changeset 0 3553901f7fa8
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 initiates the "Data Call dial-up networking call-back" scenario for 
       
    15 // the GSM Test Harness.  This test is setup to make an outgoing data-call that transfers
       
    16 // data and then is terminated from the remote end.  The test then quickly responds to 
       
    17 // an incoming call.  Data is received and the call is terminated again from the remote end.
       
    18 // The client (application) side must start the emulator and drive the ETel API.  The 
       
    19 // emulator side runs the designated script.
       
    20 // 
       
    21 //
       
    22 
       
    23 /**
       
    24  @file
       
    25  @note There are mulitple classes implemented in this file.
       
    26  @note These classes are CTestDriveDataCallCallBack and CTestDataCallCallBack.
       
    27 */
       
    28 
       
    29 #include <e32test.h>
       
    30 #include "Te_LoopBackCDataCallCallBack.h"
       
    31 #include "../../hayes/TSYCONFG.H" // for KInternetAccessPoint
       
    32 
       
    33 //
       
    34 // Test-side class
       
    35 // With the assistance of the base class, this class must start the emulator
       
    36 // and drive the ETel API.
       
    37 //
       
    38 CTestDriveDataCallCallBack* CTestDriveDataCallCallBack::NewL(const TScriptList aScriptListEntry,
       
    39 													         TInt aVarDelay)
       
    40 /**
       
    41  * 2 Phase Constructor
       
    42  *
       
    43  * This method creates an instance of CTestDriveDataCallCallBack.  The ConstructL for
       
    44  * for CTestDriveDataCallCallBack is inherited from and implemented in CTestBase. The 
       
    45  * ConstructL uses the CTestDriveDataCallCallBack object to load ond open the two iPhone 
       
    46  * objects, one from each server. 
       
    47  *
       
    48  * @param aScriptListEntry: enum indicating which script to use for this test.
       
    49  * @param aVarDelay: integer indicating variable delay value, in seconds, to be used with an EWait script
       
    50  * @leave Leaves if a failure occurs during connect or open of the iPhone by ConstructL.
       
    51  * @return pointer to the instance of CTestDriveDataCallCallBack.
       
    52  */
       
    53 	{
       
    54 	CTestDriveDataCallCallBack* aA=new(ELeave) CTestDriveDataCallCallBack(aScriptListEntry, aVarDelay);
       
    55 	CleanupStack::PushL(aA);
       
    56 	aA->ConstructL();
       
    57 	CleanupStack::Pop();
       
    58 	return aA;
       
    59 	}
       
    60 
       
    61 
       
    62 CTestDriveDataCallCallBack::CTestDriveDataCallCallBack(const TScriptList aScriptListEntry,
       
    63 												       TInt aVarDelay
       
    64 													  ) : iScriptListEntry(aScriptListEntry), 
       
    65 														  iVarDelay(aVarDelay)
       
    66 /**
       
    67  * This method is the constructor for CTestDriveDataCallCallBack.
       
    68  *
       
    69  * @param aScriptListEntry: enum indicating which script to use for this test.
       
    70  * @param aVarDelay: integer indicating variable delay value, in seconds, to be used with an EWait script
       
    71  * @note Initializes private data "aScriptListEntry" to received parameter.
       
    72  * @note Initializes private data "aVarDelay" to received parameter.
       
    73  */
       
    74 	{}
       
    75 
       
    76 TInt CTestDriveDataCallCallBack::RunTestL()
       
    77 /**
       
    78  * This method is invoked to start a "Data Call dial-up networking call-back" test. 
       
    79  * This method sets the CTestBase current script to run and the CTestBase variable delay value to use for an EWait 
       
    80  * script and then starts the modem emulator side of the test.
       
    81  *
       
    82  * @return KErrNone when no error exists.
       
    83  * @return KErrAlreadyExists is returned if modem emulator exists and retry limit expires.
       
    84  * @return Variable depending on return value from test's DriveETelApiL method and thread monitoring.
       
    85  */
       
    86 	{
       
    87 	iCurrentScript=iScriptListEntry;
       
    88 	iVariableDelay=iVarDelay;
       
    89 	return StartEmulatorL();
       
    90 	}
       
    91 
       
    92 TInt CTestDriveDataCallCallBack::DriveETelApiL()
       
    93 /**
       
    94  * This method contains the real meat of the Client-side "Data Call dial-up networking 
       
    95  * call-back" test code.  This method sets up an outgoing data-call write test that is 
       
    96  * terminated from the remote end.  The test then quickly responds to an incoming call.  
       
    97  * Data is received and the call is terminated again from the remote end.
       
    98  */
       
    99 	{
       
   100 	_LIT(KDataLineName,"Data");
       
   101 
       
   102 	INFO_PRINTF1(_L("Opening Mobile Phone\n"));
       
   103 
       
   104 	RLine line;
       
   105 	INFO_PRINTF1(_L("Opening Data Line\n"));
       
   106 	TESTL(line.Open(iPhone,KDataLineName)==KErrNone);
       
   107 
       
   108 	INFO_PRINTF1(_L("Opening New Data Call\n"));
       
   109 	RCall call;
       
   110 	TESTL(call.OpenNewCall(line)==KErrNone);
       
   111 
       
   112 	TRequestStatus reqStatus;
       
   113 	RMobilePhone::TMMTableSettings tableSettings;
       
   114 	tableSettings.iLocId=KInternetAccessPoint;
       
   115 	RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings);
       
   116 	iPhone.InitialiseMM(reqStatus , tableSettingsPckg); 	
       
   117 	User::WaitForRequest(reqStatus);
       
   118 	TESTL(reqStatus == KErrNone);
       
   119 
       
   120 	// dial
       
   121 	_LIT(KDialString,"+1234");
       
   122 	TESTL(call.Dial(KDialString)==KErrNone);
       
   123 
       
   124 	INFO_PRINTF1(_L("Loan Data Call Port to Comm Server\n"));
       
   125 	RCall::TCommPort commPort;
       
   126 	TESTL(call.LoanDataPort(commPort)==KErrNone);
       
   127 
       
   128 	RCommServ cs;
       
   129 	TESTL(cs.Connect()==KErrNone);
       
   130 
       
   131 	RComm port;
       
   132 	TESTL(port.Open(cs,commPort.iPort,ECommShared)==KErrNone);
       
   133 
       
   134 	// Transfer data
       
   135 	TRequestStatus stat;
       
   136 	port.Write(stat,KWriteTestCallBackData);
       
   137 	User::WaitForRequest(stat);
       
   138 	TESTL(stat.Int()==KErrNone);
       
   139 
       
   140     //-- a small delay between successive writes to the COM port
       
   141     //-- I had to insert it to fix mistiming between script execution and sending AT-commands to modem
       
   142     User::After(500000);		
       
   143 
       
   144 	port.Write(stat,KWriteTestCallBackData);
       
   145 	User::WaitForRequest(stat);
       
   146 	TESTL(stat.Int()==KErrNone);
       
   147 
       
   148 	// Remote termination of call should have occurred in scripts, 
       
   149 	// close port and comm server
       
   150 	port.Close();
       
   151 	cs.Close();
       
   152 	INFO_PRINTF1(_L("Reclaim Data Call Port from Comm Server\n"));
       
   153 	TESTL(call.RecoverDataPort()==KErrNone);
       
   154 
       
   155 	// Now wait for an incoming call...
       
   156 	INFO_PRINTF1(_L("Wait to Answer incoming Data Call\n"));
       
   157 	TESTL(call.AnswerIncomingCall()==KErrNone);
       
   158 
       
   159 	INFO_PRINTF1(_L("Loan Data Call Port to Comm Server\n"));
       
   160 	TESTL(call.LoanDataPort(commPort)==KErrNone);
       
   161 
       
   162 	TESTL(cs.Connect()==KErrNone);
       
   163 	TESTL(port.Open(cs,commPort.iPort,ECommShared)==KErrNone);
       
   164 
       
   165 	port.Write(stat,KWriteTestCallBackData2);
       
   166 	User::WaitForRequest(stat);
       
   167 	TESTL(stat.Int()==KErrNone);
       
   168 
       
   169     //-- a small delay between successive writes to the COM port
       
   170     //-- I had to insert it to fix mistiming between script execution and sending AT-commands to modem
       
   171     User::After(500000);		
       
   172 
       
   173 	port.Write(stat,KWriteTestCallBackData2);
       
   174 	User::WaitForRequest(stat);
       
   175 	TESTL(stat.Int()==KErrNone);
       
   176 
       
   177 	// Remote termination of call should have occurred in scripts, 
       
   178 	// close port and comm server
       
   179 	port.Close();
       
   180 	cs.Close();
       
   181 	INFO_PRINTF1(_L("Reclaim Data Call Port from Comm Server\n"));
       
   182 	TESTL(call.RecoverDataPort()==KErrNone);
       
   183 
       
   184 	TInt32 ss;
       
   185 	TInt8 bar;
       
   186 	iPhone.GetSignalStrength(stat,ss,bar);
       
   187 	//	mmPhone.GetSignalStrength(stat,ss,bar);
       
   188 	User::WaitForRequest(stat);
       
   189 	TESTL(stat==KErrNone);
       
   190 
       
   191 	// close iPhone, line and call
       
   192 	line.Close();
       
   193 	call.Close();
       
   194 	return KErrNone;
       
   195 	}
       
   196 
       
   197 //
       
   198 // Emulator-side class
       
   199 // With the assistance of the base class, this class must run the designated script
       
   200 //
       
   201 CTestDataCallCallBack* CTestDataCallCallBack::NewL(const TScript* aScript)
       
   202 /**
       
   203  * 2 Phase Constructor
       
   204  *
       
   205  * This method creates an instance of CTestDataCallCallBack.
       
   206  *
       
   207  * @param aScript: pointer to the specifics of the script to run. 
       
   208  * @leave Leaves if out of memory when attempting to create. 
       
   209  * @return pointer to the instance of CTestDataCallCallBack.
       
   210  */
       
   211 	{
       
   212 	CTestDataCallCallBack* aA=new(ELeave) CTestDataCallCallBack(aScript);
       
   213 	CleanupStack::PushL(aA);
       
   214 	aA->ConstructL();
       
   215 	CleanupStack::Pop();
       
   216 	return aA;
       
   217 	}
       
   218 
       
   219 CTestDataCallCallBack* CTestDataCallCallBack::NewL(const TScript* aScript, const TInt aVarDelay)
       
   220 	{
       
   221 	CTestDataCallCallBack* aA=new(ELeave) CTestDataCallCallBack(aScript, aVarDelay);
       
   222 	CleanupStack::PushL(aA);
       
   223 	aA->ConstructL();
       
   224 	CleanupStack::Pop();
       
   225 	return aA;
       
   226 	}
       
   227 
       
   228 CTestDataCallCallBack::CTestDataCallCallBack(const TScript* aScript) : iScript(aScript)
       
   229 /**
       
   230  * This method is the constructor for CTestDataCallCallBack.
       
   231  *
       
   232  * @param aScript: pointer to the specifics of the script to run. 
       
   233  * @note Initializes private data "aScript" to received parameter.
       
   234  */
       
   235 	{}
       
   236 
       
   237 CTestDataCallCallBack::CTestDataCallCallBack(const TScript* aScript, const TInt aVarDelay) : CATScriptEng(aVarDelay), iScript(aScript)
       
   238 	{}
       
   239 
       
   240 void CTestDataCallCallBack::ConstructL()
       
   241 /**
       
   242  * This method is used to implement the 2 Phase Constructor for CTestDataCallCallBack.
       
   243  * This method uses the CATBase ConstructL to configure the port to be used.
       
   244  *
       
   245  * @leave  Leaves if CATBase leaves.
       
   246  */
       
   247 	{
       
   248 	CATScriptEng::ConstructL();
       
   249 	}
       
   250 
       
   251 TInt CTestDataCallCallBack::Start()
       
   252 /**
       
   253  * This method is defined as a pure virtual function that must be implemented.
       
   254  * This method is currently not used by the Etel regression test harness.
       
   255  * Instead of using this method to start the scripts, the CTestTxMess::Start()
       
   256  * method is used to start the scripts.  The CTestTxMess::Start() is called by
       
   257  * the responder thread of the scripting engine to start the execution of the script.
       
   258  *
       
   259  * @return KErrNone.
       
   260  */
       
   261 	{
       
   262 	StartScript(iScript);
       
   263 	return KErrNone;
       
   264 	}
       
   265 
       
   266 void CTestDataCallCallBack::SpecificAlgorithmL(TInt /* aParam */)
       
   267 /**
       
   268  * This method is defined as a pure virtual function that must be implemented.
       
   269  * This method is currently not used by the Etel regression test harness.
       
   270  * Instead of using this method to perform an algorithm specific to this test,
       
   271  * the CTestTxMess::SpecificAlgorithm() method is used.  The CTestTxMess::SpecificAlgorithm() 
       
   272  * is called by the scripting engine to perform the test specific algorithm.
       
   273  */
       
   274 	{
       
   275 	}
       
   276 
       
   277 void CTestDataCallCallBack::Complete(TInt aError)
       
   278 /**
       
   279  * This method is defined as a pure virtual function that must be implemented.
       
   280  * This method is currently not used by the Etel regression test harness.
       
   281  * Instead of using this method to end the scripts, the CTestTxMess::Complete()
       
   282  * method is used to end the scripts.  The CTestTxMess::Complete() is called by
       
   283  * the scripting engine to end the execution of the script.
       
   284  */
       
   285 	{
       
   286 	iReturnValue=aError;
       
   287 	CActiveScheduler::Stop();
       
   288 	}