telephonyserverplugins/simatktsy/tests/src/ccsatcomponenttestbase.cpp
changeset 0 3553901f7fa8
child 5 7ef16719d8cb
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2008-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 //
       
    15 
       
    16 
       
    17 
       
    18 /**
       
    19  @file base class for SAT component tests
       
    20 */
       
    21 
       
    22 #include <ctsy/ltsy/mltsydispatchphoneinterface.h>
       
    23 #include <ctsy/ltsy/mltsydispatchsecurityinterface.h>
       
    24 #include <ctsy/ltsy/mltsydispatchsiminterface.h>
       
    25 #include <ctsy/ltsy/mltsydispatchcallcontrolinterface.h>
       
    26 #include <pcktcs.h>
       
    27 #include <ctsy/mmtsy_names.h>
       
    28 #include <ctsy/serviceapi/mmtsy_ipcdefs.h>
       
    29 #include <test/tmockltsydata.h>
       
    30 #include <ctsy/serviceapi/gsmerror.h>
       
    31 #include <ctsy/serviceapi/cmmutility.h>
       
    32 #include <test/mockltsyindicatorids.h>
       
    33 #include <ctsy/ltsy/mltsydispatchsatinterface.h>
       
    34 #include <ctsy/ltsy/mltsydispatchphonebookinterface.h> //for KLtsyDispatchPhonebookSmsStoreWriteEntryApiId
       
    35 #include <cstktsy/ttlv.h>
       
    36 #include <charconv.h> 
       
    37 
       
    38 #include "ccsatcomponenttestbase.h"
       
    39 
       
    40 
       
    41 _LIT(KDoubleColon, "::");
       
    42 _LIT(KMmTsyWithDispatcherModuleName, "phonetsywithdispatcher");
       
    43 
       
    44 
       
    45 /**
       
    46 To push a CleanupItem ont the cleanupstack to close the phone
       
    47 */
       
    48 void CCSatComponentTestBase::Cleanup(TAny* self)
       
    49 	{
       
    50 	static_cast<CCSatComponentTestBase*>(self)->DoCleanup();
       
    51 	}
       
    52 	
       
    53 /**
       
    54 Close the Phone a the server connection
       
    55 */	
       
    56 void CCSatComponentTestBase::DoCleanup()
       
    57 	{
       
    58 	iSms.Close();
       
    59 	iSat.Close();
       
    60 	iPhone.Close();
       
    61 	iMockLTSY.Close();
       
    62 	
       
    63 	TInt ret = iTelServer.UnloadPhoneModule(KMmTsyWithDispatcherModuleName);
       
    64 	if (ret != KErrNone)
       
    65 		{
       
    66 		INFO_PRINTF1(_L("Failed to unload phone module"));
       
    67 		}
       
    68 	
       
    69     iTelServer.Close();
       
    70  
       
    71 	}
       
    72 
       
    73 /**
       
    74 Assert MockLtsy Terminated all handlings without errors
       
    75 */
       
    76 void CCSatComponentTestBase::AssertMockLtsyStatusL()
       
    77 	{
       
    78 	TBool hasWaitingExpect;
       
    79 	TBool hasPendingComplete;
       
    80 	TBool hasError;
       
    81 	iMockLTSY.GetStatus(hasWaitingExpect,hasPendingComplete,hasError);
       
    82 	if (hasWaitingExpect || hasPendingComplete)
       
    83 		{
       
    84 		ERR_PRINTF1(_L("MockLTsy still have pending/waiting events!"));
       
    85 		}
       
    86 	if (hasWaitingExpect || hasPendingComplete || hasError)
       
    87 		{
       
    88 		TBuf<255> log;
       
    89 		do	{
       
    90 			iMockLTSY.GetNextLogLine(log);
       
    91 			INFO_PRINTF1(log);
       
    92 			} 
       
    93 		while(log.Length() > 0);
       
    94 		User::Leave(KErrTEFUnitFail); // Fail the test
       
    95 		}
       
    96 	}
       
    97 
       
    98 	
       
    99 /**
       
   100 Open Server session
       
   101 */
       
   102 void CCSatComponentTestBase::OpenEtelServerL(TExtendedErrorClient aSetExtendedErrorClient)
       
   103 	{
       
   104 	TInt ret = iTelServer.Connect();
       
   105 
       
   106 	if (ret != KErrNone)
       
   107 		{
       
   108 		INFO_PRINTF1(_L("Failed connect phone"));
       
   109 		User::Leave(ret);
       
   110 		}
       
   111 
       
   112 	ret = iTelServer.LoadPhoneModule(KMmTsyWithDispatcherModuleName);
       
   113 
       
   114 	if (ret != KErrNone)
       
   115 		{
       
   116 		INFO_PRINTF1(_L("Failed load phone module"));
       
   117 		iTelServer.Close();
       
   118 		User::Leave(ret);
       
   119 		}
       
   120 		
       
   121 	if(aSetExtendedErrorClient == EUseExtendedError)
       
   122 		{
       
   123 		iTelServer.SetExtendedErrorGranularity(	RTelServer::EErrorExtended );
       
   124 		}
       
   125 	}
       
   126 
       
   127 /**
       
   128 Standard function to open the phone up to the end of the boot sequence
       
   129 */
       
   130 void CCSatComponentTestBase::OpenPhoneL()
       
   131 	{
       
   132 	RBuf8 data;
       
   133 	CleanupClosePushL(data);
       
   134 
       
   135 	TInt err = iPhone.Open(iTelServer,KMmTsyPhoneName);
       
   136 	ASSERT_EQUALS(KErrNone, err);
       
   137 
       
   138 	//open SMS messaging session
       
   139 	err = iSms.Open(iPhone);
       
   140 	ASSERT_EQUALS(KErrNone, err);
       
   141 	
       
   142 	TRequestStatus modemDetectedStatus;
       
   143 	RPhone::TModemDetection modemDetection;
       
   144 	iPhone.NotifyModemDetected(modemDetectedStatus,modemDetection);
       
   145 
       
   146 
       
   147 	
       
   148 	err=iMockLTSY.Connect();
       
   149 	ASSERT_EQUALS(KErrNone, err);
       
   150 	TRequestStatus mockLtsyStatus;
       
   151 	iMockLTSY.NotifyTerminated(mockLtsyStatus);
       
   152 	 
       
   153 	TRfStateInfo rfstatus = ERfsStateInfoNormal;
       
   154 	TMockLtsyData1<TRfStateInfo> rfstatdata(rfstatus);
       
   155 	rfstatdata.SerialiseL(data);
       
   156 	iMockLTSY.CompleteL(MLtsyDispatchPhoneBootNotifyModemStatusReady::KLtsyDispatchPhoneBootNotifyModemStatusReadyApiId,KErrNone, data, 1);
       
   157 	
       
   158 	// EMobilePhoneGetNetworkRegistrationStatus
       
   159 	iMockLTSY.ExpectL(MLtsyDispatchPhoneGetNetworkRegistrationStatus::KLtsyDispatchPhoneGetNetworkRegistrationStatusApiId);
       
   160 	RMobilePhone::TMobilePhoneRegistrationStatus regStatus = RMobilePhone::ERegisteredOnHomeNetwork;
       
   161 	TMockLtsyData1<RMobilePhone::TMobilePhoneRegistrationStatus> retNetRegStatusData(regStatus);
       
   162 	data.Close();
       
   163 	retNetRegStatusData.SerialiseL(data);
       
   164 	iMockLTSY.CompleteL(MLtsyDispatchPhoneGetNetworkRegistrationStatus::KLtsyDispatchPhoneGetNetworkRegistrationStatusApiId,KErrNone,data, 0);
       
   165 	
       
   166 	// EMmTsyBootNotifySimStatusReadyIPC
       
   167 	iMockLTSY.ExpectL(MLtsyDispatchPhoneBootNotifySimStatusReady::KLtsyDispatchPhoneBootNotifySimStatusReadyApiId);
       
   168 	iMockLTSY.CompleteL(MLtsyDispatchPhoneBootNotifySimStatusReady::KLtsyDispatchPhoneBootNotifySimStatusReadyApiId,KErrNone,0);
       
   169 	
       
   170 	// Prepare MockLtsy for the internal getters of the network information
       
   171 	DriverPrepInternalGettersMockLtsyL();
       
   172 	
       
   173 	// EMobilePhoneGetHomeNetwork
       
   174 	data.Close();
       
   175 	iMockLTSY.ExpectL(MLtsyDispatchPhoneGetHomeNetwork::KLtsyDispatchPhoneGetHomeNetworkApiId);
       
   176 	RMobilePhone::TMobilePhoneNetworkInfoV5 homeNetwork;
       
   177 	homeNetwork.iMode = RMobilePhone::ENetworkModeWcdma;
       
   178 	homeNetwork.iStatus = RMobilePhone::ENetworkStatusCurrent;
       
   179 	homeNetwork.iBandInfo = RMobilePhone::EBandUnknown;
       
   180 	homeNetwork.iCountryCode = _L("234");
       
   181 	homeNetwork.iCdmaSID = _L("");
       
   182 	homeNetwork.iAnalogSID = _L("");
       
   183 	homeNetwork.iNetworkId = _L("23499");
       
   184 	homeNetwork.iDisplayTag = _L("symbian");
       
   185 	homeNetwork.iShortName = _L("symbian");
       
   186 	homeNetwork.iLongName = _L("symbian mobile");
       
   187 	homeNetwork.iAccess = RMobilePhone::ENetworkAccessUtran;
       
   188 	homeNetwork.iEgprsAvailableIndicator = ETrue;
       
   189 	homeNetwork.iHsdpaAvailableIndicator = ETrue;
       
   190 	TMockLtsyData1<RMobilePhone::TMobilePhoneNetworkInfoV5> homeNetworkData(homeNetwork);
       
   191 	homeNetworkData.SerialiseL(data);
       
   192 	iMockLTSY.CompleteL(MLtsyDispatchPhoneGetHomeNetwork::KLtsyDispatchPhoneGetHomeNetworkApiId,KErrNone,data,0);
       
   193 
       
   194 	// EMmTsySecurityGetPin1DisableSupportedIPC
       
   195  	iMockLTSY.ExpectL(MLtsyDispatchSecurityGetPin1DisableSupported::KLtsyDispatchSecurityGetPin1DisableSupportedApiId);
       
   196 	TBool pin1DisableSupport = ETrue;
       
   197 	TMockLtsyData1<TBool> pin1DisableSupportData(pin1DisableSupport);
       
   198 	data.Close();
       
   199 	pin1DisableSupportData.SerialiseL(data);
       
   200 	iMockLTSY.CompleteL(MLtsyDispatchSecurityGetPin1DisableSupported::KLtsyDispatchSecurityGetPin1DisableSupportedApiId,KErrNone,data,0);
       
   201 
       
   202 	//EMmTsySimRefreshRegisterIPC
       
   203 	TUint16 refreshFileList = KCacheAdn | KCacheFdn | KCacheServiceTable | KCacheALSline;
       
   204 	TMockLtsyData1<TUint16> refreshFileListData(refreshFileList);
       
   205 	data.Close();
       
   206 	refreshFileListData.SerialiseL(data);
       
   207 	iMockLTSY.ExpectL(MLtsyDispatchPhoneSimRefreshRegister::KLtsyDispatchPhoneSimRefreshRegisterApiId,data);
       
   208 	iMockLTSY.CompleteL(MLtsyDispatchPhoneSimRefreshRegister::KLtsyDispatchPhoneSimRefreshRegisterApiId,KErrNone);
       
   209 		
       
   210 	//EMobilePhoneGetServiceTable
       
   211 	RMobilePhone::TMobilePhoneServiceTable serviceTable = RMobilePhone::ESIMServiceTable;
       
   212 	TMockLtsyData1<RMobilePhone::TMobilePhoneServiceTable> serviceTableData(serviceTable);
       
   213 	data.Close();
       
   214 	serviceTableData.SerialiseL(data);
       
   215 	iMockLTSY.ExpectL(MLtsyDispatchSimGetServiceTable::KLtsyDispatchSimGetServiceTableApiId, data);
       
   216 
       
   217 	RMobilePhone::TMobilePhoneServiceTableV1 simServiceTable;
       
   218 	simServiceTable.iServices1To8  = 0xFF;
       
   219 	simServiceTable.iServices9To16 = 0xFF;
       
   220 	simServiceTable.iServices17To24= 0xFF;
       
   221 	simServiceTable.iServices25To32= 0xFF;
       
   222 	simServiceTable.iServices33To40= 0xFF;
       
   223 	simServiceTable.iServices41To48= 0xFF;
       
   224 	simServiceTable.iServices49To56= 0xFF;
       
   225 	
       
   226 	TMockLtsyData1<RMobilePhone::TMobilePhoneServiceTableV1> serviceTableResultData(simServiceTable);
       
   227 	data.Close();
       
   228 	serviceTableResultData.SerialiseL(data);
       
   229 	iMockLTSY.CompleteL(MLtsyDispatchSimGetServiceTable::KLtsyDispatchSimGetServiceTableApiId,KErrNone,data);
       
   230 		
       
   231 	// EMobilePhoneGetALSLine
       
   232 	iMockLTSY.ExpectL(MLtsyDispatchCallControlGetActiveAlsLine::KLtsyDispatchCallControlGetActiveAlsLineApiId);
       
   233 
       
   234 	RMobilePhone::TMobilePhoneALSLine alsLine = RMobilePhone::EAlternateLinePrimary;
       
   235 	TMockLtsyData1<RMobilePhone::TMobilePhoneALSLine> alsLineData(alsLine);
       
   236 	data.Close();
       
   237 	alsLineData.SerialiseL(data);
       
   238 	iMockLTSY.CompleteL(MLtsyDispatchCallControlGetActiveAlsLine::KLtsyDispatchCallControlGetActiveAlsLineApiId,KErrNone,data,0);
       
   239 	
       
   240 	// ECustomGetIccCallForwardingStatusIPC
       
   241 	iMockLTSY.ExpectL(MLtsyDispatchCallControlGetCallForwardingIndicator::KLtsyDispatchCallControlGetCallForwardingIndicatorApiId);
       
   242 
       
   243 	RMobilePhone::TMobilePhoneCFUIndicatorV6 indicator;
       
   244 	indicator.iMultipleSubscriberProfileID = RMobilePhone::KProfileIdentityTwo;
       
   245 	indicator.iIndicator = RMobilePhone::KCFUIndicatorVoice;
       
   246 	indicator.iCFNumber.iNumberPlan = RMobilePhone::ETelexNumberPlan;
       
   247 	indicator.iCFNumber.iTypeOfNumber = RMobilePhone::ENationalNumber;
       
   248 	_LIT(KTelNumber, "012345678");
       
   249 	indicator.iCFNumber.iTelNumber = KTelNumber; 
       
   250 	TMockLtsyData1<RMobilePhone::TMobilePhoneCFUIndicatorV6> indicatorData(indicator);
       
   251 	data.Close();
       
   252 	indicatorData.SerialiseL(data);
       
   253 	iMockLTSY.CompleteL(MLtsyDispatchCallControlGetCallForwardingIndicator::KLtsyDispatchCallControlGetCallForwardingIndicatorApiId,KErrNone,data,0);
       
   254 	
       
   255 	// EMobilePhoneGetIccMessageWaitingIndicators
       
   256 	iMockLTSY.ExpectL(MLtsyDispatchSimGetIccMessageWaitingIndicators::KLtsyDispatchSimGetIccMessageWaitingIndicatorsApiId);
       
   257 
       
   258 	RMobilePhone::TMobilePhoneMessageWaitingV1 expectedMessageIndicators;
       
   259 	TMockLtsyData1<RMobilePhone::TMobilePhoneMessageWaitingV1>
       
   260 	                                indicatorsData(expectedMessageIndicators);
       
   261     data.Close();
       
   262     indicatorsData.SerialiseL(data); 
       
   263 	iMockLTSY.CompleteL(MLtsyDispatchSimGetIccMessageWaitingIndicators::KLtsyDispatchSimGetIccMessageWaitingIndicatorsApiId, KErrNone, data);
       
   264 
       
   265 	iMockLTSY.ExpectL(MLtsyDispatchCallControlGetAlsPpSupport::KLtsyDispatchCallControlGetAlsPpSupportApiId);
       
   266 	 
       
   267  	RMmCustomAPI::TAlsSupport alsSupport = RMmCustomAPI::EAlsSupportOff;
       
   268  	TMockLtsyData1<RMmCustomAPI::TAlsSupport> alsLtsyData1(alsSupport);
       
   269  	data.Close();
       
   270  	alsLtsyData1.SerialiseL(data);
       
   271  	iMockLTSY.CompleteL(MLtsyDispatchCallControlGetAlsPpSupport::KLtsyDispatchCallControlGetAlsPpSupportApiId, KErrNone, data);
       
   272  	
       
   273  	iMockLTSY.ExpectL(MLtsyDispatchSimGetCustomerServiceProfile::KLtsyDispatchSimGetCustomerServiceProfileApiId);
       
   274  
       
   275  	// Prepare data for the mockLtsy's CompleteL
       
   276  	RMobilePhone::TMobilePhoneCspFileV1 cspComp;
       
   277  	cspComp.iCallOfferingServices = 0x01;
       
   278  	cspComp.iCallRestrictionServices = 0x02;
       
   279  	cspComp.iOtherSuppServices = 0x03;
       
   280  	cspComp.iCallCompletionServices = 0x04;
       
   281  	cspComp.iTeleservices = 0x05;
       
   282  	cspComp.iCphsTeleservices = 0x06;
       
   283  	cspComp.iCphsFeatures = 0x07;
       
   284  	cspComp.iNumberIdentServices = 0x08;
       
   285  	cspComp.iPhase2PlusServices = 0x09;
       
   286  	cspComp.iValueAddedServices = 0x0A;
       
   287  	TMockLtsyData1<RMobilePhone::TMobilePhoneCspFileV1> cspCompData(cspComp);
       
   288  	data.Close();
       
   289  	cspCompData.SerialiseL(data);
       
   290 	iMockLTSY.CompleteL(MLtsyDispatchSimGetCustomerServiceProfile::KLtsyDispatchSimGetCustomerServiceProfileApiId, KErrNone, data);
       
   291  	
       
   292 
       
   293 	
       
   294 	User::WaitForRequest(mockLtsyStatus);
       
   295 	AssertMockLtsyStatusL();
       
   296 	CleanupStack::PopAndDestroy(1); // data
       
   297 	}
       
   298 
       
   299 /**
       
   300 Sends ExpectL and CompleteL commands to MockLtsy for getters of various network information.
       
   301 These getters are internal to the CtsyDispatcher.
       
   302 This method should be called immediately after the CompleteL for KLtsyDispatchPhoneBootNotifyModemStatusReadyApiId,
       
   303 since these getters are triggered on the CtsyDispacther receiving a BootNotifyModemStatusReady indication. 
       
   304 */
       
   305 void CCSatComponentTestBase::DriverPrepInternalGettersMockLtsyL()
       
   306 	{
       
   307 	RBuf8 data;
       
   308 	CleanupClosePushL(data);
       
   309 	
       
   310 	//
       
   311 	// Prepare MockLtsy for processing a getter for CurrentNetworkInfo
       
   312 	//
       
   313 	iMockLTSY.ExpectL(MLtsyDispatchPhoneGetCurrentNetworkInfo::KLtsyDispatchPhoneGetCurrentNetworkInfoApiId);
       
   314 
       
   315 	// Prepare the KLtsyDispatchPhoneGetCurrentNetworkInfoApiId data for CompleteL
       
   316 	RMobilePhone::TMobilePhoneNetworkInfoV5 networkInfoComplete;
       
   317 	
       
   318 	// V5
       
   319 	networkInfoComplete.iEgprsAvailableIndicator = KEgprsAvailable;
       
   320 	networkInfoComplete.iHsdpaAvailableIndicator = KHsdpaAvailable;
       
   321 	// V2
       
   322 	networkInfoComplete.iAccess = KAccess;
       
   323 	// V1
       
   324 	networkInfoComplete.iMode        = KMode;
       
   325 	networkInfoComplete.iStatus      = KStatus;
       
   326 	networkInfoComplete.iBandInfo    = KBandInfo;
       
   327 	networkInfoComplete.iCountryCode = KCountryCode;
       
   328 	networkInfoComplete.iCdmaSID     = KCdmaSID;
       
   329 	networkInfoComplete.iAnalogSID   = KAnalogSID;
       
   330 	networkInfoComplete.iNetworkId   = KNetworkId;
       
   331 	networkInfoComplete.iDisplayTag  = KDisplayTag;
       
   332 	networkInfoComplete.iShortName   = KShortName;
       
   333 	networkInfoComplete.iLongName    = KLongName;
       
   334 	
       
   335 	RMobilePhone::TMobilePhoneLocationAreaV1 locationAreaComplete;
       
   336 	locationAreaComplete.iAreaKnown = KAreaKnown;
       
   337 	locationAreaComplete.iLocationAreaCode = KLocationAreaCode;
       
   338 	locationAreaComplete.iCellId = KCellId;
       
   339 	
       
   340     TMockLtsyData2<RMobilePhone::TMobilePhoneNetworkInfoV5, 
       
   341                    RMobilePhone::TMobilePhoneLocationAreaV1> mockCNCData2(networkInfoComplete, locationAreaComplete);
       
   342 	
       
   343 	data.Close();
       
   344 	mockCNCData2.SerialiseL(data);
       
   345 	iMockLTSY.CompleteL(MLtsyDispatchPhoneGetCurrentNetworkInfo::KLtsyDispatchPhoneGetCurrentNetworkInfoApiId, KErrNone, data);
       
   346 
       
   347 	//
       
   348 	// Prepare MockLtsy for processing a getter for NetworkModeChange
       
   349 	//
       
   350 	iMockLTSY.ExpectL(MLtsyDispatchPhoneGetNetworkMode::KLtsyDispatchPhoneGetNetworkModeApiId);
       
   351 
       
   352 	// Prepare the KLtsyDispatchPhoneGetNetworkModeApiId data for CompleteL
       
   353     RMobilePhone::TMobilePhoneNetworkMode networkModeComplete;
       
   354     networkModeComplete = KNetworkMode;
       
   355 
       
   356     TMockLtsyData1<RMobilePhone::TMobilePhoneNetworkMode> mockNMCData1(networkModeComplete);
       
   357 	
       
   358 	data.Close();
       
   359 	mockNMCData1.SerialiseL(data);
       
   360 	iMockLTSY.CompleteL(MLtsyDispatchPhoneGetNetworkMode::KLtsyDispatchPhoneGetNetworkModeApiId, KErrNone, data);
       
   361 
       
   362 	//
       
   363 	// Prepare MockLtsy for processing a getter for NitzInfoChange
       
   364 	//
       
   365 	iMockLTSY.ExpectL(MLtsyDispatchPhoneGetNitzInfo::KLtsyDispatchPhoneGetNitzInfoApiId);
       
   366 	RMobilePhone::TMobilePhoneNITZ nitzComplete(2008, EMay, 12, 11,  59,  0, 0);
       
   367 	nitzComplete.iShortNetworkId = KShortName;
       
   368 	nitzComplete.iLongNetworkId = KLongName;
       
   369 	nitzComplete.iNitzFieldsUsed = KNitzFieldsUsed;
       
   370 	nitzComplete.iTimeZone = KTimeZone;
       
   371 	nitzComplete.iDST = KDst;
       
   372 	
       
   373 	TMockLtsyData1<RMobilePhone::TMobilePhoneNITZ> mockNitzData1(nitzComplete);
       
   374 	data.Close();
       
   375 	mockNitzData1.SerialiseL(data);
       
   376 	iMockLTSY.CompleteL(MLtsyDispatchPhoneGetNitzInfo::KLtsyDispatchPhoneGetNitzInfoApiId, KErrNone, data);
       
   377     
       
   378 	//
       
   379 	// Prepare MockLtsy for processing a getter for SignalStrengthChange
       
   380 	//
       
   381 	iMockLTSY.ExpectL(MLtsyDispatchPhoneGetSignalStrength::KLtsyDispatchPhoneGetSignalStrengthApiId);
       
   382 	TInt32 signalStrengthComplete(KSignalStrength);
       
   383 	TInt8 barComplete(KBar);
       
   384 	TMockLtsyData2<TInt32, TInt8> mockSigSthData2(signalStrengthComplete, barComplete);
       
   385 	data.Close();
       
   386 	mockSigSthData2.SerialiseL(data);
       
   387 	iMockLTSY.CompleteL(MLtsyDispatchPhoneGetSignalStrength::KLtsyDispatchPhoneGetSignalStrengthApiId, KErrNone, data);
       
   388 	
       
   389 	//
       
   390 	// Prepare MockLtsy for processing a getter for BatteryInfoChange
       
   391 	//
       
   392 	iMockLTSY.ExpectL(MLtsyDispatchPhoneGetBatteryInfo::KLtsyDispatchPhoneGetBatteryInfoApiId);
       
   393 	RMobilePhone::TMobilePhoneBatteryInfoV1 battInfo;
       
   394 	battInfo.iChargeLevel = KBatteryChargeLevel;
       
   395 	battInfo.iStatus = KBatteryStatus;
       
   396 	                     
       
   397 	TMockLtsyData1<RMobilePhone::TMobilePhoneBatteryInfoV1> mockBattInfoData1(battInfo);
       
   398 	data.Close();
       
   399 	mockBattInfoData1.SerialiseL(data);
       
   400 	iMockLTSY.CompleteL(MLtsyDispatchPhoneGetBatteryInfo::KLtsyDispatchPhoneGetBatteryInfoApiId, KErrNone, data);
       
   401 	
       
   402 	data.Close();
       
   403 	CleanupStack::PopAndDestroy();  // data
       
   404 	}
       
   405 
       
   406 /**
       
   407  * Waits until the MockLTSY queued events is empty
       
   408  */
       
   409 
       
   410 void CCSatComponentTestBase::WaitForMockLTSYTerminated()
       
   411 	{
       
   412 	TRequestStatus reqStatus;
       
   413 	iMockLTSY.NotifyTerminated(reqStatus); 
       
   414 	User::WaitForRequest(reqStatus);
       
   415 	ASSERT_TRUE(reqStatus.Int() == KErrNone);
       
   416 	}
       
   417 	
       
   418 
       
   419 /**
       
   420 Sends ExpectL and CompleteL commands to MockLtsy for getters of various network information.
       
   421 These getters are internal to the CtsyDispatcher.
       
   422 This method should be called immediately after the CompleteL for KLtsyDispatchPhoneBootNotifyModemStatusReadyApiId,
       
   423 since these getters are triggered on the CtsyDispacther receiving a BootNotifyModemStatusReady indication. 
       
   424 */
       
   425 void CCSatComponentTestBase::PrepInternalGettersMockLtsy()
       
   426 	{
       
   427 	RBuf8 data;
       
   428 	CleanupClosePushL(data);
       
   429 	
       
   430 	//
       
   431 	// Prepare MockLtsy for processing a getter for CurrentNetworkInfo
       
   432 	//
       
   433 	iMockLTSY.ExpectL(MLtsyDispatchPhoneGetCurrentNetworkInfo::KLtsyDispatchPhoneGetCurrentNetworkInfoApiId);
       
   434 
       
   435 	// Prepare the KLtsyDispatchPhoneGetCurrentNetworkInfoApiId data for CompleteL
       
   436 	RMobilePhone::TMobilePhoneNetworkInfoV5 networkInfoComplete;
       
   437 	
       
   438 	// V5
       
   439 	networkInfoComplete.iEgprsAvailableIndicator = KEgprsAvailable;
       
   440 	networkInfoComplete.iHsdpaAvailableIndicator = KHsdpaAvailable;
       
   441 	// V2
       
   442 	networkInfoComplete.iAccess = KAccess;
       
   443 	// V1
       
   444 	networkInfoComplete.iMode        = KMode;
       
   445 	networkInfoComplete.iStatus      = KStatus;
       
   446 	networkInfoComplete.iBandInfo    = KBandInfo;
       
   447 	networkInfoComplete.iCountryCode = KCountryCode;
       
   448 	networkInfoComplete.iCdmaSID     = KCdmaSID;
       
   449 	networkInfoComplete.iAnalogSID   = KAnalogSID;
       
   450 	networkInfoComplete.iNetworkId   = KNetworkId;
       
   451 	networkInfoComplete.iDisplayTag  = KDisplayTag;
       
   452 	networkInfoComplete.iShortName   = KShortName;
       
   453 	networkInfoComplete.iLongName    = KLongName;
       
   454 	
       
   455 	RMobilePhone::TMobilePhoneLocationAreaV1 locationAreaComplete;
       
   456 	locationAreaComplete.iAreaKnown = KAreaKnown;
       
   457 	locationAreaComplete.iLocationAreaCode = KLocationAreaCode;
       
   458 	locationAreaComplete.iCellId = KCellId;
       
   459 	
       
   460     TMockLtsyData2<RMobilePhone::TMobilePhoneNetworkInfoV5, 
       
   461                    RMobilePhone::TMobilePhoneLocationAreaV1> mockCNCData2(networkInfoComplete, locationAreaComplete);
       
   462 	
       
   463 	data.Close();
       
   464 	mockCNCData2.SerialiseL(data);
       
   465 	iMockLTSY.CompleteL(MLtsyDispatchPhoneGetCurrentNetworkInfo::KLtsyDispatchPhoneGetCurrentNetworkInfoApiId, KErrNone, data);
       
   466 
       
   467 	//
       
   468 	// Prepare MockLtsy for processing a getter for NetworkModeChange
       
   469 	//
       
   470 	iMockLTSY.ExpectL(MLtsyDispatchPhoneGetNetworkMode::KLtsyDispatchPhoneGetNetworkModeApiId);
       
   471 
       
   472 	// Prepare the KLtsyDispatchPhoneGetNetworkModeApiId data for CompleteL
       
   473     RMobilePhone::TMobilePhoneNetworkMode networkModeComplete;
       
   474     networkModeComplete = KNetworkMode;
       
   475 
       
   476     TMockLtsyData1<RMobilePhone::TMobilePhoneNetworkMode> mockNMCData1(networkModeComplete);
       
   477 	
       
   478 	data.Close();
       
   479 	mockNMCData1.SerialiseL(data);
       
   480 	iMockLTSY.CompleteL(MLtsyDispatchPhoneGetNetworkMode::KLtsyDispatchPhoneGetNetworkModeApiId, KErrNone, data);
       
   481 
       
   482 	//
       
   483 	// Prepare MockLtsy for processing a getter for NitzInfoChange
       
   484 	//
       
   485 	iMockLTSY.ExpectL(MLtsyDispatchPhoneGetNitzInfo::KLtsyDispatchPhoneGetNitzInfoApiId);
       
   486 	RMobilePhone::TMobilePhoneNITZ nitzComplete(2008, EMay, 12, 11,  59,  0, 0);
       
   487 	nitzComplete.iShortNetworkId = KShortName;
       
   488 	nitzComplete.iLongNetworkId = KLongName;
       
   489 	nitzComplete.iNitzFieldsUsed = KNitzFieldsUsed;
       
   490 	nitzComplete.iTimeZone = KTimeZone;
       
   491 	nitzComplete.iDST = KDst;
       
   492 	
       
   493 	TMockLtsyData1<RMobilePhone::TMobilePhoneNITZ> mockNitzData1(nitzComplete);
       
   494 	data.Close();
       
   495 	mockNitzData1.SerialiseL(data);
       
   496 	iMockLTSY.CompleteL(MLtsyDispatchPhoneGetNitzInfo::KLtsyDispatchPhoneGetNitzInfoApiId, KErrNone, data);
       
   497     
       
   498 	//
       
   499 	// Prepare MockLtsy for processing a getter for SignalStrengthChange
       
   500 	//
       
   501 	iMockLTSY.ExpectL(MLtsyDispatchPhoneGetSignalStrength::KLtsyDispatchPhoneGetSignalStrengthApiId);
       
   502 	TInt32 signalStrengthComplete(KSignalStrength);
       
   503 	TInt8 barComplete(KBar);
       
   504 	TMockLtsyData2<TInt32, TInt8> mockSigSthData2(signalStrengthComplete, barComplete);
       
   505 	data.Close();
       
   506 	mockSigSthData2.SerialiseL(data);
       
   507 	iMockLTSY.CompleteL(MLtsyDispatchPhoneGetSignalStrength::KLtsyDispatchPhoneGetSignalStrengthApiId, KErrNone, data);
       
   508 	
       
   509 	//
       
   510 	// Prepare MockLtsy for processing a getter for BatteryInfoChange
       
   511 	//
       
   512 	iMockLTSY.ExpectL(MLtsyDispatchPhoneGetBatteryInfo::KLtsyDispatchPhoneGetBatteryInfoApiId);
       
   513 	RMobilePhone::TMobilePhoneBatteryInfoV1 battInfo;
       
   514 	battInfo.iChargeLevel = KBatteryChargeLevel;
       
   515 	battInfo.iStatus = KBatteryStatus;
       
   516 	                     
       
   517 	TMockLtsyData1<RMobilePhone::TMobilePhoneBatteryInfoV1> mockBattInfoData1(battInfo);
       
   518 	data.Close();
       
   519 	mockBattInfoData1.SerialiseL(data);
       
   520 	iMockLTSY.CompleteL(MLtsyDispatchPhoneGetBatteryInfo::KLtsyDispatchPhoneGetBatteryInfoApiId, KErrNone, data);
       
   521 	
       
   522 	data.Close();
       
   523 	CleanupStack::PopAndDestroy();  // data
       
   524 	}
       
   525 	
       
   526 /**
       
   527 Dial a call
       
   528 @param aCall the call to use to dial
       
   529 @param aService type of call (must match the line the call what created on)
       
   530 @param aCallId Call ID the TSY allocates for this call
       
   531 */
       
   532 void CCSatComponentTestBase::DialL(RMobileCall& aCall, TInt aCallId, RMobilePhone::TMobileService aService)
       
   533 	{
       
   534 	RBuf8 data;
       
   535 	CleanupClosePushL(data);
       
   536 
       
   537 	// EEtelCallDial
       
   538 	RMobileCall::TMobileCallParamsV1 callParams;
       
   539 	RMobileCall::TMobileCallParamsV1Pckg callParamsPckg(callParams);
       
   540     callParams.iInterval = 0;
       
   541     callParams.iCug.iCugIndex = 0xFFFF;
       
   542 	RMobileCall::TMobileCallInfoV1 callInfo;
       
   543 	RMobileCall::TMobileCallInfoV1Pckg callInfoPckg(callInfo);
       
   544 	callInfo.iDialledParty.iTelNumber.Copy(_L("02071541111"));
       
   545 	callInfo.iService = aService;
       
   546 	callInfo.iValid = RMobileCall::KCallDialledParty | RMobileCall::KCallAlternating;
       
   547 	TMockLtsyCallData2<RMobileCall::TMobileCallParamsV1, RMobileCall::TMobileCallInfoV1> 
       
   548 		dialData(0, aService, callParams, callInfo);
       
   549 	dialData.SerialiseL(data);
       
   550 	iMockLTSY.ExpectL(EEtelCallDial,data);
       
   551 
       
   552 	// EMobileCallGetMobileCallInfo
       
   553 	callInfo.iService = aService; 
       
   554 	callInfo.iEmergency = EFalse;
       
   555 	callInfo.iRemoteParty.iCallingName = _L("");
       
   556 	callInfo.iRemoteParty.iRemoteIdStatus = RMobileCall::ERemoteIdentityUnknown;
       
   557 	callInfo.iRemoteParty.iRemoteNumber.iTelNumber = _L("");
       
   558 	callInfo.iRemoteParty.iRemoteNumber.iNumberPlan = RMobilePhone::EUnknownNumberingPlan;
       
   559 	callInfo.iRemoteParty.iRemoteNumber.iTypeOfNumber = RMobilePhone::EUnknownNumber;
       
   560 	callInfo.iForwarded = EFalse;
       
   561 	callInfo.iValid = RMobileCall::KCallDialledParty | RMobileCall::KCallRemoteParty;
       
   562 	
       
   563 	TMockLtsyCallData1<RMobileCall::TMobileCallInfoV1> callInfoData(aCallId, aService, callInfo);
       
   564 	data.Close();
       
   565 	callInfoData.SerialiseL(data);
       
   566 	iMockLTSY.CompleteL(EMobileCallGetMobileCallInfo,KErrNone,data,0);
       
   567 
       
   568 	// complete Dial
       
   569 	TMockLtsyCallData0 dialCompleteData(aCallId,aService);
       
   570 	data.Close();
       
   571 	dialCompleteData.SerialiseL(data);
       
   572 	iMockLTSY.CompleteL(EEtelCallDial,KErrNone,data,0);
       
   573 
       
   574 	TRequestStatus requestStatus ;
       
   575 	aCall.Dial(requestStatus,callInfo.iDialledParty.iTelNumber);
       
   576 	User::WaitForRequest(requestStatus);
       
   577 	AssertMockLtsyStatusL();
       
   578 	ASSERT_EQUALS(KErrNone, requestStatus.Int());
       
   579 
       
   580 	CleanupStack::PopAndDestroy(1);
       
   581 	}
       
   582 
       
   583 /**
       
   584 Open packet service session.
       
   585 @param aStartAttachStatus Starting attach status.
       
   586 @param aStartAttachMode Starting atach mode.  The CTSY does not even cache this value so it does not really matter what it gets set to.
       
   587 */
       
   588 void CCSatComponentTestBase::OpenPacketServiceL(RPacketService& aRPacketService, RPacketService::TStatus aStartAttachStatus, RPacketService::TAttachMode aStartAttachMode)
       
   589 	{
       
   590 	RBuf8 data;
       
   591 	CleanupClosePushL(data);
       
   592 	
       
   593 	TRequestStatus mockLtsyStatus;
       
   594 	iMockLTSY.NotifyTerminated(mockLtsyStatus);
       
   595 	
       
   596 	iMockLTSY.ExpectL(EPacketNotifyStatusChange);
       
   597 	
       
   598 	TBool resumed = EFalse;
       
   599 	TMockLtsyData2<RPacketService::TStatus , TBool> comNotifyStatus(aStartAttachStatus, resumed);
       
   600 	comNotifyStatus.SerialiseL(data);
       
   601 	iMockLTSY.CompleteL(EPacketNotifyStatusChange,KErrNone, data);
       
   602 	
       
   603 	TBool expInitState = ETrue;	 
       
   604 	TMockLtsyData1<TBool> expGetAttachMode(expInitState);
       
   605 	data.Close();
       
   606 	expGetAttachMode.SerialiseL(data);
       
   607 	iMockLTSY.ExpectL(EPacketGetAttachMode, data);
       
   608 	
       
   609 	TMockLtsyData1<RPacketService::TAttachMode> comGetAttachMode(aStartAttachMode);
       
   610 	data.Close();
       
   611 	comGetAttachMode.SerialiseL(data);
       
   612 	iMockLTSY.CompleteL(EPacketGetAttachMode,KErrNone, data);
       
   613 	
       
   614 	//this is actually a sync call to LTSY where return represents a context id offset rather than error code.
       
   615 	iMockLTSY.ExpectL(EPacketInitProxiesIPC, 3);	
       
   616 	
       
   617 	//this actually completes before all messages between CSAT<->LTSY have finished.
       
   618 	TInt err = aRPacketService.Open(iPhone);
       
   619 		
       
   620 	// Wait for the end of initialisation
       
   621 	User::WaitForRequest(mockLtsyStatus);
       
   622 	AssertMockLtsyStatusL();
       
   623 	
       
   624 	CleanupStack::PopAndDestroy(); // data
       
   625 	}
       
   626 	
       
   627 
       
   628 /**
       
   629 Context initiation
       
   630 @param aPacketContext context object
       
   631 @param aContextName context name
       
   632 */
       
   633 TInt CCSatComponentTestBase::InitContextL(RPacketContext& aPacketContext, TInfoName& aContextName, TInfoName aHostCidName)
       
   634 {
       
   635 	RBuf8 data;
       
   636 	CleanupClosePushL(data);
       
   637 
       
   638 	// data for initialisation of the context 
       
   639 	TRequestStatus initStatus;
       
   640 	RPacketContext::TDataChannelV2 dataCh;
       
   641 	TPckg<RPacketContext::TDataChannelV2> pckgInit(dataCh);	
       
   642     TMockLtsyData2< TInfoName, TInfoName > ltsyInit(aContextName, aHostCidName);
       
   643 	ltsyInit.SerialiseL(data);	
       
   644 	iMockLTSY.ExpectL(EPacketContextInitialiseContext, data);
       
   645 	
       
   646 	TMockLtsyData1< TInfoName > ltsyData(aContextName);
       
   647 	data.Close();
       
   648 	ltsyData.SerialiseL(data);
       
   649 	iMockLTSY.CompleteL(EPacketContextInitialiseContext, KErrNone, data);
       
   650 	//initialisation of the context
       
   651 	aPacketContext.InitialiseContext(initStatus, pckgInit);
       
   652 	User::WaitForRequest(initStatus);
       
   653 	
       
   654 	CleanupStack::PopAndDestroy(1); // data
       
   655 	return initStatus.Int();
       
   656 }
       
   657 
       
   658 
       
   659 
       
   660 /**
       
   661 Context activation
       
   662 @param aContextName context name
       
   663 */
       
   664 TInt CCSatComponentTestBase::SetContextActiveL(TInfoName& aContextName)
       
   665 {
       
   666 	RBuf8 data;
       
   667 	CleanupClosePushL(data);
       
   668 
       
   669 	//data for CompleteL    
       
   670  	TContextMisc  completeMisc;
       
   671     completeMisc.iStatus = RPacketContext::EStatusActive;
       
   672  	TMockLtsyData2 <TInfoName, TContextMisc>
       
   673  														 ltsyData1(aContextName, completeMisc);
       
   674 	ltsyData1.SerialiseL(data);	
       
   675 	
       
   676 	TRequestStatus mockLtsyStatus;
       
   677 	iMockLTSY.NotifyTerminated(mockLtsyStatus);
       
   678 	//send completion
       
   679 	iMockLTSY.CompleteL(EPacketContextNotifyStatusChange, KErrNone, data);
       
   680 	// wait for completion
       
   681 	User::WaitForRequest(mockLtsyStatus);	
       
   682 	
       
   683 	CleanupStack::PopAndDestroy(1); // data
       
   684 	
       
   685 	return mockLtsyStatus.Int();
       
   686 }
       
   687 
       
   688 
       
   689 /**
       
   690 Set context to new status
       
   691 @param aContextName context name
       
   692 @param aStatus status to set 
       
   693 */
       
   694 TInt CCSatComponentTestBase::SetContextStatusL(TInfoName& aContextName, RPacketContext::TContextStatus aStatus)
       
   695 {
       
   696 	RBuf8 data;
       
   697 	CleanupClosePushL(data);
       
   698 
       
   699 	//data for CompleteL    
       
   700  	TContextMisc  completeMisc;
       
   701     completeMisc.iStatus = aStatus;
       
   702  	TMockLtsyData2 <TInfoName, TContextMisc>
       
   703  														 ltsyData1(aContextName, completeMisc);
       
   704 	ltsyData1.SerialiseL(data);	
       
   705 	
       
   706 	TRequestStatus mockLtsyStatus;
       
   707 	iMockLTSY.NotifyTerminated(mockLtsyStatus);
       
   708 	//send completion
       
   709 	iMockLTSY.CompleteL(EPacketContextNotifyStatusChange, KErrNone, data);
       
   710 	// wait for completion
       
   711 	User::WaitForRequest(mockLtsyStatus);	
       
   712 	
       
   713 	CleanupStack::PopAndDestroy(1); // data
       
   714 	
       
   715 	return mockLtsyStatus.Int();
       
   716 }
       
   717 
       
   718 
       
   719 
       
   720 /**
       
   721 Create QoS and set profile params
       
   722 @param aPacketQoS packet qos object
       
   723 @param aPacketContext context object
       
   724 @param aRequested profile
       
   725 */
       
   726 
       
   727 TInt CCSatComponentTestBase::CreateQoSAndSetProfileParamLC(RPacketQoS& aPacketQoS, 
       
   728 													       RPacketContext& aPacketContext, 
       
   729 													       TInfoName& aContextName,
       
   730 														   TPacketDataConfigBase& aRequested,
       
   731 														   TInfoName aPrimaryContextName)
       
   732 {
       
   733 	// ------ create New QoS -------------------------------------------------
       
   734 	TName qosName;
       
   735 	aPacketQoS.OpenNewQoS(aPacketContext, qosName);
       
   736 	CleanupClosePushL(aPacketQoS);	
       
   737 	
       
   738 	RBuf8 expectDataSPP;
       
   739 	CleanupClosePushL(expectDataSPP);
       
   740 	
       
   741 	TInt ret(KErrArgument); 	
       
   742  	
       
   743  	// Get Context current status 
       
   744  	// test 1: context not inited
       
   745     RPacketContext::TContextStatus contextStatus;    
       
   746     TBool statusChanged = EFalse;
       
   747     aPacketContext.GetStatus(contextStatus);
       
   748     
       
   749     //check  Context current status 
       
   750     if ( RPacketContext::EStatusActivating != contextStatus &&
       
   751              RPacketContext::EStatusActive != contextStatus)
       
   752     	{ 	   		
       
   753     		// and change it to RPacketContext::EStatusActive     		
       
   754     		SetContextActiveL(aContextName);  
       
   755     		statusChanged = ETrue;  		
       
   756     	}  
       
   757  	
       
   758  	
       
   759 	// ------ SetProfileParameters --------------------------------------------
       
   760 	TRequestStatus requestStatus;	
       
   761 	
       
   762 	if (TPacketDataConfigBase::KConfigGPRS == aRequested.ExtensionId())
       
   763 	{
       
   764 		RPacketQoS::TQoSGPRSRequested*  req;
       
   765 		req = reinterpret_cast< RPacketQoS::TQoSGPRSRequested* > ( &aRequested );
       
   766 		TPckg<RPacketQoS::TQoSGPRSRequested> pckg(*req);
       
   767 		// prepare data for expectDataSPP ... 
       
   768 		// ... context status
       
   769 		RPacketContext::TContextStatus contextStatus;
       
   770 		aPacketContext.GetStatus(contextStatus);
       
   771 		AssertMockLtsyStatusL();
       
   772 		// ... get  contextConfig
       
   773 		RPacketContext::TContextConfigGPRS contextConfig;
       
   774 		TPckg< RPacketContext::TContextConfigGPRS > pckgContextConfig = 
       
   775 		                   ( TPckg< RPacketContext::TContextConfigGPRS > ) contextConfig;	
       
   776 		aPacketContext.GetConfig(requestStatus, pckgContextConfig);
       
   777 		User::WaitForRequest(requestStatus);
       
   778 		AssertMockLtsyStatusL();	
       
   779 		
       
   780 		// data for SetProfileParameters's ExpectL		
       
   781 		TContextParams	contextParams;
       
   782 		contextParams.iContextName = aContextName;
       
   783 		contextParams.iContextType = contextConfig.iNWIContext;
       
   784 		contextParams.iPdpType = contextConfig.iPdpType;
       
   785 		contextParams.iPrimaryContextName = aPrimaryContextName;
       
   786 		contextParams.iContextStatus = contextStatus;		
       
   787 		TMockLtsyData2<TContextParams, RPacketQoS::TQoSGPRSRequested> 
       
   788 		                    expExpect(contextParams, *req);
       
   789 	    expExpect.SerialiseL(expectDataSPP);
       
   790 		
       
   791 		iMockLTSY.ExpectL(EPacketQoSSetProfileParams, expectDataSPP);
       
   792 		aPacketQoS.SetProfileParameters(requestStatus, pckg);
       
   793 		User::WaitForRequest(requestStatus);					
       
   794 		AssertMockLtsyStatusL();
       
   795 		ret = KErrNone;
       
   796 	}
       
   797 	
       
   798 	if (TPacketDataConfigBase::KConfigRel99Rel4 == aRequested.ExtensionId())
       
   799 	{
       
   800 		RPacketQoS::TQoSR99_R4Requested* req;
       
   801 		req = reinterpret_cast< RPacketQoS::TQoSR99_R4Requested* > ( &aRequested );		
       
   802 		TPckg<RPacketQoS::TQoSR99_R4Requested> pckg(*req);
       
   803 		
       
   804 		// prepare data for expectDataSPP ... 
       
   805 		// ... context status
       
   806 		RPacketContext::TContextStatus contextStatus;
       
   807 		aPacketContext.GetStatus(contextStatus);
       
   808 		// ... get  contextConfig
       
   809 		RPacketContext::TContextConfigR99_R4 contextConfig;
       
   810 		TPckg< RPacketContext::TContextConfigR99_R4 > pckgContextConfig = 
       
   811 		                   ( TPckg< RPacketContext::TContextConfigR99_R4 > ) contextConfig;	
       
   812 		aPacketContext.GetConfig(requestStatus, pckgContextConfig);
       
   813 		User::WaitForRequest(requestStatus);	
       
   814 		
       
   815 		// data for SetProfileParameters's ExpectL
       
   816 		TInfoName primaryContextName;	
       
   817 		TContextParams	contextParams;
       
   818 		contextParams.iContextName = aContextName;
       
   819 		contextParams.iContextType = contextConfig.iNWIContext;
       
   820 		contextParams.iPdpType = contextConfig.iPdpType;
       
   821 		contextParams.iPrimaryContextName = primaryContextName;
       
   822 		contextParams.iContextStatus = contextStatus;		
       
   823 		TMockLtsyData2<TContextParams, RPacketQoS::TQoSR99_R4Requested> 
       
   824 		                    expExpect(contextParams, *req);
       
   825 		expectDataSPP.Close();                    
       
   826 	    expExpect.SerialiseL(expectDataSPP);
       
   827 		
       
   828 		iMockLTSY.ExpectL(EPacketQoSSetProfileParams, expectDataSPP);		
       
   829 		aPacketQoS.SetProfileParameters(requestStatus, pckg);
       
   830 		User::WaitForRequest(requestStatus);
       
   831 		AssertMockLtsyStatusL();
       
   832 		ret = KErrNone;
       
   833 	}
       
   834 	
       
   835 	if (TPacketDataConfigBase::KConfigRel5 == aRequested.ExtensionId())
       
   836 	{
       
   837 		RPacketQoS::TQoSR5Requested* req;
       
   838 		req = reinterpret_cast< RPacketQoS::TQoSR5Requested* > ( &aRequested );		
       
   839 		TPckg<RPacketQoS::TQoSR5Requested> pckg(*req);
       
   840 		
       
   841 		// prepare data for expectDataSPP ... 
       
   842 		// ... context status
       
   843 		RPacketContext::TContextStatus contextStatus;
       
   844 		aPacketContext.GetStatus(contextStatus);
       
   845 		// ... get  contextConfig
       
   846 		RPacketContext::TContextConfig_R5 contextConfig;
       
   847 		TPckg< RPacketContext::TContextConfig_R5 > pckgContextConfig = 
       
   848 		                   ( TPckg< RPacketContext::TContextConfig_R5 > ) contextConfig;	
       
   849 		aPacketContext.GetConfig(requestStatus, pckgContextConfig);
       
   850 		User::WaitForRequest(requestStatus);	
       
   851 		
       
   852 		// data for SetProfileParameters's ExpectL
       
   853 		TInfoName primaryContextName;	
       
   854 		TContextParams	contextParams;
       
   855 		contextParams.iContextName = aContextName;
       
   856 		contextParams.iContextType = contextConfig.iNWIContext;
       
   857 		contextParams.iPdpType = contextConfig.iPdpType;
       
   858 		contextParams.iPrimaryContextName = primaryContextName;
       
   859 		contextParams.iContextStatus = contextStatus;		
       
   860 		TMockLtsyData2<TContextParams, RPacketQoS::TQoSR5Requested> 
       
   861 		                    expExpect(contextParams, *req);
       
   862 	    expectDataSPP.Close();
       
   863 	    expExpect.SerialiseL(expectDataSPP);
       
   864 		
       
   865 		iMockLTSY.ExpectL(EPacketQoSSetProfileParams, expectDataSPP);	
       
   866 		
       
   867 		aPacketQoS.SetProfileParameters(requestStatus, pckg);
       
   868 		User::WaitForRequest(requestStatus);
       
   869 		AssertMockLtsyStatusL();
       
   870 		ret = KErrNone;
       
   871 	}
       
   872     
       
   873     
       
   874     // if context status was changed
       
   875     if (statusChanged)
       
   876     	{
       
   877     	// return to previous status
       
   878     	SetContextStatusL(aContextName, contextStatus);
       
   879     	}
       
   880     
       
   881     CleanupStack::PopAndDestroy(1);// expectDataSPP    
       
   882     // aPacketQoS is still in CleanupStack !!!	
       
   883 	return ret;
       
   884 }
       
   885 
       
   886 
       
   887 /**
       
   888 Set status to RPacketService
       
   889 @param aStatus status to set
       
   890 @param aIsResumed -- is resumed
       
   891 */
       
   892 TInt CCSatComponentTestBase::SetPacketServiceStatusL(RPacketService::TStatus& aStatus, TBool aIsResumed)
       
   893 	{
       
   894 	
       
   895 	RBuf8 data;
       
   896 	CleanupClosePushL(data);
       
   897 	
       
   898 	// Data for CompleteL
       
   899 	TMockLtsyData2 <RPacketService::TStatus, TBool > ltsyData(aStatus, aIsResumed);
       
   900 	ltsyData.SerialiseL(data);
       
   901 	
       
   902 	TRequestStatus mockLtsyStatus;
       
   903 	iMockLTSY.NotifyTerminated(mockLtsyStatus);	
       
   904 		
       
   905 	// Issue the Complete...	
       
   906 	iMockLTSY.CompleteL(EPacketNotifyStatusChange, KErrNone, data);
       
   907 	User::WaitForRequest(mockLtsyStatus);
       
   908 	
       
   909 	CleanupStack::PopAndDestroy(1); // data
       
   910 	
       
   911 	return mockLtsyStatus.Int();	
       
   912 	}
       
   913 	
       
   914 /**
       
   915 Add filter to RContext
       
   916 @param aContext RPacketContext use to add filter 
       
   917 @param aPacketFilterInfo -- Reference to a TPacketFilterV2 class packaged inside a TPckg<> class.
       
   918 */
       
   919 TInt CCSatComponentTestBase::AddContextPacketFilterL(RPacketContext& aContext, 
       
   920 													TInfoName& aContextName, 
       
   921 													RPacketContext::TPacketFilterV2& aFilter, 
       
   922 													TBool aIsFailInCSAT)
       
   923 	{
       
   924 	
       
   925 	RBuf8 data;
       
   926 	CleanupClosePushL(data);
       
   927 		
       
   928 	TRequestStatus requestStatus;
       
   929 	
       
   930 	RPacketContext::TPacketFilterV2Pckg filterPckg (aFilter);
       
   931 
       
   932     // if request reaches LTSY
       
   933 	if (!aIsFailInCSAT)
       
   934 		{
       
   935 		//data for ExpectL
       
   936 		RPacketContext::TContextConfigGPRS configGPRS;
       
   937 		CArrayFixFlat< RPacketContext::TPacketFilterV2 >* filterArray = new ( ELeave ) CArrayFixFlat
       
   938                             <RPacketContext::TPacketFilterV2>( 1 );
       
   939 	    CleanupStack::PushL(filterArray);
       
   940 
       
   941 		filterArray->AppendL( aFilter );
       
   942 		
       
   943 		TMockLtsyContextData2< TInfoName, CArrayFixFlat< RPacketContext::TPacketFilterV2 >* > 
       
   944 					packetFilterData( configGPRS, 0, aContextName, filterArray );		
       
   945 		packetFilterData.SerialiseL(data);		 
       
   946 		iMockLTSY.ExpectL(EPacketContextAddPacketFilter, data);
       
   947 		
       
   948 		//data for CompleteL
       
   949 		TMockLtsyData1<TInfoName > contexName(aContextName);
       
   950     	data.Close();
       
   951     	contexName.SerialiseL(data); 			
       
   952 		iMockLTSY.CompleteL(EPacketContextSetConfig, KErrNone, data);
       
   953 		
       
   954 		CleanupStack::PopAndDestroy(1); // filterArray
       
   955 		}    
       
   956 		
       
   957 	aContext.AddPacketFilter(requestStatus, filterPckg);		
       
   958 	User::WaitForRequest(requestStatus);	
       
   959 	
       
   960 	CleanupStack::PopAndDestroy(1); // data
       
   961 	
       
   962 	return requestStatus.Int();
       
   963 	}
       
   964 
       
   965 TInt CCSatComponentTestBase::OpenNewCall(RLine& aLine, RCall& aCall, const TDesC& aLineName)
       
   966     {
       
   967     TName name;
       
   968     name = KMmTsyPhoneName;
       
   969     name.Append(KDoubleColon);
       
   970     name.Append(aLineName);
       
   971     name.Append(KDoubleColon);
       
   972 
       
   973    	return aCall.OpenNewCall(aLine, name);
       
   974     }
       
   975 
       
   976 TInt CCSatComponentTestBase::OpenNewCall(RLine& aLine, RCall& aCall, const TDesC& aLineName, TName& aNewName)
       
   977     {
       
   978     aNewName = KMmTsyPhoneName;
       
   979     aNewName.Append(KDoubleColon);
       
   980     aNewName.Append(aLineName);
       
   981     aNewName.Append(KDoubleColon);
       
   982 
       
   983    	return aCall.OpenNewCall(aLine, aNewName);
       
   984     }
       
   985 
       
   986 TInt CCSatComponentTestBase::CreateIncomingCall(RLine& aLine, 
       
   987                                             const TInt aCallId, 
       
   988                                             const TDesC& aLineName,
       
   989                                             TName& aIncomingCallName,
       
   990                                             RMobilePhone::TMobileService aMobileService)
       
   991 	{
       
   992     TInt errorCode = KErrNone;
       
   993     _LIT(KDoubleColon, "::");
       
   994 
       
   995     TName name;
       
   996     name = KMmTsyPhoneName;
       
   997     name.Append(KDoubleColon);
       
   998     name.Append(aLineName);
       
   999     name.Append(KDoubleColon);
       
  1000 	
       
  1001 	RCall call;
       
  1002     RBuf8 completeData;
       
  1003     CleanupClosePushL(completeData);
       
  1004 
       
  1005     TRequestStatus requestNotify;
       
  1006     TRequestStatus mockLtsyStatus;
       
  1007 
       
  1008    	errorCode = call.OpenNewCall(aLine, name);
       
  1009    	CleanupClosePushL(call);
       
  1010 
       
  1011    	if (errorCode != KErrNone)
       
  1012    		return errorCode;
       
  1013 
       
  1014 	aLine.NotifyIncomingCall(requestNotify, aIncomingCallName);
       
  1015 
       
  1016 	// Complete NotifyIncomingCall
       
  1017     RMobileCall::TMobileCallInfoV1 mobileCallInfo;
       
  1018     mobileCallInfo.iService = aMobileService;
       
  1019     TMockLtsyCallData1<RMobileCall::TMobileCallInfoV1> mockCallData1(aCallId, aMobileService, mobileCallInfo);
       
  1020     mockCallData1.SerialiseL(completeData);
       
  1021 	
       
  1022     iMockLTSY.NotifyTerminated(mockLtsyStatus);
       
  1023     iMockLTSY.CompleteL(KMockLtsyDispatchCallControlNotifyIncomingCallIndId, KErrNone, completeData);
       
  1024     User::WaitForRequest(mockLtsyStatus);
       
  1025     AssertMockLtsyStatusL();
       
  1026     ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int());
       
  1027     
       
  1028     User::WaitForRequest(requestNotify);
       
  1029     AssertMockLtsyStatusL();
       
  1030     ASSERT_EQUALS(KErrNone, requestNotify.Int());
       
  1031     
       
  1032     // Complete NotifyCallStatusChange with ringing status
       
  1033     RMobileCall::TMobileCallStatus callStatus = RMobileCall::EStatusRinging;
       
  1034     TMockLtsyCallData1<RMobileCall::TMobileCallStatus> mockCallData2(aCallId, aMobileService, callStatus);
       
  1035     completeData.Close();
       
  1036     mockCallData2.SerialiseL(completeData);
       
  1037 
       
  1038     iMockLTSY.NotifyTerminated(mockLtsyStatus);
       
  1039     iMockLTSY.CompleteL(KMockLtsyDispatchCallControlNotifyCallStatusChangeIndId , KErrNone, completeData);
       
  1040     User::WaitForRequest(mockLtsyStatus);
       
  1041     AssertMockLtsyStatusL();
       
  1042     ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int());
       
  1043 
       
  1044 	call.Close();
       
  1045 	AssertMockLtsyStatusL();
       
  1046 	CleanupStack::PopAndDestroy(2); // data, completeData 
       
  1047 	
       
  1048 	return errorCode;
       
  1049 	}
       
  1050 
       
  1051 void CCSatComponentTestBase::CloseIncomingCall(RCall& aCall, const TInt aCallId,
       
  1052                                            RMobilePhone::TMobileService aMobileService)
       
  1053 	{
       
  1054     RBuf8 expectData;
       
  1055     CleanupClosePushL(expectData);
       
  1056 
       
  1057 	TInt hangUpCause = KErrGsmReleaseByUser;
       
  1058 	TBool autoStChangeDisable = EFalse;
       
  1059     TMockLtsyCallData2<TInt, TBool> mockData2(aCallId, aMobileService, 
       
  1060                                              hangUpCause, 
       
  1061                                              autoStChangeDisable);
       
  1062     mockData2.SerialiseL(expectData);
       
  1063     iMockLTSY.ExpectL(EEtelCallHangUp, expectData);
       
  1064     
       
  1065 	aCall.Close();
       
  1066 	AssertMockLtsyStatusL();
       
  1067 
       
  1068     CleanupStack::PopAndDestroy(1); // expectData 
       
  1069 	}
       
  1070 	
       
  1071 	
       
  1072 void CCSatComponentTestBase::CloseLineL(RLine& aLine, TInt aCallId, RMobilePhone::TMobileService aMobileService)
       
  1073 	{
       
  1074 	RBuf8 expectData;
       
  1075 	CleanupClosePushL(expectData);
       
  1076 	
       
  1077 	// Get Call Status	
       
  1078 	RCall::TStatus callStatus;
       
  1079 	aLine.GetStatus(callStatus);
       
  1080 
       
  1081 	// Hang up call if call is still connecting 
       
  1082 	// so in this case we have to prepare expectData
       
  1083 	if ( !( RMobileCall::EStatusIdle == callStatus ||
       
  1084             RMobileCall::EStatusDisconnecting == callStatus ||
       
  1085             RMobileCall::EStatusDisconnectingWithInband == callStatus )
       
  1086            && aCallId !=0 && aMobileService != RMobilePhone::EServiceUnspecified)
       
  1087 		{
       
  1088 		// prepare data for close line
       
  1089 		TInt symbianHangUpCause( KErrGsmReleaseByUser );
       
  1090 		TBool autoStChangeDisable = EFalse;   
       
  1091 		TMockLtsyCallData2<TInt, TBool> expData(aCallId, aMobileService, symbianHangUpCause, autoStChangeDisable);
       
  1092 		expData.SerialiseL(expectData); 
       
  1093 		iMockLTSY.ExpectL(EEtelCallHangUp, expectData);
       
  1094 		}	
       
  1095 
       
  1096     // close line
       
  1097    	aLine.Close();   
       
  1098    	
       
  1099    	CleanupStack::PopAndDestroy(1); // expectData 	
       
  1100 	}
       
  1101 
       
  1102 //  ExpectL and CopmleteL must precede this function.
       
  1103 void CCSatComponentTestBase::CallGetMobileCallInfoL(TInt aCallId, 
       
  1104                                                RMobilePhone::TMobileService aService, 
       
  1105                                                const TDesC &aTelNumber)
       
  1106 	{
       
  1107 	_LIT(KNullDesC , "");
       
  1108 	
       
  1109 	RBuf8 data;
       
  1110 	CleanupClosePushL(data);
       
  1111 
       
  1112 	RMobileCall::TMobileCallInfoV1 callInfo;
       
  1113 	callInfo.iDialledParty.iTelNumber.Copy(aTelNumber);
       
  1114 	callInfo.iService = aService;
       
  1115 	callInfo.iEmergency = EFalse;
       
  1116 	callInfo.iRemoteParty.iCallingName = KNullDesC;
       
  1117 	callInfo.iRemoteParty.iRemoteIdStatus = RMobileCall::ERemoteIdentityUnknown;
       
  1118 	callInfo.iRemoteParty.iRemoteNumber.iTelNumber = KNullDesC;
       
  1119 	callInfo.iRemoteParty.iRemoteNumber.iNumberPlan = RMobilePhone::EUnknownNumberingPlan;
       
  1120 	callInfo.iRemoteParty.iRemoteNumber.iTypeOfNumber = RMobilePhone::EUnknownNumber;
       
  1121 	callInfo.iForwarded = EFalse;
       
  1122 	callInfo.iValid = RMobileCall::KCallDialledParty | RMobileCall::KCallRemoteParty;
       
  1123 
       
  1124 	TMockLtsyCallData1<RMobileCall::TMobileCallInfoV1> callInfoData(aCallId, aService, callInfo);
       
  1125 	callInfoData.SerialiseL(data);
       
  1126 		
       
  1127     iMockLTSY.CompleteL(EMobileCallGetMobileCallInfo, KErrNone, data);
       
  1128     
       
  1129     CleanupStack::PopAndDestroy(1);
       
  1130 	}
       
  1131 
       
  1132 CActiveScheduler* CCSatComponentTestBase::InstallSchedulerLC()
       
  1133 	{
       
  1134 	CActiveScheduler* scheduler=new (ELeave) CActiveScheduler;
       
  1135 	CActiveScheduler::Install(scheduler);	
       
  1136 	return scheduler;
       
  1137 	}
       
  1138 
       
  1139 
       
  1140 
       
  1141 /**
       
  1142  * Utility function which handles all the Expects/Completes generated by Opening an RSat object.
       
  1143  */
       
  1144 void CCSatComponentTestBase::OpenSatL(TUint8 aEnabled)
       
  1145 	{
       
  1146 	RBuf8 data;
       
  1147 	CleanupClosePushL(data);
       
  1148 	
       
  1149 	TRequestStatus reqStatus;
       
  1150 	
       
  1151 	iMockLTSY.ExpectL(MLtsyDispatchSatGetSmsControlActivated::KLtsyDispatchSatGetSmsControlActivatedApiId);
       
  1152 	
       
  1153 	TBool smsMoControlActivated = aEnabled & KSmsMoControlEnabled;
       
  1154 	TMockLtsyData1<TBool> comLtsyData(smsMoControlActivated);
       
  1155 	comLtsyData.SerialiseL(data);
       
  1156 	iMockLTSY.CompleteL(MLtsyDispatchSatGetSmsControlActivated::KLtsyDispatchSatGetSmsControlActivatedApiId, KErrNone, data, KDefaultDelay);
       
  1157 
       
  1158 	TUint8 pcmdCode = KPollInterval;
       
  1159 	TMockLtsyData1<TUint8> expLtsyData(pcmdCode);
       
  1160 	data.Close();
       
  1161 	expLtsyData.SerialiseL(data);
       
  1162 	iMockLTSY.ExpectL(MLtsyDispatchSatPCmdNotification::KLtsyDispatchSatPCmdNotificationApiId, data );
       
  1163 
       
  1164 	pcmdCode = KPollingOff;
       
  1165 	data.Close();
       
  1166 	expLtsyData.SerialiseL(data);
       
  1167 	iMockLTSY.ExpectL(MLtsyDispatchSatPCmdNotification::KLtsyDispatchSatPCmdNotificationApiId, data );
       
  1168 	
       
  1169 	pcmdCode = KMoreTime;
       
  1170 	data.Close();
       
  1171 	expLtsyData.SerialiseL(data);
       
  1172 	iMockLTSY.ExpectL(MLtsyDispatchSatPCmdNotification::KLtsyDispatchSatPCmdNotificationApiId, data );
       
  1173 	
       
  1174 	pcmdCode = KTimerManagement;
       
  1175 	data.Close();
       
  1176 	expLtsyData.SerialiseL(data);
       
  1177 	iMockLTSY.ExpectL(MLtsyDispatchSatPCmdNotification::KLtsyDispatchSatPCmdNotificationApiId, data );
       
  1178 	
       
  1179 	iMockLTSY.ExpectL(MLtsyDispatchPhoneGetPhoneId::KLtsyDispatchPhoneGetPhoneIdApiId);
       
  1180 	
       
  1181 	_LIT(KSerialNumber, "12345678");
       
  1182 	
       
  1183 	RMobilePhone::TMobilePhoneIdentityV1 phoneId;
       
  1184 	phoneId.iSerialNumber = KSerialNumber;
       
  1185 	
       
  1186 	TMockLtsyData1<RMobilePhone::TMobilePhoneIdentityV1> phoneIdData(phoneId);
       
  1187 	data.Close();
       
  1188 	phoneIdData.SerialiseL(data);
       
  1189 	iMockLTSY.CompleteL(MLtsyDispatchPhoneGetPhoneId::KLtsyDispatchPhoneGetPhoneIdApiId, KErrNone, data,KDefaultDelay);
       
  1190 	
       
  1191 	iMockLTSY.ExpectL(MLtsyDispatchSatGetDefaultBearerCapability::KLtsyDispatchSatGetDefaultBearerCapabilityApiId);
       
  1192 
       
  1193 	TBuf8<KMaxLengthDefaultBearerData> bearerCapabilities(_L8("TEST BEARER!"));
       
  1194 	TDesC8* bearerCapabilitiesPtr = &bearerCapabilities;
       
  1195 	TMockLtsyData1<TDesC8*> bearerCapabilitiesData(bearerCapabilitiesPtr);
       
  1196 	data.Close();
       
  1197 	bearerCapabilitiesData.SerialiseL(data);
       
  1198 	iMockLTSY.CompleteL(MLtsyDispatchSatGetDefaultBearerCapability::KLtsyDispatchSatGetDefaultBearerCapabilityApiId, KErrNone, data, KDefaultDelay);
       
  1199 	
       
  1200 	iMockLTSY.ExpectL(MLtsyDispatchSatGetUssdControlSupported::KLtsyDispatchSatGetUssdControlSupportedApiId);
       
  1201 
       
  1202 	TBool ussdSupported = aEnabled & KUssdEnabled;
       
  1203 	TMockLtsyData1<TBool> ussdSupportedData(ussdSupported);
       
  1204 	data.Close();
       
  1205 	ussdSupportedData.SerialiseL(data);
       
  1206 	iMockLTSY.CompleteL(MLtsyDispatchSatGetUssdControlSupported::KLtsyDispatchSatGetUssdControlSupportedApiId, KErrNone, data, KDefaultDelay);
       
  1207 	iMockLTSY.CompleteL(KMockLtsyDispatchSatUssdControlSupportedChangeIndId, KErrNone, data, KDefaultDelay); //do a future indicator completion as well as this could happen at some point
       
  1208 	
       
  1209 	iMockLTSY.ExpectL(MLtsyDispatchSatReady::KLtsyDispatchSatReadyApiId);
       
  1210 	iMockLTSY.CompleteL(MLtsyDispatchSatReady::KLtsyDispatchSatReadyApiId,KErrNone, KDefaultDelay);
       
  1211 	
       
  1212 	iMockLTSY.ExpectL(MLtsyDispatchSatGetSmsPpDownloadSupported::KLtsyDispatchSatGetSmsPpDownloadSupportedApiId);
       
  1213 
       
  1214 	TBool smsPpDdlSupported = aEnabled & KSmsPpDownloadEnabled;
       
  1215 	TMockLtsyData1<TBool> smsPpData(smsPpDdlSupported);
       
  1216 	data.Close();
       
  1217 	smsPpData.SerialiseL(data);
       
  1218 	iMockLTSY.CompleteL(MLtsyDispatchSatGetSmsPpDownloadSupported::KLtsyDispatchSatGetSmsPpDownloadSupportedApiId, KErrNone, data, KDefaultDelay);
       
  1219 		
       
  1220 	User::LeaveIfError(iSat.Open(iPhone));
       
  1221 
       
  1222 	WaitForMockLTSYTerminated();
       
  1223 	AssertMockLtsyStatusL();
       
  1224 	CleanupStack::PopAndDestroy(&data); 
       
  1225 	}
       
  1226 
       
  1227 
       
  1228 /**
       
  1229 Prepares MockLtsy with expected IPC data for proactive command notification
       
  1230 @param aPCmdNumber proactive command number
       
  1231 */
       
  1232 void CCSatComponentTestBase::PrepareMockWithExpDataForPCmdNotifyL( TUint8 aPCmdNumber )
       
  1233 	{
       
  1234 	TPckg<TUint8> pcmdCodePckg(aPCmdNumber);
       
  1235 	iMockLTSY.ExpectL(MLtsyDispatchSatPCmdNotification::KLtsyDispatchSatPCmdNotificationApiId, pcmdCodePckg);
       
  1236 	}
       
  1237 
       
  1238 
       
  1239 /**
       
  1240 Prepares MockLtsy with data for completion of proactive command notification
       
  1241 @param aCompleteTlv proactive command Tlv
       
  1242 @param aError proactive command notification result code
       
  1243 */
       
  1244 void CCSatComponentTestBase::PrepareMockWithCompleteDataForPCmdNotifyL( TPtrC8 aCompleteTlv, TInt aError, TInt aDelay )
       
  1245 	{
       
  1246 	RBuf8 data;
       
  1247 	CleanupClosePushL(data);	
       
  1248 
       
  1249 	TDesC8* tlvPtr = &aCompleteTlv;
       
  1250 	
       
  1251 	TMockLtsyData1<TDesC8*> dspTxtDscPack(tlvPtr);
       
  1252 	dspTxtDscPack.SerialiseL(data);
       
  1253 	iMockLTSY.CompleteL(KMockLtsyDispatchSatPcmdIndId, aError, data, aDelay);
       
  1254 
       
  1255 	CleanupStack::PopAndDestroy(&data);
       
  1256 	}
       
  1257 
       
  1258 
       
  1259 /**
       
  1260 Fills in a proactive command Tlv with command details and device identities
       
  1261 @param aTlv Tlv to fill in
       
  1262 @param aPCmdNumber proactive command number
       
  1263 @param aTypeOfCommand type of proactive command
       
  1264 @param aCommandQualifier proactive command qualifier
       
  1265 @param aDestDeviceId command destination device Id
       
  1266 */
       
  1267 void ProactiveCmdTlvBegin( 
       
  1268 		TTlv& aTlv, 
       
  1269 		TUint8 aPCmdNumber,
       
  1270 		TUint8 aTypeOfCommand,
       
  1271 		TUint8 aCommandQualifier,
       
  1272 		TUint8 aDestDeviceId)
       
  1273 	{
       
  1274 	aTlv.Begin(KBerTlvProactiveSimCommandTag);
       
  1275 	aTlv.AddTag(KTlvCommandDetailsTag);
       
  1276 	aTlv.AddByte(aPCmdNumber);//ETLV_CommandNumber
       
  1277 	aTlv.AddByte(aTypeOfCommand); //ETLV_TypeOfCommand
       
  1278 	aTlv.AddByte(aCommandQualifier); //ETLV_CommandQualifier
       
  1279 	
       
  1280 	if ( KDeviceIdNotSet != aDestDeviceId )
       
  1281 		{
       
  1282 		aTlv.AddTag(KTlvDeviceIdentityTag); 
       
  1283 		aTlv.AddByte(KSim); //ETLV_SourceDeviceIdentity
       
  1284 		aTlv.AddByte(aDestDeviceId); //ETLV_DestinationDeviceIdentity
       
  1285 		}
       
  1286 	}
       
  1287 
       
  1288 
       
  1289 /**
       
  1290 Generates a terminal response Tlv
       
  1291 @param aBuf A buffer to fill in Tlv
       
  1292 @param aPCmdNumber proactive command number
       
  1293 @param aTypeOfCommand type of proactive command
       
  1294 @param aCommandQualifier proactive command qualifier
       
  1295 @param aGeneralResult result code of proactive command processing
       
  1296 @param aGeneralResultAddInfo additional command result information
       
  1297 @param aAdditionalInfoTlv additional tlv data
       
  1298 */
       
  1299 void CCSatComponentTestBase::GenerateTermRspTlv(
       
  1300 		RBuf8& aBuf, 
       
  1301 		TUint8 aPCmdNumber,
       
  1302 		TUint8 aTypeOfCommand, 
       
  1303 		TUint8 aCommandQualifier, 
       
  1304 		RSat::TPCmdResult aGeneralResult, 
       
  1305 		const TDesC& aGeneralResultAddInfo, 
       
  1306 		const TDesC8& aAdditionalInfoTlv)
       
  1307 	{
       
  1308 	TTlv tlv;
       
  1309 	tlv.AddTag(KTlvCommandDetailsTag);
       
  1310 	tlv.AddByte(aPCmdNumber);//ETLV_CommandNumber
       
  1311 	tlv.AddByte(aTypeOfCommand); //ETLV_TypeOfCommand
       
  1312 	tlv.AddByte(aCommandQualifier); //ETLV_CommandQualifier
       
  1313 
       
  1314 	tlv.AddTag(KTlvDeviceIdentityTag);
       
  1315 	tlv.AddByte(KMe);
       
  1316 	tlv.AddByte(KSim);
       
  1317 	
       
  1318 	tlv.AddTag(KTlvResultTag);
       
  1319 	tlv.AddByte(aGeneralResult);
       
  1320 	TUint genResAddInfoLength = aGeneralResultAddInfo.Length();
       
  1321 	for (TUint i = 0; i < genResAddInfoLength; i++)
       
  1322 		{
       
  1323 		tlv.AddByte( static_cast< TUint8 >(aGeneralResultAddInfo[i]) );
       
  1324 		}
       
  1325 
       
  1326 	aBuf.Zero();
       
  1327 	aBuf.Append(tlv.GetDataWithoutTopLevelTag());
       
  1328 	aBuf.Append(aAdditionalInfoTlv);
       
  1329 	}
       
  1330 
       
  1331 
       
  1332 /**
       
  1333 Prepares MockLtsy with expected IPC data for terminal response
       
  1334 @param aPCmdNumber proactive command number
       
  1335 @param aTypeOfCommand type of proactive command
       
  1336 @param aCommandQualifier proactive command qualifier
       
  1337 @param aGeneralResult result code of proactive command processing
       
  1338 @param aGeneralResultAddInfo additional command result information
       
  1339 @param aAdditionalInfoTlv additional tlv data
       
  1340 @param aResultForExpect result value for ExpectL() 
       
  1341 */
       
  1342 void CCSatComponentTestBase::PrepareTerminalResponseMockDataL(
       
  1343 		TUint8 aPCmdNumber,
       
  1344 		TUint8 aTypeOfCommand,
       
  1345 		TUint8 aCommandQualifier,
       
  1346 		const TDesC& aGeneralResultAddInfo,
       
  1347 		RSat::TPCmdResult aGeneralResult,
       
  1348 		const TDesC8& aAdditionalInfoTlv,
       
  1349 		const TInt aResultForExpect)
       
  1350 	{
       
  1351 	RBuf8 data;
       
  1352 	CleanupClosePushL(data);	
       
  1353 	
       
  1354 	RBuf8 terminalRsp;
       
  1355 	CleanupClosePushL(terminalRsp);
       
  1356 	terminalRsp.CreateL(KTlvMaxSize);
       
  1357 	
       
  1358 	GenerateTermRspTlv(
       
  1359 			terminalRsp,
       
  1360 			aPCmdNumber,
       
  1361 			aTypeOfCommand,
       
  1362 			aCommandQualifier,
       
  1363 			aGeneralResult,
       
  1364 			aGeneralResultAddInfo,
       
  1365 			aAdditionalInfoTlv);
       
  1366 	
       
  1367 	TDesC8* terminalRspPtr = &terminalRsp;
       
  1368 	
       
  1369 	TMockLtsyData1<TDesC8*> termRespData(terminalRspPtr);
       
  1370 	termRespData.SerialiseL(data);
       
  1371 	
       
  1372 	iMockLTSY.ExpectL(MLtsyDispatchSatTerminalRsp::KLtsyDispatchSatTerminalRspApiId, data, aResultForExpect);
       
  1373 	
       
  1374 	CleanupStack::PopAndDestroy(&terminalRsp);
       
  1375 	CleanupStack::PopAndDestroy(&data);
       
  1376 	}
       
  1377 
       
  1378 
       
  1379 /**
       
  1380 Sends a terminal response.
       
  1381 @param aRSatTypeOfCommand proactive command number
       
  1382 @param aRspPckg packaged data for terminal response
       
  1383 @param aExpResult expected result of TerminalRsp() execution
       
  1384 */
       
  1385 void CCSatComponentTestBase::TerminalResponseL(
       
  1386 		RSat::TPCmd aRSatTypeOfCommand,
       
  1387 		const TDesC8& aRspPckg, 
       
  1388 		const TInt aExpResult)
       
  1389 	{
       
  1390 	TRequestStatus reqStatus;
       
  1391 	iSat.TerminalRsp(reqStatus, aRSatTypeOfCommand, aRspPckg);
       
  1392 	User::WaitForRequest(reqStatus);
       
  1393 	ASSERT_EQUALS(aExpResult, reqStatus.Int());
       
  1394 	}
       
  1395 	
       
  1396 	
       
  1397 /**
       
  1398 Handles sending a terminal response
       
  1399 @param aPCmdNumber proactive command number
       
  1400 @param aTypeOfCommand type of proactive command
       
  1401 @param aCommandQualifier proactive command qualifier
       
  1402 @param aRSatTypeOfCommand proactive command number
       
  1403 @param aRspPckg packaged data for terminal response
       
  1404 @param aGeneralResultAddInfo additional command result information
       
  1405 @param aGeneralResult result code of proactive command processing
       
  1406 @param aAdditionalInfoTlv additional tlv data
       
  1407 @param aExpResult expected result of TerminalRsp() execution
       
  1408 */
       
  1409 void CCSatComponentTestBase::GenerateTerminalResponseL(
       
  1410 		TUint8 aPCmdNumber,
       
  1411 		TUint8 aTypeOfCommand,
       
  1412 		TUint8 aCommandQualifier,
       
  1413 		RSat::TPCmd aRSatTypeOfCommand,
       
  1414 		const TDesC8& aRspPckg,
       
  1415 		const TDesC& aGeneralResultAddInfo,
       
  1416 		RSat::TPCmdResult aGeneralResult,
       
  1417 		const TDesC8& aAdditionalInfoTlv,
       
  1418 		const TInt aExpResult)
       
  1419 	{
       
  1420 	PrepareTerminalResponseMockDataL(
       
  1421 			aPCmdNumber,
       
  1422 			aTypeOfCommand,
       
  1423 			aCommandQualifier,
       
  1424 			aGeneralResultAddInfo,
       
  1425 			aGeneralResult,
       
  1426 			aAdditionalInfoTlv);
       
  1427 	TerminalResponseL( aRSatTypeOfCommand, aRspPckg, aExpResult);
       
  1428 	}
       
  1429 
       
  1430 
       
  1431 /**
       
  1432 End Proactive Sim Session 
       
  1433 */    
       
  1434 void CCSatComponentTestBase::EndPSimSessionL()
       
  1435 	{
       
  1436 	//this is as a result of the NotifyProactiveSimSessionEnd call down to the LTSY,
       
  1437 	//this tells the LTSY we are interested in a Sim Session End event
       
  1438 	//CSAT -> LTSY
       
  1439 	PrepareMockWithExpDataForPCmdNotifyL(KEndOfTheProactiveSession);
       
  1440 	
       
  1441 	//the client side call to be notifed when the Proactive Sim Session has ended.
       
  1442 	TRequestStatus reqStatus;
       
  1443 	iSat.NotifyProactiveSimSessionEnd(reqStatus);
       
  1444 
       
  1445 	TUint8 statusWord1 = 0x90;
       
  1446 	TUint8 statusWord2 = 0x00;
       
  1447 	TMockLtsyData2<TUint8,TUint8> notifyDataPack(statusWord1,statusWord2);
       
  1448 
       
  1449 	RBuf8 data;
       
  1450 	CleanupClosePushL(data);	
       
  1451 	notifyDataPack.SerialiseL(data);
       
  1452 	
       
  1453 	iMockLTSY.CompleteL(KMockLtsyDispatchSatNotifyProactiveSimSessionEndIndId, KErrNone, data);
       
  1454 	
       
  1455 	//wait for the client side to be notified
       
  1456 	User::WaitForRequest(reqStatus);
       
  1457 	ASSERT_EQUALS(KErrNone, reqStatus.Int());
       
  1458 	AssertMockLtsyStatusL();	
       
  1459 
       
  1460 	CleanupStack::PopAndDestroy(&data);
       
  1461 	}
       
  1462 
       
  1463 /**
       
  1464 Test if a proactive command was performed successfully
       
  1465 */
       
  1466 TBool CCSatComponentTestBase::CommandPerformedSuccessfully
       
  1467         ( 
       
  1468         TUint8 aGeneralResult 
       
  1469         )
       
  1470     {
       
  1471     TBool ret( EFalse );
       
  1472 	switch ( aGeneralResult )
       
  1473 	    { 
       
  1474         case RSat::KSuccess:
       
  1475         case RSat::KPartialComprehension:
       
  1476         case RSat::KMissingInformation:
       
  1477         case RSat::KRefreshAdditionEFRead:
       
  1478         case RSat::KSuccessRequestedIconNotDisplayed:
       
  1479         case RSat::KModifiedByCallControl:
       
  1480         case RSat::KSuccessLimitedService:
       
  1481         case RSat::KPerformedWithModifications:
       
  1482         case RSat::KRefreshUSIMNotActive:
       
  1483         	{
       
  1484     		ret = ETrue;
       
  1485             break;
       
  1486         	}
       
  1487 	    default:
       
  1488 	    	{	
       
  1489 		    ret = EFalse;
       
  1490 		    break;
       
  1491 	    	}
       
  1492 	    }
       
  1493     return ret;
       
  1494    }
       
  1495 
       
  1496 
       
  1497 /**
       
  1498 Compares 16bit descriptor with 8bit descriptor
       
  1499 @param aStringToCompareWith string to compare with
       
  1500 @param aStringToCompare string to compare
       
  1501 @return
       
  1502 Positive, if this descriptor is greater than the specified descriptor.
       
  1503 Negative, if this descriptor is less than the specified descriptor.
       
  1504 Zero, if both descriptors have the same length and the their contents are the same.
       
  1505 */
       
  1506 TInt Compare16bitDesWith8bitDesL(const TDesC8& aStringToCompareWith, const TDesC16& aStringToCompare)
       
  1507 	{
       
  1508 	RBuf8 buf;
       
  1509 
       
  1510 	buf.CreateL(aStringToCompare.Length());
       
  1511 	buf.Copy(aStringToCompare);
       
  1512 
       
  1513 	TInt res = aStringToCompareWith.Compare(buf);
       
  1514 	
       
  1515 	buf.Close();
       
  1516 	
       
  1517 	return res;
       
  1518 	}
       
  1519 
       
  1520 
       
  1521 /**
       
  1522 Converts Unicode to packed 7 bit
       
  1523 @param aInput Input string
       
  1524 @param aOutput Output string
       
  1525 @return KErrNone or the luck space of output descriptor
       
  1526 */
       
  1527 TInt CCSatComponentTestBase::UnicodeToPacked7L(const TDesC16& aInput, TDes8& aOutput)
       
  1528 	{
       
  1529 	TInt length( aInput.Length() );
       
  1530 	RBuf8 string;
       
  1531 	string.CleanupClosePushL();
       
  1532 	string.CreateL( length );
       
  1533 		
       
  1534 	// convert unicode to 7 bit SMS default alphabet
       
  1535 	CCnvCharacterSetConverter* converter = CCnvCharacterSetConverter::NewLC();
       
  1536 
       
  1537 	RFs fileServSes;
       
  1538 	ASSERT_EQUALS(CCnvCharacterSetConverter::EAvailable,
       
  1539 			converter->PrepareToConvertToOrFromL(KCharacterSetIdentifierSms7Bit, fileServSes));
       
  1540 	
       
  1541 	ASSERT_EQUALS(KErrNone,	converter->ConvertFromUnicode(string, aInput));
       
  1542 	
       
  1543 	CleanupStack::PopAndDestroy(converter);
       
  1544 
       
  1545 	// pack 7 bit data
       
  1546 	TUint8 shift( 0 );
       
  1547 	TInt packedDataSize( 0 );
       
  1548 	
       
  1549 	for ( TInt i = 0; i < length; i++ )
       
  1550 		{
       
  1551 		// Get first character
       
  1552 		TUint8 char1 = static_cast<TUint8>( string[i] >> shift ); 
       
  1553 		TUint8 char2( 0 );
       
  1554 		
       
  1555 		if ( length > ( i + 1 ) ) // if not last symbol
       
  1556 			{
       
  1557 			// Get next character
       
  1558 			char2 = static_cast<TUint8>( string[i + 1]  << ( 7 - shift ) );
       
  1559 			}
       
  1560 		
       
  1561 		// update packed character
       
  1562 		string[ packedDataSize++ ] = static_cast<TUint8>( char1 | char2 );
       
  1563 	
       
  1564 		// character is 7bit coded, so the shift can not be more then 6
       
  1565 		if ( 6 == shift )
       
  1566 			{
       
  1567 			shift = 0;
       
  1568 			// the next symbol is allready packed (8 bytes packed in 7 bytes)
       
  1569 			// so let increase the counter
       
  1570 			i++;
       
  1571 			}
       
  1572 		else
       
  1573 			{
       
  1574 			shift++;
       
  1575 			}
       
  1576 		}
       
  1577 	
       
  1578 	string.SetLength( packedDataSize );
       
  1579 	
       
  1580 	if ( 0 == shift )
       
  1581 		{
       
  1582 		// 7 last bytes packed in 7 bytes, so there are 7 spare zero bits at
       
  1583 		// the end of the message. To avoid the situation where the receiving
       
  1584 		// entity confuses 7 binary zero pad bits as the @ character,
       
  1585 		// the carriage return (i.e. <CR>) character shall be used for padding
       
  1586 		// in this situation, as defined in TS 23.038 [5]. <CR> = 0x0D
       
  1587 		string[ packedDataSize - 1 ] =
       
  1588 				static_cast<TUint8>( string[ packedDataSize - 1 ] | (0x0D)<<1 );
       
  1589 		}
       
  1590 	
       
  1591 	TInt copySize = Min( packedDataSize, aOutput.MaxLength() );
       
  1592 	
       
  1593 	aOutput.Copy( string.Left( copySize ) );
       
  1594 	CleanupStack::PopAndDestroy(&string);
       
  1595 	
       
  1596 	return (packedDataSize == copySize)?KErrNone:(packedDataSize - copySize);
       
  1597 	}
       
  1598 
       
  1599