telephonyserverplugins/ctsydispatchlayer/test/dispatchertests/dispatchsrc/cctsysecurityfunegative.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 CallControl in the Common TSY.
       
    20 */
       
    21 
       
    22 #include <etel.h>
       
    23 #include <etelmm.h>
       
    24 #include <et_clsvr.h>
       
    25 #include <ctsy/mmtsy_names.h>
       
    26 #include <ctsy/serviceapi/mmtsy_ipcdefs.h>
       
    27 #include <test/tmockltsydata.h>
       
    28 #include <ctsy/serviceapi/gsmerror.h>
       
    29 
       
    30 #include <ctsy/ltsy/mltsydispatchphoneinterface.h>
       
    31 #include <ctsy/ltsy/mltsydispatchsiminterface.h>
       
    32 #include <ctsy/ltsy/mltsydispatchsecurityinterface.h>
       
    33 #include <ctsy/ltsy/mltsydispatchcallcontrolinterface.h>
       
    34 #include "mockltsyindicatorids.h"
       
    35 #include "config.h"
       
    36 
       
    37 #include "cctsysecurityfunegative.h"
       
    38 
       
    39 CTestSuite* CCTsySecurityFUNegative::CreateSuiteL(const TDesC& aName)
       
    40 	{
       
    41 	SUB_SUITE;
       
    42   	ADD_TEST_STEP_ISO_CPP(CCTsySecurityFUNegative, TestUnit0001L);
       
    43 	ADD_TEST_STEP_ISO_CPP(CCTsySecurityFUNegative, TestUnit0002L);
       
    44 	ADD_TEST_STEP_ISO_CPP(CCTsySecurityFUNegative, TestUnit0003L);
       
    45 	ADD_TEST_STEP_ISO_CPP(CCTsySecurityFUNegative, TestUnit0004L);	
       
    46 
       
    47 	ADD_TEST_STEP_ISO_CPP(CCTsySecurityFUNegative, TestUnit0006L);
       
    48 
       
    49 	ADD_TEST_STEP_ISO_CPP(CCTsySecurityFUNegative, TestUnit0008L);
       
    50 	ADD_TEST_STEP_ISO_CPP(CCTsySecurityFUNegative, TestUnit0009L);
       
    51 	ADD_TEST_STEP_ISO_CPP(CCTsySecurityFUNegative, TestUnit0010L);
       
    52 	ADD_TEST_STEP_ISO_CPP(CCTsySecurityFUNegative, TestUnit0011L);
       
    53 	ADD_TEST_STEP_ISO_CPP(CCTsySecurityFUNegative, TestUnit0012L);
       
    54 	END_SUITE;
       
    55 	}
       
    56 
       
    57 //
       
    58 // 'Negative' unit tests
       
    59 //
       
    60 
       
    61 /**
       
    62 @SYMTestCaseID BA-CTSYD-DIS-SECURITY-NEGATIVE-UN0001
       
    63 @SYMComponent telephony_ctsy
       
    64 @SYMTestCaseDesc Test returned value if EMobilePhoneGetSecurityCodeInfo is not supported by LTSY
       
    65 @SYMTestPriority High
       
    66 @SYMTestActions Invokes RMobilePhone::GetSecurityCodeInfo()
       
    67 @SYMTestExpectedResults Pass
       
    68 @SYMTestType UT
       
    69 */
       
    70 void CCTsySecurityFUNegative::TestUnit0001L()
       
    71 	{
       
    72 	TConfig config;
       
    73 	config.SetSupportedValue(MLtsyDispatchSecurityGetSecurityCodeInfo::KLtsyDispatchSecurityGetSecurityCodeInfoApiId, EFalse);
       
    74 	
       
    75 	OpenEtelServerL(EUseExtendedError);
       
    76 	CleanupStack::PushL(TCleanupItem(Cleanup, this));
       
    77 	OpenPhoneL();
       
    78 	
       
    79     TRequestStatus requestStatus;
       
    80 	RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeV5;
       
    81 	TPckg<RMobilePhone::TMobilePhoneSecurityCodeInfoV5> pckgData(codeV5);
       
    82 	RMobilePhone::TMobilePhoneSecurityCode secCode = RMobilePhone::ESecurityCodePhonePassword;
       
    83 	
       
    84 	iPhone.GetSecurityCodeInfo(requestStatus, secCode, pckgData);
       
    85     User::WaitForRequest(requestStatus);
       
    86     ASSERT_EQUALS(KErrNotSupported, requestStatus.Int());   
       
    87 	
       
    88     AssertMockLtsyStatusL();
       
    89 	config.Reset();
       
    90 	CleanupStack::PopAndDestroy(this); // this
       
    91 	}
       
    92 
       
    93 /**
       
    94 @SYMTestCaseID BA-CTSYD-DIS-SECURITY-NEGATIVE-UN0002
       
    95 @SYMComponent telephony_ctsy
       
    96 @SYMTestCaseDesc Test returned value if EMobilePhoneGetLockInfo is not supported by LTSY
       
    97 @SYMTestPriority High
       
    98 @SYMTestActions Invokes RMobilePhone::GetLockInfo()
       
    99 @SYMTestExpectedResults Pass
       
   100 @SYMTestType UT
       
   101 */
       
   102 void CCTsySecurityFUNegative::TestUnit0002L()
       
   103 	{
       
   104 	TConfig config;
       
   105 	config.SetSupportedValue(MLtsyDispatchSecurityGetLockInfo::KLtsyDispatchSecurityGetLockInfoApiId, EFalse);
       
   106 	
       
   107 	OpenEtelServerL(EUseExtendedError);
       
   108 	CleanupStack::PushL(TCleanupItem(Cleanup, this));
       
   109 	OpenPhoneL();
       
   110 	
       
   111     TRequestStatus requestStatus;
       
   112 	RMobilePhone::TMobilePhoneLock currentLock = RMobilePhone::ELockICC;
       
   113 	RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
       
   114 	RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPckg(lockInfo);
       
   115 	
       
   116 	iPhone.GetLockInfo(requestStatus, currentLock, lockInfoPckg);
       
   117     User::WaitForRequest(requestStatus);
       
   118     ASSERT_EQUALS(KErrNotSupported, requestStatus.Int());   
       
   119 	
       
   120     AssertMockLtsyStatusL();
       
   121 	config.Reset();
       
   122 	CleanupStack::PopAndDestroy(this); // this
       
   123 	}
       
   124 
       
   125 /**
       
   126 @SYMTestCaseID BA-CTSYD-DIS-SECURITY-NEGATIVE-UN0003
       
   127 @SYMComponent telephony_ctsy
       
   128 @SYMTestCaseDesc Test returned value if EMobilePhoneAbortSecurityCode is not supported by LTSY
       
   129 @SYMTestPriority High
       
   130 @SYMTestActions Invokes RMobilePhone::AbortSecurityCode()
       
   131 @SYMTestExpectedResults Pass
       
   132 @SYMTestType UT
       
   133 */
       
   134 void CCTsySecurityFUNegative::TestUnit0003L()
       
   135 	{
       
   136 	TConfig config;
       
   137 	config.SetSupportedValue(MLtsyDispatchSecurityAbortSecurityCode::KLtsyDispatchSecurityAbortSecurityCodeApiId, EFalse);
       
   138 	
       
   139 	OpenEtelServerL(EUseExtendedError);
       
   140 	CleanupStack::PushL(TCleanupItem(Cleanup,this));
       
   141 	OpenPhoneL();
       
   142 	
       
   143 	RMobilePhone::TMobilePhoneSecurityCode secCode = RMobilePhone::ESecurityCodePin2;
       
   144 	
       
   145 	TInt err = iPhone.AbortSecurityCode(secCode);
       
   146     ASSERT_EQUALS(KErrNotSupported, err);   
       
   147 	
       
   148     AssertMockLtsyStatusL();
       
   149 	config.Reset();
       
   150 	CleanupStack::PopAndDestroy(this); // this
       
   151 	}
       
   152 
       
   153 /**
       
   154 @SYMTestCaseID BA-CTSYD-DIS-SECURITY-NEGATIVE-UN0004
       
   155 @SYMComponent telephony_ctsy
       
   156 @SYMTestCaseDesc Test returned value if EMmTsySecurityGetSimActivePinStateIPC is not supported by LTSY
       
   157 @SYMTestPriority High
       
   158 @SYMTestActions Invokes RMmCustomAPI::GetActivePin()
       
   159 @SYMTestExpectedResults Pass
       
   160 @SYMTestType UT
       
   161 */
       
   162 void CCTsySecurityFUNegative::TestUnit0004L()
       
   163 	{
       
   164 	TConfig config;
       
   165 	config.SetSupportedValue(MLtsyDispatchSecurityGetCurrentActivePin::KLtsyDispatchSecurityGetCurrentActivePinApiId, EFalse);
       
   166 	
       
   167 	OpenEtelServerL(EUseExtendedError);
       
   168 	CleanupStack::PushL(TCleanupItem(Cleanup, this));
       
   169 	OpenPhoneL();
       
   170 
       
   171 	RMmCustomAPI customApi;
       
   172 	OpenCustomApiLC(customApi);
       
   173 	
       
   174 	// investigate further. KErrNotSupported returned somewhere?
       
   175 	RMobilePhone::TMobilePhoneSecurityCode code;
       
   176 	customApi.GetActivePin(code);
       
   177 	
       
   178     AssertMockLtsyStatusL();
       
   179 	config.Reset();
       
   180 	CleanupStack::PopAndDestroy(2, this); // customAPI, this
       
   181 	}
       
   182 
       
   183 /**
       
   184 @SYMTestCaseID BA-CTSYD-DIS-SECURITY-NEGATIVE-UN0006
       
   185 @SYMComponent telephony_ctsy
       
   186 @SYMTestCaseDesc Test returned value if EMobilePhoneVerifySecurityCode is not supported by LTSY
       
   187 @SYMTestPriority High
       
   188 @SYMTestActions Invokes RMobilePhone::VerifySecurityCode()
       
   189 @SYMTestExpectedResults Pass
       
   190 @SYMTestType UT
       
   191 */
       
   192 void CCTsySecurityFUNegative::TestUnit0006L()
       
   193 	{
       
   194 	TConfig config;
       
   195 	config.SetSupportedValue(MLtsyDispatchSecurityVerifySecurityCode::KLtsyDispatchSecurityVerifySecurityCodeApiId, EFalse);
       
   196 	
       
   197 	OpenEtelServerL(EUseExtendedError);
       
   198 	CleanupStack::PushL(TCleanupItem(Cleanup, this));
       
   199 	OpenPhoneL();
       
   200 	
       
   201     TRequestStatus requestStatus;
       
   202 	RMobilePhone::TMobilePhoneSecurityCode secCode = RMobilePhone::ESecurityCodePin2;
       
   203 	_LIT(KPwd,"pwd");
       
   204 	_LIT(KUnblockPwd, "unblockPwd");
       
   205 	RMobilePhone::TMobilePassword pwd;
       
   206 	RMobilePhone::TMobilePassword unblockPwd;
       
   207 	pwd.Copy(KPwd);
       
   208 	unblockPwd.Copy(KUnblockPwd);
       
   209 	
       
   210 	iPhone.VerifySecurityCode(requestStatus, secCode, pwd, unblockPwd);
       
   211 	User::WaitForRequest(requestStatus);
       
   212     ASSERT_EQUALS(KErrNotSupported, requestStatus.Int());   
       
   213 	
       
   214     AssertMockLtsyStatusL();
       
   215 	config.Reset();
       
   216 	CleanupStack::PopAndDestroy(this); // this
       
   217 	}
       
   218 
       
   219 /**
       
   220 @SYMTestCaseID BA-CTSYD-DIS-SECURITY-NEGATIVE-UN0008
       
   221 @SYMComponent telephony_ctsy
       
   222 @SYMTestCaseDesc Test returned value if ECustomCheckSecurityCodeIPC is not supported by LTSY
       
   223 @SYMTestPriority High
       
   224 @SYMTestActions Invokes RMmCustomAPI::CheckSecurityCode()
       
   225 @SYMTestExpectedResults Pass
       
   226 @SYMTestType UT
       
   227 */
       
   228 void CCTsySecurityFUNegative::TestUnit0008L()
       
   229 	{
       
   230 	TConfig config;
       
   231 	config.SetSupportedValue(MLtsyDispatchSecurityCheckSecurityCode::KLtsyDispatchSecurityCheckSecurityCodeApiId, EFalse);
       
   232 	
       
   233 	OpenEtelServerL(EUseExtendedError);
       
   234 	CleanupStack::PushL(TCleanupItem(Cleanup, this));
       
   235 	OpenPhoneL();
       
   236 	
       
   237 	TRequestStatus requestStatus;	
       
   238 	RMmCustomAPI customApi;
       
   239 	OpenCustomApiLC(customApi);
       
   240 
       
   241     RMmCustomAPI::TSecurityCodeType type(RMmCustomAPI::ESecurityCodePin1);
       
   242     
       
   243     customApi.CheckSecurityCode(requestStatus, type);
       
   244 	User::WaitForRequest(requestStatus);
       
   245 	ASSERT_EQUALS(KErrNotSupported, requestStatus.Int());
       
   246 	
       
   247 	AssertMockLtsyStatusL();
       
   248 	config.Reset();
       
   249 	CleanupStack::PopAndDestroy(2, this); // customApi, this
       
   250 	}
       
   251 
       
   252 /**
       
   253 @SYMTestCaseID BA-CTSYD-DIS-SECURITY-NEGATIVE-UN0009
       
   254 @SYMComponent telephony_ctsy
       
   255 @SYMTestCaseDesc Test returned value if ECustomDisablePhoneLockIPC is not supported by LTSY
       
   256 @SYMTestPriority High
       
   257 @SYMTestActions Invokes RMmCustomAPI::DisablePhoneLock()
       
   258 @SYMTestExpectedResults Pass
       
   259 @SYMTestType UT
       
   260 */
       
   261 void CCTsySecurityFUNegative::TestUnit0009L()
       
   262 	{
       
   263 	TConfig config;
       
   264 	config.SetSupportedValue(MLtsyDispatchSecurityDisablePhoneLock::KLtsyDispatchSecurityDisablePhoneLockApiId, EFalse);
       
   265 	
       
   266 	OpenEtelServerL(EUseExtendedError);
       
   267 	CleanupStack::PushL(TCleanupItem(Cleanup, this));
       
   268 	OpenPhoneL();
       
   269 	
       
   270 	TRequestStatus requestStatus;	
       
   271 	RMmCustomAPI customApi;
       
   272 	OpenCustomApiLC(customApi);
       
   273 
       
   274 	_LIT(KPassword, "password");
       
   275     RMobilePhone::TMobilePassword pswd(KPassword);
       
   276     
       
   277     customApi.DisablePhoneLock(requestStatus, pswd);
       
   278 	User::WaitForRequest(requestStatus);
       
   279 	ASSERT_EQUALS(requestStatus.Int(), KErrNotSupported);
       
   280 	
       
   281 	AssertMockLtsyStatusL();
       
   282 	config.Reset();
       
   283 	CleanupStack::PopAndDestroy(2, this); // customApi, this
       
   284 	}
       
   285 
       
   286 /**
       
   287 @SYMTestCaseID BA-CTSYD-DIS-SECURITY-NEGATIVE-UN0010
       
   288 @SYMComponent telephony_ctsy
       
   289 @SYMTestCaseDesc Test returned value if ECustomGetCipheringInfoIPC is not supported by LTSY
       
   290 @SYMTestPriority High
       
   291 @SYMTestActions Invokes RMmCustomAPI::GetCipheringInfo()
       
   292 @SYMTestExpectedResults Pass
       
   293 @SYMTestType UT
       
   294 */
       
   295 void CCTsySecurityFUNegative::TestUnit0010L()
       
   296 	{
       
   297 	TConfig config;
       
   298 	config.SetSupportedValue(MLtsyDispatchSecurityGetCipheringInfo::KLtsyDispatchSecurityGetCipheringInfoApiId, EFalse);
       
   299 	
       
   300 	OpenEtelServerL(EUseExtendedError);
       
   301 	CleanupStack::PushL(TCleanupItem(Cleanup, this));
       
   302 	OpenPhoneL();
       
   303 	
       
   304 	RMmCustomAPI customApi;
       
   305 	OpenCustomApiLC(customApi);
       
   306 	
       
   307 	TRequestStatus requestStatus;	
       
   308 	RMmCustomAPI::TCipheringInfo info;
       
   309     
       
   310 	customApi.GetCipheringInfo(requestStatus, info);
       
   311 	User::WaitForRequest(requestStatus);
       
   312 	ASSERT_EQUALS(requestStatus.Int(), KErrNotSupported);
       
   313 	
       
   314 	AssertMockLtsyStatusL();
       
   315 	config.Reset();
       
   316 	CleanupStack::PopAndDestroy(2, this); // customApi, this
       
   317 	}
       
   318 
       
   319 /**
       
   320 @SYMTestCaseID BA-CTSYD-DIS-SECURITY-NEGATIVE-UN0011
       
   321 @SYMComponent telephony_ctsy
       
   322 @SYMTestCaseDesc Test returned value if ECustomIsBlockedIPC is not supported by LTSY
       
   323 @SYMTestPriority High
       
   324 @SYMTestActions Invokes RMmCustomAPI::IsBlocked()
       
   325 @SYMTestExpectedResults Pass
       
   326 @SYMTestType UT
       
   327 */
       
   328 void CCTsySecurityFUNegative::TestUnit0011L()
       
   329 	{
       
   330 	TConfig config;
       
   331 	config.SetSupportedValue(MLtsyDispatchSecurityIsSecurityCodeBlocked::KLtsyDispatchSecurityIsSecurityCodeBlockedApiId, EFalse);
       
   332 	
       
   333 	OpenEtelServerL(EUseExtendedError);
       
   334 	CleanupStack::PushL(TCleanupItem(Cleanup, this));
       
   335 	OpenPhoneL();
       
   336 
       
   337 	RMmCustomAPI customApi;
       
   338 	OpenCustomApiLC(customApi);
       
   339 	
       
   340 	TRequestStatus requestStatus;	
       
   341     RMmCustomAPI::TSecurityCodeType type(RMmCustomAPI::ESecurityCodePin1);
       
   342 	TBool result;
       
   343   
       
   344 	TInt err = customApi.IsBlocked(type, result);
       
   345 	ASSERT_EQUALS(KErrNotSupported, err);
       
   346 	
       
   347 	AssertMockLtsyStatusL();
       
   348 	config.Reset();
       
   349 	CleanupStack::PopAndDestroy(2, this); // customApi, this
       
   350 	}
       
   351 
       
   352 /**
       
   353 @SYMTestCaseID BA-CTSYD-DIS-SECURITY-NEGATIVE-UN0012
       
   354 @SYMComponent telephony_ctsy
       
   355 @SYMTestCaseDesc Test returned value if ECustomCheckSecurityCodeCancelIPC is not supported by LTSY
       
   356 @SYMTestPriority High
       
   357 @SYMTestActions Invokes RMmCustomAPI::CheckSecurityCode()
       
   358 @SYMTestExpectedResults Pass
       
   359 @SYMTestType UT
       
   360 */
       
   361 void CCTsySecurityFUNegative::TestUnit0012L()
       
   362 	{
       
   363 	TConfig config;
       
   364 	config.SetSupportedValue(MLtsyDispatchSecurityCheckSecurityCodeCancel::KLtsyDispatchSecurityCheckSecurityCodeCancelApiId, EFalse);
       
   365 	
       
   366 	OpenEtelServerL(EUseExtendedError);
       
   367 	CleanupStack::PushL(TCleanupItem(Cleanup, this));
       
   368 	OpenPhoneL();
       
   369 
       
   370 	RMmCustomAPI customApi;
       
   371 	OpenCustomApiLC(customApi);
       
   372 
       
   373 	TRequestStatus mockLtsyStatus;
       
   374 	iMockLTSY.NotifyTerminated(mockLtsyStatus);
       
   375 
       
   376 	RBuf8 data;
       
   377 	CleanupClosePushL(data);
       
   378 
       
   379     DispatcherSecurity::TSecurityCodeId secCodeID = DispatcherSecurity::ESecCodePin;
       
   380     RMobilePhone::TMobilePassword secCode;    
       
   381     TMockLtsyData2 <DispatcherSecurity::TSecurityCodeId, RMobilePhone::TMobilePassword> ltsyData(secCodeID, secCode);
       
   382 	ltsyData.SerialiseL(data);	
       
   383 
       
   384     iMockLTSY.ExpectL( MLtsyDispatchSecurityCheckSecurityCode::KLtsyDispatchSecurityCheckSecurityCodeApiId, data);    
       
   385     iMockLTSY.CompleteL( MLtsyDispatchSecurityCheckSecurityCode::KLtsyDispatchSecurityCheckSecurityCodeApiId, KErrGeneral);
       
   386     
       
   387 //	RBuf8 data2;
       
   388 //	CleanupClosePushL(data2);
       
   389 //    
       
   390 //	TMockLtsyData1 <DispatcherSecurity::TSecurityCodeId > ltsyData2(secCodeID);
       
   391 //	ltsyData2.SerialiseL(data2);	
       
   392 //
       
   393 //	// this is because HandleRequest(ECustomCheckSecurityCodeCancelIPC) is called when completing by error
       
   394 //    iMockLTSY.ExpectL( MLtsyDispatchSecurityCheckSecurityCodeCancel::KLtsyDispatchSecurityCheckSecurityCodeCancelApiId, data2);  
       
   395  
       
   396     TRequestStatus requestStatus;
       
   397     RMmCustomAPI::TSecurityCodeType type(RMmCustomAPI::ESecurityCodePin1);
       
   398     
       
   399     customApi.CheckSecurityCode(requestStatus, type);
       
   400 //	customApi.CancelAsyncRequest(ECustomCheckSecurityCodeIPC);
       
   401 	User::WaitForRequest(requestStatus);
       
   402 	// as stated in the CTSY test:
       
   403 	// Request ECustomCheckSecurityCodeCancelIPC is not cancelled properly - CMmCustomSecurityTsy::CheckSecurityCodeCancelL() is never called.
       
   404 	// Return value id KErrGeneral instead od KErrCancel.
       
   405 	ASSERT_EQUALS(KErrGeneral, requestStatus.Int());
       
   406 	
       
   407 	User::WaitForRequest(mockLtsyStatus);
       
   408 	ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int());
       
   409 
       
   410 	
       
   411 	AssertMockLtsyStatusL();
       
   412 	config.Reset();
       
   413 	CleanupStack::PopAndDestroy(3, this); // data, customApi, this
       
   414 	}