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