telephonyserverplugins/multimodetsy/test/Te_LoopBack/Te_LoopBackcdatacall.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 Test" scenario for the :q
       
    15 // Test Harness.
       
    16 // This file handles both the test side and the emulator side of the GSM
       
    17 // Test Harness for this scenario.  The test side must start the emulator and 
       
    18 // drive the ETel API.  The emulator side runs the designated script.
       
    19 // 
       
    20 //
       
    21 
       
    22 /**
       
    23  @file
       
    24  @note  There are mulitple classes implemented in this file.
       
    25  @note  These classes are CTestDriveDataCall and CTestDataCall.
       
    26 */
       
    27 
       
    28 #include <e32test.h>
       
    29 #include <etelmm.h>
       
    30 #include "Te_LoopBackcdatacall.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 CTestDriveDataCall* CTestDriveDataCall::NewL(const TScriptList aScriptListEntry)
       
    39 /**
       
    40  * 2 Phase Constructor
       
    41  *
       
    42  * This method creates an instance of CTestDriveDataCall.  The ConstructL for
       
    43  * for CTestDriveDataCall is inherited from and implemented in CTestBase. The 
       
    44  * ConstructL uses the CTestDriveDataCall object to load ond open the two iPhone 
       
    45  * objects, one from each server. 
       
    46  *
       
    47  * @param aScriptListEntry: enum indicating which script to use for this test.
       
    48  * @leave Leaves if a failure occurs during connect or open of the iPhone by ConstructL.
       
    49  * @return pointer to the instance of CTestDriveDataCall.
       
    50  */
       
    51 	{
       
    52 	CTestDriveDataCall* aA=new(ELeave) CTestDriveDataCall(aScriptListEntry);
       
    53 	CleanupStack::PushL(aA);
       
    54 	aA->ConstructL();
       
    55 	CleanupStack::Pop();
       
    56 	return aA;
       
    57 	}
       
    58 
       
    59 CTestDriveDataCall::CTestDriveDataCall(const TScriptList aScriptListEntry) : iScriptListEntry(aScriptListEntry)
       
    60 /**
       
    61  * This method is the constructor for CTestDriveDataCall.
       
    62  *
       
    63  * @param aScriptListEntry: enum indicating which script to use for this test.
       
    64  * @note Initializes private data "aScriptListEntry" to received parameter.
       
    65  */
       
    66 	{}
       
    67 
       
    68 TInt CTestDriveDataCall::RunTestL()
       
    69 /**
       
    70  * This method is invoked to start a Data Call Test. 
       
    71  * This method starts the modem emulator side of the test.
       
    72  *
       
    73  * @return KErrNone when no error exists.
       
    74  * @return KErrAlreadyExists is returned if modem emulator exists and retry limit expires.
       
    75  * @return Variable depending on return value from test's DriveETelApiL method and thread monitoring.
       
    76  */
       
    77 	{
       
    78 	iCurrentScript=iScriptListEntry;
       
    79 	return StartEmulatorL();
       
    80 	}
       
    81 
       
    82 TInt CTestDriveDataCall::DriveETelApiL()
       
    83 /**
       
    84  * This method contains the real meat of the Client-side Data Call Test code.
       
    85  * This method sets up a write test for both an outgoing and incoming call for
       
    86  * a Data Call Test.
       
    87  *
       
    88  * @return KErrNone.
       
    89  */
       
    90 	{
       
    91 	_LIT(KDataLineName,"Data");
       
    92 	RLine line;
       
    93 	INFO_PRINTF1(_L("Opening Data Line\n"));
       
    94 	TESTL(line.Open(iPhone,KDataLineName)==KErrNone);
       
    95 
       
    96 	INFO_PRINTF1(_L("Opening New Data Call\n"));
       
    97 	RCall call;
       
    98 	TESTL(call.OpenNewCall(line)==KErrNone);
       
    99 
       
   100 	TRequestStatus reqStatus;
       
   101 	RMobilePhone::TMMTableSettings tableSettings;
       
   102 	tableSettings.iLocId=KInternetAccessPoint;
       
   103 	RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings);
       
   104 	iPhone.InitialiseMM(reqStatus , tableSettingsPckg); 	
       
   105 	User::WaitForRequest(reqStatus);
       
   106 	TESTL(reqStatus == KErrNone);
       
   107 
       
   108 	_LIT(KDialString,"+1234");
       
   109 	TRequestStatus stat;
       
   110 	TESTL(call.Dial(KDialString)==KErrNone);
       
   111 
       
   112 	RCall::TCommPort commPort;
       
   113 	TESTL(call.LoanDataPort(commPort)==KErrNone);
       
   114 
       
   115 	RCommServ cs;
       
   116 	TESTL(cs.Connect()==KErrNone);
       
   117 
       
   118 	RComm port;
       
   119 	TESTL(port.Open(cs,commPort.iPort,ECommShared)==KErrNone);
       
   120 
       
   121 	port.Write(stat,KWriteTestData);
       
   122 	User::WaitForRequest(stat);
       
   123 	TESTL(stat.Int()==KErrNone);
       
   124 
       
   125     //-- a small delay between successive writes to the COM port
       
   126     //-- I had to insert it to fix mistiming between script execution and sending AT-commands to modem
       
   127     User::After(500000);		
       
   128 	port.Write(stat,KWriteTestData);
       
   129 	User::WaitForRequest(stat);
       
   130 	TESTL(stat.Int()==KErrNone);
       
   131 
       
   132 	port.Close();
       
   133 	cs.Close();
       
   134 	TESTL(call.RecoverDataPort()==KErrNone);
       
   135 
       
   136 	TESTL(call.HangUp()==KErrNone);
       
   137 
       
   138 	User::After(1000000);		
       
   139 
       
   140 // Now wait for an incoming call...
       
   141 	TESTL(call.AnswerIncomingCall()==KErrNone);
       
   142 
       
   143 	TESTL(call.LoanDataPort(commPort)==KErrNone);
       
   144 
       
   145 	TESTL(cs.Connect()==KErrNone);
       
   146 	TESTL(port.Open(cs,commPort.iPort,ECommShared)==KErrNone);
       
   147 
       
   148 	port.Write(stat,KWriteTestData2);
       
   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,KWriteTestData2);
       
   157 	User::WaitForRequest(stat);
       
   158 	TESTL(stat.Int()==KErrNone);
       
   159 
       
   160 	port.Close();
       
   161 	cs.Close();
       
   162 	TESTL(call.RecoverDataPort()==KErrNone);
       
   163 
       
   164 	TESTL(call.HangUp()==KErrNone);
       
   165 	
       
   166 	call.Close();
       
   167 	line.Close();
       
   168 	return KErrNone;
       
   169 	}
       
   170 
       
   171 //
       
   172 // Emulator-side class
       
   173 // With the assistance of the base class, this class must run the designated script
       
   174 //
       
   175 CTestDataCall* CTestDataCall::NewL(const TScript* aScript)
       
   176 /**
       
   177  * 2 Phase Constructor
       
   178  *
       
   179  * This method creates an instance of CTestDataCall.
       
   180  *
       
   181  * @param aScript: pointer to the specifics of the script to run. 
       
   182  * @leave Leaves if out of memory when attempting to create. 
       
   183  * @return pointer to the instance of CTestDataCall.
       
   184  */
       
   185 	{
       
   186 	CTestDataCall* aA=new(ELeave) CTestDataCall(aScript);
       
   187 	CleanupStack::PushL(aA);
       
   188 	aA->ConstructL();
       
   189 	CleanupStack::Pop();
       
   190 	return aA;
       
   191 	}
       
   192 
       
   193 CTestDataCall::CTestDataCall(const TScript* aScript) : iScript(aScript)
       
   194 /**
       
   195  * This method is the constructor for CTestDataCall.
       
   196  *
       
   197  * @param aScript: pointer to the specifics of the script to run. 
       
   198  * @note Initializes private data "aScript" to received parameter.
       
   199  */
       
   200 	{}
       
   201 
       
   202 void CTestDataCall::ConstructL()
       
   203 /**
       
   204  * This method is used to implement the 2 Phase Constructor for CTestDataCall.
       
   205  * This method uses the CATBase ConstructL to configure the port to be used.
       
   206  *
       
   207  * @leave Leaves if CATBase leaves.
       
   208  */
       
   209 	{
       
   210 	CATScriptEng::ConstructL();
       
   211 	}
       
   212 
       
   213 TInt CTestDataCall::Start()
       
   214 /**
       
   215  * This method is defined as a pure virtual function that must be implemented.
       
   216  * This method is currently not used by the Etel regression test harness.
       
   217  * Instead of using this method to start the scripts, the CTestTxMess::Start()
       
   218  * method is used to start the scripts.  The CTestTxMess::Start() is called by
       
   219  * the responder thread of the scripting engine to start the execution of the script.
       
   220  *
       
   221  * @return KErrNone.
       
   222  */
       
   223 	{
       
   224 	StartScript(iScript);
       
   225 	return KErrNone;
       
   226 	}
       
   227 
       
   228 void CTestDataCall::SpecificAlgorithmL(TInt /* aParam */)
       
   229 /**
       
   230  * This method is defined as a pure virtual function that must be implemented.
       
   231  * This method is currently not used by the Etel regression test harness.
       
   232  * Instead of using this method to perform an algorithm specific to this test,
       
   233  * the CTestTxMess::SpecificAlgorithm() method is used.  The CTestTxMess::SpecificAlgorithm() 
       
   234  * is called by the scripting engine to perform the test specific algorithm.
       
   235  */
       
   236 	{
       
   237 	}
       
   238 
       
   239 void CTestDataCall::Complete(TInt aError)
       
   240 /**
       
   241  * This method is defined as a pure virtual function that must be implemented.
       
   242  * This method is currently not used by the Etel regression test harness.
       
   243  * Instead of using this method to end the scripts, the CTestTxMess::Complete()
       
   244  * method is used to end the scripts.  The CTestTxMess::Complete() is called by
       
   245  * the scripting engine to end the execution of the script.
       
   246  */
       
   247 	{
       
   248 	iReturnValue=aError;
       
   249 	CActiveScheduler::Stop();
       
   250 	}