telephonyserverplugins/ctsydispatchlayer/test/dispatchertests/dispatchsrc/cctsysimfu.cpp
changeset 0 3553901f7fa8
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 The TEFUnit test suite for SimControl in the Common TSY.
       
    20 */
       
    21 
       
    22 #include "cctsysimfu.h"
       
    23 #include <etel.h>
       
    24 #include <etelmm.h>
       
    25 #include <et_clsvr.h>
       
    26 #include <ctsy/mmtsy_names.h>
       
    27 #include <ctsy/serviceapi/mmtsy_ipcdefs.h>
       
    28 #include <test/tmockltsydata.h>
       
    29 #include <ctsy/serviceapi/gsmerror.h>
       
    30 #include <ctsy/serviceapi/cmmutility.h>
       
    31 #include <ctsy/ltsy/mltsydispatchsiminterface.h>
       
    32 #include <ctsy/ltsy/mltsydispatchphoneinterface.h>
       
    33 #include <etelmmerr.h>
       
    34 #include <ctsy/ltsy/cctsydispatchercallback.h>
       
    35 #include <ctsy/ltsy/mltsydispatchsecurityinterface.h>
       
    36 #include "mockltsyindicatorids.h"
       
    37 
       
    38 #include <etelmmerr.h>
       
    39 #include <e32math.h> 
       
    40 
       
    41 CTestSuite* CCTsySimFU::CreateSuiteL(const TDesC& aName)
       
    42 	{
       
    43 	SUB_SUITE;
       
    44 
       
    45 	//add use-case tests
       
    46 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUseCase0001L);
       
    47 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUseCase0002L);
       
    48 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUseCase0003L);
       
    49 
       
    50 	//add other unit tests
       
    51 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0001L);
       
    52 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0002L);
       
    53 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0003L);
       
    54 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0004L);
       
    55 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0005L);
       
    56 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0006L);
       
    57 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0007L);
       
    58 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0008L);
       
    59 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0009L);
       
    60 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0010L);
       
    61 
       
    62 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0011L);
       
    63 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0012L);
       
    64 	
       
    65 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0013L);
       
    66 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0014L);
       
    67 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0015L);
       
    68 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0016L);
       
    69 	ADD_TEST_STEP_ISO_CPP(CCTsySimFU, TestUnit0017L);
       
    70 	
       
    71 	END_SUITE;
       
    72 	}
       
    73 
       
    74 
       
    75 //
       
    76 // Use-case tests
       
    77 //
       
    78 
       
    79 /**
       
    80 @SYMTestCaseID BA-CTSYD-DIS-SIM-UC0001
       
    81 @SYMComponent telephony_ctsy
       
    82 @SYMTestCaseDesc Test support in CTSY for get, set and notify for MWIS
       
    83 @SYMTestPriority High
       
    84 @SYMTestActions Invokes RMobilePhone::NotifyIccMessageWaitingIndicatorsChange, RMobilePhone::GetIccMessageWaitingIndicators, RMobilePhone::SetIccMessageWaitingIndicators
       
    85 @SYMTestExpectedResults Pass
       
    86 @SYMTestType CT
       
    87  */
       
    88 void CCTsySimFU::TestUseCase0001L()
       
    89 	{
       
    90 	OpenEtelServerL(EUseExtendedError);
       
    91 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
    92 	OpenPhoneL();
       
    93 
       
    94 	RBuf8 data;
       
    95 	CleanupClosePushL(data);
       
    96 
       
    97 	/*
       
    98 	 * NotifyIccMessageWaitingIndicatorsChange
       
    99 	 */
       
   100 
       
   101 	TRequestStatus requestStatus;
       
   102 	TRequestStatus mockLtsyStatus;
       
   103 
       
   104 	RMobilePhone::TMobilePhoneMessageWaitingV1 mwiRet;
       
   105 	RMobilePhone::TMobilePhoneMessageWaitingV1Pckg mwiRetPckg(mwiRet);
       
   106 	iPhone.NotifyIccMessageWaitingIndicatorsChange(requestStatus, mwiRetPckg);
       
   107 
       
   108 	// Prepare the NotifyIccMessageWaitingIndicatorsChange data for CompleteL
       
   109 	RMobilePhone::TMobilePhoneMessageWaitingV1 mwiNotifComplete;
       
   110 	mwiNotifComplete.iAuxVoiceMsgs = 1;
       
   111 	mwiNotifComplete.iDataMsgs = 2;
       
   112 	mwiNotifComplete.iDisplayStatus = 3;
       
   113 	mwiNotifComplete.iEmailMsgs = 4;
       
   114 	mwiNotifComplete.iFaxMsgs = 5;
       
   115 	mwiNotifComplete.iOtherMsgs = 6;
       
   116 	mwiNotifComplete.iVoiceMsgs = 7;
       
   117 
       
   118 	TMockLtsyData1<RMobilePhone::TMobilePhoneMessageWaitingV1> mockMwisData1(mwiNotifComplete);
       
   119 
       
   120 	// Send the CompleteL to MockLtsy
       
   121 	iMockLTSY.NotifyTerminated(mockLtsyStatus);
       
   122 
       
   123 	data.Close();
       
   124 	mockMwisData1.SerialiseL(data);
       
   125 	iMockLTSY.CompleteL(KMockLtsyDispatchSimNotifyIccMessageWaitingIndicatorsChangeIndId, KErrNone, data);
       
   126 	User::WaitForRequest(mockLtsyStatus);
       
   127 	AssertMockLtsyStatusL();
       
   128     ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int());
       
   129 
       
   130     // Check completion of api
       
   131     User::WaitForRequest(requestStatus);
       
   132     AssertMockLtsyStatusL();
       
   133     ASSERT_EQUALS(KErrNone, requestStatus.Int());
       
   134 
       
   135     // Check returned data
       
   136     ASSERT_EQUALS(mwiRet.iAuxVoiceMsgs, mwiNotifComplete.iAuxVoiceMsgs);
       
   137     ASSERT_EQUALS(mwiRet.iDataMsgs, mwiNotifComplete.iDataMsgs);
       
   138     ASSERT_EQUALS(mwiRet.iDisplayStatus, mwiNotifComplete.iDisplayStatus);
       
   139     ASSERT_EQUALS(mwiRet.iEmailMsgs, mwiNotifComplete.iEmailMsgs);
       
   140     ASSERT_EQUALS(mwiRet.iFaxMsgs, mwiNotifComplete.iFaxMsgs);
       
   141     ASSERT_EQUALS(mwiRet.iOtherMsgs, mwiNotifComplete.iOtherMsgs);
       
   142     ASSERT_EQUALS(mwiRet.iVoiceMsgs, mwiNotifComplete.iVoiceMsgs);
       
   143 
       
   144 	/*
       
   145 	 * SetIccMessageWaitingIndicators.
       
   146 	 * Also test NotifyIccMessageWaitingIndicatorsChange triggered
       
   147 	 * from a client set when the SetIccMessageWaitingIndicators data values are different to previous values.
       
   148 	 */
       
   149 
       
   150     // Post notification
       
   151     TRequestStatus requestStatusNotif;
       
   152     iPhone.NotifyIccMessageWaitingIndicatorsChange(requestStatusNotif, mwiRetPckg);
       
   153 
       
   154     // Prepare ExpectL data for the Set
       
   155 	RMobilePhone::TMobilePhoneMessageWaitingV1 mwiSet;
       
   156 	RMobilePhone::TMobilePhoneMessageWaitingV1Pckg mwiSetRetPckg(mwiSet);
       
   157 	// Use values for setting the data that is different to what was used before, so that
       
   158 	// Ctsy detects a change and hence issues a notification.
       
   159 	// (Not each of the fields have necessarily to be different).
       
   160 	mwiSet.iAuxVoiceMsgs = ++mwiNotifComplete.iAuxVoiceMsgs;
       
   161 	mwiSet.iDataMsgs = ++mwiNotifComplete.iDataMsgs;
       
   162 	mwiSet.iDisplayStatus = ++mwiNotifComplete.iDisplayStatus;
       
   163 	mwiSet.iEmailMsgs = ++mwiNotifComplete.iEmailMsgs;
       
   164 	mwiSet.iFaxMsgs = ++mwiNotifComplete.iFaxMsgs;
       
   165 	mwiSet.iOtherMsgs = ++mwiNotifComplete.iOtherMsgs;
       
   166 	mwiSet.iVoiceMsgs = ++mwiNotifComplete.iVoiceMsgs;
       
   167 
       
   168 	TMockLtsyData1<RMobilePhone::TMobilePhoneMessageWaitingV1>setData(mwiSet);
       
   169 	data.Close();
       
   170 	setData.SerialiseL(data);
       
   171 
       
   172 	iMockLTSY.ExpectL(MLtsyDispatchSimSetIccMessageWaitingIndicators::KLtsyDispatchSimSetIccMessageWaitingIndicatorsApiId, data, KErrNone);
       
   173 	iMockLTSY.CompleteL(MLtsyDispatchSimSetIccMessageWaitingIndicators::KLtsyDispatchSimSetIccMessageWaitingIndicatorsApiId, KErrNone);
       
   174 
       
   175 	// Call api
       
   176 	TRequestStatus requestStatusSet;
       
   177 	iPhone.SetIccMessageWaitingIndicators(requestStatusSet, mwiSetRetPckg);
       
   178 	User::WaitForRequest(requestStatusSet);
       
   179 	ASSERT_EQUALS(KErrNone, requestStatusSet.Int());
       
   180 	AssertMockLtsyStatusL();
       
   181 
       
   182 	// Wait for notificaion
       
   183     User::WaitForRequest(requestStatusNotif);
       
   184     AssertMockLtsyStatusL();
       
   185     ASSERT_EQUALS(KErrNone, requestStatusNotif.Int());
       
   186 
       
   187 	/*
       
   188 	 * GetIccMessageWaitingIndicators
       
   189 	 */
       
   190 
       
   191 	TRequestStatus requestStatusGet;
       
   192 
       
   193 	// Send the ExpectL
       
   194 	iMockLTSY.ExpectL(MLtsyDispatchSimGetIccMessageWaitingIndicators::KLtsyDispatchSimGetIccMessageWaitingIndicatorsApiId);
       
   195 
       
   196 	// Prepare data for the mockLtsy's CompleteL
       
   197 	RMobilePhone::TMobilePhoneMessageWaitingV1 mwiComp;
       
   198 	mwiComp.iDisplayStatus = 0xff;
       
   199 	mwiComp.iVoiceMsgs = 0x01;
       
   200 	mwiComp.iAuxVoiceMsgs = 0x02;
       
   201 	mwiComp.iDataMsgs = 0x03;
       
   202 	mwiComp.iFaxMsgs = 0x04;
       
   203 	mwiComp.iEmailMsgs = 0x05;
       
   204 	mwiComp.iOtherMsgs = 0x06;
       
   205 	TMockLtsyData1<RMobilePhone::TMobilePhoneMessageWaitingV1> mwisdCompData(mwiComp);
       
   206 	data.Close();
       
   207 	mwisdCompData.SerialiseL(data);
       
   208 	iMockLTSY.CompleteL(MLtsyDispatchSimGetIccMessageWaitingIndicators::KLtsyDispatchSimGetIccMessageWaitingIndicatorsApiId, KErrNone, data);
       
   209 
       
   210 	// Now call the ipc
       
   211 	RMobilePhone::TMobilePhoneMessageWaitingV1 mwiGet;
       
   212 	RMobilePhone::TMobilePhoneMessageWaitingV1Pckg mwiGetPckg(mwiGet);
       
   213 	iPhone.GetIccMessageWaitingIndicators(requestStatusGet, mwiGetPckg);
       
   214 
       
   215 	User::WaitForRequest(requestStatusGet);
       
   216 	ASSERT_EQUALS(KErrNone, requestStatusGet.Int());
       
   217 	AssertMockLtsyStatusL();
       
   218 
       
   219 	// Check returned data
       
   220     ASSERT_EQUALS(mwiGet.iAuxVoiceMsgs, mwiComp.iAuxVoiceMsgs);
       
   221     ASSERT_EQUALS(mwiGet.iDataMsgs, mwiComp.iDataMsgs);
       
   222     ASSERT_EQUALS(mwiGet.iDisplayStatus, mwiComp.iDisplayStatus);
       
   223     ASSERT_EQUALS(mwiGet.iEmailMsgs, mwiComp.iEmailMsgs);
       
   224     ASSERT_EQUALS(mwiGet.iFaxMsgs, mwiComp.iFaxMsgs);
       
   225     ASSERT_EQUALS(mwiGet.iOtherMsgs, mwiComp.iOtherMsgs);
       
   226     ASSERT_EQUALS(mwiGet.iVoiceMsgs, mwiComp.iVoiceMsgs);
       
   227 
       
   228     data.Close();
       
   229 	AssertMockLtsyStatusL();
       
   230 	CleanupStack::PopAndDestroy(2, this); // data, this
       
   231 	}
       
   232 
       
   233 
       
   234 /**
       
   235 @SYMTestCaseID BA-CTSYD-DIS-SIM-UC0002
       
   236 @SYMComponent telephony_ctsy
       
   237 @SYMTestCaseDesc Test support in CTSY for APN Control List operations
       
   238 @SYMTestPriority High
       
   239 @SYMTestActions Invokes RMobilePhone::GetAPNControlListServiceStatus , RMobilePhone::NotifyAPNControlListServiceStatusChange, RMobilePhone::SetAPNControlListServiceStatus
       
   240 @SYMTestExpectedResults Pass
       
   241 @SYMTestType CT
       
   242  */
       
   243 void CCTsySimFU::TestUseCase0002L()
       
   244 	{
       
   245   OpenEtelServerL(EUseExtendedError);
       
   246 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   247 	OpenPhoneL();
       
   248 
       
   249 	RBuf8 data;
       
   250 	CleanupClosePushL(data);
       
   251 
       
   252 	TRequestStatus mockLtsyStatus;
       
   253 
       
   254 	/*
       
   255 	 * GetAPNControlListServiceStatus
       
   256 	 */
       
   257 
       
   258 	TRequestStatus requestStatusGet;
       
   259 
       
   260 	// Send the ExpectL
       
   261 	iMockLTSY.ExpectL(MLtsyDispatchSimGetApnControlListServiceStatus::KLtsyDispatchSimGetApnControlListServiceStatusApiId);
       
   262 
       
   263 	// Prepare data for the mockLtsy's CompleteL
       
   264 	RMobilePhone::TAPNControlListServiceStatus statusComp = RMobilePhone::EAPNControlListServiceDisabled;
       
   265 
       
   266 	TMockLtsyData1<RMobilePhone::TAPNControlListServiceStatus> statusCompData(statusComp);
       
   267 	data.Close();
       
   268 	statusCompData.SerialiseL(data);
       
   269 	iMockLTSY.CompleteL(MLtsyDispatchSimGetApnControlListServiceStatus::KLtsyDispatchSimGetApnControlListServiceStatusApiId, KErrNone, data);
       
   270 
       
   271 	// Now call the ipc
       
   272 	RMobilePhone::TAPNControlListServiceStatus statusGet;
       
   273 	iPhone.GetAPNControlListServiceStatus(requestStatusGet, statusGet);
       
   274 
       
   275 	User::WaitForRequest(requestStatusGet);
       
   276 	ASSERT_EQUALS(KErrNone, requestStatusGet.Int());
       
   277 	AssertMockLtsyStatusL();
       
   278 	ASSERT_EQUALS(statusGet, statusComp);
       
   279 
       
   280 	/*
       
   281 	 * Set the APN Control List status to Enabled using SetAPNControlListServiceStatus and check for update using
       
   282 	 * NotifyAPNControlListServiceStatusChange.
       
   283 	 */
       
   284 
       
   285 	// Post notification
       
   286 	TRequestStatus requestStatusNotif;
       
   287 	RMobilePhone::TAPNControlListServiceStatus statusNotif;
       
   288 	iPhone.NotifyAPNControlListServiceStatusChange(requestStatusNotif, statusNotif);
       
   289 
       
   290 	// Prepare ExpectL data for the Set
       
   291 	RMobilePhone::TAPNControlListServiceStatus statusSet = RMobilePhone::EAPNControlListServiceEnabled;
       
   292 
       
   293 	TMockLtsyData1<RMobilePhone::TAPNControlListServiceStatus>setData(statusSet);
       
   294 	data.Close();
       
   295 	setData.SerialiseL(data);
       
   296 
       
   297 	iMockLTSY.ExpectL(MLtsyDispatchSimSetApnControlListServiceStatus::KLtsyDispatchSimSetApnControlListServiceStatusApiId, data, KErrNone);
       
   298 	iMockLTSY.CompleteL(MLtsyDispatchSimSetApnControlListServiceStatus::KLtsyDispatchSimSetApnControlListServiceStatusApiId, KErrNone);
       
   299 
       
   300 	// Call api
       
   301 	TRequestStatus requestStatusSet;
       
   302 	iPhone.SetAPNControlListServiceStatus(requestStatusSet, statusSet);
       
   303 	User::WaitForRequest(requestStatusSet);
       
   304 	ASSERT_EQUALS(KErrNone, requestStatusSet.Int());
       
   305 	AssertMockLtsyStatusL();
       
   306 
       
   307 	// Prepare CompleteL data for the notification (will be same as that used in the Set).
       
   308 	RMobilePhone::TAPNControlListServiceStatus statusNotifComp = statusSet;
       
   309 	TMockLtsyData1<RMobilePhone::TAPNControlListServiceStatus> statusNotifCompData1(statusNotifComp);
       
   310 	data.Close();
       
   311 	statusNotifCompData1.SerialiseL(data);
       
   312 	// Send CompleteL for the notification
       
   313 	iMockLTSY.NotifyTerminated(mockLtsyStatus);
       
   314 	iMockLTSY.CompleteL(KMockLtsyDispatchSimNotifyApnControlListServiceStatusChangeIndId, KErrNone, data);
       
   315 	User::WaitForRequest(mockLtsyStatus);
       
   316 	AssertMockLtsyStatusL();
       
   317     ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int());
       
   318 
       
   319     // Check completion of notification
       
   320     User::WaitForRequest(requestStatusNotif);
       
   321     AssertMockLtsyStatusL();
       
   322     ASSERT_EQUALS(KErrNone, requestStatusNotif.Int());
       
   323 
       
   324     // Check data returned in the notification same as date used in the Set.
       
   325     ASSERT_EQUALS(statusNotif, statusSet);
       
   326 
       
   327     data.Close();
       
   328 	AssertMockLtsyStatusL();
       
   329 	CleanupStack::PopAndDestroy(2, this); // data, this
       
   330 	}
       
   331 
       
   332 /**
       
   333 @SYMTestCaseID BA-CTSYD-DIS-SIM-UC0003
       
   334 @SYMComponent telephony_ctsy
       
   335 @SYMTestCaseDesc Test support in CTSY for APN list operations
       
   336 @SYMTestPriority High
       
   337 @SYMTestActions Invokes RMobilePhone::AppendAPNName, RMobilePhone::DeleteAPNName, RMobilePhone::GetAPNname, RMobilePhone::EnumerateAPNEntries, RMobilePhone::NotifyAPNListChanged
       
   338 @SYMTestExpectedResults Pass
       
   339 @SYMTestType CT
       
   340  */
       
   341 void CCTsySimFU::TestUseCase0003L()
       
   342 	{
       
   343   OpenEtelServerL(EUseExtendedError);
       
   344 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   345 	OpenPhoneL();
       
   346 
       
   347 	RBuf8 data;
       
   348 	CleanupClosePushL(data);
       
   349 
       
   350 	/*
       
   351 	 * EnumerateAPNEntries
       
   352 	 */
       
   353 
       
   354 	TRequestStatus requestStatusEnmrt;
       
   355 
       
   356 	// Prepare ExpectL and CompleteL data
       
   357 	iMockLTSY.ExpectL(MLtsyDispatchSimEnumerateApnEntries::KLtsyDispatchSimEnumerateApnEntriesApiId);
       
   358 
       
   359 	const TUint32 KNumAPNListEntries = 5;
       
   360 	TUint32 enmrtComp = KNumAPNListEntries;
       
   361 	TMockLtsyData1<TUint32> enmrtCompData(enmrtComp);
       
   362 	data.Close();
       
   363 	enmrtCompData.SerialiseL(data);
       
   364 	iMockLTSY.CompleteL(MLtsyDispatchSimEnumerateApnEntries::KLtsyDispatchSimEnumerateApnEntriesApiId, KErrNone, data);
       
   365 
       
   366 	// Call ipc
       
   367 	TUint32 enmrtRet;
       
   368 	iPhone.EnumerateAPNEntries(requestStatusEnmrt, enmrtRet);
       
   369 	User::WaitForRequest(requestStatusEnmrt);
       
   370 	ASSERT_EQUALS(KErrNone, requestStatusEnmrt.Int());
       
   371 	AssertMockLtsyStatusL();
       
   372 
       
   373 	// Check returned data
       
   374 	ASSERT_EQUALS(enmrtComp, enmrtRet);
       
   375 
       
   376 	data.Close();
       
   377 	AssertMockLtsyStatusL();
       
   378 
       
   379 	/*
       
   380 	 * GetAPNname
       
   381 	 */
       
   382 
       
   383 	TRequestStatus requestStatusGet;
       
   384 
       
   385 	// Prepare ExpectL and CompleteL data
       
   386 	TUint32 index = 69;
       
   387 	TMockLtsyData1<TUint32> indexData(index);
       
   388 	indexData.SerialiseL(data);
       
   389 	iMockLTSY.ExpectL(MLtsyDispatchSimGetApnName::KLtsyDispatchSimGetApnNameApiId, data, KErrNone);
       
   390 
       
   391 	RMobilePhone::TAPNEntryV3 apnEntryComp;
       
   392 	const TBuf8<RMobilePhone::KMaxApnName> KApnName(_L8("Mobile Network access point 1"));
       
   393 	apnEntryComp.iApn = KApnName;
       
   394 	TMockLtsyData1<RMobilePhone::TAPNEntryV3> apnEntryData(apnEntryComp);
       
   395 	data.Close();
       
   396 	apnEntryData.SerialiseL(data);
       
   397 	iMockLTSY.CompleteL(MLtsyDispatchSimGetApnName::KLtsyDispatchSimGetApnNameApiId, KErrNone, data);
       
   398 
       
   399 	// Call ipc
       
   400 	RMobilePhone::TAPNEntryV3 apnEntryGet;
       
   401 	RMobilePhone::TAPNEntryV3Pckg apnEntryGetPckg(apnEntryGet);
       
   402 	iPhone.GetAPNname(requestStatusGet, index, apnEntryGetPckg);
       
   403 	User::WaitForRequest(requestStatusGet);
       
   404 	ASSERT_EQUALS(KErrNone, requestStatusGet.Int());
       
   405 	AssertMockLtsyStatusL();
       
   406 
       
   407 	// Check returned data
       
   408 	ASSERT_EQUALS(apnEntryGet.iApn, apnEntryComp.iApn);
       
   409 
       
   410     data.Close();
       
   411 	AssertMockLtsyStatusL();
       
   412 
       
   413 	/*
       
   414 	 * DeleteAPNName and notify of change to APN list using NotifyAPNListChanged
       
   415 	 */
       
   416 
       
   417 	// Post notification
       
   418 	TRequestStatus requestStatusNotif;
       
   419 	iPhone.NotifyAPNListChanged(requestStatusNotif);
       
   420 
       
   421 	// Prepare ExpectL and CompleteL data for the delete
       
   422 	TUint32 indexDel = 49;
       
   423 	TMockLtsyData1<TUint32> indexDelData(indexDel);
       
   424 	indexDelData.SerialiseL(data);
       
   425 	iMockLTSY.ExpectL(MLtsyDispatchSimDeleteApnName::KLtsyDispatchSimDeleteApnNameApiId, data, KErrNone);
       
   426 
       
   427 	iMockLTSY.CompleteL(MLtsyDispatchSimDeleteApnName::KLtsyDispatchSimDeleteApnNameApiId, KErrNone);
       
   428 
       
   429 	// Now call the ipc
       
   430 	TRequestStatus requestStatusDel;
       
   431 	iPhone.DeleteAPNName(requestStatusDel, indexDel);
       
   432 	User::WaitForRequest(requestStatusDel);
       
   433 	ASSERT_EQUALS(KErrNone, requestStatusDel.Int());
       
   434 	AssertMockLtsyStatusL();
       
   435 
       
   436 	// Send CompleteL for noticn
       
   437 	iMockLTSY.CompleteL(KMockLtsyDispatchSimNotifyApnListChangeIndId , KErrNone);
       
   438 	User::WaitForRequest(requestStatusNotif);
       
   439 	ASSERT_EQUALS(KErrNone, requestStatusNotif.Int());
       
   440 
       
   441     data.Close();
       
   442 	AssertMockLtsyStatusL();
       
   443 
       
   444 	/*
       
   445 	 * AppendAPNName
       
   446 	 */
       
   447 
       
   448 	// Prepare ExpectL and CompleteL data for the append
       
   449 	const TBuf8<RMobilePhone::KMaxApnName> KApnNameAppend(_L8("New Mobile Network access point 2"));
       
   450 	RMobilePhone::TAPNEntryV3 entryExp;
       
   451 	entryExp.iApn = KApnNameAppend;
       
   452 	TMockLtsyData1<RMobilePhone::TAPNEntryV3> entryExpData(entryExp);
       
   453 	data.Close();
       
   454 	entryExpData.SerialiseL(data);
       
   455 	iMockLTSY.ExpectL(MLtsyDispatchSimAppendApnName::KLtsyDispatchSimAppendApnNameApiId, data, KErrNone);
       
   456 	iMockLTSY.CompleteL(MLtsyDispatchSimAppendApnName::KLtsyDispatchSimAppendApnNameApiId, KErrNone);
       
   457 
       
   458 	// Now call the ipc
       
   459 	TRequestStatus requestStatusApp;
       
   460 	RMobilePhone::TAPNEntryV3Pckg entryAppPckg(entryExp);
       
   461 	iPhone.AppendAPNName(requestStatusApp, entryAppPckg);
       
   462 	User::WaitForRequest(requestStatusApp);
       
   463 	ASSERT_EQUALS(KErrNone, requestStatusApp.Int());
       
   464 	AssertMockLtsyStatusL();
       
   465 
       
   466     data.Close();
       
   467 	AssertMockLtsyStatusL();
       
   468 	CleanupStack::PopAndDestroy(2, this); // data, this
       
   469 	}
       
   470 
       
   471 
       
   472 
       
   473 //
       
   474 // Other unit tests
       
   475 //
       
   476 
       
   477 /**
       
   478 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0001
       
   479 @SYMComponent telephony_ctsy
       
   480 @SYMTestCaseDesc Test support in CTSYDispatch for RMobilePhone::GetServiceTable
       
   481 @SYMTestPriority High
       
   482 @SYMTestActions Invokes RMobilePhone::GetServiceTable
       
   483 @SYMTestExpectedResults Pass
       
   484 @SYMTestType UT
       
   485  */
       
   486 void CCTsySimFU::TestUnit0001L()
       
   487 	{
       
   488 	OpenEtelServerL(EUseExtendedError);
       
   489 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   490 	
       
   491 	RMobilePhone::TMobilePhoneServiceTableV1 simServiceTable;
       
   492 	simServiceTable.iServices1To8  = 0xFF;
       
   493 	simServiceTable.iServices9To16 = 0xFF;
       
   494 	simServiceTable.iServices17To24= 0xFF;
       
   495 	simServiceTable.iServices25To32= 0xFF;
       
   496 	simServiceTable.iServices33To40= 0xFF;
       
   497 	simServiceTable.iServices41To48= 0xFF;
       
   498 	simServiceTable.iServices49To56= 0xFF;
       
   499 	
       
   500 	OpenPhoneL(simServiceTable);
       
   501 
       
   502 	TRequestStatus mockLtsyStatus;
       
   503 	iMockLTSY.NotifyTerminated(mockLtsyStatus);
       
   504 
       
   505 	RBuf8 data;
       
   506 	CleanupClosePushL(data);
       
   507 
       
   508 	RMobilePhone::TMobilePhoneServiceTableV1 tbData;
       
   509 	RMobilePhone::TMobilePhoneServiceTableV1Pckg pkg(tbData);
       
   510 
       
   511 	//test getting service table when TSY not ready (ICC type is unknown)
       
   512 	
       
   513 	TRequestStatus reqStat;
       
   514 	iPhone.GetServiceTable(reqStat, RMobilePhone::EUSIMServiceTable, pkg);
       
   515 	User::WaitForRequest(reqStat);
       
   516 	ASSERT_EQUALS(reqStat.Int(), KErrMMEtelWrongMode);
       
   517 
       
   518 	//now get the ICC type.  We do this by invoking NotifySecurityEvent - why I don't know!
       
   519 	iMockLTSY.ExpectL(MLtsyDispatchSimGetActiveIccApplicationType::KLtsyDispatchSimGetActiveIccApplicationTypeApiId);
       
   520 	MLtsyDispatchSimGetActiveIccApplicationType::TIccType type =  MLtsyDispatchSimGetActiveIccApplicationType::EIccTypeSim3G;
       
   521 	TMockLtsyData1<MLtsyDispatchSimGetActiveIccApplicationType::TIccType> retIccType(type);
       
   522 	retIccType.SerialiseL(data);
       
   523 	iMockLTSY.CompleteL(MLtsyDispatchSimGetActiveIccApplicationType::KLtsyDispatchSimGetActiveIccApplicationTypeApiId,KErrNone,data, 0);
       
   524 
       
   525 	iMockLTSY.ExpectL(MLtsyDispatchSecurityGetCurrentActivePin::KLtsyDispatchSecurityGetCurrentActivePinApiId);
       
   526 
       
   527 	RMobilePhone::TMobilePhoneSecurityCode secCode = RMobilePhone::ESecurityCodePin1;
       
   528 	TMockLtsyData1<RMobilePhone::TMobilePhoneSecurityCode> secCodeData(secCode);
       
   529 	data.Close();
       
   530 	secCodeData.SerialiseL(data);	
       
   531 	iMockLTSY.CompleteL(MLtsyDispatchSecurityGetCurrentActivePin::KLtsyDispatchSecurityGetCurrentActivePinApiId, KErrNone, data);
       
   532 							
       
   533 	TRequestStatus reqStat2;
       
   534 	RMobilePhone::TMobilePhoneSecurityEvent event(RMobilePhone::EUniversalPukVerified);
       
   535 	iPhone.NotifySecurityEvent(reqStat2, event);
       
   536 
       
   537 	User::WaitForRequest(mockLtsyStatus);
       
   538 	iPhone.CancelAsyncRequest(EMobilePhoneNotifySecurityEvent);
       
   539 
       
   540 	User::After(5000000);  // A delay is required by MockSY when being tested on hardware.
       
   541 
       
   542 	
       
   543 	//test getting cached service table
       
   544 	
       
   545 	iPhone.GetServiceTable(reqStat, RMobilePhone::ESIMServiceTable, pkg);
       
   546 	User::WaitForRequest(reqStat);
       
   547 	ASSERT_EQUALS(reqStat.Int(), KErrNone);
       
   548 	ASSERT_EQUALS(tbData.iServices1To8,simServiceTable.iServices1To8);
       
   549 	ASSERT_EQUALS(tbData.iServices9To16,simServiceTable.iServices9To16);
       
   550 	ASSERT_EQUALS(tbData.iServices17To24,simServiceTable.iServices17To24);
       
   551 	ASSERT_EQUALS(tbData.iServices25To32,simServiceTable.iServices25To32);
       
   552 	ASSERT_EQUALS(tbData.iServices33To40,simServiceTable.iServices33To40);
       
   553 	ASSERT_EQUALS(tbData.iServices41To48,simServiceTable.iServices41To48);
       
   554 	ASSERT_EQUALS(tbData.iServices49To56,simServiceTable.iServices49To56);
       
   555 
       
   556 	//finally test successful retrieval of service table
       
   557 
       
   558 	RMobilePhone::TMobilePhoneServiceTable serviceTable = RMobilePhone::EUSIMServiceTable;
       
   559 	TMockLtsyData1<RMobilePhone::TMobilePhoneServiceTable> serviceTableData(serviceTable);
       
   560 	data.Close();
       
   561 	serviceTableData.SerialiseL(data);
       
   562 	
       
   563 	iMockLTSY.ExpectL(MLtsyDispatchSimGetServiceTable::KLtsyDispatchSimGetServiceTableApiId, data);
       
   564 
       
   565 	RMobilePhone::TMobilePhoneServiceTableV1 serviceTableResult;
       
   566 	serviceTableResult.iServices1To8  = 0xFF;
       
   567 	serviceTableResult.iServices9To16 = 0xFF;
       
   568 	serviceTableResult.iServices17To24= 0xFF;
       
   569 	serviceTableResult.iServices25To32= 0xFF;
       
   570 	serviceTableResult.iServices33To40= 0xFF;
       
   571 	serviceTableResult.iServices41To48= 0xFF;
       
   572 	serviceTableResult.iServices49To56= 0xFF;
       
   573 
       
   574 	TMockLtsyData1<RMobilePhone::TMobilePhoneServiceTableV1> serviceTableResultData(serviceTableResult);
       
   575 	data.Close();
       
   576 	serviceTableResultData.SerialiseL(data);
       
   577 	iMockLTSY.CompleteL(MLtsyDispatchSimGetServiceTable::KLtsyDispatchSimGetServiceTableApiId,KErrNone,data,0);
       
   578 
       
   579 	iPhone.GetServiceTable(reqStat, RMobilePhone::EUSIMServiceTable, pkg);
       
   580 	User::WaitForRequest(reqStat);
       
   581 	ASSERT_EQUALS(reqStat.Int(), KErrNone);
       
   582 	ASSERT_EQUALS(tbData.iServices1To8, serviceTableResult.iServices1To8);
       
   583 	ASSERT_EQUALS(tbData.iServices9To16, serviceTableResult.iServices9To16);
       
   584 	ASSERT_EQUALS(tbData.iServices17To24, serviceTableResult.iServices17To24);
       
   585 	ASSERT_EQUALS(tbData.iServices25To32, serviceTableResult.iServices25To32);
       
   586 	ASSERT_EQUALS(tbData.iServices33To40, serviceTableResult.iServices33To40);
       
   587 	ASSERT_EQUALS(tbData.iServices41To48, serviceTableResult.iServices41To48);
       
   588 	ASSERT_EQUALS(tbData.iServices49To56, serviceTableResult.iServices49To56);
       
   589 
       
   590 
       
   591 #ifdef EMULATOR_ONLY
       
   592 	//test cancel
       
   593 	
       
   594 	data.Close();
       
   595 	serviceTableData.SerialiseL(data);
       
   596 	iMockLTSY.ExpectL(MLtsyDispatchSimGetServiceTable::KLtsyDispatchSimGetServiceTableApiId, data);
       
   597 	//no complete as testing cancel
       
   598 
       
   599 	iPhone.GetServiceTable(reqStat, RMobilePhone::EUSIMServiceTable, pkg);
       
   600 	iPhone.CancelAsyncRequest(EMobilePhoneGetServiceTable);
       
   601 	User::WaitForRequest(reqStat);
       
   602 	ASSERT_EQUALS(KErrCancel, reqStat.Int());
       
   603 #endif // EMULATOR_ONLY
       
   604 
       
   605 	data.Close();
       
   606 	AssertMockLtsyStatusL();
       
   607 	CleanupStack::PopAndDestroy(2, this); // data, this
       
   608 	}
       
   609 
       
   610 
       
   611 /**
       
   612 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0002
       
   613 @SYMComponent telephony_ctsy
       
   614 @SYMTestCaseDesc Test support in CTSYDispatch for RMobilePhone::ChangeSecurityCode
       
   615 @SYMTestPriority High
       
   616 @SYMTestActions Invokes RMobilePhone::ChangeSecurityCode
       
   617 @SYMTestExpectedResults Pass
       
   618 @SYMTestType UT
       
   619  */
       
   620 void CCTsySimFU::TestUnit0002L()
       
   621 	{
       
   622 	OpenEtelServerL(EUseExtendedError);
       
   623 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   624 	OpenPhoneL();
       
   625 
       
   626 	RBuf8 data;
       
   627 	CleanupClosePushL(data);
       
   628 
       
   629 	TRequestStatus reqStatus;
       
   630 
       
   631 	_LIT(KOldPwd,"oldPswd");
       
   632 	_LIT(KNewPwd,"newPswd");
       
   633 	RMobilePhone::TMobilePhonePasswordChangeV1 pwdChange;
       
   634 	pwdChange.iNewPassword = KNewPwd;
       
   635 	pwdChange.iOldPassword = KOldPwd;
       
   636 
       
   637 	// Choose Phone Device Lock
       
   638 	RMobilePhone::TMobilePhoneSecurityCode secCode = RMobilePhone::ESecurityCodePhonePassword;
       
   639 
       
   640 	// Prepare Mock Ltsy data for the ExpectL
       
   641 	TMockLtsyData2<RMobilePhone::TMobilePhoneSecurityCode,
       
   642 				   RMobilePhone::TMobilePhonePasswordChangeV1> pwdData(secCode, pwdChange);
       
   643 	pwdData.SerialiseL(data);
       
   644 
       
   645 	iMockLTSY.ExpectL(MLtsyDispatchSimChangeSecurityCode::KLtsyDispatchSimChangeSecurityCodeApiId, data);
       
   646 
       
   647 	// The Mock Ltsy CompleteL doesn't require data
       
   648 	iMockLTSY.CompleteL(MLtsyDispatchSimChangeSecurityCode::KLtsyDispatchSimChangeSecurityCodeApiId, KErrNone);
       
   649 
       
   650 	// Call the API
       
   651 	iPhone.ChangeSecurityCode(reqStatus, secCode, pwdChange);
       
   652 	User::WaitForRequest(reqStatus);
       
   653 	ASSERT_EQUALS(KErrNone, reqStatus.Int());
       
   654 
       
   655 	data.Close();
       
   656 
       
   657 	AssertMockLtsyStatusL();
       
   658 	CleanupStack::PopAndDestroy(2, this); // data, this
       
   659 	}
       
   660 
       
   661 
       
   662 /**
       
   663 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0003
       
   664 @SYMComponent telephony_ctsy
       
   665 @SYMTestCaseDesc Test support in CTSYDispatch for RMobilePhone::GetSubscriberId
       
   666 @SYMTestPriority High
       
   667 @SYMTestActions Invokes RMobilePhone::GetSubscriberId
       
   668 @SYMTestExpectedResults Pass
       
   669 @SYMTestType UT
       
   670  */
       
   671 void CCTsySimFU::TestUnit0003L()
       
   672 	{
       
   673 	OpenEtelServerL(EUseExtendedError);
       
   674 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   675 	OpenPhoneL();
       
   676 
       
   677 	TRequestStatus mockLtsyStatus;
       
   678 	iMockLTSY.NotifyTerminated(mockLtsyStatus);
       
   679 
       
   680 	RBuf8 data;
       
   681 	CleanupClosePushL(data);
       
   682 
       
   683 	TRequestStatus reqStatus;
       
   684 	_LIT8  (KIMSI8, "012012012012999");
       
   685 	_LIT16(KIMSI16, "012012012012999");
       
   686 
       
   687 	// Send the ExpectL
       
   688 	iMockLTSY.ExpectL(MLtsyDispatchSimGetSubscriberId::KLtsyDispatchSimGetSubscriberIdApiId);
       
   689 
       
   690 	// Prepare data for the mockLtsy's CompleteL
       
   691 	// Note the CTSY expects the data in 8-bit format.
       
   692 	TBuf8<RMobilePhone::KIMSISize> idComp(KIMSI8);
       
   693 	TMockLtsyData1<TBuf8<RMobilePhone::KIMSISize> > idCompData(idComp);
       
   694 
       
   695 	data.Close();
       
   696 	idCompData.SerialiseL(data);
       
   697 	iMockLTSY.CompleteL(MLtsyDispatchSimGetSubscriberId::KLtsyDispatchSimGetSubscriberIdApiId, KErrNone, data);
       
   698 
       
   699 	// Now call the ipc
       
   700 	RMobilePhone::TMobilePhoneSubscriberId idGet;
       
   701 	iPhone.GetSubscriberId(reqStatus, idGet);
       
   702 
       
   703 	User::WaitForRequest(reqStatus);
       
   704 	ASSERT_EQUALS(KErrNone, reqStatus.Int());
       
   705 	AssertMockLtsyStatusL();
       
   706 	ASSERT_TRUE(idGet == KIMSI16); // ASSERT_EQUALS will not work here
       
   707 
       
   708 	data.Close();
       
   709 	AssertMockLtsyStatusL();
       
   710 	CleanupStack::PopAndDestroy(2, this); // data, this
       
   711 	}
       
   712 
       
   713 
       
   714 /**
       
   715 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0004
       
   716 @SYMComponent telephony_ctsy
       
   717 @SYMTestCaseDesc Test support in CTSYDispatch for RMobilePhone::GetCustomerServiceProfile
       
   718 @SYMTestPriority High
       
   719 @SYMTestActions Invokes RMobilePhone::GetCustomerServiceProfile
       
   720 @SYMTestExpectedResults Pass
       
   721 @SYMTestType UT
       
   722  */
       
   723 void CCTsySimFU::TestUnit0004L()
       
   724 	{
       
   725 	OpenEtelServerL(EUseExtendedError);
       
   726 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   727 	OpenPhoneL();
       
   728 
       
   729 	TRequestStatus mockLtsyStatus;
       
   730 	iMockLTSY.NotifyTerminated(mockLtsyStatus);
       
   731 
       
   732 	RBuf8 data;
       
   733 	CleanupClosePushL(data);
       
   734 
       
   735 	TRequestStatus reqStatus;
       
   736 
       
   737 	// Send the ExpectL
       
   738 	iMockLTSY.ExpectL(MLtsyDispatchSimGetCustomerServiceProfile::KLtsyDispatchSimGetCustomerServiceProfileApiId);
       
   739 
       
   740 	// Prepare data for the mockLtsy's CompleteL
       
   741 	RMobilePhone::TMobilePhoneCspFileV1 cspComp;
       
   742 	cspComp.iCallOfferingServices = 0x01;
       
   743 	cspComp.iCallRestrictionServices = 0x02;
       
   744 	cspComp.iOtherSuppServices = 0x03;
       
   745 	cspComp.iCallCompletionServices = 0x04;
       
   746 	cspComp.iTeleservices = 0x05;
       
   747 	cspComp.iCphsTeleservices = 0x06;
       
   748 	cspComp.iCphsFeatures = 0x07;
       
   749 	cspComp.iNumberIdentServices = 0x08;
       
   750 	cspComp.iPhase2PlusServices = 0x09;
       
   751 	cspComp.iValueAddedServices = 0x0A;
       
   752 	TMockLtsyData1<RMobilePhone::TMobilePhoneCspFileV1> cspCompData(cspComp);
       
   753 	data.Close();
       
   754 	cspCompData.SerialiseL(data);
       
   755 	iMockLTSY.CompleteL(MLtsyDispatchSimGetCustomerServiceProfile::KLtsyDispatchSimGetCustomerServiceProfileApiId, KErrNone, data);
       
   756 
       
   757 	// Now call the ipc
       
   758 	RMobilePhone::TMobilePhoneCspFileV1 cspGet;
       
   759 	RMobilePhone::TMobilePhoneCspFileV1Pckg cspGetPckg(cspGet);
       
   760 	iPhone.GetCustomerServiceProfile(reqStatus, cspGetPckg);
       
   761 	User::WaitForRequest(reqStatus);
       
   762 	ASSERT_EQUALS(KErrNone, reqStatus.Int());
       
   763 	AssertMockLtsyStatusL();
       
   764 	ASSERT_EQUALS(cspComp.iCallOfferingServices, cspGet.iCallOfferingServices);
       
   765 	ASSERT_EQUALS(cspComp.iCallRestrictionServices, cspGet.iCallRestrictionServices);
       
   766 	ASSERT_EQUALS(cspComp.iOtherSuppServices, cspGet.iOtherSuppServices);
       
   767 	ASSERT_EQUALS(cspComp.iCallCompletionServices, cspGet.iCallCompletionServices);
       
   768 	ASSERT_EQUALS(cspComp.iTeleservices, cspGet.iTeleservices);
       
   769 	ASSERT_EQUALS(cspComp.iCphsTeleservices, cspGet.iCphsTeleservices);
       
   770 	ASSERT_EQUALS(cspComp.iCphsFeatures, cspGet.iCphsFeatures);
       
   771 	ASSERT_EQUALS(cspComp.iNumberIdentServices, cspGet.iNumberIdentServices);
       
   772 	ASSERT_EQUALS(cspComp.iPhase2PlusServices, cspGet.iPhase2PlusServices);
       
   773 	ASSERT_EQUALS(cspComp.iValueAddedServices, cspGet.iValueAddedServices);
       
   774 
       
   775 	data.Close();
       
   776 	AssertMockLtsyStatusL();
       
   777 	CleanupStack::PopAndDestroy(2, this); // data, this
       
   778 	}
       
   779 
       
   780 
       
   781 /**
       
   782 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0005
       
   783 @SYMComponent telephony_ctsy
       
   784 @SYMTestCaseDesc Test support in CTSYDispatch for RMobilePhone::SetFdnSetting, RMobilePhone::VerifySecurityCode
       
   785 @SYMTestPriority High
       
   786 @SYMTestActions Invokes RMobilePhone::SetFdnSetting
       
   787 @SYMTestExpectedResults Pass
       
   788 @SYMTestType UT
       
   789  */
       
   790 void CCTsySimFU::TestUnit0005L()
       
   791 	{
       
   792 	/*
       
   793 	 * This test uses VerifySecurityCode with SetFdnSetting to get the SetFdnSetting sent to the LTSY
       
   794 	 */
       
   795 
       
   796 	OpenEtelServerL(EUseExtendedError);
       
   797 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   798 	OpenPhoneL();
       
   799 
       
   800 	TRequestStatus mockLtsyStatus;
       
   801 	iMockLTSY.NotifyTerminated(mockLtsyStatus);
       
   802 
       
   803 	RBuf8 data;
       
   804 	CleanupClosePushL(data);
       
   805 
       
   806 	TRequestStatus reqStatus, reqStatusNotif, reqStatusVerify;
       
   807 
       
   808 	// Prepare data for mockLtsy for the VerifySecurityCode.
       
   809 	// This mimics the scenario that Pin2 code is required to make SetFdnSetting complete successfully.
       
   810 	// Therefore we use VerifySecurityCode to supply the Pin2 code.
       
   811 	RMobilePhone::TMobilePhoneSecurityCode secCode = RMobilePhone::ESecurityCodePin2;
       
   812 
       
   813 	_LIT(KPwd,"pwd");
       
   814 	_LIT(KUnblockPwd, "unblockPwd");
       
   815 	RMobilePhone::TMobilePassword pwd;
       
   816 	RMobilePhone::TMobilePassword unblockPwd;
       
   817 	pwd.Copy(KPwd);
       
   818 	unblockPwd.Copy(KUnblockPwd);
       
   819 
       
   820 	RMobilePhone::TCodeAndUnblockCode twoCodes;
       
   821 	twoCodes.iCode.Copy(KPwd);
       
   822 	twoCodes.iUnblockCode.Copy(KUnblockPwd);
       
   823 	TMockLtsyData2<RMobilePhone::TMobilePhoneSecurityCode, RMobilePhone::TCodeAndUnblockCode> verifyData(secCode, twoCodes);
       
   824 	verifyData.SerialiseL(data);
       
   825 
       
   826 	// Call the ipc for SetFdnSetting.
       
   827 	// Also call NotifyFdnStatusChange as this is triggered by CTSY when SetFdnSetting completes
       
   828     RMobilePhone::TMobilePhoneFdnStatus  fdnStatus(RMobilePhone::EFdnUnknown);
       
   829     iPhone.NotifyFdnStatusChange(reqStatusNotif, fdnStatus);
       
   830 	RMobilePhone::TMobilePhoneFdnSetting  fdnSetting(RMobilePhone::EFdnSetOff);
       
   831 	iPhone.SetFdnSetting(reqStatus, fdnSetting);
       
   832 
       
   833 	// Send the ExpectL and CompleteL for VerifySecurityCode
       
   834 	iMockLTSY.ExpectL(MLtsyDispatchSecurityVerifySecurityCode::KLtsyDispatchSecurityVerifySecurityCodeApiId, data, KErrNone);
       
   835 	iMockLTSY.CompleteL(MLtsyDispatchSecurityVerifySecurityCode::KLtsyDispatchSecurityVerifySecurityCodeApiId, KErrNone);
       
   836 
       
   837 	// Send ExpectL for SetFdnSetting
       
   838 	data.Close();
       
   839 	TMockLtsyData1<RMobilePhone::TMobilePhoneFdnSetting> setData(fdnSetting);
       
   840 	data.Close();
       
   841 	setData.SerialiseL(data);
       
   842 	iMockLTSY.ExpectL(MLtsyDispatchSimSetFdnSetting::KLtsyDispatchSimSetFdnSettingApiId, data, KErrGeneral);
       
   843 
       
   844 	// Call ipc for VerifySecurityCode
       
   845 	iPhone.VerifySecurityCode(reqStatusVerify, secCode, pwd, unblockPwd);
       
   846 
       
   847 	// Wait for VerifySecurityCode...
       
   848 	User::WaitForRequest(reqStatusVerify);
       
   849 	ASSERT_EQUALS(KErrNone, reqStatusVerify.Int());
       
   850 	AssertMockLtsyStatusL();
       
   851 
       
   852 	// Now send the CompleteL for SetFdnSetting since CTSY sends this ipc down to LTSY after completing VerifySecurityCode.
       
   853 	iMockLTSY.CompleteL(MLtsyDispatchSimSetFdnSetting::KLtsyDispatchSimSetFdnSettingApiId, KErrNone);
       
   854 
       
   855 	// Wait for SetFdnSetting...
       
   856 	User::WaitForRequest(reqStatus);
       
   857 	ASSERT_EQUALS(KErrNone, reqStatus.Int());
       
   858 	AssertMockLtsyStatusL();
       
   859 
       
   860 	User::WaitForRequest(reqStatusNotif);
       
   861 	ASSERT_EQUALS(KErrNone, reqStatusNotif.Int());
       
   862 	ASSERT_EQUALS(fdnStatus, RMobilePhone::EFdnNotActive);
       
   863 
       
   864 	data.Close();
       
   865 	AssertMockLtsyStatusL();
       
   866 	CleanupStack::PopAndDestroy(2, this); // data, this
       
   867 	}
       
   868 
       
   869 /**
       
   870 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0006
       
   871 @SYMComponent telephony_ctsy
       
   872 @SYMTestCaseDesc Test support in CTSYDispatch for a Sim Refresh indicator from teh LTSY
       
   873 @SYMTestPriority High
       
   874 @SYMTestActions Invokes SIM Refresh IPC 
       
   875 @SYMTestExpectedResults Pass
       
   876 @SYMTestType UT
       
   877  */
       
   878 void CCTsySimFU::TestUnit0006L()
       
   879 	{
       
   880 	OpenEtelServerL(EUseExtendedError);
       
   881 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   882 	
       
   883 	RBuf8 data;
       
   884 	CleanupClosePushL(data);
       
   885 	
       
   886 	OpenPhoneL();
       
   887 	
       
   888 	/****************************Nothing to Refresh***********************************************/
       
   889 
       
   890 	//KCacheAdn KCacheFdn KCacheServiceTable KCacheALSline
       
   891 	TUint16 refreshFileList = 0;
       
   892 	
       
   893 	TMockLtsyData1<TUint16> refreshFileListData(refreshFileList);
       
   894 	refreshFileListData.SerialiseL(data);
       
   895 	iMockLTSY.CompleteL(KMockLtsyDispatchSimRefreshSimFilesIndId, KErrNone, data);
       
   896 	data.Close();
       
   897 	
       
   898 	iMockLTSY.ExpectL(MLtsyDispatchSimGetSubscriberId::KLtsyDispatchSimGetSubscriberIdApiId);
       
   899 	
       
   900 	// Prepare data for the mockLtsy's CompleteL Note the CTSY expects the data in 8-bit format.
       
   901 	_LIT8  (KIMSI8, "012012012012999");
       
   902 	TBuf8<RMobilePhone::KIMSISize> idComp(KIMSI8);
       
   903 	TMockLtsyData1<TBuf8<RMobilePhone::KIMSISize> > idCompData(idComp);
       
   904 	idCompData.SerialiseL(data);
       
   905 	iMockLTSY.CompleteL(MLtsyDispatchSimGetSubscriberId::KLtsyDispatchSimGetSubscriberIdApiId, KErrNone, data);
       
   906 	data.Close();
       
   907 
       
   908 	WaitForMockLTSYTerminated();
       
   909 	
       
   910 	AssertMockLtsyStatusL();
       
   911 	
       
   912 	/****************************Service Table Refresh***********************************************/
       
   913 	
       
   914 	//KCacheAdn KCacheFdn KCacheServiceTable KCacheALSline
       
   915 	refreshFileList = KCacheServiceTable;
       
   916 
       
   917 	refreshFileListData.SerialiseL(data);
       
   918 	iMockLTSY.CompleteL(KMockLtsyDispatchSimRefreshSimFilesIndId, KErrNone, data);
       
   919 	data.Close();
       
   920 	
       
   921 	iMockLTSY.ExpectL(MLtsyDispatchSimGetSubscriberId::KLtsyDispatchSimGetSubscriberIdApiId);
       
   922 	
       
   923 	idCompData.SerialiseL(data);
       
   924 	iMockLTSY.CompleteL(MLtsyDispatchSimGetSubscriberId::KLtsyDispatchSimGetSubscriberIdApiId, KErrNone, data);
       
   925 	data.Close();
       
   926 
       
   927 	
       
   928 	RMobilePhone::TMobilePhoneServiceTable serviceTable = RMobilePhone::ESIMServiceTable;
       
   929 	TMockLtsyData1<RMobilePhone::TMobilePhoneServiceTable> serviceTableData(serviceTable);
       
   930 	serviceTableData.SerialiseL(data);
       
   931 	iMockLTSY.ExpectL(MLtsyDispatchSimGetServiceTable::KLtsyDispatchSimGetServiceTableApiId, data);
       
   932 	data.Close();
       
   933 	
       
   934 	RMobilePhone::TMobilePhoneServiceTableV1 serviceTableResult;
       
   935 	serviceTableResult.iServices1To8  = 0xFF;
       
   936 	serviceTableResult.iServices9To16 = 0xFF;
       
   937 	serviceTableResult.iServices17To24= 0xFF;
       
   938 	serviceTableResult.iServices25To32= 0xFF;
       
   939 	serviceTableResult.iServices33To40= 0xFF;
       
   940 	serviceTableResult.iServices41To48= 0xFF;
       
   941 	serviceTableResult.iServices49To56= 0xFF;
       
   942 	TMockLtsyData1<RMobilePhone::TMobilePhoneServiceTableV1> serviceTableResultData(serviceTableResult);
       
   943 	serviceTableResultData.SerialiseL(data);
       
   944 	iMockLTSY.CompleteL(MLtsyDispatchSimGetServiceTable::KLtsyDispatchSimGetServiceTableApiId,KErrNone,data,0);
       
   945 	data.Close();
       
   946 
       
   947 	
       
   948 	TInt error = KErrNone;
       
   949 	TMockLtsyData1<TInt> simRefreshDoneExpLtsyData(error);
       
   950 	simRefreshDoneExpLtsyData.SerialiseL(data);
       
   951 	iMockLTSY.ExpectL(MLtsyDispatchSimSimRefreshDone::KLtsyDispatchSimSimRefreshDoneApiId,data);
       
   952 	data.Close();
       
   953 		
       
   954 	WaitForMockLTSYTerminated();
       
   955 	
       
   956 	AssertMockLtsyStatusL();
       
   957 
       
   958 	/****************************ALS Line Refresh***********************************************/
       
   959 
       
   960 	//KCacheAdn KCacheFdn KCacheServiceTable KCacheALSline
       
   961 	refreshFileList = KCacheALSline;
       
   962 
       
   963 	refreshFileListData.SerialiseL(data);
       
   964 	iMockLTSY.CompleteL(KMockLtsyDispatchSimRefreshSimFilesIndId, KErrNone, data);
       
   965 	data.Close();
       
   966 	
       
   967 	iMockLTSY.ExpectL(MLtsyDispatchSimGetSubscriberId::KLtsyDispatchSimGetSubscriberIdApiId);
       
   968 	
       
   969 	idCompData.SerialiseL(data);
       
   970 	iMockLTSY.CompleteL(MLtsyDispatchSimGetSubscriberId::KLtsyDispatchSimGetSubscriberIdApiId, KErrNone, data);
       
   971 	data.Close();
       
   972 	
       
   973 	error = 0; //CTSY sends down 0 - EFalse, (No Read Error) see CMmPhoneTsy::ResetMEAlsInfo
       
   974 	simRefreshDoneExpLtsyData.SerialiseL(data);
       
   975 	iMockLTSY.ExpectL(MLtsyDispatchSimSimRefreshDone::KLtsyDispatchSimSimRefreshDoneApiId,data);
       
   976 	data.Close();
       
   977 		
       
   978 	WaitForMockLTSYTerminated();
       
   979 	
       
   980 	AssertMockLtsyStatusL();
       
   981 
       
   982 	/****************************Service Table Refresh && ALS Line Refresh*************************************/
       
   983 
       
   984 	//KCacheAdn KCacheFdn KCacheServiceTable KCacheALSline
       
   985 	refreshFileList = KCacheServiceTable | KCacheALSline;
       
   986 
       
   987 	refreshFileListData.SerialiseL(data);
       
   988 	iMockLTSY.CompleteL(KMockLtsyDispatchSimRefreshSimFilesIndId, KErrNone, data);
       
   989 	data.Close();
       
   990 
       
   991 	iMockLTSY.ExpectL(MLtsyDispatchSimGetSubscriberId::KLtsyDispatchSimGetSubscriberIdApiId);
       
   992 	
       
   993 	idCompData.SerialiseL(data);
       
   994 	iMockLTSY.CompleteL(MLtsyDispatchSimGetSubscriberId::KLtsyDispatchSimGetSubscriberIdApiId, KErrNone, data);
       
   995 	data.Close();
       
   996 
       
   997 	serviceTableData.SerialiseL(data);
       
   998 	iMockLTSY.ExpectL(MLtsyDispatchSimGetServiceTable::KLtsyDispatchSimGetServiceTableApiId, data);
       
   999 	data.Close();
       
  1000 	
       
  1001 	serviceTableResultData.SerialiseL(data);
       
  1002 	iMockLTSY.CompleteL(MLtsyDispatchSimGetServiceTable::KLtsyDispatchSimGetServiceTableApiId,KErrNone,data,0);
       
  1003 	data.Close();
       
  1004 
       
  1005 	//CTSY defect would cause teh below expect, now if def'ed out see CMmPhoneTsy::CompleteCacheSimL
       
  1006 	//error = 1; //CTSY sends down 1
       
  1007 	//simRefreshDoneExpLtsyData.SerialiseL(data);
       
  1008 	//iMockLTSY.ExpectL(MLtsyDispatchSimSimRefreshDone::KLtsyDispatchSimSimRefreshDoneApiId,data);
       
  1009 	//data.Close();
       
  1010 
       
  1011 	error = 0; 
       
  1012 	simRefreshDoneExpLtsyData.SerialiseL(data);
       
  1013 	iMockLTSY.ExpectL(MLtsyDispatchSimSimRefreshDone::KLtsyDispatchSimSimRefreshDoneApiId,data);
       
  1014 	data.Close();
       
  1015 
       
  1016 	
       
  1017 	WaitForMockLTSYTerminated();
       
  1018 	
       
  1019 	AssertMockLtsyStatusL();
       
  1020 	
       
  1021 	//see phonebookfu for full refresh of Fdn and Adn phonebooks.
       
  1022 	
       
  1023 	CleanupStack::PopAndDestroy(2, this); // data, this
       
  1024 	}
       
  1025 
       
  1026 /**
       
  1027 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0007
       
  1028 @SYMComponent telephony_ctsy
       
  1029 @SYMTestCaseDesc Test support in CTSYDispatch for Power SIM On and Off
       
  1030 @SYMTestPriority High
       
  1031 @SYMTestActions Invokes RMmCustomAPI::PowerSimOn() and RMmCustomAPI::PowerSimOff()
       
  1032 @SYMTestExpectedResults Pass
       
  1033 @SYMTestType UT
       
  1034  */
       
  1035 void CCTsySimFU::TestUnit0007L()
       
  1036 	{
       
  1037 	OpenEtelServerL(EUseExtendedError);
       
  1038 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
  1039 	
       
  1040 	OpenPhoneL();
       
  1041 	
       
  1042 	RMmCustomAPI customApi;
       
  1043 	OpenCustomApiLC(customApi);
       
  1044 
       
  1045 	TRequestStatus reqStatus;
       
  1046 
       
  1047 	/*******************************************************************/
       
  1048 	
       
  1049 	//power sim on with complete returning KErrNone
       
  1050 	TInt error = KErrNone;
       
  1051 	
       
  1052 	iMockLTSY.ExpectL(MLtsyDispatchSimPowerSimOn::KLtsyDispatchSimPowerSimOnApiId);
       
  1053 	iMockLTSY.CompleteL(MLtsyDispatchSimPowerSimOn::KLtsyDispatchSimPowerSimOnApiId,error);
       
  1054 	
       
  1055 	customApi.PowerSimOn(reqStatus);
       
  1056 	User::WaitForRequest(reqStatus);
       
  1057 	ASSERT_EQUALS(reqStatus.Int(),error);
       
  1058 	AssertMockLtsyStatusL();
       
  1059 
       
  1060 	/*******************************************************************/
       
  1061 
       
  1062 	//power sim on with complete returning KErrGeneral
       
  1063 	error = KErrGeneral;
       
  1064 	
       
  1065 	iMockLTSY.ExpectL(MLtsyDispatchSimPowerSimOn::KLtsyDispatchSimPowerSimOnApiId);
       
  1066 	iMockLTSY.CompleteL(MLtsyDispatchSimPowerSimOn::KLtsyDispatchSimPowerSimOnApiId,error);
       
  1067 	
       
  1068 	customApi.PowerSimOn(reqStatus);
       
  1069 	User::WaitForRequest(reqStatus);
       
  1070 	ASSERT_EQUALS(reqStatus.Int(),error);
       
  1071 	AssertMockLtsyStatusL();
       
  1072 
       
  1073 	/*******************************************************************/
       
  1074 
       
  1075 	//power sim off with complete returning KErrNone
       
  1076 	error = KErrNone;
       
  1077 	
       
  1078 	iMockLTSY.ExpectL(MLtsyDispatchSimPowerSimOff::KLtsyDispatchSimPowerSimOffApiId);
       
  1079 	iMockLTSY.CompleteL(MLtsyDispatchSimPowerSimOff::KLtsyDispatchSimPowerSimOffApiId,error);
       
  1080 	
       
  1081 	customApi.PowerSimOff(reqStatus);
       
  1082 	User::WaitForRequest(reqStatus);
       
  1083 	ASSERT_EQUALS(reqStatus.Int(),error);
       
  1084 	AssertMockLtsyStatusL();
       
  1085 
       
  1086 	/*******************************************************************/
       
  1087 
       
  1088 	//power sim off with complete returning KErrGeneral
       
  1089 	error = KErrGeneral;
       
  1090 	
       
  1091 	iMockLTSY.ExpectL(MLtsyDispatchSimPowerSimOff::KLtsyDispatchSimPowerSimOffApiId);
       
  1092 	iMockLTSY.CompleteL(MLtsyDispatchSimPowerSimOff::KLtsyDispatchSimPowerSimOffApiId,error);
       
  1093 	
       
  1094 	customApi.PowerSimOff(reqStatus);
       
  1095 	User::WaitForRequest(reqStatus);
       
  1096 	ASSERT_EQUALS(reqStatus.Int(),error);
       
  1097 	AssertMockLtsyStatusL();
       
  1098 
       
  1099 
       
  1100 	
       
  1101 	CleanupStack::PopAndDestroy(&customApi);
       
  1102 	CleanupStack::PopAndDestroy(this);
       
  1103 	}
       
  1104 
       
  1105 /**
       
  1106 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0008
       
  1107 @SYMComponent telephony_ctsy
       
  1108 @SYMTestCaseDesc Test support in CTSYDispatch for a send APDU request (async and sync)
       
  1109 @SYMTestPriority High
       
  1110 @SYMTestActions Invokes RMmCustomAPI::SendAPDUReq()
       
  1111 @SYMTestExpectedResults Pass
       
  1112 @SYMTestType UT
       
  1113  */
       
  1114 void CCTsySimFU::TestUnit0008L()
       
  1115 	{
       
  1116 	OpenEtelServerL(EUseExtendedError);
       
  1117 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
  1118 	
       
  1119 	RBuf8 data;
       
  1120 	CleanupClosePushL(data);
       
  1121 		
       
  1122 	OpenPhoneL();
       
  1123 		
       
  1124 	RMmCustomAPI customApi;
       
  1125 	OpenCustomApiLC(customApi);
       
  1126 
       
  1127 	TRequestStatus reqStatus;
       
  1128 	
       
  1129 	_LIT8(KApduDataExp,"APDU DATA EXP ");
       
  1130 	_LIT8(KApduDataComp,"APDU DATA COMP");
       
  1131 	TDesC8* commandData = const_cast<TDesC8*>(&KApduDataExp);
       
  1132 	TDesC8* responseData = const_cast<TDesC8*>(&KApduDataComp);
       
  1133 	
       
  1134 	
       
  1135 	/*****************************************************************************/
       
  1136 	//test SendAPDUReq async method in KErrNone case
       
  1137 	
       
  1138 	TInt error = KErrNone;
       
  1139 	
       
  1140 	TUint8 serviceTypeExp  = 101;
       
  1141 	TUint8 cardReaderNumberExp = 102;
       
  1142 	TUint8 applicationTypeExp = 103;
       
  1143 	TMockLtsyData4<TUint8,TUint8,TUint8,TDesC8*> sendApduReqExpData(serviceTypeExp,cardReaderNumberExp,applicationTypeExp,commandData);
       
  1144 	sendApduReqExpData.SerialiseL(data);
       
  1145 	iMockLTSY.ExpectL(MLtsyDispatchSimSendApduRequest::KLtsyDispatchSimSendApduRequestApiId,data);
       
  1146 	data.Close();
       
  1147 	
       
  1148 	TUint8 serviceTypeComp  = 201;
       
  1149 	TUint8 cardReaderNumberComp = 202;
       
  1150 	TUint8 applicationTypeComp = 203;
       
  1151 	TMockLtsyData4<TUint8,TUint8,TUint8,TDesC8*> sendApduReqCompData(serviceTypeComp,cardReaderNumberComp,applicationTypeComp,responseData);
       
  1152 	sendApduReqCompData.SerialiseL(data);
       
  1153 	iMockLTSY.CompleteL(MLtsyDispatchSimSendApduRequest::KLtsyDispatchSimSendApduRequestApiId,error,data);
       
  1154 	data.Close();
       
  1155 	
       
  1156 	TBuf8<3> info;
       
  1157 	info.Append(serviceTypeExp);
       
  1158 	info.Append(cardReaderNumberExp);
       
  1159 	info.Append(applicationTypeExp);
       
  1160 	
       
  1161 	RBuf8 dataBuf;
       
  1162 	CleanupClosePushL(dataBuf);
       
  1163 	dataBuf.CreateL(KApduDataExp);
       
  1164 	
       
  1165 	RMmCustomAPI::TApdu apdu(info,dataBuf);
       
  1166 	customApi.SendAPDUReq(reqStatus,apdu);
       
  1167 	User::WaitForRequest(reqStatus);
       
  1168 	ASSERT_EQUALS(reqStatus.Int(),error);
       
  1169 	ASSERT_EQUALS(info[0],serviceTypeComp);
       
  1170 	ASSERT_EQUALS(info[1],cardReaderNumberComp);
       
  1171 	ASSERT_EQUALS(info[2],applicationTypeComp);
       
  1172 	ASSERT_TRUE(dataBuf == KApduDataComp);
       
  1173 	
       
  1174 	AssertMockLtsyStatusL();
       
  1175 	
       
  1176 	
       
  1177 	/*****************************************************************************/
       
  1178 	//test SendAPDUReq async method in KErrGeneral case
       
  1179 	
       
  1180 	error = KErrGeneral;
       
  1181 	
       
  1182 	sendApduReqExpData.SerialiseL(data);
       
  1183 	iMockLTSY.ExpectL(MLtsyDispatchSimSendApduRequest::KLtsyDispatchSimSendApduRequestApiId,data);
       
  1184 	data.Close();
       
  1185 	
       
  1186 	sendApduReqCompData.SerialiseL(data);
       
  1187 	iMockLTSY.CompleteL(MLtsyDispatchSimSendApduRequest::KLtsyDispatchSimSendApduRequestApiId,error,data);
       
  1188 	data.Close();
       
  1189 	
       
  1190 	info.Zero();
       
  1191 	info.Append(serviceTypeExp);
       
  1192 	info.Append(cardReaderNumberExp);
       
  1193 	info.Append(applicationTypeExp);
       
  1194 	
       
  1195 	dataBuf = KApduDataExp;
       
  1196 	
       
  1197 	customApi.SendAPDUReq(reqStatus,apdu);
       
  1198 	User::WaitForRequest(reqStatus);
       
  1199 	ASSERT_EQUALS(reqStatus.Int(),error);
       
  1200 	ASSERT_EQUALS(info[0],serviceTypeExp); //no change
       
  1201 	ASSERT_EQUALS(info[1],cardReaderNumberExp); //no change
       
  1202 	ASSERT_EQUALS(info[2],applicationTypeExp); //no change
       
  1203 	ASSERT_TRUE(dataBuf == KApduDataExp); //no change
       
  1204 	
       
  1205 	AssertMockLtsyStatusL();
       
  1206 		
       
  1207 	/*****************************************************************************/
       
  1208 	//test SendAPDUReq sync method in KErrNone case
       
  1209 	
       
  1210 	error = KErrNone;
       
  1211 	
       
  1212 	sendApduReqExpData.SerialiseL(data);
       
  1213 	iMockLTSY.ExpectL(MLtsyDispatchSimSendApduRequest::KLtsyDispatchSimSendApduRequestApiId,data);
       
  1214 	data.Close();
       
  1215 	
       
  1216 	sendApduReqCompData.SerialiseL(data);
       
  1217 	iMockLTSY.CompleteL(MLtsyDispatchSimSendApduRequest::KLtsyDispatchSimSendApduRequestApiId,error,data);
       
  1218 	data.Close();
       
  1219 	
       
  1220 	info.Zero();
       
  1221 	info.Append(serviceTypeExp);
       
  1222 	info.Append(cardReaderNumberExp);
       
  1223 	info.Append(applicationTypeExp);
       
  1224 	
       
  1225 	dataBuf.Copy(KApduDataExp);
       
  1226 		
       
  1227 	TInt ret = customApi.SendAPDUReq(apdu);
       
  1228 	ASSERT_EQUALS(ret,error);
       
  1229 	ASSERT_EQUALS(info[0],serviceTypeComp);
       
  1230 	ASSERT_EQUALS(info[1],cardReaderNumberComp);
       
  1231 	ASSERT_EQUALS(info[2],applicationTypeComp);
       
  1232 	ASSERT_TRUE(dataBuf == KApduDataComp);
       
  1233 	
       
  1234 	AssertMockLtsyStatusL();
       
  1235 	CleanupStack::PopAndDestroy(&dataBuf);
       
  1236 	
       
  1237 	/*****************************************************************************/
       
  1238 	//test SendAPDUReq V2 async method in KErrNone case
       
  1239 	
       
  1240 	error = KErrNone;
       
  1241 	
       
  1242 	const TUint8 KCardReaderId = 1;
       
  1243 	RMmCustomAPI::TApduParameters apduParameters;
       
  1244 	apduParameters.iCardReaderId = KCardReaderId;
       
  1245 	apduParameters.iCmdData = KApduDataExp;
       
  1246 	apduParameters.iRspData.Zero();
       
  1247 	
       
  1248 	TMockLtsyData2<TUint8,TDesC8*> sendApduV2ReqExpData(apduParameters.iCardReaderId,commandData);
       
  1249 	sendApduV2ReqExpData.SerialiseL(data);
       
  1250 	iMockLTSY.ExpectL(MLtsyDispatchSimSendApduRequestV2::KLtsyDispatchSimSendApduRequestV2ApiId,data);
       
  1251 	data.Close();
       
  1252 
       
  1253 	
       
  1254 	TMockLtsyData1<TDesC8*> sendApduV2ReqCompData(responseData);
       
  1255 	sendApduV2ReqCompData.SerialiseL(data);
       
  1256 	iMockLTSY.CompleteL(MLtsyDispatchSimSendApduRequestV2::KLtsyDispatchSimSendApduRequestV2ApiId,error,data);
       
  1257 	data.Close();
       
  1258 	
       
  1259 	customApi.SendAPDUReq(reqStatus, apduParameters);
       
  1260 	User::WaitForRequest(reqStatus);
       
  1261 	ASSERT_EQUALS(reqStatus.Int(),error);
       
  1262 	ASSERT_EQUALS(apduParameters.iCardReaderId,KCardReaderId); 	//not changed
       
  1263 	ASSERT_TRUE(apduParameters.iCmdData == KApduDataExp); 		//not changed
       
  1264 	ASSERT_TRUE(apduParameters.iRspData == KApduDataComp);		
       
  1265 
       
  1266 	AssertMockLtsyStatusL();
       
  1267 	
       
  1268 	/*****************************************************************************/
       
  1269 	//test SendAPDUReq V2 async method in KErrGeneral case
       
  1270 	error = KErrGeneral;
       
  1271 		
       
  1272 	apduParameters.iCardReaderId = KCardReaderId;
       
  1273 	apduParameters.iCmdData = KApduDataExp;
       
  1274 	apduParameters.iRspData.Zero();
       
  1275 	
       
  1276 	sendApduV2ReqExpData.SerialiseL(data);
       
  1277 	iMockLTSY.ExpectL(MLtsyDispatchSimSendApduRequestV2::KLtsyDispatchSimSendApduRequestV2ApiId,data);
       
  1278 	data.Close();
       
  1279 
       
  1280 	sendApduV2ReqCompData.SerialiseL(data);
       
  1281 	iMockLTSY.CompleteL(MLtsyDispatchSimSendApduRequestV2::KLtsyDispatchSimSendApduRequestV2ApiId,error,data);
       
  1282 	data.Close();
       
  1283 	
       
  1284 	customApi.SendAPDUReq(reqStatus, apduParameters);
       
  1285 	User::WaitForRequest(reqStatus);
       
  1286 	ASSERT_EQUALS(reqStatus.Int(),error);
       
  1287 	ASSERT_EQUALS(apduParameters.iCardReaderId,KCardReaderId); 	//not changed
       
  1288 	ASSERT_TRUE(apduParameters.iCmdData == KApduDataExp); 		//not changed
       
  1289 	ASSERT_TRUE(apduParameters.iRspData == KNullDesC8);			//not changed
       
  1290 
       
  1291 	AssertMockLtsyStatusL();
       
  1292 	
       
  1293 	
       
  1294 	CleanupStack::PopAndDestroy(&customApi);
       
  1295 	CleanupStack::PopAndDestroy(&data);
       
  1296 	CleanupStack::PopAndDestroy(this);
       
  1297 	}
       
  1298 
       
  1299 /**
       
  1300 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0009
       
  1301 @SYMComponent telephony_ctsy
       
  1302 @SYMTestCaseDesc Test support in CTSYDispatch for SIM warm reset
       
  1303 @SYMTestPriority High
       
  1304 @SYMTestActions Invokes RMmCustomAPI::SimWarmReset()
       
  1305 @SYMTestExpectedResults Pass
       
  1306 @SYMTestType UT
       
  1307  */
       
  1308 void CCTsySimFU::TestUnit0009L()
       
  1309 	{
       
  1310 	OpenEtelServerL(EUseExtendedError);
       
  1311 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
  1312 		
       
  1313 	OpenPhoneL();
       
  1314 		
       
  1315 	RMmCustomAPI customApi;
       
  1316 	OpenCustomApiLC(customApi);
       
  1317 
       
  1318 	TRequestStatus reqStatus;
       
  1319 	
       
  1320 	TInt error = KErrNone;
       
  1321 	
       
  1322 	iMockLTSY.ExpectL(MLtsyDispatchSimSimWarmReset::KLtsyDispatchSimSimWarmResetApiId);
       
  1323 	iMockLTSY.CompleteL(MLtsyDispatchSimSimWarmReset::KLtsyDispatchSimSimWarmResetApiId,error);
       
  1324 	
       
  1325 	customApi.SimWarmReset(reqStatus);
       
  1326 	User::WaitForRequest(reqStatus);
       
  1327 	ASSERT_EQUALS(reqStatus.Int(),error);
       
  1328 	AssertMockLtsyStatusL();
       
  1329 	
       
  1330 	
       
  1331 	error = KErrGeneral;
       
  1332 	
       
  1333 	iMockLTSY.ExpectL(MLtsyDispatchSimSimWarmReset::KLtsyDispatchSimSimWarmResetApiId);
       
  1334 	iMockLTSY.CompleteL(MLtsyDispatchSimSimWarmReset::KLtsyDispatchSimSimWarmResetApiId,error);
       
  1335 	
       
  1336 	customApi.SimWarmReset(reqStatus);
       
  1337 	User::WaitForRequest(reqStatus);
       
  1338 	ASSERT_EQUALS(reqStatus.Int(),error);
       
  1339 	AssertMockLtsyStatusL();
       
  1340 	
       
  1341 	CleanupStack::PopAndDestroy(&customApi);
       
  1342 	CleanupStack::PopAndDestroy(this);
       
  1343 	}
       
  1344 
       
  1345 /**
       
  1346 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0010
       
  1347 @SYMComponent telephony_ctsy
       
  1348 @SYMTestCaseDesc Test support in CTSYDispatch for Notify Sim Card Status indicator
       
  1349 @SYMTestPriority High
       
  1350 @SYMTestActions Invokes RMmCustomAPI::NotifySimCardStatus()
       
  1351 @SYMTestExpectedResults Pass
       
  1352 @SYMTestType UT
       
  1353  */
       
  1354 void CCTsySimFU::TestUnit0010L()
       
  1355 	{
       
  1356 	OpenEtelServerL(EUseExtendedError);
       
  1357 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
  1358 		
       
  1359 	OpenPhoneL();
       
  1360 		
       
  1361 	RMmCustomAPI customApi;
       
  1362 	OpenCustomApiLC(customApi);
       
  1363 
       
  1364 	TRequestStatus reqStatus;
       
  1365 	
       
  1366 	TInt error = KErrNone;
       
  1367 	
       
  1368 	RMmCustomAPI::TSIMCardStatus cardStatus;
       
  1369 	customApi.NotifySimCardStatus(reqStatus, cardStatus);
       
  1370 	
       
  1371 	RMmCustomAPI::TSIMCardStatus expectedStatus = RMmCustomAPI::SimCardInserted;
       
  1372 	RBuf8 data;
       
  1373 	TMockLtsyData1<RMmCustomAPI::TSIMCardStatus> completeData(expectedStatus);
       
  1374 	completeData.SerialiseL(data);
       
  1375 	iMockLTSY.CompleteL(KLtsyDispatchSimNotifySimCardStatusApiId,error,data);
       
  1376 	data.Close();
       
  1377 	
       
  1378 	User::WaitForRequest(reqStatus);
       
  1379 	ASSERT_EQUALS(reqStatus.Int(),error);
       
  1380 	ASSERT_EQUALS(cardStatus, expectedStatus);
       
  1381 	AssertMockLtsyStatusL();
       
  1382 	
       
  1383 	CleanupStack::PopAndDestroy(&customApi);
       
  1384 	CleanupStack::PopAndDestroy(this);
       
  1385 	}
       
  1386 
       
  1387 /**
       
  1388 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0011
       
  1389 @SYMComponent telephony_ctsy
       
  1390 @SYMTestCaseDesc Test support in CTSYDispatch for Set SIM Message Status Read
       
  1391 @SYMTestPriority High
       
  1392 @SYMTestActions Invokes RMmCustomAPI::SetSimMessageStatusRead()
       
  1393 @SYMTestExpectedResults Pass
       
  1394 @SYMTestType UT
       
  1395  */
       
  1396 void CCTsySimFU::TestUnit0011L()
       
  1397 	{
       
  1398 	OpenEtelServerL(EUseExtendedError);
       
  1399 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
  1400 		
       
  1401 	OpenPhoneL();
       
  1402 		
       
  1403 	RMmCustomAPI customApi;
       
  1404 	OpenCustomApiLC(customApi);
       
  1405 
       
  1406 
       
  1407 	TInt error = KErrNone;
       
  1408 	
       
  1409 	TTime expectedTime;
       
  1410 	expectedTime.HomeTime();
       
  1411 	
       
  1412 	TInt timeZoneDiff = 8; //2 hours ahead of GMT
       
  1413 	
       
  1414 	TRequestStatus reqStatus;
       
  1415 	iMockLTSY.NotifyTerminated(reqStatus); 
       
  1416 	
       
  1417 	RBuf8 data;
       
  1418 	TMockLtsyData2<TTime, TInt> completeData(expectedTime, timeZoneDiff);
       
  1419 	completeData.SerialiseL(data);
       
  1420 	iMockLTSY.ExpectL(MLtsyDispatchSimSetSimMessageStatusRead::KLtsyDispatchSimSetSimMessageStatusReadApiId,data,error);
       
  1421 	data.Close();
       
  1422 	iMockLTSY.CompleteL(MLtsyDispatchSimSetSimMessageStatusRead::KLtsyDispatchSimSetSimMessageStatusReadApiId,error);
       
  1423 	
       
  1424 	customApi.SetSimMessageStatusRead(expectedTime, timeZoneDiff);
       
  1425 	
       
  1426 
       
  1427 	User::WaitForRequest(reqStatus);
       
  1428 	ASSERT_TRUE(reqStatus.Int() == KErrNone);
       
  1429 
       
  1430 	AssertMockLtsyStatusL();
       
  1431 	
       
  1432 	CleanupStack::PopAndDestroy(&customApi);
       
  1433 	CleanupStack::PopAndDestroy(this);
       
  1434 	}
       
  1435 /**
       
  1436 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0012
       
  1437 @SYMComponent telephony_ctsy
       
  1438 @SYMTestCaseDesc Test support in CTSYDispatch for Read Sim File
       
  1439 @SYMTestPriority High
       
  1440 @SYMTestActions Invokes RMmCustomAPI::ReadSimFile()
       
  1441 @SYMTestExpectedResults Pass
       
  1442 @SYMTestType UT
       
  1443  */
       
  1444 void CCTsySimFU::TestUnit0012L()
       
  1445 	{
       
  1446 	OpenEtelServerL(EUseExtendedError);
       
  1447 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
  1448 	
       
  1449 	RBuf8 data;
       
  1450 	CleanupClosePushL(data);
       
  1451 	
       
  1452 	OpenPhoneL();
       
  1453 	
       
  1454 	RMmCustomAPI customApi;
       
  1455 	OpenCustomApiLC(customApi);
       
  1456 
       
  1457 	TRequestStatus reqStatus;
       
  1458 	
       
  1459 	TInt error = KErrNone;
       
  1460 
       
  1461 	//example Ef(Imsi) path
       
  1462 	RMmCustomAPI::TSimFilePath path;
       
  1463 	path.Append(0x3F);
       
  1464 	path.Append(0x00);
       
  1465 	path.Append(0x7F);
       
  1466 	path.Append(0x00);
       
  1467 	path.Append(0x6F);
       
  1468 	path.Append(0x07);
       
  1469 	path.Append(0x00);
       
  1470 	path.Append(0x00);
       
  1471 	
       
  1472 	const TUint16 offset = 0;
       
  1473 	const TUint16 size = 15;
       
  1474 	
       
  1475 	RMmCustomAPI::TSimFileInfo simFileInfo;
       
  1476 	simFileInfo.iPath = path;
       
  1477 	simFileInfo.iOffSet = offset;
       
  1478 	simFileInfo.iSize = size;
       
  1479 	RMmCustomAPI::TSimFileInfoPckg simFileInfoPckg(simFileInfo);
       
  1480 	
       
  1481 	TDesC8* pathPtr =  &simFileInfo.iPath;
       
  1482 	TMockLtsyData3<TDesC8*,TUint16,TUint16> readSimExpData(pathPtr,simFileInfo.iOffSet,simFileInfo.iSize);
       
  1483 	readSimExpData.SerialiseL(data);
       
  1484 	iMockLTSY.ExpectL(MLtsyDispatchSimReadSimFile::KLtsyDispatchSimReadSimFileApiId,data);
       
  1485 	data.Close();
       
  1486 	
       
  1487 	_LIT8(KResponseBytes,"RESPONSE BYTES");
       
  1488 	TDesC8* responseBytesPtr = const_cast<TDesC8*>(&KResponseBytes);
       
  1489 	TMockLtsyData1<TDesC8*> readSimCompData(responseBytesPtr);
       
  1490 	readSimCompData.SerialiseL(data);
       
  1491 	iMockLTSY.CompleteL(MLtsyDispatchSimReadSimFile::KLtsyDispatchSimReadSimFileApiId,error,data);
       
  1492 	data.Close();
       
  1493 		
       
  1494 	TBuf8<20> responseBytes;
       
  1495 	customApi.ReadSimFile(reqStatus,simFileInfoPckg,responseBytes);
       
  1496 	User::WaitForRequest(reqStatus);
       
  1497 	ASSERT_EQUALS(reqStatus.Int(),error);
       
  1498 	ASSERT_TRUE(responseBytes == KResponseBytes);
       
  1499 	AssertMockLtsyStatusL();
       
  1500 	
       
  1501 	/*****************************************************************************/
       
  1502 	
       
  1503 	error = KErrGeneral;
       
  1504 	readSimExpData.SerialiseL(data);
       
  1505 	iMockLTSY.ExpectL(MLtsyDispatchSimReadSimFile::KLtsyDispatchSimReadSimFileApiId,data);
       
  1506 	data.Close();
       
  1507 
       
  1508 	readSimCompData.SerialiseL(data);
       
  1509 	iMockLTSY.CompleteL(MLtsyDispatchSimReadSimFile::KLtsyDispatchSimReadSimFileApiId,error,data);
       
  1510 	data.Close();
       
  1511 	
       
  1512 	responseBytes.Zero();
       
  1513 	
       
  1514 	customApi.ReadSimFile(reqStatus,simFileInfoPckg,responseBytes);
       
  1515 	User::WaitForRequest(reqStatus);
       
  1516 	ASSERT_EQUALS(reqStatus.Int(),error);
       
  1517 	ASSERT_TRUE(responseBytes == KNullDesC8);
       
  1518 	AssertMockLtsyStatusL();
       
  1519 	
       
  1520 	
       
  1521 	CleanupStack::PopAndDestroy(&customApi);
       
  1522 	CleanupStack::PopAndDestroy(&data);
       
  1523 	CleanupStack::PopAndDestroy(this);
       
  1524 	}
       
  1525 
       
  1526 /**
       
  1527 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0013
       
  1528 @SYMComponent telephony_ctsy
       
  1529 @SYMTestCaseDesc Test support in CTSYDispatch for Activate SimLock
       
  1530 @SYMTestPriority High
       
  1531 @SYMTestActions Invokes RMmCustomAPI::ActivateSimLock()
       
  1532 @SYMTestExpectedResults Pass
       
  1533 @SYMTestType UT
       
  1534  */
       
  1535 void CCTsySimFU::TestUnit0013L()
       
  1536 	{
       
  1537 	OpenEtelServerL(EUseExtendedError);
       
  1538 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
  1539 		
       
  1540 	OpenPhoneL();
       
  1541 	
       
  1542 	RMmCustomAPI customApi;
       
  1543 	OpenCustomApiLC(customApi);
       
  1544 	
       
  1545 	RBuf8 data;
       
  1546 	CleanupClosePushL(data);	
       
  1547 	
       
  1548 	TRequestStatus reqStatus;
       
  1549 	
       
  1550 	_LIT(KPassword, "12345");
       
  1551 	
       
  1552 	RMmCustomAPI::TSimLockPassword simLockPassword;
       
  1553 	RMmCustomAPI::TLockNumber lockNumber;
       
  1554 	
       
  1555 	lockNumber = RMmCustomAPI::EOperator;
       
  1556 	simLockPassword.Copy(KPassword);
       
  1557 	
       
  1558 	TDesC* expectedSimLockPassword = const_cast<TDesC*> (&KPassword);
       
  1559 	RMmCustomAPI::TLockNumber expectedlockNumber = lockNumber;
       
  1560 	TMockLtsyData2<TDesC*, RMmCustomAPI::TLockNumber> activateSimLockData(expectedSimLockPassword, expectedlockNumber);
       
  1561 	data.Close();
       
  1562 	activateSimLockData.SerialiseL(data);
       
  1563 	
       
  1564 	// asynchronous request
       
  1565 	
       
  1566 	iMockLTSY.ExpectL(MLtsyDispatchSimSimLockActivate::KLtsyDispatchSimSimLockActivateApiId, data);
       
  1567 	iMockLTSY.CompleteL(MLtsyDispatchSimSimLockActivate::KLtsyDispatchSimSimLockActivateApiId, KErrNone);
       
  1568 	
       
  1569 	customApi.ActivateSimLock(reqStatus, simLockPassword, lockNumber);
       
  1570 	User::WaitForRequest(reqStatus);
       
  1571 	ASSERT_EQUALS(KErrNone, reqStatus.Int());
       
  1572 	
       
  1573 	// synchronous request
       
  1574 	iMockLTSY.ExpectL(MLtsyDispatchSimSimLockActivate::KLtsyDispatchSimSimLockActivateApiId, data);
       
  1575 	iMockLTSY.CompleteL(MLtsyDispatchSimSimLockActivate::KLtsyDispatchSimSimLockActivateApiId, KErrNone);
       
  1576 	
       
  1577 	TInt ret = customApi.ActivateSimLock(simLockPassword, lockNumber);
       
  1578 	ASSERT_EQUALS(KErrNone, ret);
       
  1579 	
       
  1580 	// failure case for asynchronous request
       
  1581 	
       
  1582 	iMockLTSY.ExpectL(MLtsyDispatchSimSimLockActivate::KLtsyDispatchSimSimLockActivateApiId, data);
       
  1583 	iMockLTSY.CompleteL(MLtsyDispatchSimSimLockActivate::KLtsyDispatchSimSimLockActivateApiId, KErrGeneral);
       
  1584 	
       
  1585 	customApi.ActivateSimLock(reqStatus, simLockPassword, lockNumber);
       
  1586 	User::WaitForRequest(reqStatus);
       
  1587 	ASSERT_EQUALS(KErrGeneral, reqStatus.Int());
       
  1588 	
       
  1589 	// failure case for synchronous request
       
  1590 	
       
  1591 	iMockLTSY.ExpectL(MLtsyDispatchSimSimLockActivate::KLtsyDispatchSimSimLockActivateApiId, data);
       
  1592 	iMockLTSY.CompleteL(MLtsyDispatchSimSimLockActivate::KLtsyDispatchSimSimLockActivateApiId, KErrGeneral);
       
  1593 	
       
  1594 	ret = customApi.ActivateSimLock(simLockPassword, lockNumber);
       
  1595 	ASSERT_EQUALS(KErrGeneral, ret);
       
  1596 	
       
  1597 	AssertMockLtsyStatusL();
       
  1598 	CleanupStack::PopAndDestroy(3, this); //data, customApi, this
       
  1599 	}
       
  1600 
       
  1601 /**
       
  1602 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0014
       
  1603 @SYMComponent telephony_ctsy
       
  1604 @SYMTestCaseDesc Test support in CTSYDispatch for DeActivate SimLock
       
  1605 @SYMTestPriority High
       
  1606 @SYMTestActions Invokes RMmCustomAPI::DeActivateSimLock()
       
  1607 @SYMTestExpectedResults Pass
       
  1608 @SYMTestType UT
       
  1609  */
       
  1610 void CCTsySimFU::TestUnit0014L()
       
  1611 	{
       
  1612 	OpenEtelServerL(EUseExtendedError);
       
  1613 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
  1614 		
       
  1615 	OpenPhoneL();
       
  1616 	
       
  1617 	RMmCustomAPI customApi;
       
  1618 	OpenCustomApiLC(customApi);
       
  1619 	
       
  1620 	RBuf8 data;
       
  1621 	CleanupClosePushL(data);	
       
  1622 	
       
  1623 	TRequestStatus reqStatus;
       
  1624 	
       
  1625 	_LIT(KPassword, "12345");
       
  1626 	
       
  1627 	RMmCustomAPI::TSimLockPassword simLockPassword;
       
  1628 	RMmCustomAPI::TLockNumber lockNumber;
       
  1629 	
       
  1630 	lockNumber = RMmCustomAPI::EOperator;
       
  1631 	simLockPassword.Copy(KPassword);
       
  1632 	
       
  1633 	TDesC* expectedSimLockPassword = const_cast<TDesC*> (&KPassword);
       
  1634 	RMmCustomAPI::TLockNumber expectedlockNumber = lockNumber;
       
  1635 	TMockLtsyData2<TDesC*, RMmCustomAPI::TLockNumber> activateSimLockData(expectedSimLockPassword, expectedlockNumber);
       
  1636 	data.Close();
       
  1637 	activateSimLockData.SerialiseL(data);
       
  1638 	
       
  1639 	// asynchronous request
       
  1640 	
       
  1641 	iMockLTSY.ExpectL(MLtsyDispatchSimSimLockDeActivate::KLtsyDispatchSimSimLockDeActivateApiId, data);
       
  1642 	iMockLTSY.CompleteL(MLtsyDispatchSimSimLockDeActivate::KLtsyDispatchSimSimLockDeActivateApiId, KErrNone);
       
  1643 	
       
  1644 	customApi.DeActivateSimLock(reqStatus, simLockPassword, lockNumber);
       
  1645 	User::WaitForRequest(reqStatus);
       
  1646 	ASSERT_EQUALS(KErrNone, reqStatus.Int());
       
  1647 	
       
  1648 	// synchronous request
       
  1649 	
       
  1650 	iMockLTSY.ExpectL(MLtsyDispatchSimSimLockDeActivate::KLtsyDispatchSimSimLockDeActivateApiId, data);
       
  1651 	iMockLTSY.CompleteL(MLtsyDispatchSimSimLockDeActivate::KLtsyDispatchSimSimLockDeActivateApiId, KErrNone);
       
  1652 	
       
  1653 	TInt ret = customApi.DeActivateSimLock(simLockPassword, lockNumber);
       
  1654 	ASSERT_EQUALS(KErrNone, ret);
       
  1655 	
       
  1656 	// failure case for asynchronous request
       
  1657 	iMockLTSY.ExpectL(MLtsyDispatchSimSimLockDeActivate::KLtsyDispatchSimSimLockDeActivateApiId, data);
       
  1658 	iMockLTSY.CompleteL(MLtsyDispatchSimSimLockDeActivate::KLtsyDispatchSimSimLockDeActivateApiId, KErrGeneral);
       
  1659 	
       
  1660 	customApi.DeActivateSimLock(reqStatus, simLockPassword, lockNumber);
       
  1661 	User::WaitForRequest(reqStatus);
       
  1662 	ASSERT_EQUALS(KErrGeneral, reqStatus.Int());
       
  1663 	
       
  1664 	// failure case for synchronous request
       
  1665 	
       
  1666 	iMockLTSY.ExpectL(MLtsyDispatchSimSimLockDeActivate::KLtsyDispatchSimSimLockDeActivateApiId, data);
       
  1667 	iMockLTSY.CompleteL(MLtsyDispatchSimSimLockDeActivate::KLtsyDispatchSimSimLockDeActivateApiId, KErrGeneral);
       
  1668 	
       
  1669 	ret = customApi.DeActivateSimLock(simLockPassword, lockNumber);
       
  1670 	ASSERT_EQUALS(KErrGeneral, ret);
       
  1671 	
       
  1672 	
       
  1673 	AssertMockLtsyStatusL();
       
  1674 	CleanupStack::PopAndDestroy(3, this); //data, customApi, this
       
  1675 	}
       
  1676 
       
  1677 /**
       
  1678 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0015
       
  1679 @SYMComponent telephony_ctsy
       
  1680 @SYMTestCaseDesc Test support in CTSYDispatch for Get Answer to Reset
       
  1681 @SYMTestPriority High
       
  1682 @SYMTestActions Invokes RMmCustomAPI::GetATR()
       
  1683 @SYMTestExpectedResults Pass
       
  1684 @SYMTestType UT
       
  1685  */
       
  1686 void CCTsySimFU::TestUnit0015L()
       
  1687 	{
       
  1688 	OpenEtelServerL(EUseExtendedError);
       
  1689 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
  1690 		
       
  1691 	OpenPhoneL();
       
  1692 
       
  1693 	RMmCustomAPI customApi;
       
  1694 	OpenCustomApiLC(customApi);
       
  1695 
       
  1696 	RBuf8 dataExpect;
       
  1697 	CleanupClosePushL(dataExpect);	
       
  1698 	
       
  1699 	RBuf8 dataComplete;
       
  1700 	CleanupClosePushL(dataComplete);
       
  1701 	
       
  1702 	TRequestStatus reqStatus;
       
  1703 	
       
  1704 	_LIT8(KAnswerToResetSend, "ExampleAnswerToResetSend");
       
  1705 	_LIT8(KAnswerToResetReceive, "ExampleAnswerToResetReturn");
       
  1706 	TBuf8<100> answerToReset(KAnswerToResetSend);
       
  1707 	
       
  1708 	TDesC8* expectedAnswerToReset = const_cast<TDesC8*> (&KAnswerToResetSend);
       
  1709 	TMockLtsyData1<TDesC8*> getATRData(expectedAnswerToReset);
       
  1710 	dataExpect.Close();
       
  1711 	getATRData.SerialiseL(dataExpect);
       
  1712 	
       
  1713 	iMockLTSY.ExpectL(MLtsyDispatchSimGetAnswerToReset::KLtsyDispatchSimGetAnswerToResetApiId, dataExpect);
       
  1714 	
       
  1715 	TDesC8* returnAnswerToReset = const_cast<TDesC8*> (&KAnswerToResetReceive);
       
  1716 	TMockLtsyData1<TDesC8*> getATRDataReturn(returnAnswerToReset);
       
  1717 	dataComplete.Close();
       
  1718 	getATRDataReturn.SerialiseL(dataComplete);
       
  1719 	iMockLTSY.CompleteL(MLtsyDispatchSimGetAnswerToReset::KLtsyDispatchSimGetAnswerToResetApiId, KErrNone, dataComplete);
       
  1720 	
       
  1721 	customApi.GetATR(reqStatus, answerToReset);
       
  1722 	User::WaitForRequest(reqStatus);
       
  1723 	ASSERT_EQUALS(KErrNone, reqStatus.Int());
       
  1724 	ASSERT_EQUALS(0, answerToReset.Compare(KAnswerToResetReceive));
       
  1725 	
       
  1726 	// failure case
       
  1727 		
       
  1728 	TBuf8<100> answerToReset2(KAnswerToResetSend);
       
  1729 	
       
  1730 	iMockLTSY.ExpectL(MLtsyDispatchSimGetAnswerToReset::KLtsyDispatchSimGetAnswerToResetApiId, dataExpect);
       
  1731 	iMockLTSY.CompleteL(MLtsyDispatchSimGetAnswerToReset::KLtsyDispatchSimGetAnswerToResetApiId, KErrGeneral, dataComplete);
       
  1732 		
       
  1733 	customApi.GetATR(reqStatus, answerToReset2);
       
  1734 	User::WaitForRequest(reqStatus);
       
  1735 	ASSERT_EQUALS(KErrGeneral, reqStatus.Int());
       
  1736 	
       
  1737 	
       
  1738 	AssertMockLtsyStatusL();
       
  1739 	CleanupStack::PopAndDestroy(4, this); // dataComplete, dataExpect, customApi, this
       
  1740 	}
       
  1741 
       
  1742 /**
       
  1743 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0016
       
  1744 @SYMComponent telephony_ctsy
       
  1745 @SYMTestCaseDesc Test support in CTSYDispatch for Get Sim Card Reader Status
       
  1746 @SYMTestPriority High
       
  1747 @SYMTestActions Invokes RMmCustomAPI::GetSimCardReaderStatus()
       
  1748 @SYMTestExpectedResults Pass
       
  1749 @SYMTestType UT
       
  1750  */
       
  1751 void CCTsySimFU::TestUnit0016L()
       
  1752 	{
       
  1753 	OpenEtelServerL(EUseExtendedError);
       
  1754 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
  1755 		
       
  1756 	OpenPhoneL();
       
  1757 		
       
  1758 	RMmCustomAPI customApi;
       
  1759 	OpenCustomApiLC(customApi);
       
  1760 	
       
  1761 	RBuf8 dataComplete;
       
  1762 	CleanupClosePushL(dataComplete);	
       
  1763 	
       
  1764 	TRequestStatus reqStatus;
       
  1765 	
       
  1766 	RMmCustomAPI::TSimCardReaderStatus simCardReaderStatus;
       
  1767 
       
  1768 	iMockLTSY.ExpectL(MLtsyDispatchSimGetSimCardReaderStatus::KLtsyDispatchSimGetSimCardReaderStatusApiId);
       
  1769 	
       
  1770 	TUint8 responseStatus = 10;
       
  1771 	TMockLtsyData1<TUint8> getSimReaderStatusDataReturn(responseStatus);
       
  1772 	dataComplete.Close();
       
  1773 	getSimReaderStatusDataReturn.SerialiseL(dataComplete);
       
  1774 	iMockLTSY.CompleteL(MLtsyDispatchSimGetSimCardReaderStatus::KLtsyDispatchSimGetSimCardReaderStatusApiId, KErrNone, dataComplete);
       
  1775 	
       
  1776 	customApi.GetSimCardReaderStatus(reqStatus, simCardReaderStatus);
       
  1777 	User::WaitForRequest(reqStatus);
       
  1778 	ASSERT_EQUALS(KErrNone, reqStatus.Int());
       
  1779 	ASSERT_EQUALS(responseStatus, simCardReaderStatus.GetStatus());
       
  1780 	
       
  1781 	// failure case
       
  1782 	
       
  1783 	iMockLTSY.ExpectL(MLtsyDispatchSimGetSimCardReaderStatus::KLtsyDispatchSimGetSimCardReaderStatusApiId);
       
  1784 	iMockLTSY.CompleteL(MLtsyDispatchSimGetSimCardReaderStatus::KLtsyDispatchSimGetSimCardReaderStatusApiId, KErrGeneral, dataComplete);
       
  1785 	
       
  1786 	RMmCustomAPI::TSimCardReaderStatus simCardReaderStatus2;
       
  1787 	simCardReaderStatus2.SetStatus(0);
       
  1788 	
       
  1789 	customApi.GetSimCardReaderStatus(reqStatus, simCardReaderStatus2);
       
  1790 	User::WaitForRequest(reqStatus);
       
  1791 	ASSERT_EQUALS(KErrGeneral, reqStatus.Int());
       
  1792 	
       
  1793 	AssertMockLtsyStatusL();
       
  1794 	CleanupStack::PopAndDestroy(3, this); // dataComplete, customApi, this
       
  1795 	}
       
  1796 
       
  1797 /**
       
  1798 @SYMTestCaseID BA-CTSYD-DIS-SIM-UN0017
       
  1799 @SYMComponent telephony_ctsy
       
  1800 @SYMTestCaseDesc Test support in CTSYDispatch for Get Wlan Sim Authentication Data
       
  1801 @SYMTestPriority High
       
  1802 @SYMTestActions Invokes RMmCustomAPI::GetWlanSimAuthenticationData()
       
  1803 @SYMTestExpectedResults Pass
       
  1804 @SYMTestType UT
       
  1805  */
       
  1806 void CCTsySimFU::TestUnit0017L()
       
  1807 	{
       
  1808 	OpenEtelServerL(EUseExtendedError);
       
  1809 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
  1810 		
       
  1811 	OpenPhoneL();
       
  1812 		
       
  1813 	RMmCustomAPI customApi;
       
  1814 	OpenCustomApiLC(customApi);
       
  1815 
       
  1816 	RBuf8 dataExpect;
       
  1817 	CleanupClosePushL(dataExpect);	
       
  1818 	RBuf8 dataComplete;
       
  1819 	CleanupClosePushL(dataComplete);	
       
  1820 		
       
  1821 	TRequestStatus reqStatus;
       
  1822 	TUint32 randomValue; 
       
  1823 
       
  1824 	_LIT8(KCK,"CipheringKey");
       
  1825 	_LIT8(KIK,"IntegrityKey");
       
  1826 	_LIT8(KRES,"Response");
       
  1827 	_LIT8(KAUTN,"AUTN Value");
       
  1828 	_LIT8(KAUTS,"AUTS Value");
       
  1829 	
       
  1830 	TDesC8* responseCipheringKey = const_cast<TDesC8*>(&KCK);
       
  1831 	TDesC8* responseIntegrityKey = const_cast<TDesC8*>(&KIK);
       
  1832 	TDesC8* responseResponse = const_cast<TDesC8*>(&KRES);
       
  1833 	TDesC8* responseAUTN = const_cast<TDesC8*>(&KAUTN);
       
  1834 	TDesC8* responseAUTS = const_cast<TDesC8*>(&KAUTS);
       
  1835 
       
  1836 	TInt rfStateInfo ( 0 ); // assume that rfStateInfo has not been set
       
  1837 	
       
  1838 	// generate a random parameter 
       
  1839 	TBuf8<16> randomParameter;
       
  1840 	for (TInt i = 0; i< 16; i++)
       
  1841 		{
       
  1842 		randomValue = Math::Random();
       
  1843 		randomParameter.Append(randomValue);
       
  1844 		}
       
  1845 	TDesC8* responseRandomParam = &randomParameter;
       
  1846 	
       
  1847 	// EapSim method
       
  1848 	TMockLtsyData2<TDesC8*, TInt> getSimAuthenticationEapSimData(responseRandomParam, rfStateInfo);
       
  1849 	dataExpect.Close();
       
  1850 	getSimAuthenticationEapSimData.SerialiseL(dataExpect);
       
  1851 	iMockLTSY.ExpectL(MLtsyDispatchSimGetSimAuthenticationEapSimData::KLtsyDispatchSimGetSimAuthenticationEapSimDataApiId, dataExpect);
       
  1852 	
       
  1853 	TMockLtsyData2<TDesC8*,TDesC8*> getSimAuthenticationEapSimDataReturn(responseResponse, responseCipheringKey);
       
  1854 	dataComplete.Close();
       
  1855 	getSimAuthenticationEapSimDataReturn.SerialiseL(dataComplete);
       
  1856 	iMockLTSY.CompleteL(MLtsyDispatchSimGetSimAuthenticationEapSimData::KLtsyDispatchSimGetSimAuthenticationEapSimDataApiId, KErrNone, dataComplete);
       
  1857 	
       
  1858 	
       
  1859 	RMmCustomAPI::TSimAuthenticationEapSim eapSim;
       
  1860 	eapSim.iRandomParameters.Copy(randomParameter);
       
  1861 	RMmCustomAPI::TSimDataPckg simDataPckg(eapSim);
       
  1862 	customApi.GetWlanSimAuthenticationData(reqStatus, simDataPckg);
       
  1863 	
       
  1864 	User::WaitForRequest(reqStatus);
       
  1865 	ASSERT_EQUALS(KErrNone, reqStatus.Int());
       
  1866 	ASSERT_EQUALS(0, eapSim.iSRES.Compare(KRES));
       
  1867 	ASSERT_EQUALS(0, eapSim.iKC.Compare(KCK));
       
  1868 	
       
  1869 	// failure case of EapSim method 
       
  1870 	
       
  1871 	randomParameter.Zero();
       
  1872 	for (TInt j = 0; j< 16; j++)
       
  1873 		{
       
  1874 		randomValue = Math::Random();
       
  1875 		randomParameter.Append(randomValue);
       
  1876 		}
       
  1877 	responseRandomParam = &randomParameter;
       
  1878 	
       
  1879 	TMockLtsyData2<TDesC8*, TInt> getSimAuthenticationEapSimData2(responseRandomParam, rfStateInfo);
       
  1880 	dataExpect.Close();
       
  1881 	getSimAuthenticationEapSimData2.SerialiseL(dataExpect);
       
  1882 	iMockLTSY.ExpectL(MLtsyDispatchSimGetSimAuthenticationEapSimData::KLtsyDispatchSimGetSimAuthenticationEapSimDataApiId, dataExpect);
       
  1883 	
       
  1884 	iMockLTSY.CompleteL(MLtsyDispatchSimGetSimAuthenticationEapSimData::KLtsyDispatchSimGetSimAuthenticationEapSimDataApiId, KErrGeneral, dataComplete);
       
  1885 		
       
  1886 	
       
  1887 	RMmCustomAPI::TSimAuthenticationEapSim eapSim2;
       
  1888 	eapSim2.iRandomParameters.Copy(randomParameter);
       
  1889 	RMmCustomAPI::TSimDataPckg simDataPckg2(eapSim2);
       
  1890 	customApi.GetWlanSimAuthenticationData(reqStatus, simDataPckg2);
       
  1891 	
       
  1892 	User::WaitForRequest(reqStatus);
       
  1893 	ASSERT_EQUALS(KErrGeneral, reqStatus.Int());
       
  1894 		
       
  1895 	// EapAka method
       
  1896 	
       
  1897 	// generate a random parameter 
       
  1898 	TBuf8<16> randomParameter2;
       
  1899 	for (TInt k = 0; k< 16; k++)
       
  1900 		{
       
  1901 		randomValue = Math::Random();
       
  1902 		randomParameter2.Append(randomValue);
       
  1903 		}
       
  1904 	TDesC8* responseRandomParam2 = &randomParameter2;
       
  1905 	
       
  1906 	TMockLtsyData3<TDesC8*, TDesC8*, TInt> getSimAuthenticationEapAkaData(responseRandomParam2, responseAUTN, rfStateInfo);
       
  1907 	dataExpect.Close();
       
  1908 	getSimAuthenticationEapAkaData.SerialiseL(dataExpect);
       
  1909 	iMockLTSY.ExpectL(MLtsyDispatchSimGetSimAuthenticationEapAkaData::KLtsyDispatchSimGetSimAuthenticationEapAkaDataApiId, dataExpect);
       
  1910 	
       
  1911 	TMockLtsyData4<TDesC8*, TDesC8*, TDesC8*, TDesC8*> getSimAuthenticationEapAkaDataReturn(responseResponse, responseCipheringKey, responseIntegrityKey, responseAUTS);
       
  1912 	dataComplete.Close();
       
  1913 	getSimAuthenticationEapAkaDataReturn.SerialiseL(dataComplete);
       
  1914 	iMockLTSY.CompleteL(MLtsyDispatchSimGetSimAuthenticationEapAkaData::KLtsyDispatchSimGetSimAuthenticationEapAkaDataApiId, KErrNone, dataComplete);
       
  1915 	
       
  1916 	RMmCustomAPI::TSimAuthenticationEapAka eapAka;
       
  1917 	eapAka.iRandomParameters.Copy(randomParameter2);
       
  1918 	eapAka.iAUTN.Copy(KAUTN);
       
  1919 	RMmCustomAPI::TAkaDataPckg akaDataPckg(eapAka);
       
  1920 	
       
  1921 	customApi.GetWlanSimAuthenticationData(reqStatus, akaDataPckg);
       
  1922 	User::WaitForRequest(reqStatus);
       
  1923 	ASSERT_EQUALS(KErrNone, reqStatus.Int());
       
  1924 	ASSERT_EQUALS(0, eapAka.iRES.Compare(KRES));
       
  1925 	ASSERT_EQUALS(0, eapAka.iCK.Compare(KCK));
       
  1926 	ASSERT_EQUALS(0, eapAka.iIK.Compare(KIK));
       
  1927 
       
  1928 	// failure case of EapAka method to check AUTS value
       
  1929 	
       
  1930 	// generate a random parameter 
       
  1931 	TBuf8<16> randomParameter3;
       
  1932 	for (TInt l = 0; l< 16; l++)
       
  1933 		{
       
  1934 		randomValue = Math::Random();
       
  1935 		randomParameter3.Append(randomValue);
       
  1936 		}
       
  1937 	TDesC8* responseRandomParam3 = &randomParameter3;
       
  1938 	
       
  1939 	TMockLtsyData3<TDesC8*, TDesC8*, TInt> getSimAuthenticationEapAkaData2(responseRandomParam3, responseAUTN, rfStateInfo);
       
  1940 	dataExpect.Close();
       
  1941 	getSimAuthenticationEapAkaData2.SerialiseL(dataExpect);
       
  1942 	iMockLTSY.ExpectL(MLtsyDispatchSimGetSimAuthenticationEapAkaData::KLtsyDispatchSimGetSimAuthenticationEapAkaDataApiId, dataExpect);
       
  1943 
       
  1944 	iMockLTSY.CompleteL(MLtsyDispatchSimGetSimAuthenticationEapAkaData::KLtsyDispatchSimGetSimAuthenticationEapAkaDataApiId, KErrGeneral, dataComplete);
       
  1945 		
       
  1946 	RMmCustomAPI::TSimAuthenticationEapAka eapAka2;
       
  1947 	eapAka2.iRandomParameters.Copy(randomParameter3);
       
  1948 	eapAka2.iAUTN.Copy(KAUTN);
       
  1949 	RMmCustomAPI::TAkaDataPckg akaDataPckg2(eapAka2);
       
  1950 	
       
  1951 	customApi.GetWlanSimAuthenticationData(reqStatus, akaDataPckg2);
       
  1952 	User::WaitForRequest(reqStatus);
       
  1953 	ASSERT_EQUALS(KErrGeneral, reqStatus.Int());
       
  1954 	ASSERT_EQUALS(0, eapAka2.iAUTS.Compare(KAUTS));
       
  1955 	
       
  1956 	AssertMockLtsyStatusL();
       
  1957 	CleanupStack::PopAndDestroy(4, this); //dataComplete, dataExpect, customApi, this
       
  1958 	}