telephonyserverplugins/simatktsy/tests/src/ccsatsetupeventlistfu.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 SetUpEventList in the SAT.
       
    20 */
       
    21 
       
    22 #include "ccsatsetupeventlistfu.h"
       
    23 #include <satcs.h>                  // Etel SAT IPC definitions
       
    24 #include <ctsy/ltsy/mltsydispatchsatinterface.h>
       
    25 #include <test/mockltsyindicatorids.h>
       
    26 
       
    27 
       
    28 static const TUint8 KDelay = 10;
       
    29 
       
    30 static const TUint8 KPcmdNumber = 1;
       
    31 //channel 1, Link established or Packet data service activated	
       
    32 static const TUint8 KChannelStatusByte1 = 0x81;
       
    33 
       
    34 static const TInt KSubAddressLength = 100;
       
    35 
       
    36 // these constants are used to show that they are NOT supported by TSY
       
    37 static const TUint8 KDisplayParamsChanges_missing	              = 0x0C;
       
    38 static const TUint8 KLocalConnection_missing               	  = 0x0D;
       
    39 
       
    40 //ETLV_CommandNumber
       
    41 static const TUint8 KTestCommandNumber = 0x01;
       
    42 //ETLV_CommandQualifier	
       
    43 static const TUint8 KTestCommandQualifier = 0x00;
       
    44 
       
    45 
       
    46 
       
    47 CTestSuite* CCSatSetUpEventListFU::CreateSuiteL(const TDesC& aName)
       
    48 	{
       
    49 	SUB_SUITE;
       
    50 	
       
    51 	ADD_TEST_STEP_ISO_CPP(CCSatSetUpEventListFU, TestNotifySetUpEventListPCmd0001L);
       
    52 	ADD_TEST_STEP_ISO_CPP(CCSatSetUpEventListFU, TestNotifySetUpEventListPCmd0001bL);	
       
    53 	ADD_TEST_STEP_ISO_CPP(CCSatSetUpEventListFU, TestNotifySetUpEventListPCmd0001cL);	
       
    54 	ADD_TEST_STEP_ISO_CPP(CCSatSetUpEventListFU, TestNotifySetUpEventListPCmd0001dL);	
       
    55 	ADD_TEST_STEP_ISO_CPP(CCSatSetUpEventListFU, TestNotifySetUpEventListPCmd0001eL);	
       
    56 	ADD_TEST_STEP_ISO_CPP(CCSatSetUpEventListFU, TestNotifySetUpEventListPCmd0001fL);	
       
    57 	ADD_TEST_STEP_ISO_CPP(CCSatSetUpEventListFU, TestNotifySetUpEventListPCmd0001gL);	
       
    58 	ADD_TEST_STEP_ISO_CPP(CCSatSetUpEventListFU, TestNotifySetUpEventListPCmd0001hL);	
       
    59 	ADD_TEST_STEP_ISO_CPP(CCSatSetUpEventListFU, TestNotifySetUpEventListPCmd0001iL);	
       
    60 	ADD_TEST_STEP_ISO_CPP(CCSatSetUpEventListFU, TestNotifySetUpEventListPCmd0001jL);
       
    61 	
       
    62 	ADD_TEST_STEP_ISO_CPP(CCSatSetUpEventListFU, TestNotifySetUpEventListPCmd0002L);	
       
    63 	ADD_TEST_STEP_ISO_CPP(CCSatSetUpEventListFU, TestNotifySetUpEventListPCmd0004L);	
       
    64 	ADD_TEST_STEP_ISO_CPP(CCSatSetUpEventListFU, TestEventDownload0001L);	
       
    65 	
       
    66 	END_SUITE;
       
    67 	}
       
    68 
       
    69 
       
    70 //
       
    71 // Actual test cases
       
    72 //
       
    73 
       
    74 
       
    75 /**
       
    76 @SYMTestCaseID BA-CSAT-SUEL-SNSUELPC-0001
       
    77 @SYMPREQ 1780
       
    78 @SYMComponent  telephony_csat
       
    79 @SYMTestCaseDesc Test support in CSAT for RSat::NotifySetUpEventListPCmd
       
    80 @SYMTestPriority High
       
    81 @SYMTestActions Invokes RSat::NotifySetUpEventListPCmd
       
    82 @SYMTestExpectedResults Pass
       
    83 @SYMTestType CT
       
    84 */
       
    85 void CCSatSetUpEventListFU::TestNotifySetUpEventListPCmd0001L()
       
    86 	{	
       
    87 	static const TUint8 events[] = {KEventUserActivity};
       
    88 	
       
    89 	OpenEtelServerL(EUseExtendedError);
       
    90 	CleanupStack::PushL(TCleanupItem(Cleanup,this));	
       
    91 	OpenPhoneL();
       
    92 	OpenSatL();
       
    93 	
       
    94 	TRequestStatus requestStatus;
       
    95 	TRequestStatus mockLtsyStatus;
       
    96 
       
    97  	//-------------------------------------------------------------------------
       
    98 	// TEST C: Successful completion request of
       
    99 	// RSat::NotifySetUpEventListPCmd 
       
   100  	//-------------------------------------------------------------------------
       
   101 	
       
   102 	// see TestNotifySetUpEventListPCmd0001bL - TestNotifySetUpEventListPCmd0001kL
       
   103 	
       
   104  	//-------------------------------------------------------------------------
       
   105 	// TEST E: Unsolicited completion of RSat::NotifySetUpEventListPCmd
       
   106 	// from LTSY.
       
   107  	//-------------------------------------------------------------------------
       
   108 	// prepare TLV for
       
   109 	TTlv eventTlv;	
       
   110 	PrepareTlv( eventTlv, events, sizeof(events)/sizeof(TUint8));	
       
   111 	const TDesC8& tlv = eventTlv.End();			
       
   112 	
       
   113 	iMockLTSY.NotifyTerminated(mockLtsyStatus);
       
   114 	// post Complete with KErrNone	
       
   115 	CompleteMockDispatchSatPcmdL(tlv, KErrNone);
       
   116 	
       
   117 	// as TerminalResponse is called from CTSY
       
   118 	// Prepare here ExpectL for it
       
   119 	TBuf8<1> resultAddInfo;
       
   120 	resultAddInfo.Append(RSat::KNoSpecificMeProblem); 	
       
   121 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KMeUnableToProcessCmd, resultAddInfo);
       
   122 	
       
   123 	User::WaitForRequest(mockLtsyStatus);
       
   124 	ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int());
       
   125 	
       
   126 	//-------------------------------------------------------------------------
       
   127 	// TEST B: failure on completion of pending request from LTSY->CTSY
       
   128  	//-------------------------------------------------------------------------
       
   129 	
       
   130 	//Prepare data for ExpectL needed by NotifySetUpEventListPCmd
       
   131 	//and post that ExpectL
       
   132 	PrepareMockLDataWithExpL(KSetUpEventList);
       
   133 				
       
   134 	// Post Notify itself
       
   135 	RSat::TSetUpEventListV1 eventList;
       
   136 	RSat::TSetUpEventListV1Pckg eventListPck(eventList);
       
   137 	iSat.NotifySetUpEventListPCmd(requestStatus, eventListPck);
       
   138 	
       
   139 	iMockLTSY.NotifyTerminated(mockLtsyStatus);
       
   140 			
       
   141 	// post Complete with KErrUnknown, the request must be left pending
       
   142 	CompleteMockDispatchSatPcmdL(tlv, KErrUnknown);
       
   143 	
       
   144 	User::WaitForRequest(mockLtsyStatus);
       
   145 	ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int());
       
   146 
       
   147 	// post next Complete with KErrNone to complete request successfully
       
   148 	CompleteMockDispatchSatPcmdL(tlv, KErrNone);
       
   149 	
       
   150 	User::WaitForRequest(requestStatus);
       
   151 	ASSERT_EQUALS(KErrNone, requestStatus.Int());
       
   152 
       
   153 	// ---TERMINAL RESPONSE---
       
   154 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KSuccess, KNullDesC8);			
       
   155 	// call TerminalRsp
       
   156 	RSat::TSetUpEventListRspV1 resp;
       
   157 	RSat::TSetUpEventListRspV1Pckg respPckg(resp);
       
   158 	resp.iGeneralResult = RSat::KSuccess;	
       
   159 	resp.SetPCmdNumber(KPcmdNumber);	
       
   160 	TerminalResponseL(respPckg);
       
   161 	
       
   162 	AssertMockLtsyStatusL();
       
   163 	CleanupStack::PopAndDestroy(1, this); // this
       
   164 
       
   165 	}
       
   166 
       
   167 
       
   168 /**
       
   169 @SYMTestCaseID BA-CSAT-SUEL-SNSUELPC-0002
       
   170 @SYMPREQ 1780
       
   171 @SYMComponent  telephony_csat
       
   172 @SYMTestCaseDesc Test support in CSAT for cancelling of RSat::NotifySetUpEventListPCmd
       
   173 @SYMTestPriority High
       
   174 @SYMTestActions Invokes cancelling of RSat::NotifySetUpEventListPCmd
       
   175 @SYMTestExpectedResults Pass
       
   176 @SYMTestType CT
       
   177 */
       
   178 void CCSatSetUpEventListFU::TestNotifySetUpEventListPCmd0002L()
       
   179 	{
       
   180 	static const TUint8 events[] = {KEventUserActivity};
       
   181 	OpenEtelServerL(EUseExtendedError);
       
   182 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   183 	OpenPhoneL();
       
   184 	OpenSatL();
       
   185 
       
   186 	//-------------------------------------------------------------------------
       
   187 	// Test cancelling of RSat::NotifySetUpEventListPCmd
       
   188  	//-------------------------------------------------------------------------
       
   189 	
       
   190 	//Prepare data for ExpectL needed by NotifySetUpEventListPCmd
       
   191 	//and post that ExpectL
       
   192 	PrepareMockLDataWithExpL(KSetUpEventList);
       
   193 	
       
   194 	TRequestStatus requestStatus;					
       
   195 	// Post Notify itself
       
   196 	RSat::TSetUpEventListV1 eventList;
       
   197 	RSat::TSetUpEventListV1Pckg eventListPck(eventList);
       
   198 	iSat.NotifySetUpEventListPCmd(requestStatus, eventListPck);
       
   199 	// cancel Notify
       
   200 	iSat.CancelAsyncRequest(ESatNotifySetUpEventListPCmd);
       
   201 	
       
   202 	User::WaitForRequest(requestStatus);
       
   203 	ASSERT_EQUALS(KErrCancel, requestStatus.Int());		
       
   204 		
       
   205 	// Now post Complete after cancel
       
   206 	TRequestStatus mockLtsyStatus;
       
   207 	iMockLTSY.NotifyTerminated(mockLtsyStatus);	 
       
   208 	TTlv eventTlv;	
       
   209 	PrepareTlv( eventTlv, events, sizeof(events)/sizeof(TUint8));	
       
   210 	CompleteMockDispatchSatPcmdL(eventTlv.End(), KErrNone);
       
   211 	// as TerminalResponse is called from CTSY
       
   212 	// Prepare here ExpectL for it
       
   213 	TBuf8<1> resultAddInfo;
       
   214 	resultAddInfo.Append(RSat::KNoSpecificMeProblem); 	
       
   215 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KMeUnableToProcessCmd, resultAddInfo);	
       
   216 
       
   217 	// wait for CompleteMockDispatchSatPcmdL
       
   218 	User::WaitForRequest(mockLtsyStatus);
       
   219 	ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int());	
       
   220 		
       
   221 	AssertMockLtsyStatusL();
       
   222 	CleanupStack::PopAndDestroy(1); // this
       
   223 	}
       
   224 
       
   225 
       
   226 /**
       
   227 @SYMTestCaseID BA-CSAT-SUEL-SNSUELPC-0004
       
   228 @SYMPREQ 1780
       
   229 @SYMComponent  telephony_csat
       
   230 @SYMTestCaseDesc Test support in CSAT for multiple client requests to RSat::NotifySetUpEventListPCmd
       
   231 @SYMTestPriority High
       
   232 @SYMTestActions Invokes multiple client requests to RSat::NotifySetUpEventListPCmd
       
   233 @SYMTestExpectedResults Pass
       
   234 @SYMTestType CT
       
   235 */
       
   236 void CCSatSetUpEventListFU::TestNotifySetUpEventListPCmd0004L()
       
   237 	{
       
   238 	static const TUint8 events[] = {KEventUserActivity};
       
   239 	
       
   240 	OpenEtelServerL(EUseExtendedError);
       
   241 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   242 	OpenPhoneL();
       
   243 	OpenSatL();
       
   244 
       
   245 	// Open second client
       
   246 	RTelServer telServer2;
       
   247 	TInt ret = telServer2.Connect();
       
   248 	ASSERT_EQUALS(KErrNone, ret);
       
   249 	CleanupClosePushL(telServer2);
       
   250 
       
   251 	RMobilePhone phone2;
       
   252 	ret = phone2.Open(telServer2,KMmTsyPhoneName);
       
   253 	ASSERT_EQUALS(KErrNone, ret);
       
   254 	CleanupClosePushL(phone2);		
       
   255 	RSat sat2;	
       
   256 	User::LeaveIfError(sat2.Open(phone2));
       
   257 	CleanupClosePushL(sat2);
       
   258 
       
   259 	TRequestStatus requestStatus;
       
   260 	TRequestStatus requestStatus2;
       
   261 
       
   262 	//Prepare data for ExpectL needed by NotifySetUpEventListPCmd
       
   263 	//and post that ExpectL
       
   264 	PrepareMockLDataWithExpL(KSetUpEventList);
       
   265 			
       
   266 	// Post first Notify 
       
   267 	RSat::TSetUpEventListV1 eventList;
       
   268 	RSat::TSetUpEventListV1Pckg eventListPck(eventList);
       
   269 	iSat.NotifySetUpEventListPCmd(requestStatus, eventListPck);
       
   270 	
       
   271 	// Post second Notify 
       
   272 	RSat::TSetUpEventListV1 eventList2;
       
   273 	RSat::TSetUpEventListV1Pckg eventListPck2(eventList2);
       
   274 	sat2.NotifySetUpEventListPCmd(requestStatus2, eventListPck2);
       
   275 		
       
   276 	// prepare TLV for the first client
       
   277 	TTlv eventTlv;	
       
   278 	PrepareTlv( eventTlv, events, sizeof(events)/sizeof(TUint8));
       
   279 	
       
   280 	// post Complete for
       
   281 	CompleteMockDispatchSatPcmdL(eventTlv.End(), KErrNone);		    
       
   282 			    
       
   283 	User::WaitForRequest(requestStatus);
       
   284 	ASSERT_EQUALS(KErrNone, requestStatus.Int());
       
   285 	ASSERT_EQUALS((TUint)RSat::KUserActivity, eventList.iEvents);	
       
   286 	ASSERT_EQUALS(RSat::EUpdateEventList, eventList.iType);
       
   287 	
       
   288 	User::WaitForRequest(requestStatus2);
       
   289 	ASSERT_EQUALS(KErrNone, requestStatus2.Int());
       
   290 	ASSERT_EQUALS((TUint)RSat::KUserActivity, eventList2.iEvents);	
       
   291 	ASSERT_EQUALS(RSat::EUpdateEventList, eventList2.iType);
       
   292 	
       
   293 	// ---TERMINAL RESPONSE from the first client---
       
   294 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KSuccess, KNullDesC8);			
       
   295 	// call TerminalRsp
       
   296 	RSat::TSetUpEventListRspV1 resp;
       
   297 	RSat::TSetUpEventListRspV1Pckg respPckg(resp);
       
   298 	resp.iGeneralResult = RSat::KSuccess;	
       
   299 	resp.SetPCmdNumber(KPcmdNumber);	
       
   300 	TerminalResponseL(respPckg);
       
   301 	AssertMockLtsyStatusL();	
       
   302 	// ---ENVELOPE: EVENT DOWNLOAD from the first client---
       
   303 	PrepareAndCallEventDownloadL(KEventUserActivity);
       
   304 		
       
   305 	// ---TERMINAL RESPONSE from the second client---
       
   306 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KSuccess, KNullDesC8);		
       
   307 	sat2.TerminalRsp(requestStatus2, RSat::ESetUpEventList, respPckg);
       
   308 	User::WaitForRequest(requestStatus2);
       
   309 	ASSERT_EQUALS(KErrNone, requestStatus2.Int());
       
   310 	AssertMockLtsyStatusL();		
       
   311 	// ---ENVELOPE: EVENT DOWNLOAD from the second client---
       
   312 	PrepareAndCallEventDownloadL(KEventUserActivity, &sat2, EFalse, KErrNone);	
       
   313 	
       
   314 	AssertMockLtsyStatusL();	
       
   315 	CleanupStack::PopAndDestroy(4, this); // ...,  this
       
   316 	}
       
   317 
       
   318 
       
   319 /**
       
   320 @SYMTestCaseID BA-CSAT-SUEL-SNSUELPC-0001b
       
   321 @SYMPREQ 1780
       
   322 @SYMComponent  telephony_csat
       
   323 @SYMTestCaseDesc Expected Sequence 1.1 (SET UP EVENT LIST, User Activity)
       
   324 @SYMTestPriority High
       
   325 @SYMTestActions Invokes RSat::NotifySetUpEventListPCmd
       
   326 @SYMTestExpectedResults Pass
       
   327 @SYMTestType CT
       
   328 */
       
   329 void CCSatSetUpEventListFU::TestNotifySetUpEventListPCmd0001bL()
       
   330 	{
       
   331 	static const TUint8 events[] = {KEventUserActivity};
       
   332 	
       
   333 	OpenEtelServerL(EUseExtendedError);
       
   334 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   335 	
       
   336 	OpenPhoneL();
       
   337 	OpenSatL();
       
   338 	
       
   339 	TRequestStatus requestStatus;	
       
   340 	
       
   341  	//-------------------------------------------------------------------------
       
   342 	// Expected Sequence 1.1 (SET UP EVENT LIST, User Activity)
       
   343 	// see ETSI TS 102 384 V6.5.0 
       
   344  	//-------------------------------------------------------------------------
       
   345 	
       
   346 	//Prepare data for ExpectL needed by NotifySetUpEventListPCmd
       
   347 	//and post that ExpectL
       
   348 	PrepareMockLDataWithExpL(KSetUpEventList);
       
   349 			
       
   350 	// Post Notify itself
       
   351 	RSat::TSetUpEventListV1 eventList;
       
   352 	RSat::TSetUpEventListV1Pckg eventListPck(eventList);
       
   353 	iSat.NotifySetUpEventListPCmd(requestStatus, eventListPck);
       
   354 		
       
   355 	// prepare TLV for
       
   356 	TTlv eventTlv;
       
   357 	PrepareTlv( eventTlv, events, sizeof(events)/sizeof(TUint8));	
       
   358 	// post Complete with KErrNone
       
   359 	CompleteMockDispatchSatPcmdL(eventTlv.End(), KErrNone);		    
       
   360 			    
       
   361 	User::WaitForRequest(requestStatus);
       
   362 	ASSERT_EQUALS(KErrNone, requestStatus.Int());
       
   363 	ASSERT_EQUALS((TUint)RSat::KUserActivity, eventList.iEvents);	
       
   364 	ASSERT_EQUALS(RSat::EUpdateEventList, eventList.iType);
       
   365 	
       
   366 	// ---TERMINAL RESPONSE---
       
   367 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KSuccess, KNullDesC8);			
       
   368 	// call TerminalRsp
       
   369 	RSat::TSetUpEventListRspV1 resp;
       
   370 	RSat::TSetUpEventListRspV1Pckg respPckg(resp);
       
   371 	resp.iGeneralResult = RSat::KSuccess;	
       
   372 	resp.SetPCmdNumber(KPcmdNumber);	
       
   373 	TerminalResponseL(respPckg);
       
   374 	AssertMockLtsyStatusL();
       
   375 	
       
   376 	// ---ENVELOPE: EVENT DOWNLOAD---
       
   377 	PrepareAndCallEventDownloadL(KEventUserActivity);
       
   378 
       
   379 	AssertMockLtsyStatusL();
       
   380 	CleanupStack::PopAndDestroy(1); //  this
       
   381 	} 
       
   382 
       
   383 
       
   384 /**
       
   385 @SYMTestCaseID BA-CSAT-SUEL-SNSUELPC-0001c
       
   386 @SYMPREQ 1780
       
   387 @SYMComponent  telephony_csat
       
   388 @SYMTestCaseDesc Test for KEventIdleScreenAvailable and  KEventLanguageSelection events
       
   389 @SYMTestPriority High
       
   390 @SYMTestActions Invokes RSat::NotifySetUpEventListPCmd
       
   391 @SYMTestExpectedResults Pass
       
   392 @SYMTestType CT
       
   393 */
       
   394 void CCSatSetUpEventListFU::TestNotifySetUpEventListPCmd0001cL()
       
   395 	{	
       
   396 	static const TUint8 events[] = {KEventIdleScreenAvailable, KEventLanguageSelection};
       
   397 	
       
   398 	OpenEtelServerL(EUseExtendedError);
       
   399 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   400 	
       
   401 	OpenPhoneL();
       
   402 	OpenSatL();
       
   403 	
       
   404 	TRequestStatus requestStatus;	
       
   405 	
       
   406  	//-------------------------------------------------------------------------
       
   407 	// Test for KEventIdleScreenAvailable and  KEventLanguageSelection events
       
   408  	//-------------------------------------------------------------------------
       
   409 	
       
   410 	//Prepare data for ExpectL needed by NotifySetUpEventListPCmd
       
   411 	//and post that ExpectL
       
   412 	PrepareMockLDataWithExpL(KSetUpEventList);
       
   413 			
       
   414 	// Post Notify itself
       
   415 	RSat::TSetUpEventListV1 eventList;
       
   416 	RSat::TSetUpEventListV1Pckg eventListPck(eventList);
       
   417 	iSat.NotifySetUpEventListPCmd(requestStatus, eventListPck);
       
   418 		
       
   419 	// prepare TLV for
       
   420 	TTlv eventTlv;	
       
   421 	PrepareTlv( eventTlv, events, sizeof(events)/sizeof(TUint8));	
       
   422 	// post Complete with KErrNone
       
   423 	CompleteMockDispatchSatPcmdL(eventTlv.End(), KErrNone);		    
       
   424 			    
       
   425 	User::WaitForRequest(requestStatus);
       
   426 	ASSERT_EQUALS(KErrNone, requestStatus.Int());	
       
   427 	// create constant to compare with data got in NotifySetUpEventListPCmd 
       
   428 	TUint eventsFlag = RSat::KIdleScreenAvailable + RSat::KLanguageSelection; // as we asked for  KEventIdleScreenAvailable and KEventLanguageSelection
       
   429 	ASSERT_EQUALS(eventsFlag, eventList.iEvents);	
       
   430 	ASSERT_EQUALS(RSat::EUpdateEventList, eventList.iType);
       
   431 	
       
   432 	// ---TERMINAL RESPONSE---
       
   433 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KSuccess, KNullDesC8);			
       
   434 	// call TerminalRsp
       
   435 	RSat::TSetUpEventListRspV1 resp;
       
   436 	RSat::TSetUpEventListRspV1Pckg respPckg(resp);
       
   437 	resp.iGeneralResult = RSat::KSuccess;	
       
   438 	resp.SetPCmdNumber(KPcmdNumber);	
       
   439 	TerminalResponseL(respPckg);
       
   440 	AssertMockLtsyStatusL();
       
   441 	
       
   442 	// ---ENVELOPE: KEventLanguageSelection---
       
   443 	PrepareAndCallEventDownloadL(KEventLanguageSelection);
       
   444 	// ---ENVELOPE: KEventIdleScreenAvailable---
       
   445 	PrepareAndCallEventDownloadL(KEventIdleScreenAvailable);	
       
   446 
       
   447 	AssertMockLtsyStatusL();
       
   448 	CleanupStack::PopAndDestroy(1); //  this
       
   449 	}
       
   450 
       
   451 
       
   452 
       
   453 /**
       
   454 @SYMTestCaseID BA-CSAT-SUEL-SNSUELPC-0001d
       
   455 @SYMPREQ 1780
       
   456 @SYMComponent  telephony_csat
       
   457 @SYMTestCaseDesc Test for KEventBrowserTermination, KEventDataAvailable and  KEventChannelStatus events
       
   458 @SYMTestPriority High
       
   459 @SYMTestActions Invokes RSat::NotifySetUpEventListPCmd
       
   460 @SYMTestExpectedResults Pass
       
   461 @SYMTestType CT
       
   462 */
       
   463 void CCSatSetUpEventListFU::TestNotifySetUpEventListPCmd0001dL()
       
   464 	{	
       
   465 	static const TUint8 events[] = {KEventBrowserTermination, KEventDataAvailable, KEventChannelStatus};
       
   466 	
       
   467 	OpenEtelServerL(EUseExtendedError);
       
   468 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   469 	
       
   470 	OpenPhoneL();
       
   471 	OpenSatL();
       
   472 	
       
   473 	TRequestStatus requestStatus;	
       
   474 	
       
   475  	//-------------------------------------------------------------------------
       
   476 	// Test for KEventBrowserTermination, KEventDataAvailable and  KEventChannelStatus events
       
   477  	//-------------------------------------------------------------------------
       
   478 	
       
   479 	//Prepare data for ExpectL needed by NotifySetUpEventListPCmd
       
   480 	//and post that ExpectL
       
   481 	PrepareMockLDataWithExpL(KSetUpEventList);
       
   482 			
       
   483 	// Post Notify itself
       
   484 	RSat::TSetUpEventListV1 eventList;
       
   485 	RSat::TSetUpEventListV1Pckg eventListPck(eventList);
       
   486 	iSat.NotifySetUpEventListPCmd(requestStatus, eventListPck);
       
   487 		
       
   488 	// prepare TLV for
       
   489 	TTlv eventTlv;	
       
   490 	PrepareTlv( eventTlv, events, sizeof(events)/sizeof(TUint8));	
       
   491 	// post Complete with KErrNone
       
   492 	CompleteMockDispatchSatPcmdL(eventTlv.End(), KErrNone);		    
       
   493 			    
       
   494 	User::WaitForRequest(requestStatus);
       
   495 	ASSERT_EQUALS(KErrNone, requestStatus.Int());	
       
   496 	TUint eventsFlag = RSat::KBrowserTermination + RSat::KDataAvailable + RSat::KChannelStatus; 
       
   497 	ASSERT_EQUALS(eventsFlag, eventList.iEvents);	
       
   498 	ASSERT_EQUALS(RSat::EUpdateEventList, eventList.iType);
       
   499 	
       
   500 	// ---TERMINAL RESPONSE---
       
   501 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KSuccess, KNullDesC8);			
       
   502 	// call TerminalRsp
       
   503 	RSat::TSetUpEventListRspV1 resp;
       
   504 	RSat::TSetUpEventListRspV1Pckg respPckg(resp);
       
   505 	resp.iGeneralResult = RSat::KSuccess;	
       
   506 	resp.SetPCmdNumber(KPcmdNumber);	
       
   507 	TerminalResponseL(respPckg);
       
   508 	AssertMockLtsyStatusL();
       
   509 	
       
   510 	// ---ENVELOPE: KEventBrowserTermination---
       
   511 	PrepareAndCallEventDownloadL(KEventBrowserTermination);
       
   512 	// ---ENVELOPE: KEventDataAvailable---
       
   513 	PrepareAndCallEventDownloadL(KEventDataAvailable);	
       
   514 	// ---ENVELOPE: KEventChannelStatus---
       
   515 	PrepareAndCallEventDownloadL(KEventChannelStatus);	
       
   516 
       
   517 	AssertMockLtsyStatusL();
       
   518 	CleanupStack::PopAndDestroy(1); //  this
       
   519 	}
       
   520 
       
   521 /**
       
   522 @SYMTestCaseID BA-CSAT-SUEL-SNSUELPC-0001e
       
   523 @SYMPREQ 1780
       
   524 @SYMComponent  telephony_csat
       
   525 @SYMTestCaseDesc Test for KEventMTCall, KEventCallConnected, KEventCallDisconnected, KEventLocationStatus and  KEventAccessTechnologyChange events
       
   526 @SYMTestPriority High
       
   527 @SYMTestActions Invokes RSat::NotifySetUpEventListPCmd
       
   528 @SYMTestExpectedResults Pass
       
   529 @SYMTestType CT
       
   530 */
       
   531 void CCSatSetUpEventListFU::TestNotifySetUpEventListPCmd0001eL()
       
   532 	{	
       
   533 	static const TUint8 eventListComplete[] = {	KEventMTCall, 
       
   534 												KEventCallConnected, 
       
   535 												KEventCallDisconnected, 
       
   536 												KEventLocationStatus, 
       
   537 												KEventAccessTechnologyChange};
       
   538 	
       
   539 	OpenEtelServerL(EUseExtendedError);
       
   540 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   541 	
       
   542 	OpenPhoneL();
       
   543 	OpenSatL();
       
   544 	
       
   545 	TRequestStatus requestStatus;	
       
   546 	
       
   547  	//-------------------------------------------------------------------------
       
   548 	// Test for KEventMTCall, KEventCallConnected, KEventCallDisconnected, KEventLocationStatus, 
       
   549 	// and  KEventAccessTechnologyChange events.  TSY is responsible for these events
       
   550 	// and they shouldn't be reported to ETel
       
   551  	//-------------------------------------------------------------------------
       
   552 	
       
   553 	//Prepare data for ExpectL needed by NotifySetUpEventListPCmd
       
   554 	//and post that ExpectL
       
   555 	PrepareMockLDataWithExpL(KSetUpEventList);
       
   556 			
       
   557 	// Post Notify itself
       
   558 	RSat::TSetUpEventListV1 eventList;
       
   559 	RSat::TSetUpEventListV1Pckg eventListPck(eventList);
       
   560 	iSat.NotifySetUpEventListPCmd(requestStatus, eventListPck);
       
   561 		
       
   562 	// prepare TLV for
       
   563 	TTlv eventTlv;	
       
   564 	PrepareTlv( eventTlv, eventListComplete, sizeof(eventListComplete)/sizeof(TUint8));	
       
   565 	// post Complete with KErrNone
       
   566 	CompleteMockDispatchSatPcmdL(eventTlv.End(), KErrNone);		    
       
   567 			    
       
   568 	User::WaitForRequest(requestStatus);
       
   569 	ASSERT_EQUALS(KErrNone, requestStatus.Int());	
       
   570 	// user receives empty event list
       
   571 	TUint eventsFlag = 0; 
       
   572 	ASSERT_EQUALS(eventsFlag, eventList.iEvents);	
       
   573 	ASSERT_EQUALS(RSat::EUpdateEventList, eventList.iType);	
       
   574 	
       
   575 	// ---TERMINAL RESPONSE---
       
   576 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KSuccess, KNullDesC8);			
       
   577 	// call TerminalRsp
       
   578 	RSat::TSetUpEventListRspV1 resp;
       
   579 	RSat::TSetUpEventListRspV1Pckg respPckg(resp);
       
   580 	resp.iGeneralResult = RSat::KSuccess;	
       
   581 	resp.SetPCmdNumber(KPcmdNumber);	
       
   582 	TerminalResponseL(respPckg);	
       
   583 	
       
   584 	AssertMockLtsyStatusL();
       
   585 	CleanupStack::PopAndDestroy(1); //  this
       
   586 	} 
       
   587 
       
   588 /**
       
   589 @SYMTestCaseID BA-CSAT-SUEL-SNSUELPC-0001f
       
   590 @SYMPREQ 1780
       
   591 @SYMComponent  telephony_csat
       
   592 @SYMTestCaseDesc Tests for all possible flow of CSatNotifySetUpEventList::TerminalResponseL
       
   593 @SYMTestPriority High
       
   594 @SYMTestActions Invokes RSat::NotifySetUpEventListPCmd
       
   595 @SYMTestExpectedResults Pass
       
   596 @SYMTestType CT
       
   597 */
       
   598 void CCSatSetUpEventListFU::TestNotifySetUpEventListPCmd0001fL()
       
   599 	{	
       
   600 	OpenEtelServerL(EUseExtendedError);
       
   601 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   602 	OpenPhoneL();
       
   603 	OpenSatL();
       
   604 	
       
   605 	// test all possible parameters for CSatNotifySendUssd::CreateTerminalRespL()
       
   606 	
       
   607 	DoTestTerminalResponseL();	
       
   608 
       
   609 	AssertMockLtsyStatusL();
       
   610 	CleanupStack::PopAndDestroy(1, this); //this
       
   611 	}
       
   612 
       
   613 
       
   614 /**
       
   615 @SYMTestCaseID BA-CSAT-SUEL-SNSUELPC-0001g
       
   616 @SYMPREQ 1780
       
   617 @SYMComponent  telephony_csat
       
   618 @SYMTestCaseDesc Test send ENVELOPE for events handled by TSY (just for coverage!)
       
   619 @SYMTestPriority High
       
   620 @SYMTestActions Invokes RSat::NotifySetUpEventListPCmd
       
   621 @SYMTestExpectedResults Pass
       
   622 @SYMTestType CT
       
   623 */
       
   624 void CCSatSetUpEventListFU::TestNotifySetUpEventListPCmd0001gL()
       
   625 	{	
       
   626 	static const TUint8 eventListComplete[] = {	KEventMTCall, 
       
   627 													KEventCallConnected,
       
   628 													KEventCallDisconnected, 
       
   629 													KEventLocationStatus, 
       
   630 													KEventAccessTechnologyChange};
       
   631 	
       
   632 	OpenEtelServerL(EUseExtendedError);
       
   633 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   634 	
       
   635 	OpenPhoneL();
       
   636 	OpenSatL();
       
   637 	
       
   638 	TRequestStatus requestStatus;	
       
   639  	//-------------------------------------------------------------------------
       
   640 	// Test ENVELOPE for events handled by TSY:
       
   641 	//KEventMTCall, KEventCallConnected, KEventCallDisconnected, KEventLocationStatus, 
       
   642 	//and  KEventAccessTechnologyChange. 
       
   643 	// (just for coverage!)
       
   644  	//-------------------------------------------------------------------------
       
   645 	
       
   646 	//Prepare data for ExpectL needed by NotifySetUpEventListPCmd
       
   647 	//and post that ExpectL
       
   648 	PrepareMockLDataWithExpL(KSetUpEventList);
       
   649 			
       
   650 	// Post Notify itself
       
   651 	RSat::TSetUpEventListV1 eventList;
       
   652 	RSat::TSetUpEventListV1Pckg eventListPck(eventList);
       
   653 	iSat.NotifySetUpEventListPCmd(requestStatus, eventListPck);
       
   654 	
       
   655 	// prepare TLV for
       
   656 	TTlv eventTlv;	
       
   657 	PrepareTlv( eventTlv, eventListComplete, sizeof(eventListComplete)/sizeof(TUint8));	
       
   658 	// post Complete with KErrNone
       
   659 	CompleteMockDispatchSatPcmdL(eventTlv.End(), KErrNone);		    
       
   660 			    
       
   661 	User::WaitForRequest(requestStatus);
       
   662 	ASSERT_EQUALS(KErrNone, requestStatus.Int());
       
   663 	ASSERT_EQUALS((TUint)0, eventList.iEvents);	
       
   664 	ASSERT_EQUALS(RSat::EUpdateEventList, eventList.iType);
       
   665 	
       
   666 	// ---TERMINAL RESPONSE---
       
   667 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KSuccess, KNullDesC8);			
       
   668 	// call TerminalRsp
       
   669 	RSat::TSetUpEventListRspV1 resp;
       
   670 	RSat::TSetUpEventListRspV1Pckg respPckg(resp);
       
   671 	resp.iGeneralResult = RSat::KSuccess;	
       
   672 	resp.SetPCmdNumber(KPcmdNumber);	
       
   673 	TerminalResponseL(respPckg);
       
   674 	AssertMockLtsyStatusL();
       
   675 		
       
   676 	// ENVELOPE for KEventMTCall
       
   677 	EnvelopeFromTsyL(KEventMTCall);
       
   678 	
       
   679 	// ENVELOPE for KEventCallConnected	
       
   680 	EnvelopeFromTsyL(KEventCallConnected);
       
   681 	
       
   682 	// ENVELOPE for KEventCallDisconnected
       
   683 	EnvelopeFromTsyL(KEventCallDisconnected);
       
   684 	
       
   685 	// ENVELOPE for KEventLocationStatus
       
   686 	EnvelopeFromTsyL(KEventLocationStatus);
       
   687 	
       
   688 	// ENVELOPE for KEventAccessTechnologyChange
       
   689 	EnvelopeFromTsyL(KEventAccessTechnologyChange);
       
   690 	
       
   691 	AssertMockLtsyStatusL();
       
   692 	CleanupStack::PopAndDestroy(1); //  this
       
   693 	} 
       
   694 
       
   695 /**
       
   696 @SYMTestCaseID BA-CSAT-SUEL-SNSUELPC-0001h
       
   697 @SYMPREQ 1780
       
   698 @SYMComponent  telephony_csat
       
   699 @SYMTestCaseDesc Test send Unsolicited ENVELOPE  for events handled by TSY (just for coverage!)
       
   700 @SYMTestPriority High
       
   701 @SYMTestActions Invokes RSat::NotifySetUpEventListPCmd
       
   702 @SYMTestExpectedResults Pass
       
   703 @SYMTestType CT
       
   704 */
       
   705 void CCSatSetUpEventListFU::TestNotifySetUpEventListPCmd0001hL()
       
   706 	{	
       
   707 	OpenEtelServerL(EUseExtendedError);
       
   708 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   709 	
       
   710 	OpenPhoneL();
       
   711 	OpenSatL();
       
   712 	
       
   713 	TRequestStatus requestStatus;	
       
   714  	//-------------------------------------------------------------------------
       
   715 	// Test Unsolicited ENVELOPE for events handled by TSY:
       
   716 	//KEventMTCall, KEventCallConnected, KEventCallDisconnected, KEventLocationStatus, 
       
   717 	//and  KEventAccessTechnologyChange. 
       
   718 	// (just for coverage!)
       
   719  	//-------------------------------------------------------------------------
       
   720 	
       
   721 	// Unsolicited ENVELOPE for KEventMTCall
       
   722 	EnvelopeFromTsyL(KEventMTCall, EFalse);
       
   723 	
       
   724 	// Unsolicited ENVELOPE for KEventCallConnected	
       
   725 	EnvelopeFromTsyL(KEventCallConnected, EFalse);
       
   726 	
       
   727 	// Unsolicited ENVELOPE for KEventCallDisconnected
       
   728 	EnvelopeFromTsyL(KEventCallDisconnected, EFalse);
       
   729 	
       
   730 	// Unsolicited ENVELOPE for KEventLocationStatus
       
   731 	EnvelopeFromTsyL(KEventLocationStatus, EFalse);
       
   732 	
       
   733 	// Unsolicited ENVELOPE for KEventAccessTechnologyChange
       
   734 	EnvelopeFromTsyL(KEventAccessTechnologyChange, EFalse);
       
   735 	
       
   736 	// Unsolicited ENVELOPE for KEventUserActivity
       
   737 	EnvelopeFromTsyL(KEventUserActivity, EFalse);
       
   738 	
       
   739 	AssertMockLtsyStatusL();
       
   740 	CleanupStack::PopAndDestroy(1); //  this
       
   741 	} 
       
   742 
       
   743 /**
       
   744 @SYMTestCaseID BA-CSAT-SUEL-SNSUELPC-0001i
       
   745 @SYMPREQ 1780
       
   746 @SYMComponent  telephony_csat
       
   747 @SYMTestCaseDesc Test send Unsolicited ENVELOPE and  failure to dispatch request to LTSY for events handled by ETEL (just for coverage!)
       
   748 @SYMTestPriority High
       
   749 @SYMTestActions Invokes RSat::NotifySetUpEventListPCmd
       
   750 @SYMTestExpectedResults Pass
       
   751 @SYMTestType CT
       
   752 */
       
   753 void CCSatSetUpEventListFU::TestNotifySetUpEventListPCmd0001iL()
       
   754 	{	
       
   755 	static const TUint8 events[] = {KEventUserActivity, 
       
   756 									KEventIdleScreenAvailable, 
       
   757 									KEventBrowserTermination,
       
   758 									KEventLanguageSelection,						
       
   759 									KEventDataAvailable, 
       
   760 									KEventChannelStatus};
       
   761 	
       
   762 	OpenEtelServerL(EUseExtendedError);
       
   763 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   764 	OpenPhoneL();
       
   765 	OpenSatL();
       
   766 	
       
   767 	// ---ENVELOPE:  KEventUserActivity ---
       
   768 	PrepareAndCallEventDownloadL(KEventUserActivity, NULL, ETrue, KErrNone);	
       
   769 	
       
   770 	// ---ENVELOPE:  KEventIdleScreenAvailable ---
       
   771 	PrepareAndCallEventDownloadL(KEventIdleScreenAvailable, NULL, ETrue, KErrNone);
       
   772 	
       
   773 	// ---ENVELOPE:  KEventBrowserTermination ---
       
   774 	PrepareAndCallEventDownloadL(KEventBrowserTermination, NULL, ETrue, KErrNone);
       
   775 	
       
   776 	// ---ENVELOPE:  KEventLanguageSelection ---
       
   777 	PrepareAndCallEventDownloadL(KEventLanguageSelection, NULL, ETrue, KErrNone);
       
   778 	
       
   779 	// ---ENVELOPE:  KEventDataAvailable ---
       
   780 	PrepareAndCallEventDownloadL(KEventDataAvailable, NULL, ETrue, KErrNone);
       
   781 	
       
   782 	// ---ENVELOPE:  KEventChannelStatus ---
       
   783 	PrepareAndCallEventDownloadL(KEventChannelStatus, NULL, ETrue, KErrNone);
       
   784 	
       
   785 	
       
   786 	//-------------------------------------------------------------------------	
       
   787 	// Failure to dispatch request to LTSY
       
   788 	// Like "Test A" of 0001 tests for ENVELOPE command
       
   789 	//-------------------------------------------------------------------------
       
   790 	//Prepare data for ExpectL needed by NotifySetUpEventListPCmd
       
   791 	//and post that ExpectL
       
   792 	PrepareMockLDataWithExpL(KSetUpEventList);
       
   793 	
       
   794 	TRequestStatus requestStatus;			
       
   795 	// Post Notify itself
       
   796 	RSat::TSetUpEventListV1 eventList;
       
   797 	RSat::TSetUpEventListV1Pckg eventListPck(eventList);
       
   798 	iSat.NotifySetUpEventListPCmd(requestStatus, eventListPck);
       
   799 		
       
   800 	// prepare TLV for
       
   801 	TTlv eventTlv;
       
   802 	PrepareTlv( eventTlv, events, sizeof(events)/sizeof(TUint8));
       
   803 	
       
   804 	// post Complete with KErrNone
       
   805 	CompleteMockDispatchSatPcmdL(eventTlv.End(), KErrNone);		    
       
   806 			    
       
   807 	User::WaitForRequest(requestStatus);
       
   808 	ASSERT_EQUALS(KErrNone, requestStatus.Int());	
       
   809 	TUint eventsFlag = 	RSat::KUserActivity + RSat::KIdleScreenAvailable + 
       
   810 						RSat::KBrowserTermination + RSat::KLanguageSelection + 
       
   811 						RSat::KDataAvailable + RSat::KChannelStatus;
       
   812 	ASSERT_EQUALS(eventsFlag, eventList.iEvents);	
       
   813 	ASSERT_EQUALS(RSat::EUpdateEventList, eventList.iType);
       
   814 	
       
   815 	// ---TERMINAL RESPONSE---
       
   816 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KSuccess, KNullDesC8);			
       
   817 	// call TerminalRsp
       
   818 	RSat::TSetUpEventListRspV1 resp;
       
   819 	RSat::TSetUpEventListRspV1Pckg respPckg(resp);
       
   820 	resp.iGeneralResult = RSat::KSuccess;	
       
   821 	resp.SetPCmdNumber(KPcmdNumber);	
       
   822 	TerminalResponseL(respPckg);
       
   823 	AssertMockLtsyStatusL();
       
   824 	
       
   825 	// ---ENVELOPE: KEventUserActivity---
       
   826 	PrepareAndCallEventDownloadL(KEventUserActivity, NULL, EFalse, KErrUnknown);
       
   827 	
       
   828 	// ---ENVELOPE: KEventIdleScreenAvailable---
       
   829 	PrepareAndCallEventDownloadL(KEventIdleScreenAvailable, NULL, EFalse, KErrUnknown);
       
   830 		
       
   831 	// ---ENVELOPE: KEventBrowserTermination---
       
   832 	PrepareAndCallEventDownloadL(KEventBrowserTermination, NULL, EFalse, KErrUnknown);
       
   833 			
       
   834 	// ---ENVELOPE: KEventLanguageSelection---
       
   835 	PrepareAndCallEventDownloadL(KEventLanguageSelection, NULL, EFalse, KErrUnknown);
       
   836 				
       
   837 	// ---ENVELOPE: KEventDataAvailable---
       
   838 	PrepareAndCallEventDownloadL(KEventDataAvailable, NULL, EFalse, KErrUnknown);
       
   839 					
       
   840 	// ---ENVELOPE: KEventChannelStatus---
       
   841 	PrepareAndCallEventDownloadL(KEventChannelStatus, NULL, EFalse, KErrUnknown);
       
   842 	
       
   843 	AssertMockLtsyStatusL();
       
   844 	CleanupStack::PopAndDestroy(1, this); //this
       
   845 	} 
       
   846 
       
   847 
       
   848 
       
   849 /**
       
   850 @SYMTestCaseID BA-CSAT-SUEL-SNSUELPC-0001j
       
   851 @SYMPREQ 1780
       
   852 @SYMComponent  telephony_csat
       
   853 @SYMTestCaseDesc Some tests for coverage of CSatNotifySetUpEventList::CompleteNotifyL()
       
   854 @SYMTestPriority High
       
   855 @SYMTestActions Invokes RSat::NotifySetUpEventListPCmd
       
   856 @SYMTestExpectedResults Pass
       
   857 @SYMTestType CT
       
   858 */
       
   859 void CCSatSetUpEventListFU::TestNotifySetUpEventListPCmd0001jL()
       
   860 	{	
       
   861 	static const  TUint8 eventListComplete[] = {KEventUserActivity, KEventUserActivity};
       
   862 	
       
   863 	OpenEtelServerL(EUseExtendedError);
       
   864 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   865 	
       
   866 	OpenPhoneL();
       
   867 	OpenSatL();
       
   868 	
       
   869 	TRequestStatus requestStatus;	
       
   870 	TRequestStatus mockStatus;
       
   871 	
       
   872  	
       
   873 	//Prepare data for ExpectL needed by NotifySetUpEventListPCmd
       
   874 	//and post that ExpectL
       
   875 	PrepareMockLDataWithExpL(KSetUpEventList);			
       
   876 	// Post Notify itself
       
   877 	RSat::TSetUpEventListV1 eventList;
       
   878 	RSat::TSetUpEventListV1Pckg eventListPck(eventList);
       
   879 	iSat.NotifySetUpEventListPCmd(requestStatus, eventListPck);		
       
   880 	
       
   881 	//-------------------------------------------------------------------------
       
   882 	//Pass TLV-buffer from LTSY to TSY without KTlvEventListTag tag
       
   883 	//-------------------------------------------------------------------------	
       
   884 	TTlv eventTlv;
       
   885 	eventTlv.Begin(KBerTlvProactiveSimCommandTag);
       
   886 	eventTlv.AddTag(KTlvCommandDetailsTag);
       
   887 	eventTlv.AddByte(KTestCommandNumber);//ETLV_CommandNumber
       
   888 	eventTlv.AddByte(KSetUpEventList); //ETLV_TypeOfCommand
       
   889 	eventTlv.AddByte(KTestCommandQualifier); //ETLV_CommandQualifier	
       
   890 	eventTlv.AddTag(KTlvDeviceIdentityTag); 
       
   891 	eventTlv.AddByte(KSim); //ETLV_SourceDeviceIdentity
       
   892 	eventTlv.AddByte(KMe);	
       
   893 		
       
   894 	iMockLTSY.NotifyTerminated(mockStatus);
       
   895 	// post Complete with KErrNone
       
   896 	CompleteMockDispatchSatPcmdL(eventTlv.End(), KErrNone);		
       
   897 	// as TerminalResponse is called from CTSY (in this case)
       
   898 	// Prepare here ExpectL for it
       
   899 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KErrorRequiredValuesMissing, KNullDesC8);	
       
   900 	// wait for complete of iMockLTSY.NotifyTerminated(mockStatus) because TSY doesn't inform client 
       
   901 	// about errors from LTSY
       
   902 	User::WaitForRequest(mockStatus);
       
   903 	ASSERT_EQUALS(KErrNone, mockStatus.Int());
       
   904 	AssertMockLtsyStatusL();	
       
   905 	
       
   906 	//-------------------------------------------------------------------------
       
   907 	//Pass event from LTSY to TSY with invalid event code
       
   908 	//-------------------------------------------------------------------------	
       
   909 	// prepare TLV with invalid event code
       
   910 	TUint8 wrongEventList[] = {0xFF};
       
   911 	PrepareTlv( eventTlv, wrongEventList, sizeof(wrongEventList)/sizeof(TUint8));
       
   912 	
       
   913 	iMockLTSY.NotifyTerminated(mockStatus);
       
   914 	// post Complete with KErrNone
       
   915 	CompleteMockDispatchSatPcmdL(eventTlv.End(), KErrNone);
       
   916 	// as TerminalResponse is called from CTSY (in this case)
       
   917 	// Prepare here ExpectL for it
       
   918 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KCmdBeyondMeCapabilities, KNullDesC8);
       
   919 	// wait for complete of iMockLTSY.NotifyTerminated(mockStatus) because TSY doesn't inform client 
       
   920 	// about errors from LTSY
       
   921 	User::WaitForRequest(mockStatus);
       
   922 	ASSERT_EQUALS(KErrNone, mockStatus.Int());
       
   923 	AssertMockLtsyStatusL();
       
   924 	
       
   925 	//-------------------------------------------------------------------------
       
   926 	//Pass TLV-buffer from LTSY to TSY without EvenList (remove all events)
       
   927 	//-------------------------------------------------------------------------	
       
   928 	PrepareTlv( eventTlv, NULL, 0);
       
   929 	eventTlv.AddTag(KTlvEventListTag); 
       
   930 	// post Complete with KErrNone
       
   931 	CompleteMockDispatchSatPcmdL(eventTlv.End(), KErrNone);		
       
   932 	
       
   933 	User::WaitForRequest(requestStatus);
       
   934 	ASSERT_EQUALS(KErrNone, requestStatus.Int());
       
   935 	ASSERT_EQUALS((TUint) 0, eventList.iEvents);	
       
   936 	ASSERT_EQUALS(RSat::ERemoveExistingEventList, eventList.iType);
       
   937 	
       
   938 	// ---TERMINAL RESPONSE---
       
   939 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KSuccess, KNullDesC8);			
       
   940 	// call TerminalRsp
       
   941 	RSat::TSetUpEventListRspV1 resp;
       
   942 	RSat::TSetUpEventListRspV1Pckg respPckg(resp);
       
   943 	resp.iGeneralResult = RSat::KSuccess;	
       
   944 	resp.SetPCmdNumber(KPcmdNumber);	
       
   945 	TerminalResponseL(respPckg);
       
   946 	AssertMockLtsyStatusL();		
       
   947 		
       
   948 	//-------------------------------------------------------------------------
       
   949 	//Pass event list from LTSY to TSY with two identical events 
       
   950 	//-------------------------------------------------------------------------	
       
   951 	// Post Notify again
       
   952 	PrepareMockLDataWithExpL(KSetUpEventList);			
       
   953 	iSat.NotifySetUpEventListPCmd(requestStatus, eventListPck);	
       
   954 	// prepare TLV
       
   955 	PrepareTlv( eventTlv, eventListComplete, sizeof(eventListComplete)/sizeof(TUint8));
       
   956 	
       
   957 	iMockLTSY.NotifyTerminated(mockStatus);
       
   958 	// post Complete with KErrNone
       
   959 	CompleteMockDispatchSatPcmdL(eventTlv.End(), KErrNone);
       
   960 	
       
   961 	User::WaitForRequest(requestStatus);
       
   962 	ASSERT_EQUALS(KErrNone, requestStatus.Int());
       
   963 	ASSERT_EQUALS((TUint) RSat::KUserActivity, eventList.iEvents);	
       
   964 	ASSERT_EQUALS(RSat::EUpdateEventList, eventList.iType);
       
   965 	
       
   966 	// ---TERMINAL RESPONSE---
       
   967 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KSuccess, KNullDesC8);			
       
   968 	// call TerminalRsp
       
   969 	TerminalResponseL(respPckg);
       
   970 	AssertMockLtsyStatusL();
       
   971 		
       
   972 	// ---ENVELOPE: EVENT DOWNLOAD---
       
   973 	PrepareAndCallEventDownloadL(KEventUserActivity);
       
   974 	
       
   975 	AssertMockLtsyStatusL();
       
   976 	CleanupStack::PopAndDestroy(1); //  this
       
   977 	} 
       
   978 
       
   979 
       
   980 /**
       
   981 @SYMTestCaseID BA-CSAT-SUEL-SED-0001
       
   982 @SYMPREQ 1780
       
   983 @SYMComponent  telephony_csat
       
   984 @SYMTestCaseDesc Test support in CSAT for RSat::EventDownload
       
   985 @SYMTestPriority High
       
   986 @SYMTestActions Invokes RSat::EventDownload
       
   987 @SYMTestExpectedResults Pass
       
   988 @SYMTestType CT
       
   989 */
       
   990 void CCSatSetUpEventListFU::TestEventDownload0001L()
       
   991 	{
       
   992 	OpenEtelServerL(EUseExtendedError);
       
   993 	CleanupStack::PushL(TCleanupItem(Cleanup,this));	
       
   994 	OpenPhoneL();
       
   995 	OpenSatL();
       
   996 	
       
   997 	TRequestStatus requestStatus;	
       
   998 	 
       
   999 	//-------------------------------------------------------------------------
       
  1000 	// TEST Unsolicited call of RSat::EventDownload
       
  1001 	// without getting notifications from CTSY
       
  1002  	//-------------------------------------------------------------------------	
       
  1003 	RSat::TEventDownloadBaseV2 			 baseEventInfo;
       
  1004 	RSat::TEventDownloadBaseV2Pckg 		 baseEventInfoPckg(baseEventInfo);
       
  1005 	iSat.EventDownload(requestStatus, RSat::KIdleScreenAvailable, baseEventInfoPckg);		
       
  1006 	
       
  1007 	User::WaitForRequest(requestStatus);
       
  1008 	ASSERT_EQUALS(KErrNone, requestStatus.Int())	
       
  1009 
       
  1010 	AssertMockLtsyStatusL();
       
  1011 	CleanupStack::PopAndDestroy(1, this); //  this
       
  1012 
       
  1013 	// All other EventDownload tests are the part of NotifySetUpEventListPCmd tests	
       
  1014 	}
       
  1015 
       
  1016 
       
  1017 //----------------------------------------------------------------------------------------------------------
       
  1018 // Utility functions
       
  1019 //----------------------------------------------------------------------------------------------------------
       
  1020 
       
  1021 /**
       
  1022 *  Prepare data for ExpectL() and post ExpectL.	
       
  1023 * @param aPCmdNumber - code of Proactive SIM commands	 
       
  1024 */
       
  1025 void CCSatSetUpEventListFU::PrepareMockLDataWithExpL( TUint8 aCommand )
       
  1026 	{
       
  1027 	TPckg<TUint8> pcmdCodePckg(aCommand);
       
  1028 	iMockLTSY.ExpectL(MLtsyDispatchSatPCmdNotification::KLtsyDispatchSatPCmdNotificationApiId, pcmdCodePckg);
       
  1029 	}
       
  1030 
       
  1031 /**
       
  1032 * prepare tlv buffer 
       
  1033 * @param aTlv - tlv buffer to prepare
       
  1034 * @param aEventList -  List of codes of events  
       
  1035 * @param aNumberOfEvents - number of events
       
  1036 */ 
       
  1037 void CCSatSetUpEventListFU::PrepareTlv(TTlv& aTlv, const TUint8* aEventList, TUint8 aNumberOfEvents)
       
  1038 	{	
       
  1039 	aTlv.Begin(KBerTlvProactiveSimCommandTag);
       
  1040 	aTlv.AddTag(KTlvCommandDetailsTag);
       
  1041 	aTlv.AddByte(KTestCommandNumber);//ETLV_CommandNumber
       
  1042 	aTlv.AddByte(KSetUpEventList); //ETLV_TypeOfCommand
       
  1043 	aTlv.AddByte(KTestCommandQualifier); //ETLV_CommandQualifier	
       
  1044 	aTlv.AddTag(KTlvDeviceIdentityTag); 
       
  1045 	aTlv.AddByte(KSim); //ETLV_SourceDeviceIdentity
       
  1046 	aTlv.AddByte(KMe);
       
  1047 	
       
  1048 	if (0 < aNumberOfEvents)
       
  1049 		{
       
  1050 		aTlv.AddTag(KTlvEventListTag);
       
  1051 		
       
  1052 		for (TInt i = 0; i < aNumberOfEvents; i++)
       
  1053 			{
       
  1054 			aTlv.AddByte(aEventList[i]);
       
  1055 			}
       
  1056 		}	
       
  1057 	}
       
  1058 
       
  1059 
       
  1060 /**
       
  1061  * prepare mock for processing of proactive command
       
  1062  * @param aCompleteTlv - tlv buffer to send
       
  1063  * @param aError - result for request completion
       
  1064  */ 
       
  1065 void CCSatSetUpEventListFU::CompleteMockDispatchSatPcmdL( TPtrC8 aCompleteTlv, TInt aError )
       
  1066 	{
       
  1067 	RBuf8 data;
       
  1068 	CleanupClosePushL(data);	
       
  1069 
       
  1070 	TDesC8* tlvPtr = &aCompleteTlv;	
       
  1071 	TMockLtsyData1<TDesC8*> dspTxtDscPack(tlvPtr);
       
  1072 	dspTxtDscPack.SerialiseL(data);
       
  1073 	iMockLTSY.CompleteL(KMockLtsyDispatchSatPcmdIndId, aError, data, KDelay);
       
  1074 	
       
  1075 	CleanupStack::PopAndDestroy(&data);
       
  1076 	}
       
  1077 
       
  1078 
       
  1079 
       
  1080 /**
       
  1081  * prepare data and call  iMockLTSY.ExpectL(MLtsyDispatchSatTerminalRsp::KLtsyDispatchSatTerminalRspApiId, data);	
       
  1082  * @param aPCmdNumber - command number	 
       
  1083  * @param aGeneralResult - result of terminal response
       
  1084  * @param aResultAddInfo - result's additional info
       
  1085  * @param aErrorForExpect -  error, expected from LTSY
       
  1086  */ 
       
  1087 void CCSatSetUpEventListFU::PrepareTerminalResponseMockDataWithExpL(
       
  1088 		TUint8 aPCmdNumber,		
       
  1089 		RSat::TPCmdResult aGeneralResult,
       
  1090 		const TDesC8& aResultAddInfo,
       
  1091 		TInt aErrorForExpect)
       
  1092 	{
       
  1093 	RBuf8 data;
       
  1094 	CleanupClosePushL(data);
       
  1095 	
       
  1096 	RBuf8 terminalRsp;
       
  1097 	CleanupClosePushL(terminalRsp);
       
  1098 	terminalRsp.CreateL(KTlvMaxSize);
       
  1099 		
       
  1100 	TTlv tlv;
       
  1101 	tlv.AddTag(KTlvCommandDetailsTag);
       
  1102 	tlv.AddByte(aPCmdNumber);//ETLV_CommandNumber
       
  1103 	tlv.AddByte(KSetUpEventList); //ETLV_TypeOfCommand
       
  1104 	tlv.AddByte(KTestCommandQualifier); //ETLV_CommandQualifier 0x00 -- according to Test requirement
       
  1105 
       
  1106 	tlv.AddTag(KTlvDeviceIdentityTag);
       
  1107 	tlv.AddByte(KMe);
       
  1108 	tlv.AddByte(KSim);
       
  1109 		
       
  1110 	tlv.AddTag(KTlvResultTag);
       
  1111 	tlv.AddByte(aGeneralResult);
       
  1112 	if (aResultAddInfo.Length())
       
  1113 		{
       
  1114 		tlv.AddByte( ( TUint8 ) aResultAddInfo[0] );
       
  1115 		}
       
  1116 	
       
  1117 	terminalRsp.Append(tlv.GetDataWithoutTopLevelTag());	
       
  1118 	
       
  1119 	TDesC8* terminalRspPtr = &terminalRsp;	
       
  1120 	TMockLtsyData1<TDesC8*> termRespData(terminalRspPtr);
       
  1121 	termRespData.SerialiseL(data);
       
  1122 	
       
  1123 	iMockLTSY.ExpectL(MLtsyDispatchSatTerminalRsp::KLtsyDispatchSatTerminalRspApiId, data, aErrorForExpect);
       
  1124 	
       
  1125 	CleanupStack::PopAndDestroy(&terminalRsp);
       
  1126 	CleanupStack::PopAndDestroy(&data);
       
  1127 	}
       
  1128 
       
  1129 /**
       
  1130  * prepare data and call iSat.TerminalRsp(reqStatus, aRSatTypeOfCommand, aRspPckg);
       
  1131  * @param aRspPckg - data for response 
       
  1132  * @param aExpectedError - error, which is expected from CTSY 
       
  1133  */ 
       
  1134 void CCSatSetUpEventListFU::TerminalResponseL(const TDesC8& aRspPckg, TInt aExpectedError)
       
  1135 	{
       
  1136 	TRequestStatus reqStatus;
       
  1137 	iSat.TerminalRsp(reqStatus, RSat::ESetUpEventList, aRspPckg);
       
  1138 	User::WaitForRequest(reqStatus);
       
  1139 	ASSERT_EQUALS(aExpectedError, reqStatus.Int());
       
  1140 	}
       
  1141 
       
  1142 /**
       
  1143  * prepare data and call iSat.EventDownload;
       
  1144  * @param aEvent - code of event 
       
  1145  */ 
       
  1146 void CCSatSetUpEventListFU::PrepareAndCallEventDownloadL(const TUint8 aEvent)
       
  1147 	{
       
  1148 	PrepareAndCallEventDownloadL(	aEvent, 
       
  1149 									NULL,  		// aClientSat,
       
  1150 									EFalse,		// aIsUnsolicited,
       
  1151 									KErrNone); 	//aErrorForExpect)	
       
  1152 	}
       
  1153 
       
  1154 /**
       
  1155  * prepare data and call iSat.EventDownload;
       
  1156  * @param aEvent - code of event
       
  1157  * @param aUseOwnSat - if interal sat (iSat) is used
       
  1158  * @param aClientSat - pointer to sat object (if aUseOwnSat == EFalse)
       
  1159  * @param aIsUnsolicited - if this command is unsolicited one
       
  1160  * @param aErrorForExpect -  error, expected from LTSY 
       
  1161  */ 
       
  1162 void CCSatSetUpEventListFU::PrepareAndCallEventDownloadL( const TUint8 aEvent,														
       
  1163 														  const RSat* aClientSat,
       
  1164 														  TBool aIsUnsolicited,
       
  1165 														  TInt  aErrorForExpect)
       
  1166 	{	
       
  1167 	RBuf8 data;
       
  1168 	CleanupClosePushL(data);
       
  1169 	
       
  1170 	RBuf8 eventData;
       
  1171 	CleanupClosePushL(eventData);
       
  1172 	
       
  1173 	RSat::TEventDownloadBaseV2 			 baseEventInfo;
       
  1174 	RSat::TEventDownloadBaseV2Pckg 		 baseEventInfoPckg(baseEventInfo);
       
  1175 	
       
  1176 	// BY DEFAULT use base event info
       
  1177 	eventData.CreateL(baseEventInfoPckg);
       
  1178 	
       
  1179 	TRequestStatus requestStatus;	
       
  1180 	// Create envelope
       
  1181 	TTlv envelope;
       
  1182 	envelope.Begin(KBerTlvEventDownloadTag);
       
  1183 	// Event list
       
  1184 	envelope.AddTag(KTlvEventListTag);
       
  1185 	envelope.AddByte(aEvent);
       
  1186 	// Device identities
       
  1187 	envelope.AddTag(KTlvDeviceIdentityTag);	
       
  1188 	envelope.AddByte( (aEvent ==KEventIdleScreenAvailable)? KDisplay : KMe);	
       
  1189 	envelope.AddByte(KSim);
       
  1190 		
       
  1191 	RSat::TEventList singleEvent( RSat::KUserActivity);	
       
  1192 	switch (aEvent)
       
  1193 		{
       
  1194 		case KEventUserActivity:
       
  1195 			{		  
       
  1196 			singleEvent = RSat::KUserActivity; 								
       
  1197 			break;
       
  1198 			}	
       
  1199 		
       
  1200 		 case KEventIdleScreenAvailable:
       
  1201 			 {			
       
  1202 			 singleEvent = RSat::KIdleScreenAvailable;				 				 
       
  1203 			 break;
       
  1204 			 }
       
  1205 		
       
  1206 		 case KEventBrowserTermination:
       
  1207 			 {
       
  1208 			 singleEvent = RSat::KBrowserTermination;
       
  1209 			 
       
  1210 			 // change default event data
       
  1211 			 RSat::TBrowserTerminationEventV2	 browserTermination;
       
  1212 			 RSat::TBrowserTerminationEventV2Pckg browserTerminationPckg(browserTermination);
       
  1213 			 browserTermination.iCause = RSat::EUserTermination;
       
  1214 			 // use special (browserTermination) event info
       
  1215 			 eventData.Close();
       
  1216 			 eventData.CreateL(browserTerminationPckg);			 
       
  1217 			 
       
  1218 			 // Cause
       
  1219 		     envelope.AddTag( KTlvBrowserTerminationCauseTag );
       
  1220 		     envelope.AddByte( KBrowserTerminationUser );				 
       
  1221 			 break;
       
  1222 			 }
       
  1223 		
       
  1224 		 case KEventLanguageSelection:
       
  1225 			 {
       
  1226 			 singleEvent = RSat::KLanguageSelection; 
       
  1227 			 
       
  1228 			 // change default event data
       
  1229 			 RSat::TLanguageSelectionEventV2      lang;
       
  1230 			 RSat::TLanguageSelectionEventV2Pckg  langPck(lang);			 
       
  1231 			 //data for event download	
       
  1232 			 TUint languageCode(0xABCD); // some language code	
       
  1233 			 lang.iLanguage = languageCode;			 
       
  1234 			 // use special (lang) event info
       
  1235 			 eventData.Close();
       
  1236 			 eventData.CreateL(langPck);		
       
  1237 			 
       
  1238 			 // Language
       
  1239 			 envelope.AddTag( KTlvLanguageTag );
       
  1240 			 envelope.AddByte( TUint8( ( languageCode >> 8 ) & 0x7f ) );// MSB
       
  1241 			 envelope.AddByte( TUint8( ( languageCode ) & 0x7f ) );// LSB			 
       
  1242 			 break;
       
  1243 			 }
       
  1244 		
       
  1245 		 case KEventDataAvailable:
       
  1246 			 {
       
  1247 			 singleEvent = RSat::KDataAvailable;
       
  1248 			 
       
  1249 			 // change default event data
       
  1250 			 RSat::TDataAvailableEventV2	 	 dataAvailable;
       
  1251 			 RSat::TDataAvailableEventV2Pckg  	 dataAvailablePckg(dataAvailable);			 
       
  1252 			 TUint8 length = 0x22; // some length
       
  1253 			 //data for event download	
       
  1254 			 dataAvailable.iStatus.Append(KChannelStatusByte1);
       
  1255 			 dataAvailable.iLength = length;
       
  1256 			 // use special (dataavailable) event info
       
  1257 			 eventData.Close();
       
  1258 			 eventData.CreateL(dataAvailablePckg);	
       
  1259 			 
       
  1260 			 // Channel status
       
  1261 			 envelope.AddTag( KTlvChannelStatusTag );
       
  1262 			 envelope.AddByte( KChannelStatusByte1 );
       
  1263 			 // Channel data length
       
  1264 			 envelope.AddTag( KTlvChannelDataLengthTag );
       
  1265 			 envelope.AddByte( length );
       
  1266 		     break;
       
  1267 		     }
       
  1268 		   	
       
  1269 		 case KEventChannelStatus:
       
  1270 		   	 {
       
  1271 		   	 singleEvent = RSat::KChannelStatus;
       
  1272 		   	
       
  1273 		   	 // change default event data
       
  1274 		   	 RSat::TChannelStatusEventV2			 channelStatus;
       
  1275 		   	 RSat::TChannelStatusEventV2Pckg 	 channelStatusPckg(channelStatus);
       
  1276 		     //data for event download	
       
  1277 		   	 channelStatus.iStatus.Append(KChannelStatusByte1);		   	
       
  1278 		   	 // use special (channel status) event info	
       
  1279 		   	 eventData.Close();
       
  1280 		   	 eventData.CreateL(channelStatusPckg);
       
  1281 		  		  
       
  1282 		     // Channel status
       
  1283 		     envelope.AddTag( KTlvChannelStatusTag );
       
  1284 		     envelope.AddByte( KChannelStatusByte1 );
       
  1285 		     break;
       
  1286 		   	 }
       
  1287 
       
  1288 		 case KLocalConnection_missing:
       
  1289 			 {
       
  1290 			 singleEvent = RSat::KCardReaderStatus;
       
  1291 			 break;
       
  1292 			 }
       
  1293 			 
       
  1294 		 case KDisplayParamsChanges_missing:
       
  1295 			 {
       
  1296 			 singleEvent = RSat::KCardReaderStatus;
       
  1297 			 break;
       
  1298 			 }
       
  1299 			 
       
  1300 		 case KEventCardReaderStatus:
       
  1301 			 {
       
  1302 			 singleEvent = RSat::KCardReaderStatus;
       
  1303 			 break;
       
  1304 			 }
       
  1305 		         
       
  1306 		 // Not reported to the client
       
  1307 		 case KEventMTCall:
       
  1308 		 case KEventCallConnected:
       
  1309 		 case KEventCallDisconnected:
       
  1310 		 case KEventLocationStatus:
       
  1311 		 case KEventAccessTechnologyChange:
       
  1312 		 default:
       
  1313 			 {
       
  1314 			 // we have nothing to do here
       
  1315 			 // so let's go out
       
  1316 			 CleanupStack::PopAndDestroy(&eventData);
       
  1317 			 CleanupStack::PopAndDestroy(&data);
       
  1318 			 return;
       
  1319 			 }
       
  1320 			 
       
  1321 		}// end Switch
       
  1322 		
       
  1323 	// if this request is NOT Unsolicited
       
  1324 	if (!aIsUnsolicited)
       
  1325 		{
       
  1326 		TDesC8* envelopePtr = &const_cast<TDesC8&>(envelope.End());
       
  1327 		TMockLtsyData1<TDesC8*> eventDownloadExpLtsyData(envelopePtr);
       
  1328 		eventDownloadExpLtsyData.SerialiseL(data);
       
  1329 		iMockLTSY.ExpectL(MLtsyDispatchSatEventDownloadEnvelope::KLtsyDispatchSatEventDownloadEnvelopeApiId,
       
  1330 							data, aErrorForExpect);
       
  1331 		}
       
  1332 	
       
  1333 	// this if-else just because of multiple client test
       
  1334 	if (aClientSat)
       
  1335 		{
       
  1336 		// it means that this request is from the second client
       
  1337 		aClientSat->EventDownload(requestStatus, singleEvent, eventData);		
       
  1338 		}
       
  1339 	else
       
  1340 		{		
       
  1341 		//ETel calls event download
       
  1342 		iSat.EventDownload(requestStatus, singleEvent, eventData);
       
  1343 		}
       
  1344 	
       
  1345 	User::WaitForRequest(requestStatus);
       
  1346 	ASSERT_EQUALS(aErrorForExpect, requestStatus.Int())
       
  1347 	AssertMockLtsyStatusL();
       
  1348 	
       
  1349 	CleanupStack::PopAndDestroy(&eventData);
       
  1350 	CleanupStack::PopAndDestroy(&data);
       
  1351 	}
       
  1352 
       
  1353 /**
       
  1354  * prepare data and force TSY to send ENVELOPE
       
  1355  * @param aEvent - code of event
       
  1356  * @param aIsEnvelopeSent- ETrue if ENVELOPE is  really sent to LTSY
       
  1357  */ 
       
  1358 void CCSatSetUpEventListFU::EnvelopeFromTsyL(const TUint8 aEvent, TBool aIsEnvelopeSent)
       
  1359 	{	
       
  1360 	static const TUint8 someId = 111;
       
  1361 	
       
  1362 	switch (aEvent)
       
  1363 		{
       
  1364 		 case KEventMTCall:
       
  1365 			 {
       
  1366 			 // ---Prepare and call CompleteMTCallL with correct data-----------------------------				 
       
  1367 			 //Type of Number (TON) and numbering plan identification (NPI).
       
  1368 			 //MSB - 1, Type of Number - 011 (Network Specific Number), Numbering Plan - 1001 (Private numbering plan) 10111001 = B9 Hex
       
  1369 			 const TUint8 KTonAndNpi = (0x80) | (RMobilePhone::ENetworkSpecificNumber << 4) | (RMobilePhone::EPrivateNumberPlan);			 			 	
       
  1370 			 TBuf8<KAddrMaxLength> address;
       
  1371 			 address.Append(KTonAndNpi);
       
  1372 			 address.Append(_L8("1234567")); //dummy address 			 	
       
  1373 			 TBuf8<KSubAddressLength> subAddress;
       
  1374 			 subAddress.Append(_L8("12345678910")); //dummy subAddress 	
       
  1375 			 CompleteMTCallL(someId, &address, &subAddress, aIsEnvelopeSent);			 
       
  1376 			 
       
  1377 			 // ---Prepare and call CompleteMTCallL with NULL-address and subAddress lenght ------
       
  1378 			 address.Zero();	
       
  1379 			 subAddress.Zero();
       
  1380 			 address.Append(KTonAndNpi);			
       
  1381 			 CompleteMTCallL(someId, &address, &subAddress, aIsEnvelopeSent);		 
       
  1382 			 
       
  1383 			 // ---Prepare and call CompleteMTCallL without KTonAndNpi ----------------------------
       
  1384 			 address.Zero();			 
       
  1385 			 CompleteMTCallL(someId, &address, &subAddress, aIsEnvelopeSent);			 
       
  1386 			 break;
       
  1387 			 }
       
  1388 			 
       
  1389 		 case KEventCallConnected:
       
  1390 			 {			 			
       
  1391 			 // ---Prepare and call CompleteCallConnectedL with nearEnd = EFalse --------------------
       
  1392 			 TBool nearEnd = EFalse;
       
  1393 			 CompleteCallConnectedL(someId, nearEnd, aIsEnvelopeSent);
       
  1394 			 
       
  1395 			 // ---Prepare and call CompleteCallConnectedL with nearEnd = ETrue --------------------
       
  1396 			 nearEnd = ETrue;
       
  1397 			 CompleteCallConnectedL(someId, nearEnd, aIsEnvelopeSent);			 
       
  1398 			 break;
       
  1399 			 }
       
  1400 			 
       
  1401 		 case KEventCallDisconnected:
       
  1402 			 {
       
  1403 			 // ---Prepare and call CompleteCallDisconnectedL with nearEnd = EFalse and cause given---
       
  1404 			 TBool nearEnd = EFalse;
       
  1405 			 TBuf8 <KMaxCauseLength> cause;
       
  1406 			 cause.Append(_L8("1234567"));			 
       
  1407 			 CompleteCallDisconnectedL(someId, nearEnd, &cause, aIsEnvelopeSent);
       
  1408 			 
       
  1409 			 // ---Prepare and call CompleteCallDisconnectedL with nearEnd = ETrue and without cause--
       
  1410 			 nearEnd = ETrue;
       
  1411 			 cause.Zero();			 
       
  1412 			 CompleteCallDisconnectedL(someId, nearEnd, &cause, aIsEnvelopeSent);			 
       
  1413 			 break;
       
  1414 			 }
       
  1415 			 
       
  1416 		 case KEventLocationStatus:
       
  1417 			 {
       
  1418 			 // ---Prepare and call CompleteLocationStatusL with  KLocationStatusNormalService--------
       
  1419 			 TUint8 locationStatus = KLocationStatusNormalService;
       
  1420 			 TBuf8<KCountryCodeLength> countryCode(_L8("926")); // code of some Moscow ME operator
       
  1421 			 TUint16 locationAreaCode = KLocationAreaCode;
       
  1422 			 TUint16 cellId = KCellId;
       
  1423 			 CompleteLocationStatusL(locationStatus, countryCode, locationAreaCode, cellId, aIsEnvelopeSent);
       
  1424 			 
       
  1425 			 // ---Prepare and call CompleteLocationStatusL with  KLocationStatusLimitedService--------
       
  1426 			 locationStatus = KLocationStatusLimitedService;			
       
  1427 			 CompleteLocationStatusL(locationStatus, countryCode, locationAreaCode, cellId, aIsEnvelopeSent);
       
  1428 			 
       
  1429 			 // ---Prepare and call CompleteLocationStatusL with  another countryCode------------------
       
  1430 			 countryCode.Copy(_L8("124"));			
       
  1431 			 CompleteLocationStatusL(locationStatus, countryCode, locationAreaCode, cellId, aIsEnvelopeSent);	
       
  1432 			 
       
  1433 			 // ---Prepare and call CompleteLocationStatusL with  another locationAreaCode-------------
       
  1434 			 locationAreaCode = 333; // some dummy code			
       
  1435 			 CompleteLocationStatusL(locationStatus, countryCode, locationAreaCode, cellId, aIsEnvelopeSent);
       
  1436 
       
  1437 			 // ---Prepare and call CompleteLocationStatusL with  another cellId-----------------------
       
  1438 			 cellId = 444; // some dummy id	
       
  1439 			 CompleteLocationStatusL(locationStatus, countryCode, locationAreaCode, cellId, aIsEnvelopeSent);
       
  1440 			 
       
  1441 			 // ---Prepare and call CompleteLocationStatusL with  the same data------------------------
       
  1442 			 CompleteLocationStatusL(locationStatus, countryCode, locationAreaCode, cellId, EFalse);			 
       
  1443 			 break;
       
  1444 			 }
       
  1445 			 
       
  1446 		 case KEventAccessTechnologyChange:
       
  1447 			 {
       
  1448 			 TUint8 aAccTechChange(0);
       
  1449 			 CompleteAccessTechnologyChangeL(aAccTechChange, aIsEnvelopeSent);
       
  1450 			 break;
       
  1451 			 }
       
  1452 			 
       
  1453 		 default:
       
  1454 			 {
       
  1455 			 break;
       
  1456 			 }
       
  1457 			 
       
  1458 		}// end of swith
       
  1459 	}
       
  1460 
       
  1461 
       
  1462 /**
       
  1463  * Invokes CSatEventDownloadTsy::CompleteMTCallL()
       
  1464  * @param aTransactionId - id of transaction
       
  1465  * @param aAddress - address for complete
       
  1466  * @param aSubAddress - subaddress for complete
       
  1467  * @param aIsEnvelopeSent- ETrue if ENVELOPE is  really sent to LTSY
       
  1468  */ 
       
  1469 void CCSatSetUpEventListFU::CompleteMTCallL(TUint8 aTransactionId, 
       
  1470 											TDesC8* aAddress,
       
  1471 											TDesC8* aSubAddress,
       
  1472 											TBool aIsEnvelopeSent)
       
  1473 	{
       
  1474 	RBuf8 data;
       
  1475 	CleanupClosePushL(data);
       
  1476 	
       
  1477 	TRequestStatus requestStatus;
       
  1478 		
       
  1479 	// call TSY's CompleteMTCallL
       
  1480 	TMockLtsyData3<TUint8,TDesC8*,TDesC8*> mtCallPack(aTransactionId, aAddress, aSubAddress);
       
  1481 	mtCallPack.SerialiseL(data);
       
  1482 	iMockLTSY.CompleteL(KMockLtsyDispatchSatMtCallIndId, KErrNone, data, KDelay); // use KDelay to have time for preparing MockL data 
       
  1483 	data.Close();
       
  1484 	
       
  1485 	if (aIsEnvelopeSent)
       
  1486 		{
       
  1487 		//Prepare data MockL data for TSY's ENVELOPE
       
  1488 		// Create envelope
       
  1489 		TTlv envelope;
       
  1490 		envelope.Begin(KBerTlvEventDownloadTag);
       
  1491 		// Event list
       
  1492 		envelope.AddTag ( KTlvEventListTag );
       
  1493 		envelope.AddByte( KEventMTCall );
       
  1494 		// Device identities
       
  1495 		envelope.AddTag ( KTlvDeviceIdentityTag );
       
  1496 		envelope.AddByte( KNetwork );
       
  1497 		envelope.AddByte( KSim );	
       
  1498 		// Transaction identifier
       
  1499 		envelope.AddTag ( KTlvTransactionIdentifierTag );
       
  1500 		envelope.AddByte(aTransactionId);
       
  1501 		
       
  1502 		if (aAddress->Length())
       
  1503 			{
       
  1504 			envelope.AddTag ( KTlvAddressTag );
       
  1505 			envelope.AddData( *aAddress );
       
  1506 			}
       
  1507 		
       
  1508 		if (aSubAddress->Length())
       
  1509 			{
       
  1510 			envelope.AddTag( KTlvSubaddressTag );
       
  1511 			envelope.AddData( *aSubAddress );
       
  1512 			}
       
  1513 		
       
  1514 		TDesC8* envelopePtr = &const_cast<TDesC8&>(envelope.End());
       
  1515 		TMockLtsyData1<TDesC8*> eventDownloadExpLtsyData(envelopePtr);
       
  1516 		eventDownloadExpLtsyData.SerialiseL(data);		
       
  1517 		iMockLTSY.ExpectL(MLtsyDispatchSatEventDownloadEnvelope::KLtsyDispatchSatEventDownloadEnvelopeApiId,data);
       
  1518 		}
       
  1519 	
       
  1520 	// wait for CompleteMTCallL
       
  1521 	TRequestStatus mockLtsyStatus;
       
  1522 	iMockLTSY.NotifyTerminated(mockLtsyStatus); 
       
  1523 	User::WaitForRequest(mockLtsyStatus);
       
  1524 	ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int());
       
  1525 	
       
  1526 	CleanupStack::PopAndDestroy(&data);
       
  1527 	AssertMockLtsyStatusL();
       
  1528 	}
       
  1529 
       
  1530 /**
       
  1531  * Invokes CSatEventDownloadTsy::CompleteCallConnectedL()
       
  1532  * @param aTransactionId - id of transaction
       
  1533  * @param aNearEnd - indicates phone (KMe) or network (KNetwork)
       
  1534  * @param aIsEnvelopeSent- ETrue if ENVELOPE is  really sent to LTSY
       
  1535  */
       
  1536 void CCSatSetUpEventListFU::CompleteCallConnectedL(TUint8 aTransactionId, TBool aNearEnd, 
       
  1537 												TBool aIsEnvelopeSent)
       
  1538 	{
       
  1539 	 RBuf8 data;
       
  1540 	 CleanupClosePushL(data);
       
  1541 	 
       
  1542 	 TRequestStatus requestStatus; 
       
  1543 	
       
  1544 	 TMockLtsyData2<TUint8, TBool> callConnectedTechPack(aTransactionId, aNearEnd);
       
  1545 	 callConnectedTechPack.SerialiseL(data);
       
  1546 	 iMockLTSY.CompleteL(KMockLtsyDispatchSatCallConnectedIndId, KErrNone, data, KDelay); // use KDelay to have time for preparing MockL data
       
  1547 	 data.Close();
       
  1548 	 
       
  1549 	 if (aIsEnvelopeSent)
       
  1550 		 {	 
       
  1551 		 // Create envelope
       
  1552 		 TTlv envelope;
       
  1553 		 envelope.Begin( KBerTlvEventDownloadTag );
       
  1554 		 
       
  1555 		 // Event list
       
  1556 		 envelope.AddTag(KTlvEventListTag);
       
  1557 		 envelope.AddByte(KEventCallConnected);
       
  1558 		 // Device identities
       
  1559 		 envelope.AddTag(KTlvDeviceIdentityTag);
       
  1560 		 envelope.AddByte(aNearEnd ? KMe : KNetwork);
       
  1561 		 envelope.AddByte(KSim);
       
  1562 		 // Transaction identifier
       
  1563 		 envelope.AddTag(KTlvTransactionIdentifierTag);
       
  1564 		 envelope.AddByte(aTransactionId);
       
  1565 		 
       
  1566 		 TDesC8* envelopePtr = &const_cast<TDesC8&>(envelope.End());
       
  1567 		 TMockLtsyData1<TDesC8*> eventDownloadExpLtsyData(envelopePtr);
       
  1568 		 eventDownloadExpLtsyData.SerialiseL(data);		
       
  1569 		 iMockLTSY.ExpectL(MLtsyDispatchSatEventDownloadEnvelope::KLtsyDispatchSatEventDownloadEnvelopeApiId,data);
       
  1570 		 }
       
  1571 	 
       
  1572 	 // wait for CompleteMTCallL
       
  1573 	 TRequestStatus mockLtsyStatus;
       
  1574 	 iMockLTSY.NotifyTerminated(mockLtsyStatus); 
       
  1575 	 User::WaitForRequest(mockLtsyStatus);
       
  1576 	 ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int());
       
  1577 	 
       
  1578 	 CleanupStack::PopAndDestroy(&data);
       
  1579 	 AssertMockLtsyStatusL();
       
  1580 	}	
       
  1581 
       
  1582 /**
       
  1583  * Invokes CSatEventDownloadTsy::CompleteCallDisconnectedL()
       
  1584  * @param aTransactionId - id of transaction
       
  1585  * @param aNearEnd - indicates phone (KMe) or network (KNetwork)
       
  1586  * @param aCause - the initiator of disconnect 
       
  1587  * @param aIsEnvelopeSent- ETrue if ENVELOPE is  really sent to LTSY
       
  1588  */
       
  1589 void CCSatSetUpEventListFU::CompleteCallDisconnectedL(TUint8 aTransactionId, TBool aNearEnd, 
       
  1590 													TDesC8* aCause, TBool aIsEnvelopeSent)
       
  1591 	{
       
  1592 	
       
  1593 	RBuf8 data;
       
  1594 	CleanupClosePushL(data);
       
  1595 		 
       
  1596 	TRequestStatus requestStatus; 
       
  1597 	
       
  1598 	TMockLtsyData3<TUint8,TBool,TDesC8*> callDisconnectedLtsyData(aTransactionId, aNearEnd, aCause);
       
  1599 	callDisconnectedLtsyData.SerialiseL(data);
       
  1600 	iMockLTSY.CompleteL(KMockLtsyDispatchSatCallDisconnectedIndId, KErrNone, data,  KDelay); // use KDelay to have time for preparing MockL data
       
  1601 	data.Close();
       
  1602 	
       
  1603 	if (aIsEnvelopeSent)
       
  1604 		{	
       
  1605 	    // Create envelope data
       
  1606 		TTlv envelope;
       
  1607 		envelope.Begin(KBerTlvEventDownloadTag);
       
  1608 		// Event list
       
  1609 		envelope.AddTag(KTlvEventListTag);
       
  1610 		envelope.AddByte(KEventCallDisconnected);
       
  1611 		// Device identities
       
  1612 		envelope.AddTag(KTlvDeviceIdentityTag);
       
  1613 		envelope.AddByte(aNearEnd ? KMe : KNetwork);
       
  1614 		envelope.AddByte(KSim);
       
  1615 		// Transaction identifier
       
  1616 		envelope.AddTag(KTlvTransactionIdentifierTag);
       
  1617 		envelope.AddByte(aTransactionId);    
       
  1618 		// Cause
       
  1619 		if (aCause->Length() != 0)
       
  1620 			{
       
  1621 			envelope.AddTag (KTlvCauseTag);
       
  1622 			envelope.AddData(*aCause);
       
  1623 			}
       
  1624 		
       
  1625 		TDesC8* envelopePtr = &const_cast<TDesC8&>(envelope.End());
       
  1626 		TMockLtsyData1<TDesC8*> eventDownloadExpLtsyData(envelopePtr);
       
  1627 		eventDownloadExpLtsyData.SerialiseL(data);		
       
  1628 		iMockLTSY.ExpectL(MLtsyDispatchSatEventDownloadEnvelope::KLtsyDispatchSatEventDownloadEnvelopeApiId,data);
       
  1629 		}
       
  1630 	// wait for CompleteMTCallL
       
  1631 	TRequestStatus mockLtsyStatus;
       
  1632 	iMockLTSY.NotifyTerminated(mockLtsyStatus); 
       
  1633 	User::WaitForRequest(mockLtsyStatus);
       
  1634 	ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int());
       
  1635 		 
       
  1636 	CleanupStack::PopAndDestroy(&data);
       
  1637 	AssertMockLtsyStatusL();	
       
  1638 	}
       
  1639 
       
  1640 
       
  1641 
       
  1642 /**
       
  1643  * Invokes CSatEventDownloadTsy::CompleteLocationStatusL()
       
  1644  * @param aLocationStatus - status
       
  1645  * @param aCountryCode - operator's code
       
  1646  * @param aLocationAreaCode - location area code
       
  1647  * @param aCellId - cell id
       
  1648  * @param aIsEnvelopeSent- ETrue if ENVELOPE is  really sent to LTSY
       
  1649  */
       
  1650 void CCSatSetUpEventListFU::CompleteLocationStatusL(TUint8 	aLocationStatus,
       
  1651 													TDes8&	aCountryCode,
       
  1652 													TUint16 aLocationAreaCode,
       
  1653 													TUint16 aCellId,
       
  1654 													TBool aIsEnvelopeSent)
       
  1655 	{	
       
  1656 	RBuf8 data;
       
  1657 	CleanupClosePushL(data);		 
       
  1658 	TRequestStatus requestStatus;
       
  1659 	TDesC8* countryCodePtr = &aCountryCode;
       
  1660 	TMockLtsyData4<TUint8, TDesC8*, TUint16, TUint16 >locationStatusData( aLocationStatus, 
       
  1661 																			countryCodePtr,
       
  1662 																			aLocationAreaCode,
       
  1663 																			aCellId);	
       
  1664 	locationStatusData.SerialiseL(data);
       
  1665 	iMockLTSY.CompleteL(KMockLtsyDispatchSatLocationStatusIndId, KErrNone, data,  KDelay); // use KDelay to have time for preparing MockL data
       
  1666 	data.Close();
       
  1667 	
       
  1668 	if (aIsEnvelopeSent)
       
  1669 		{
       
  1670 		// Create envelope data
       
  1671 		TTlv envelope;
       
  1672 		envelope.Begin  ( KBerTlvEventDownloadTag );
       
  1673 		// Event list
       
  1674 		envelope.AddTag ( KTlvEventListTag );
       
  1675 		envelope.AddByte( KEventLocationStatus );
       
  1676 		// Device identities
       
  1677 		envelope.AddTag ( KTlvDeviceIdentityTag );
       
  1678 		envelope.AddByte( KMe );
       
  1679 		envelope.AddByte( KSim );
       
  1680 		// Locationstatus
       
  1681 		envelope.AddTag ( KTlvLocationStatusTag );
       
  1682 		envelope.AddByte( TUint8(aLocationStatus) );
       
  1683 
       
  1684 		// Location information, this is included only if status indicates 
       
  1685 		// normal service
       
  1686 		if ( KLocationStatusNormalService == aLocationStatus )
       
  1687 			{
       
  1688 			envelope.AddTag ( KTlvLocationInformationTag );
       
  1689 			envelope.AddData( aCountryCode );        
       
  1690 			// Mobile country & network codes
       
  1691 			envelope.AddByte( TUint8( aLocationAreaCode >> 8 ) );
       
  1692 			envelope.AddByte( TUint8( aLocationAreaCode ) );
       
  1693 			envelope.AddByte( TUint8( aCellId >> 8 ) ); 
       
  1694 			envelope.AddByte( TUint8( aCellId ) );
       
  1695 			}
       
  1696 	
       
  1697 		TDesC8* envelopePtr = &const_cast<TDesC8&>(envelope.End());
       
  1698 		TMockLtsyData1<TDesC8*> eventDownloadExpLtsyData(envelopePtr);
       
  1699 		eventDownloadExpLtsyData.SerialiseL(data);		
       
  1700 		iMockLTSY.ExpectL(MLtsyDispatchSatEventDownloadEnvelope::KLtsyDispatchSatEventDownloadEnvelopeApiId,data);
       
  1701 		} 
       
  1702 	
       
  1703 	// wait for CompleteMTCallL
       
  1704 	TRequestStatus mockLtsyStatus;
       
  1705 	iMockLTSY.NotifyTerminated(mockLtsyStatus); 
       
  1706 	User::WaitForRequest(mockLtsyStatus);
       
  1707 	ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int());
       
  1708 		 
       
  1709 	CleanupStack::PopAndDestroy(&data);
       
  1710 	AssertMockLtsyStatusL();	
       
  1711 	}
       
  1712 /**
       
  1713  * Invokes CSatEventDownloadTsy::CompleteAccessTechnologyChangeL()
       
  1714  * @param aAccTechChange - Access technology
       
  1715  * @param aIsEnvelopeSent- ETrue if ENVELOPE is  really sent to LTSY
       
  1716  */
       
  1717 void CCSatSetUpEventListFU::CompleteAccessTechnologyChangeL(TUint8 aAccTechChange, TBool aIsEnvelopeSent)
       
  1718 	{
       
  1719 	RBuf8 data;
       
  1720 	CleanupClosePushL(data);
       
  1721 		 
       
  1722 	TRequestStatus requestStatus;
       
  1723 	
       
  1724 	TMockLtsyData1<TUint8> accTechData( aAccTechChange);	
       
  1725 	accTechData.SerialiseL(data);
       
  1726 	iMockLTSY.CompleteL(KMockLtsyDispatchSatAccessTechnologyChangeIndId, KErrNone, data,  KDelay); // use KDelay to have time for preparing MockL data
       
  1727 	data.Close();
       
  1728 	
       
  1729 	if (aIsEnvelopeSent)
       
  1730 		{
       
  1731 		TTlv envelope;
       
  1732 		envelope.Begin  ( KBerTlvEventDownloadTag );
       
  1733 		// event list
       
  1734 		envelope.AddTag ( KTlvEventListTag );
       
  1735 		envelope.AddByte( KEventAccessTechnologyChange );
       
  1736 		// device identities
       
  1737 		envelope.AddTag ( KTlvDeviceIdentityTag );
       
  1738 		envelope.AddByte( KMe );
       
  1739 		envelope.AddByte( KSim );	
       
  1740 		envelope.AddTag( KTlvAccessTechnologyTag );
       
  1741 		envelope.AddByte( aAccTechChange );	
       
  1742 		
       
  1743 		TDesC8* envelopePtr = &const_cast<TDesC8&>(envelope.End());
       
  1744 		TMockLtsyData1<TDesC8*> eventDownloadExpLtsyData(envelopePtr);
       
  1745 		eventDownloadExpLtsyData.SerialiseL(data);		
       
  1746 		iMockLTSY.ExpectL(MLtsyDispatchSatEventDownloadEnvelope::KLtsyDispatchSatEventDownloadEnvelopeApiId,data);
       
  1747 		}
       
  1748 	// wait for CompleteMTCallL
       
  1749 	TRequestStatus mockLtsyStatus;
       
  1750 	iMockLTSY.NotifyTerminated(mockLtsyStatus); 
       
  1751 	User::WaitForRequest(mockLtsyStatus);
       
  1752 	ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int());
       
  1753 		 
       
  1754 	CleanupStack::PopAndDestroy(&data);
       
  1755 	AssertMockLtsyStatusL();	
       
  1756 	}
       
  1757 
       
  1758 
       
  1759 /**
       
  1760  * Tests all possible "TERMINAL RESPONSE" cases. 
       
  1761  * RSat::TerminalRsp should complets with KErrNone for all valid responses and KErrCorrupt 
       
  1762  * for those that can not be used with "SET UP EVENT LIST" command  
       
  1763  */
       
  1764 void CCSatSetUpEventListFU::DoTestTerminalResponseL()
       
  1765 	{
       
  1766 	static const struct 
       
  1767 		{
       
  1768 		RSat::TPCmdResult			iGeneralResult;
       
  1769 		RSat::TAdditionalInfoType	iInfoType;
       
  1770 		TBool						iIntentionallyOmmitAdditionalInfo; // skip AdditionalInfo
       
  1771 		TUint8						iAdditionalInfo;
       
  1772 		TInt						iExpectedResult;
       
  1773 		} 
       
  1774 	KResponsesToTest[] = 
       
  1775 		{
       
  1776 			{
       
  1777 			// 0x01 - Command performed with partial comprehension;
       
  1778 			RSat::KPartialComprehension,
       
  1779 			RSat::KNoAdditionalInfo,
       
  1780 			ETrue,
       
  1781 			0,
       
  1782 			KErrNone
       
  1783 			},
       
  1784 			{
       
  1785 			// 0x02 - Command performed, with missing information;
       
  1786 			RSat::KMissingInformation,
       
  1787 			RSat::KNoAdditionalInfo,
       
  1788 			ETrue,
       
  1789 			0,
       
  1790 			KErrNone
       
  1791 			},
       
  1792 			{
       
  1793 			// 0x03 - REFRESH performed with additional EFs read;
       
  1794 			RSat::KRefreshAdditionEFRead,
       
  1795 			RSat::KNoAdditionalInfo,
       
  1796 			ETrue,
       
  1797 			0,
       
  1798 			KErrCorrupt
       
  1799 			},
       
  1800 			{ 
       
  1801 			// 0x04 - Command performed successfully, but requested icon could not be displayed;
       
  1802 			RSat::KSuccessRequestedIconNotDisplayed,
       
  1803 			RSat::KNoAdditionalInfo,
       
  1804 			ETrue,
       
  1805 			0,
       
  1806 			KErrCorrupt
       
  1807 			},
       
  1808 			{
       
  1809 			// 0x05 - Command performed, but modified by call control by NAA;
       
  1810 			RSat::KModifiedByCallControl,
       
  1811 			RSat::KNoAdditionalInfo,
       
  1812 			ETrue,
       
  1813 			0,
       
  1814 			KErrCorrupt
       
  1815 			},
       
  1816 			{
       
  1817 			// 0x06 - Command performed successfully, limited service;
       
  1818 			RSat::KSuccessLimitedService,
       
  1819 			RSat::KNoAdditionalInfo,
       
  1820 			ETrue,
       
  1821 			0,
       
  1822 			KErrCorrupt
       
  1823 			},
       
  1824 			{
       
  1825 			// 0x07 - Command performed with modification;
       
  1826 			RSat::KPerformedWithModifications,
       
  1827 			RSat::KNoAdditionalInfo,
       
  1828 			ETrue,
       
  1829 			0,
       
  1830 			KErrCorrupt
       
  1831 			},
       
  1832 			{
       
  1833 			// 0x08 - REFRESH performed but indicated NAA was not active;
       
  1834 			RSat::KRefreshUSIMNotActive,
       
  1835 			RSat::KNoAdditionalInfo,
       
  1836 			ETrue,
       
  1837 			0,
       
  1838 			KErrCorrupt
       
  1839 			},
       
  1840 			{
       
  1841 			// 0x09 - Command performed successfully, tone not played;
       
  1842 			RSat::KPlayTonePerformedSuccessfully,
       
  1843 			RSat::KNoAdditionalInfo,
       
  1844 			ETrue,
       
  1845 			0,
       
  1846 			KErrCorrupt
       
  1847 			},
       
  1848 			{
       
  1849 			// 0x10 - Proactive UICC session terminated by the user;
       
  1850 			RSat::KPSessionTerminatedByUser,
       
  1851 			RSat::KNoAdditionalInfo,
       
  1852 			ETrue,
       
  1853 			0,
       
  1854 			KErrCorrupt
       
  1855 			},
       
  1856 			{
       
  1857 			// 0x11 - Backward move in the proactive UICC session requested by the user;
       
  1858 			RSat::KBackwardModeRequestedByUser,
       
  1859 			RSat::KNoAdditionalInfo,
       
  1860 			ETrue,
       
  1861 			0,
       
  1862 			KErrCorrupt			
       
  1863 			},
       
  1864 			{
       
  1865 			// 0x12 - No response from user;
       
  1866 			RSat::KNoResponseFromUser,
       
  1867 			RSat::KNoAdditionalInfo,
       
  1868 			ETrue,
       
  1869 			0,
       
  1870 			KErrCorrupt			
       
  1871 			},
       
  1872 			{
       
  1873 			// 0x13 - Help information required by the user;
       
  1874 			RSat::KHelpRequestedByUser,
       
  1875 			RSat::KNoAdditionalInfo,
       
  1876 			ETrue,
       
  1877 			0,
       
  1878 			KErrCorrupt			
       
  1879 			},
       
  1880 			{
       
  1881 			// 0x14 - reserved for GSM/3G.
       
  1882 			RSat::KUssdTransactionTerminatedByUser,
       
  1883 			RSat::KNoAdditionalInfo, 
       
  1884 			ETrue,
       
  1885 			0,
       
  1886 			KErrCorrupt
       
  1887 			},
       
  1888 			{
       
  1889 			// 0x20 - terminal currently unable to process command;
       
  1890 			RSat::KMeUnableToProcessCmd,
       
  1891 			RSat::KMeProblem,
       
  1892 			EFalse,
       
  1893 			0xAE, // dummy additional info
       
  1894 			KErrNone
       
  1895 			},
       
  1896 			{
       
  1897 			// 0x20 without additional information (erroneous)
       
  1898 			RSat::KMeUnableToProcessCmd,
       
  1899 			RSat::KMeProblem, 
       
  1900 			ETrue, // Intentional error !
       
  1901 			0,
       
  1902 			KErrCorrupt
       
  1903 			},	
       
  1904 			
       
  1905 			{
       
  1906 			// 0x21 - Network currently unable to process command;
       
  1907 			RSat::KNetworkUnableToProcessCmd,
       
  1908 			RSat::KSatNetworkErrorInfo,
       
  1909 			ETrue,
       
  1910 			0,
       
  1911 			KErrCorrupt
       
  1912 			},
       
  1913 			{
       
  1914 			// 0x22 - User did not accept the proactive command;
       
  1915 			RSat::KPCmdNotAcceptedByUser,
       
  1916 			RSat::KNoAdditionalInfo,
       
  1917 			ETrue,
       
  1918 			0,
       
  1919 			KErrCorrupt
       
  1920 			},
       
  1921 			{
       
  1922 			// 0x23 - User cleared down call before connection or network release;
       
  1923 			RSat::KCallClearedBeforeConnectionOrReleased,
       
  1924 			RSat::KNoAdditionalInfo,
       
  1925 			ETrue,
       
  1926 			0,
       
  1927 			KErrCorrupt
       
  1928 			},
       
  1929 			{
       
  1930 			// 0x24 - Action in contradiction with the current timer state;
       
  1931 			RSat::KContradictionWithTimerState,
       
  1932 			RSat::KNoAdditionalInfo,
       
  1933 			ETrue,
       
  1934 			0,
       
  1935 			KErrCorrupt
       
  1936 			},
       
  1937 			{
       
  1938 			// 0x25 - Interaction with call control by NAA, temporary problem;
       
  1939 			RSat::KInteractionWithCCTemporaryError,
       
  1940 			RSat::KNoAdditionalInfo,
       
  1941 			ETrue,
       
  1942 			0,
       
  1943 			KErrCorrupt
       
  1944 			},
       
  1945 			{
       
  1946 			// 0x26 - Launch browser generic error code;
       
  1947 			RSat::KLaunchBrowserError,
       
  1948 			RSat::KNoAdditionalInfo,
       
  1949 			ETrue,
       
  1950 			0,
       
  1951 			KErrCorrupt
       
  1952 			},
       
  1953 			{
       
  1954 			// 0x27 - MMS temporary problem.
       
  1955 			RSat::KMMSTemporaryProblem,
       
  1956 			RSat::KNoAdditionalInfo,
       
  1957 			ETrue,
       
  1958 			0,
       
  1959 			KErrCorrupt
       
  1960 			},
       
  1961 			{
       
  1962 			// 0x30 - Command beyond terminal's capabilities;
       
  1963 			RSat::KCmdBeyondMeCapabilities,
       
  1964 			RSat::KNoAdditionalInfo,
       
  1965 			ETrue,
       
  1966 			0,
       
  1967 			KErrNone
       
  1968 			},			
       
  1969 			{
       
  1970 			// 0x31 - Command type not understood by terminal;
       
  1971 			RSat::KCmdTypeNotUnderstood,
       
  1972 			RSat::KNoAdditionalInfo,
       
  1973 			ETrue,
       
  1974 			0,
       
  1975 			KErrNone
       
  1976 			},
       
  1977 			{ 
       
  1978 			// 0x32 - Command data not understood by terminal;
       
  1979 			RSat::KCmdDataNotUnderstood,
       
  1980 			RSat::KNoAdditionalInfo,
       
  1981 			ETrue,
       
  1982 			0,
       
  1983 			KErrNone
       
  1984 			},
       
  1985 			{
       
  1986 			// 0x33 - Command number not known by terminal;
       
  1987 			RSat::KCmdNumberNotKnown,
       
  1988 			RSat::KNoAdditionalInfo,
       
  1989 			ETrue,
       
  1990 			0,
       
  1991 			KErrNone
       
  1992 			},
       
  1993 			{
       
  1994 			// 0x34 - reserved for GSM/3G;
       
  1995 			RSat::KSsReturnError,
       
  1996 			RSat::KNoAdditionalInfo,
       
  1997 			ETrue,
       
  1998 			0,
       
  1999 			KErrCorrupt
       
  2000 			},
       
  2001 			{
       
  2002 			// 0x35 - reserved for GSM/3G;
       
  2003 			RSat::KSmsRpError,
       
  2004 			RSat::KNoAdditionalInfo,
       
  2005 			ETrue,
       
  2006 			0,
       
  2007 			KErrCorrupt
       
  2008 			},
       
  2009 			{ 
       
  2010 			// 0x36 - Error, required values are missing;
       
  2011 			RSat::KErrorRequiredValuesMissing,
       
  2012 			RSat::KNoAdditionalInfo,
       
  2013 			ETrue,
       
  2014 			0,
       
  2015 			KErrNone
       
  2016 			},			
       
  2017 			{
       
  2018 			// 0x37 - reserved for GSM/3G;
       
  2019 			RSat::KUssdReturnError,
       
  2020 			RSat::KSatNetworkErrorInfo,
       
  2021 			EFalse,
       
  2022 			0,
       
  2023 			KErrCorrupt
       
  2024 			},
       
  2025 			{
       
  2026 			// 0x38 - MultipleCard commands error;
       
  2027 			RSat::KMultipleCardCmdsError,
       
  2028 			RSat::KMeProblem,
       
  2029 			EFalse,
       
  2030 			0,
       
  2031 			KErrCorrupt
       
  2032 			},
       
  2033 			{
       
  2034 			// 0x39 - Interaction with call control by NAA, permanent problem;
       
  2035 			RSat::KInteractionWithCCPermanentError,
       
  2036 			RSat::KNoAdditionalInfo,
       
  2037 			ETrue,
       
  2038 			0,
       
  2039 			KErrCorrupt
       
  2040 			},
       
  2041 			
       
  2042 			{
       
  2043 			// 0x3A - Bearer Independent Protocol error;
       
  2044 			RSat::KBearerIndepProtocolError,
       
  2045 			RSat::KMeProblem, 
       
  2046 			EFalse,
       
  2047 			RSat::KNoSpecificBIPError,
       
  2048 			KErrCorrupt
       
  2049 			},
       
  2050 			{
       
  2051 			// 0x3A without additional information (erroneous)
       
  2052 			RSat::KBearerIndepProtocolError,
       
  2053 			RSat::KMeProblem, 
       
  2054 			ETrue, // Intentional error
       
  2055 			0,
       
  2056 			KErrCorrupt
       
  2057 			},
       
  2058 			{
       
  2059 			// 0x3B - Access Technology unable to process command;
       
  2060 			RSat::KAccessTechUnableProcessCmd,
       
  2061 			RSat::KNoAdditionalInfo,
       
  2062 			ETrue,
       
  2063 			0,
       
  2064 			KErrCorrupt
       
  2065 			},
       
  2066 			{
       
  2067 			// 0x3C - Frames error;
       
  2068 			RSat::KFramesError,
       
  2069 			RSat::KMeProblem,
       
  2070 			EFalse,
       
  2071 			RSat::KNoSpecificCauseCanBeGiven,
       
  2072 			KErrCorrupt
       
  2073 			},
       
  2074 			{
       
  2075 			// 0x3D - MMS Error.
       
  2076 			RSat::KMMSError,
       
  2077 			RSat::KNoAdditionalInfo,
       
  2078 			ETrue,
       
  2079 			0,
       
  2080 			KErrCorrupt
       
  2081 			}
       
  2082 		};	
       
  2083 
       
  2084 	static const TUint8 events[] = {KEventUserActivity};
       
  2085 	
       
  2086 	const TInt KNumberOfResponsesToTest = sizeof(KResponsesToTest)/ sizeof(KResponsesToTest[0]);
       
  2087 	
       
  2088 	TRequestStatus requestStatus;
       
  2089 	// prepare TLV for
       
  2090 	TTlv eventTlv;	
       
  2091 	PrepareTlv( eventTlv, events, sizeof(events)/sizeof(TUint8));
       
  2092 	const TDesC8& tlvEnd = eventTlv.End();
       
  2093 	
       
  2094 	TBuf8<1> resultAddInfo;			
       
  2095 	RSat::TSetUpEventListV1 eventList;
       
  2096 	RSat::TSetUpEventListV1Pckg eventListPck(eventList);
       
  2097 	
       
  2098 		
       
  2099 
       
  2100 	//Prepare data for ExpectL needed by NotifySetUpEventListPCmd
       
  2101 	//and post that ExpectL
       
  2102 	PrepareMockLDataWithExpL(KSetUpEventList);						
       
  2103 	// Post Notify itself		
       
  2104 	iSat.NotifySetUpEventListPCmd(requestStatus, eventListPck);		
       
  2105 	// post Complete with KErrNone
       
  2106 	CompleteMockDispatchSatPcmdL(tlvEnd, KErrNone);		    
       
  2107 					    
       
  2108 	User::WaitForRequest(requestStatus);
       
  2109 	ASSERT_EQUALS(KErrNone, requestStatus.Int());				
       
  2110 	// ------------------------------------------------------------------------------------
       
  2111 	// Tell Mock to return KErrUnknown when dispatching forthcoming RSat::TerminalRsp()
       
  2112 	// something like  "Test A" of 001 test for TerminalResponse	
       
  2113 	//-------------------------------------------------------------------------------------
       
  2114 	PrepareTerminalResponseMockDataWithExpL(KPcmdNumber, RSat::KSuccess, KNullDesC8, KErrUnknown);	
       
  2115 	
       
  2116 	// call TerminalRsp
       
  2117 	RSat::TSetUpEventListRspV1 resp;
       
  2118 	RSat::TSetUpEventListRspV1Pckg respPckg(resp);		
       
  2119 	resp.SetPCmdNumber(KPcmdNumber);
       
  2120 	resp.iGeneralResult	= RSat::KSuccess;
       
  2121 	resp.iInfoType 		= RSat::KNoAdditionalInfo;	
       
  2122 	TerminalResponseL(respPckg, KErrUnknown);		
       
  2123 	AssertMockLtsyStatusL();
       
  2124 	
       
  2125 	// ---------------------------------------------------------------
       
  2126 	//Execute All cases for terminal response
       
  2127 	// ---------------------------------------------------------------
       
  2128 		
       
  2129 	for(TInt i = 0; i < KNumberOfResponsesToTest; i++)
       
  2130 		{	
       
  2131 		//Prepare data for ExpectL needed by NotifySetUpEventListPCmd
       
  2132 		//and post that ExpectL
       
  2133 		PrepareMockLDataWithExpL(KSetUpEventList);						
       
  2134 		// Post Notify itself		
       
  2135 		iSat.NotifySetUpEventListPCmd(requestStatus, eventListPck);		
       
  2136 		// post Complete with KErrNone
       
  2137 		CompleteMockDispatchSatPcmdL(tlvEnd, KErrNone);		    
       
  2138 						    
       
  2139 		User::WaitForRequest(requestStatus);
       
  2140 		ASSERT_EQUALS(KErrNone, requestStatus.Int());				
       
  2141 		
       
  2142 		// now test a "TERMINAL RESPONSE" specific to this loop 		
       
  2143 		resultAddInfo.Zero();				
       
  2144 		if ((	RSat::KNoAdditionalInfo	==	KResponsesToTest[i].iInfoType ||
       
  2145 				RSat::KMeProblem		==	KResponsesToTest[i].iInfoType	) && 
       
  2146 				!KResponsesToTest[i].iIntentionallyOmmitAdditionalInfo)
       
  2147 			{			
       
  2148 			resultAddInfo.Append(KResponsesToTest[i].iAdditionalInfo);
       
  2149 			}
       
  2150 					
       
  2151 		PrepareTerminalResponseMockDataWithExpL(KPcmdNumber,
       
  2152 												KResponsesToTest[i].iGeneralResult, 
       
  2153 												resultAddInfo);
       
  2154 		// call TerminalRsp
       
  2155 		RSat::TSetUpEventListRspV1 resp;
       
  2156 		RSat::TSetUpEventListRspV1Pckg respPckg(resp);
       
  2157 		resp.iGeneralResult = KResponsesToTest[i].iGeneralResult;
       
  2158 		resp.iInfoType 		= KResponsesToTest[i].iInfoType;
       
  2159 		if(!KResponsesToTest[i].iIntentionallyOmmitAdditionalInfo)
       
  2160 			{
       
  2161 			resp.iAdditionalInfo.Append(KResponsesToTest[i].iAdditionalInfo);
       
  2162 			}
       
  2163 		
       
  2164 		resp.SetPCmdNumber(KPcmdNumber);	
       
  2165 		TerminalResponseL(respPckg, KResponsesToTest[i].iExpectedResult);
       
  2166 		AssertMockLtsyStatusL();
       
  2167 			
       
  2168 		// ---ENVELOPE: EVENT DOWNLOAD---
       
  2169 		// There is No ENVELOPE sent in case of errors!					
       
  2170 		}
       
  2171 	
       
  2172 	}
       
  2173 
       
  2174