telephonyserverplugins/multimodetsy/test/Te_LoopBack/Te_LoopBackcssfax.cpp
changeset 0 3553901f7fa8
child 19 630d2f34d719
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 // Test trying to retrieve Signal Strength information while a fax is being received
       
    15 // This file implements simultaneous retrieval of signal strength information and an incoming
       
    16 // fax.  Also, the test is repeated with retrieval of signal strength information and an incoming
       
    17 // data call.
       
    18 // See CDataCall.cpp for fully documented test scenario.
       
    19 // 
       
    20 //
       
    21 
       
    22 /**
       
    23  @file
       
    24 */
       
    25 
       
    26 #include <e32test.h>
       
    27 #include <etelmm.h>
       
    28 #include <et_clsvr.h>
       
    29 #include <faxstd.h>
       
    30 
       
    31 #include "Te_LoopBackcssfax.h"
       
    32 #include "../../hayes/TSYCONFG.H" // for KInternetAccessPoint
       
    33 
       
    34 //
       
    35 // Test-side class
       
    36 // With the assistance of the base class, this class must start the emulator
       
    37 // and drive the ETel API.
       
    38 //
       
    39 CTestDriveSsFax* CTestDriveSsFax::NewL(const TScriptList aScriptListEntry)
       
    40 	{
       
    41 	CTestDriveSsFax* aA=new(ELeave) CTestDriveSsFax(aScriptListEntry);
       
    42 	CleanupStack::PushL(aA);
       
    43 	aA->ConstructL();
       
    44 	CleanupStack::Pop();
       
    45 	return aA;
       
    46 	}
       
    47 
       
    48 CTestDriveSsFax::CTestDriveSsFax(const TScriptList aScriptListEntry) : iScriptListEntry(aScriptListEntry)
       
    49 	{}
       
    50 
       
    51 TInt CTestDriveSsFax::RunTestL()
       
    52 	{
       
    53 	iCurrentScript=iScriptListEntry;
       
    54 	return StartEmulatorL();
       
    55 	}
       
    56 
       
    57 TInt CTestDriveSsFax::DriveETelApiL()
       
    58 //
       
    59 // This function contains the real meat of the Client-side test code
       
    60 //
       
    61 	{
       
    62 	_LIT(KFaxLineName,"Fax");
       
    63 	_LIT(KMmPhoneName,"GsmPhone1");
       
    64 
       
    65 	RMobilePhone mmPhone;
       
    66 	INFO_PRINTF1(_L("Opening Multimode Phone\n"));
       
    67 	TESTL(mmPhone.Open(iServer,KMmPhoneName)==KErrNone);
       
    68 
       
    69 	RLine faxLine;
       
    70 	INFO_PRINTF1(_L("Opening Fax Line\n"));
       
    71 	TESTL(faxLine.Open(iPhone,KFaxLineName)==KErrNone);
       
    72  	RCall faxCall;
       
    73 	INFO_PRINTF1(_L("Opening New fax Call\n"));
       
    74 	TESTL(faxCall.OpenNewCall(faxLine)==KErrNone);
       
    75 
       
    76 	TRequestStatus stat1,stat2,reqStatus;
       
    77 	RMobilePhone::TMMTableSettings tableSettings;
       
    78 	tableSettings.iLocId=KInternetAccessPoint;
       
    79 	RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings);
       
    80 	iPhone.InitialiseMM(reqStatus , tableSettingsPckg); 	
       
    81 	User::WaitForRequest(reqStatus);
       
    82 	TESTL(reqStatus == KErrNone);
       
    83 
       
    84 	// Now wait for an incoming fax call...
       
    85 	INFO_PRINTF1(_L("Answering a Fax Call\n"));
       
    86 	RCall::TFaxSessionSettings faxSessionSettings;
       
    87 	faxSessionSettings.iMode=RCall::EReceive;
       
    88 	faxSessionSettings.iFaxRetrieveType=RCall::EFaxOnDemand;
       
    89 	faxSessionSettings.iFaxClass=EClassAuto;
       
    90 	faxSessionSettings.iFaxId.Zero();
       
    91 	faxSessionSettings.iMaxSpeed=14400;
       
    92 	faxSessionSettings.iMinSpeed=12000;
       
    93 	faxSessionSettings.iRxResolution=EFaxNormal;
       
    94 	faxSessionSettings.iRxCompression=EModifiedHuffman;
       
    95 	faxCall.SetFaxSettings(faxSessionSettings);
       
    96 	faxCall.AnswerIncomingCall(stat2);
       
    97 	User::After(2000000L);					// Wait for a 2secs to make sure the port is "access denied"
       
    98 
       
    99 	INFO_PRINTF1(_L("Get Signal Strength\n"));
       
   100 	TInt32 signalStrength;
       
   101 	TInt8 bar=0;
       
   102 	mmPhone.GetSignalStrength(stat1,signalStrength,bar);
       
   103 	User::WaitForRequest(stat1);
       
   104 	TESTL(stat1==KErrAccessDenied);			// The port is "access denied" by this time
       
   105 
       
   106 	User::WaitForRequest(stat2);
       
   107 	TESTL(stat2==KFaxErrReceiveTimeout);		// We don't actually send any data
       
   108 	User::After(300000L);
       
   109 	TESTL(faxCall.HangUp()==KErrNone);
       
   110 	
       
   111 	mmPhone.Close();
       
   112 	faxLine.Close();
       
   113 	faxCall.Close();
       
   114 	return KErrNone;
       
   115 	}
       
   116 
       
   117 //
       
   118 // Emulator-side class
       
   119 // With the assistance of the base class, this class must run the designated script
       
   120 //
       
   121 CTestSsFax* CTestSsFax::NewL(const TScript* aScript)
       
   122 	{
       
   123 	CTestSsFax* aA=new(ELeave) CTestSsFax(aScript);
       
   124 	CleanupStack::PushL(aA);
       
   125 	aA->ConstructL();
       
   126 	CleanupStack::Pop();
       
   127 	return aA;
       
   128 	}
       
   129 
       
   130 CTestSsFax::CTestSsFax(const TScript* aScript) : iScript(aScript)
       
   131 	{}
       
   132 
       
   133 void CTestSsFax::ConstructL()
       
   134 	{
       
   135 	CATScriptEng::ConstructL();
       
   136 	}
       
   137 
       
   138 TInt CTestSsFax::Start()
       
   139 	{
       
   140 	StartScript(iScript);
       
   141 	return KErrNone;
       
   142 	}
       
   143 
       
   144 void CTestSsFax::SpecificAlgorithmL(TInt /* aParam */)
       
   145 	{
       
   146 	}
       
   147 
       
   148 void CTestSsFax::Complete(TInt aError)
       
   149 	{
       
   150 	iReturnValue=aError;
       
   151 	CActiveScheduler::Stop();
       
   152 	}
       
   153 
       
   154 //
       
   155 // Test-side class
       
   156 // With the assistance of the base class, this class must start the emulator
       
   157 // and drive the ETel API.
       
   158 //
       
   159 
       
   160 class RSpecialCall : public RCall
       
   161 	{
       
   162 public:
       
   163 	void RecoverDataPortAsync(TRequestStatus& aStatus);
       
   164 	};
       
   165 
       
   166 void RSpecialCall::RecoverDataPortAsync(TRequestStatus& aStatus)
       
   167 	{
       
   168 	Blank(EEtelCallRecoverDataPort,aStatus);
       
   169 	}
       
   170 
       
   171 CTestDriveSSData* CTestDriveSSData::NewL(const TScriptList aScriptListEntry)
       
   172 	{
       
   173 	CTestDriveSSData* aA=new(ELeave) CTestDriveSSData(aScriptListEntry);
       
   174 	CleanupStack::PushL(aA);
       
   175 	aA->ConstructL();
       
   176 	CleanupStack::Pop();
       
   177 	return aA;
       
   178 	}
       
   179 
       
   180 CTestDriveSSData::CTestDriveSSData(const TScriptList aScriptListEntry) : iScriptListEntry(aScriptListEntry)
       
   181 	{}
       
   182 
       
   183 TInt CTestDriveSSData::RunTestL()
       
   184 	{
       
   185 	iCurrentScript=iScriptListEntry;
       
   186 	return StartEmulatorL();
       
   187 	}
       
   188 
       
   189 TInt CTestDriveSSData::DriveETelApiL()
       
   190 //
       
   191 // This function contains the real meat of the Client-side test code
       
   192 //
       
   193 	{
       
   194 	_LIT(KDataLineName,"Data");
       
   195 	_LIT(KMmPhoneName,"GsmPhone1");
       
   196 
       
   197 	RMobilePhone mmPhone;
       
   198 	INFO_PRINTF1(_L("Opening Multimode Phone\n"));
       
   199 	TESTL(mmPhone.Open(iServer,KMmPhoneName)==KErrNone);
       
   200 
       
   201 	RLine line;
       
   202 	INFO_PRINTF1(_L("Opening Data Line\n"));
       
   203 	TESTL(line.Open(iPhone,KDataLineName)==KErrNone);
       
   204 
       
   205 	INFO_PRINTF1(_L("Opening New Data Call\n"));
       
   206 	RSpecialCall call;
       
   207 	TESTL(call.OpenNewCall(line)==KErrNone);
       
   208 
       
   209 	TRequestStatus stat,stat1,reqStatus;
       
   210 
       
   211 	RMobilePhone::TMMTableSettings tableSettings;
       
   212 	tableSettings.iLocId=KInternetAccessPoint;
       
   213 	RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings);
       
   214 	iPhone.InitialiseMM(reqStatus , tableSettingsPckg); 	
       
   215 	User::WaitForRequest(reqStatus);
       
   216 	TESTL(reqStatus == KErrNone);
       
   217 
       
   218 	_LIT(KDialString,"+1234");
       
   219 	TInt status = call.Dial(KDialString);
       
   220 	TESTL(status == KErrNone);
       
   221 
       
   222 	TInt32 signalStrength;
       
   223 	TInt8 bar = 0;
       
   224 	mmPhone.GetSignalStrength(stat1,signalStrength,bar);
       
   225 
       
   226 	RCall::TCommPort commPort;
       
   227 	TESTL(call.LoanDataPort(commPort)==KErrNone);
       
   228 
       
   229 	RCommServ cs;
       
   230 	TESTL(cs.Connect()==KErrNone);
       
   231 
       
   232 	RComm port;
       
   233 	TESTL(port.Open(cs,commPort.iPort,ECommShared)==KErrNone);
       
   234 
       
   235 	port.Write(stat,KDataSsWriteTestData);
       
   236 	User::WaitForRequest(stat);
       
   237 	TESTL(stat.Int()==KErrNone);
       
   238 
       
   239     //-- a small delay between successive writes to the COM port
       
   240     //-- I had to insert it to fix mistiming between script execution and sending AT-commands to modem
       
   241     User::After(500000);		
       
   242 
       
   243 	port.Write(stat,KDataSsWriteTestData);
       
   244 	User::WaitForRequest(stat);
       
   245 	TESTL(stat.Int()==KErrNone);
       
   246 
       
   247 	port.Close();
       
   248 	cs.Close();
       
   249 
       
   250 	call.RecoverDataPort();
       
   251 
       
   252 	User::After(500000L);
       
   253 
       
   254 	User::WaitForRequest(stat1); // Result of GetSignalStrength()
       
   255 	TESTL(stat1==KErrAccessDenied);
       
   256 
       
   257 	TESTL(call.HangUp()==KErrNone);
       
   258 
       
   259 	mmPhone.Close();
       
   260 	line.Close();
       
   261 	call.Close();
       
   262 	return KErrNone;
       
   263 	}
       
   264 
       
   265 //
       
   266 // Emulator-side class
       
   267 // With the assistance of the base class, this class must run the designated script
       
   268 //
       
   269 CTestSSData* CTestSSData::NewL(const TScript* aScript)
       
   270 	{
       
   271 	CTestSSData* aA=new(ELeave) CTestSSData(aScript);
       
   272 	CleanupStack::PushL(aA);
       
   273 	aA->ConstructL();
       
   274 	CleanupStack::Pop();
       
   275 	return aA;
       
   276 	}
       
   277 
       
   278 CTestSSData::CTestSSData(const TScript* aScript) : iScript(aScript)
       
   279 	{}
       
   280 
       
   281 void CTestSSData::ConstructL()
       
   282 	{
       
   283 	CATScriptEng::ConstructL();
       
   284 	}
       
   285 
       
   286 TInt CTestSSData::Start()
       
   287 	{
       
   288 	StartScript(iScript);
       
   289 	return KErrNone;
       
   290 	}
       
   291 
       
   292 void CTestSSData::SpecificAlgorithmL(TInt /* aParam */)
       
   293 	{
       
   294 	}
       
   295 
       
   296 void CTestSSData::Complete(TInt aError)
       
   297 	{
       
   298 	iReturnValue=aError;
       
   299 	CActiveScheduler::Stop();
       
   300 	}