telephonyserverplugins/simatktsy/tests/src/ccsatlanguagenotificationfu.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 LanguageNotification in the SAT.
       
    20 */
       
    21 
       
    22 #include "ccsatlanguagenotificationfu.h"
       
    23 #include <cstktsy/bertlv_defs.h>
       
    24 #include <etel.h>
       
    25 #include <etelmm.h>
       
    26 #include <etelsat.h>
       
    27 #include <ctsy/serviceapi/gsmerror.h>
       
    28 #include <ctsy/mmtsy_names.h>
       
    29 #include <satcs.h>                 
       
    30 #include <ctsy/ltsy/sat_defs.h>
       
    31 #include <cstktsy/ttlv.h>
       
    32 
       
    33 #include <ctsy/ltsy/mltsydispatchsatinterface.h>
       
    34 #include <ctsy/ltsy/mltsydispatchphoneinterface.h> 
       
    35 #include <test/mockltsyindicatorids.h>
       
    36 #include <test/tmockltsydata.h>
       
    37 
       
    38 
       
    39 const TUint8 KCmdId = 1;
       
    40 
       
    41 // command specifier for language notification
       
    42 const TUint8 KSpecific = 0x01;
       
    43 const TUint8 KNonSpecific = 0x00;
       
    44 
       
    45 _LIT8(KSpanishLang, "se");
       
    46 
       
    47 
       
    48 CTestSuite* CCSatLanguageNotificationFU::CreateSuiteL(const TDesC& aName)
       
    49 	{
       
    50 	SUB_SUITE;
       
    51 
       
    52 	ADD_TEST_STEP_ISO_CPP(CCSatLanguageNotificationFU, TestNotifyLanguageNotificationPCmd0001L);
       
    53 	ADD_TEST_STEP_ISO_CPP(CCSatLanguageNotificationFU, TestNotifyLanguageNotificationPCmd0002L);
       
    54 	ADD_TEST_STEP_ISO_CPP(CCSatLanguageNotificationFU, TestNotifyLanguageNotificationPCmd0004L);
       
    55 
       
    56 	END_SUITE;
       
    57 	}
       
    58 
       
    59 
       
    60 //
       
    61 // Actual test cases
       
    62 //
       
    63 
       
    64 
       
    65 /**
       
    66 @SYMTestCaseID BA-CSAT-LN-SNLNPC-0001
       
    67 @SYMPREQ 1780
       
    68 @SYMComponent  telephony_csat
       
    69 @SYMTestCaseDesc Test support in CSAT for RSat::NotifyLanguageNotificationPCmd
       
    70 @SYMTestPriority High
       
    71 @SYMTestActions Invokes RSat::NotifyLanguageNotificationPCmd
       
    72 @SYMTestExpectedResults Pass
       
    73 @SYMTestType CT
       
    74 */
       
    75 void CCSatLanguageNotificationFU::TestNotifyLanguageNotificationPCmd0001L()
       
    76 	{
       
    77 	OpenEtelServerL(EUseExtendedError);
       
    78 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
    79 	OpenPhoneL();
       
    80 	OpenSatL();	
       
    81 
       
    82 	TTlv tlv;	
       
    83 	
       
    84 	TRequestStatus notifyStatus;
       
    85 	RSat::TLanguageNotificationV2 lang;
       
    86 	RSat::TLanguageNotificationV2Pckg langPck(lang);
       
    87 	
       
    88 	RBuf8 data;
       
    89 	CleanupClosePushL(data);
       
    90 	
       
    91  	//-------------------------------------------------------------------------
       
    92 	// TEST C: Successful completion request of
       
    93 	// RSat::NotifyLanguageNotificationPCmd in case of NonSpecific notification 
       
    94  	//-------------------------------------------------------------------------
       
    95 	
       
    96 	PrepareTlv( tlv, KNonSpecific);
       
    97 	TDesC8* tlvDscPtr = &const_cast<TDesC8&>(tlv.End());
       
    98 	TMockLtsyData1<TDesC8*> tlvDscPack(tlvDscPtr);
       
    99 
       
   100 	PrepareDispatchL();
       
   101 
       
   102 	iSat.NotifyLanguageNotificationPCmd(notifyStatus, langPck);
       
   103 
       
   104 	CompleteDispatchL( *tlvDscPtr);
       
   105 	
       
   106 	User::WaitForRequest(notifyStatus);
       
   107 	ASSERT_EQUALS(KErrNone, notifyStatus.Int());	
       
   108 	ASSERT_EQUALS(RSat::ENonSpecificLangNotification, lang.iNotificationType);
       
   109 	ASSERT_EQUALS(KCmdId, lang.PCmdNumber());
       
   110 	
       
   111 	//terminal response	
       
   112 	RSat::TLanguageNotificationRspV2 langRsp;
       
   113 	RSat::TLanguageNotificationRspV2Pckg langRspPckg(langRsp);
       
   114 	langRsp.SetPCmdNumber(KCmdId);
       
   115 	langRsp.iGeneralResult = RSat::KSuccess;
       
   116 	langRsp.iInfoType = RSat::KNoAdditionalInfo;
       
   117 	langRsp.iAdditionalInfo = KNullDesC;
       
   118 	
       
   119 	GenerateTerminalResponseL(KCmdId,	KLanguageNotification,	KNonSpecific,
       
   120 			RSat::ELanguageNotification, langRspPckg,	langRsp.iAdditionalInfo, 
       
   121 			langRsp.iGeneralResult);
       
   122 	
       
   123 	AssertMockLtsyStatusL();
       
   124 
       
   125  	//-------------------------------------------------------------------------
       
   126 	// TEST E: Unsolicited completion of RSat::NotifyLanguageNotificationPCmd
       
   127 	// from LTSY.
       
   128  	//-------------------------------------------------------------------------
       
   129 
       
   130 	PrepareTlv( tlv, KSpecific, KSpanishLang);	
       
   131 	tlv.End();
       
   132 	
       
   133 	TRequestStatus mocklStatus;
       
   134 	iMockLTSY.NotifyTerminated(mocklStatus);	    
       
   135 	tlvDscPack.SerialiseL(data);
       
   136 	iMockLTSY.CompleteL(KMockLtsyDispatchSatPcmdIndId, KErrNone, data);
       
   137 	
       
   138 	langRsp.iAdditionalInfo.Zero();
       
   139 	langRsp.iAdditionalInfo.Append(RSat::KNoSpecificMeProblem);;
       
   140 
       
   141 	PrepareTerminalResponseMockDataL( KCmdId, KLanguageNotification, KSpecific,
       
   142 			langRsp.iAdditionalInfo, RSat::KMeUnableToProcessCmd, KNullDesC8);
       
   143 
       
   144 	User::WaitForRequest(mocklStatus);
       
   145 	AssertMockLtsyStatusL();
       
   146 	ASSERT_EQUALS(KErrNone, mocklStatus.Int());
       
   147 		
       
   148  	//-------------------------------------------------------------------------
       
   149 	// TEST C2: Successful completion request of
       
   150 	// RSat::NotifyLanguageNotificationPCmd in case of Specific notification 
       
   151  	//-------------------------------------------------------------------------
       
   152 		
       
   153 	PrepareDispatchL();
       
   154 
       
   155 	iSat.NotifyLanguageNotificationPCmd(notifyStatus, langPck);
       
   156 
       
   157 	CompleteDispatchL( *tlvDscPtr);
       
   158 	
       
   159 	User::WaitForRequest(notifyStatus);
       
   160 	ASSERT_EQUALS(KErrNone, notifyStatus.Int());	
       
   161 	ASSERT_EQUALS(RSat::ESpecificLangNotification, lang.iNotificationType);
       
   162 	ASSERT_EQUALS(KCmdId, lang.PCmdNumber());
       
   163 	TUint16 tmpLang;
       
   164 	TSatUtility::CopyTwo8toOne16LE( KSpanishLang, tmpLang, 0 );
       
   165 	ASSERT_EQUALS(tmpLang, lang.iLanguage);
       
   166 	
       
   167 	//terminal response	
       
   168 	langRsp.iGeneralResult = RSat::KSuccess;
       
   169 	langRsp.iInfoType = RSat::KNoAdditionalInfo;
       
   170 	langRsp.iAdditionalInfo = KNullDesC;
       
   171 	
       
   172 	GenerateTerminalResponseL(KCmdId,	KLanguageNotification,	KSpecific,
       
   173 			RSat::ELanguageNotification, langRspPckg,	langRsp.iAdditionalInfo, 
       
   174 			langRsp.iGeneralResult);
       
   175 	
       
   176 	AssertMockLtsyStatusL();
       
   177 		
       
   178 	//-------------------------------------------------------------------------
       
   179 	// TEST B: failure on completion of pending request from LTSY->CTSY
       
   180  	//-------------------------------------------------------------------------
       
   181 
       
   182 	PrepareDispatchL();
       
   183 
       
   184 	iSat.NotifyLanguageNotificationPCmd(notifyStatus, langPck);
       
   185 
       
   186 	CompleteDispatchL( *tlvDscPtr, KErrUnknown );
       
   187 	
       
   188 	User::WaitForRequest(notifyStatus);
       
   189 	ASSERT_EQUALS(KErrUnknown, notifyStatus.Int());	
       
   190 
       
   191 	AssertMockLtsyStatusL();
       
   192 	CleanupStack::PopAndDestroy(2, this); // data, this
       
   193 
       
   194 	}
       
   195 
       
   196 
       
   197 /**
       
   198 @SYMTestCaseID BA-CSAT-LN-SNLNPC-0002
       
   199 @SYMPREQ 1780
       
   200 @SYMComponent  telephony_csat
       
   201 @SYMTestCaseDesc Test support in CSAT for cancelling of RSat::NotifyLanguageNotificationPCmd
       
   202 @SYMTestPriority High
       
   203 @SYMTestActions Invokes cancelling of RSat::NotifyLanguageNotificationPCmd
       
   204 @SYMTestExpectedResults Pass
       
   205 @SYMTestType CT
       
   206 */
       
   207 void CCSatLanguageNotificationFU::TestNotifyLanguageNotificationPCmd0002L()
       
   208 	{
       
   209 	OpenEtelServerL(EUseExtendedError);
       
   210 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   211 	OpenPhoneL();
       
   212 	OpenSatL();	
       
   213 
       
   214  	//-------------------------------------------------------------------------
       
   215 	// Test cancelling of RSat::NotifyLanguageNotificationPCmd
       
   216  	//-------------------------------------------------------------------------
       
   217 	TRequestStatus notifyStatus;
       
   218 	RSat::TLanguageNotificationV2 lang;
       
   219 	RSat::TLanguageNotificationV2Pckg langPck(lang);
       
   220 
       
   221 	PrepareDispatchL();
       
   222 
       
   223 	iSat.NotifyLanguageNotificationPCmd(notifyStatus, langPck);
       
   224 	
       
   225 	iSat.CancelAsyncRequest(ESatNotifyLanguageNotificationPCmd);
       
   226 	
       
   227 	User::WaitForRequest(notifyStatus);
       
   228 	ASSERT_EQUALS( KErrCancel, notifyStatus.Int());
       
   229 	
       
   230 	CleanupStack::PopAndDestroy(1, this); 
       
   231 	}
       
   232 
       
   233 
       
   234 /**
       
   235 @SYMTestCaseID BA-CSAT-LN-SNLNPC-0004
       
   236 @SYMComponent  telephony_csat
       
   237 @SYMPREQ 1780
       
   238 @SYMTestCaseDesc Test support in CSAT for multiple client requests to RSat::NotifyLanguageNotificationPCmd
       
   239 @SYMTestPriority High
       
   240 @SYMTestActions Invokes multiple client requests to RSat::NotifyLanguageNotificationPCmd
       
   241 @SYMTestExpectedResults Pass
       
   242 @SYMTestType CT
       
   243 */
       
   244 void CCSatLanguageNotificationFU::TestNotifyLanguageNotificationPCmd0004L()
       
   245 	{
       
   246 	OpenEtelServerL(EUseExtendedError);
       
   247 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   248 	OpenPhoneL();
       
   249 	OpenSatL();
       
   250 
       
   251 	// Open second client
       
   252 	RTelServer telServer2;
       
   253 	TInt ret = telServer2.Connect();
       
   254 	ASSERT_EQUALS(KErrNone, ret);
       
   255 	CleanupClosePushL(telServer2);
       
   256 
       
   257 	RMobilePhone phone2;
       
   258 	ret = phone2.Open(telServer2,KMmTsyPhoneName);
       
   259 	ASSERT_EQUALS(KErrNone, ret);
       
   260 	CleanupClosePushL(phone2);
       
   261 	
       
   262 	RSat sat2;	
       
   263 	ret = sat2.Open(phone2);
       
   264 	ASSERT_EQUALS(KErrNone, ret);
       
   265 	CleanupClosePushL(sat2);
       
   266 
       
   267 	//-------------------------------------------------------------------------
       
   268 	// Test A: Test multiple clients requesting RSat::NotifyLanguageNotificationPCmd
       
   269 	// when they both pass the same T-class version
       
   270  	//-------------------------------------------------------------------------
       
   271 
       
   272 	TTlv tlv;	
       
   273 	
       
   274 	PrepareTlv( tlv, KNonSpecific);
       
   275 	TDesC8* tlvDscPtr = &const_cast<TDesC8&>(tlv.End());
       
   276 	TMockLtsyData1<TDesC8*> tlvDscPack(tlvDscPtr);
       
   277 
       
   278 	PrepareDispatchL();
       
   279 
       
   280 	TRequestStatus notifyStatus;
       
   281 	TRequestStatus notifyStatus2;
       
   282 	RSat::TLanguageNotificationV2 lang;
       
   283 	RSat::TLanguageNotificationV2 lang2;
       
   284 	RSat::TLanguageNotificationV2Pckg langPck(lang);
       
   285 	RSat::TLanguageNotificationV2Pckg langPck2(lang2);
       
   286 	
       
   287 	iSat.NotifyLanguageNotificationPCmd(notifyStatus, langPck);
       
   288 	sat2.NotifyLanguageNotificationPCmd(notifyStatus2, langPck2);
       
   289 
       
   290 	CompleteDispatchL( *tlvDscPtr);
       
   291 	
       
   292 	User::WaitForRequest(notifyStatus);
       
   293 	ASSERT_EQUALS(KErrNone, notifyStatus.Int());	
       
   294 	ASSERT_EQUALS(RSat::ENonSpecificLangNotification, lang.iNotificationType);
       
   295 	ASSERT_EQUALS(KCmdId, lang.PCmdNumber());
       
   296 
       
   297 	User::WaitForRequest(notifyStatus2);
       
   298 	ASSERT_EQUALS(KErrNone, notifyStatus2.Int());	
       
   299 	ASSERT_EQUALS(RSat::ENonSpecificLangNotification, lang2.iNotificationType);
       
   300 	ASSERT_EQUALS(KCmdId, lang2.PCmdNumber());	
       
   301 
       
   302 	CleanupStack::PopAndDestroy(4, this); //sat2 phone2 telServer2 this
       
   303 	}
       
   304 
       
   305 
       
   306 /**
       
   307 * prepare tlv buffer for refresh proactive command 
       
   308 * @param aTlv - tlv buffer to prepare
       
   309 * @param aCmdQualifier - type of refresh command
       
   310 * @param aLang - two-byte language code
       
   311 */   	
       
   312 void CCSatLanguageNotificationFU::PrepareTlv(TTlv& aTlv, TUint8 aCmdQualifier, const TDesC8& aLang) 
       
   313 	{
       
   314 	aTlv.Begin(KBerTlvProactiveSimCommandTag);
       
   315 	aTlv.AddTag(KTlvCommandDetailsTag);
       
   316 	aTlv.AddByte(KCmdId);//ETLV_CommandNumber
       
   317 	aTlv.AddByte(KLanguageNotification); //ETLV_TypeOfCommand
       
   318 	aTlv.AddByte(aCmdQualifier); //ETLV_CommandQualifier
       
   319 
       
   320 	aTlv.AddTag(KTlvDeviceIdentityTag); 
       
   321 	aTlv.AddByte(KSim); //ETLV_SourceDeviceIdentity
       
   322 	aTlv.AddByte(KMe); //ETLV_DestinationDeviceIdentity
       
   323 	
       
   324 	if(0 < aLang.Length())
       
   325 		{
       
   326 		aTlv.AddTag(KTlvLanguageTag); 
       
   327 		aTlv.AddData(aLang);
       
   328 		}
       
   329 	}
       
   330 
       
   331 /**
       
   332 * prepare mock complete for processing of proactive command
       
   333 * @param aTlvDsc - tlv buffer to send
       
   334 * @param aRes - result for request completion
       
   335 */   	
       
   336 void CCSatLanguageNotificationFU::CompleteDispatchL(const TDesC8& aTlvDsc, TInt aRes)
       
   337 	{
       
   338 	RBuf8 data;
       
   339 	CleanupClosePushL(data);
       
   340 	
       
   341 	TDesC8* tlvDscPtr = const_cast<TDesC8*>(&aTlvDsc);
       
   342 	TMockLtsyData1<TDesC8*> tlvDscPack(tlvDscPtr);
       
   343 
       
   344 	tlvDscPack.SerialiseL(data);
       
   345 	iMockLTSY.CompleteL(KMockLtsyDispatchSatPcmdIndId, aRes, data);
       
   346 
       
   347 	CleanupStack::PopAndDestroy(1); 
       
   348 	}
       
   349 
       
   350 /**
       
   351 * prepare mock for dispatch of sat notification  
       
   352 */   	
       
   353 void CCSatLanguageNotificationFU::PrepareDispatchL()
       
   354 	{
       
   355 	RBuf8 data;
       
   356 	CleanupClosePushL(data);
       
   357 
       
   358 	TUint8 pcmdCode = KLanguageNotification;
       
   359 	TMockLtsyData1<TUint8> expLtsyData(pcmdCode);
       
   360 	expLtsyData.SerialiseL(data);
       
   361 	
       
   362 	iMockLTSY.ExpectL(MLtsyDispatchSatPCmdNotification::KLtsyDispatchSatPCmdNotificationApiId,data);
       
   363  	
       
   364 	CleanupStack::PopAndDestroy(1); 
       
   365 	}
       
   366