sysstatemgmt/systemstatereferenceplugins/test/tunitcustcmd/src/tcmd_step_simsecuritycheck.cpp
changeset 0 4e1aa6a622a0
child 21 ccb4f6b3db21
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     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  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code
       
    20 */
       
    21 
       
    22 #include "tcmd_step_simsecuritycheck.h"
       
    23 #include "ssmsecuritychecknotifier.h"
       
    24 #include "ssmuiproviderdll.h"
       
    25 #include "ssmcustomcmdfactory.h"
       
    26 #include <ssm/startupdomainpskeys.h>
       
    27 #include <e32event.h>
       
    28 #include <e32std.h>
       
    29 #include <s32file.h>
       
    30 
       
    31 //Swp policy file for sim status swp
       
    32 _LIT(KTestSimStatusSwpPolicy, "ssm.swp.policy.simstatus.dll");
       
    33 
       
    34 //Exe name which defines startup PS keys
       
    35 _LIT (KExeToDefineStartUpPS, "\\sys\\bin\\definestartupps.exe");
       
    36 
       
    37 //Exe name which defines emergency call PS keys
       
    38 _LIT (KExeToDefineEmergencyCallPS, "\\sys\\bin\\defineemergencycallps.exe");
       
    39 
       
    40 // Use to write the PIN Check Security test case nos.
       
    41 _LIT(KTestCmdSecurityCheckTestFile, "c:\\cmdsecuritychecktest\\pinchecksecuritycaseno.txt");
       
    42 
       
    43 static TInt CallBack2L(TAny* aCCustomCmdTestSecurityCheck);
       
    44 
       
    45 CCustomCmdTestSimSecurityCheck::~CCustomCmdTestSimSecurityCheck()
       
    46 	{
       
    47 	delete iAsyncStopScheduler;
       
    48 	delete iActiveSchedulerWait;
       
    49 	delete iActiveScheduler;
       
    50 	}
       
    51 
       
    52 CCustomCmdTestSimSecurityCheck::CCustomCmdTestSimSecurityCheck()
       
    53 	{
       
    54 	//Set test step name
       
    55 	SetTestStepName(KTCCustomCmdTestSimSecurityCheck);
       
    56 	}
       
    57 
       
    58 TVerdict CCustomCmdTestSimSecurityCheck::doTestStepPreambleL()
       
    59 	{
       
    60 	INFO_PRINTF1(_L("doTestStepPreambleL"));
       
    61 	//Create and install active scheduler
       
    62 	iActiveScheduler = new(ELeave) CActiveScheduler;
       
    63 	CActiveScheduler::Install (iActiveScheduler);
       
    64 	iActiveSchedulerWait = new(ELeave) CActiveSchedulerWait;
       
    65 	
       
    66 	//Needed fro calling calback for stopping active scheduler
       
    67 	iAsyncStopScheduler = new(ELeave) CAsyncCallBack(CActive::EPriorityIdle);
       
    68 
       
    69 	RProcess processHandle;
       
    70 	CleanupClosePushL(processHandle);
       
    71 	//Start the test exe which defines startup related property keys
       
    72 	processHandle.Create(KExeToDefineStartUpPS, KNullDesC);
       
    73 	processHandle.Resume();
       
    74 	
       
    75 	// wait for the newly created process to rendezvous
       
    76 	TRequestStatus status;
       
    77 	processHandle.Rendezvous(status);
       
    78 	User::WaitForRequest(status);
       
    79 	
       
    80 	TInt retVal = status.Int();
       
    81 	TEST(KErrNone == retVal);
       
    82 	// leave if the process has not started properly
       
    83 	User::LeaveIfError(retVal);
       
    84 	CleanupStack::PopAndDestroy();
       
    85 	
       
    86 	//Start the test exe which defines emergency call related property keys
       
    87 	processHandle.Create(KExeToDefineEmergencyCallPS, KNullDesC);
       
    88 	processHandle.Resume();
       
    89 	processHandle.Close();
       
    90 	
       
    91 	RegisterSimSecurityStatus();
       
    92 	
       
    93 	//there are 8 different scenarios to test the custom command. Check the test spec for the scenarios.
       
    94  	//CMiscAdaptationRef::SecurityStateChange() has been changed to simulate the scenarios.
       
    95  	//CMiscAdaptationRef::SecurityStateChange() function uses pinchecksecuritycaseno.txt file to select the scenarios.
       
    96  	//This test case uses scenario 1 to test custom command.
       
    97 	_LIT(KDirNameOfTestCasesNumFile, "c:\\cmdsecuritychecktest\\");
       
    98 	
       
    99 	//connect to file server
       
   100 	User::LeaveIfError(iFs.Connect());
       
   101 	TInt err = iFs.MkDirAll(KDirNameOfTestCasesNumFile);
       
   102 	if (KErrAlreadyExists != err && KErrNone != err)
       
   103 		{
       
   104 		INFO_PRINTF1(_L("Leaving as it could not create directory"));
       
   105 		User::Leave(err);
       
   106 		}
       
   107 	RFile file;
       
   108 	CleanupClosePushL(file);
       
   109 	err = file.Replace(iFs, KTestCmdSecurityCheckTestFile, EFileWrite | EFileStream);
       
   110 	RFileWriteStream stream(file);
       
   111 	CleanupClosePushL(stream);
       
   112    
       
   113 	stream.WriteInt32L(1);
       
   114 	stream.CommitL();
       
   115 	CleanupStack::PopAndDestroy(&stream);
       
   116 	CleanupStack::PopAndDestroy(&file);
       
   117 	
       
   118 	User::After(1000000);
       
   119 	//Create a security check cmd
       
   120 	iCustomCmdCheck = static_cast<CCustomCmdSimSecurityCheck*>(SsmCustomCmdFactory::CmdSimSecurityCheckNewL());
       
   121 	return CTestStep::doTestStepPreambleL();
       
   122 	}
       
   123 
       
   124 TVerdict CCustomCmdTestSimSecurityCheck::doTestStepPostambleL()
       
   125 	{
       
   126 	iFs.Delete(KTestCmdSecurityCheckTestFile);
       
   127 	iFs.Close();
       
   128 	return CTestStep::doTestStepPostambleL();
       
   129 	}
       
   130 
       
   131 // CCustomCmdTestSimSecurityCheck::RegisterSimSecurityStatus()
       
   132 // This method is used to define the SIM status proeprty with SSM's secure ID
       
   133 // and to map the SIM status PandS key with the SIM Status SWP policy
       
   134 void CCustomCmdTestSimSecurityCheck::RegisterSimSecurityStatus()
       
   135     {
       
   136     INFO_PRINTF1(_L("RegisterSimSecurityStatus"));
       
   137     
       
   138     _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
       
   139        
       
   140     //Define the property for sim status for swp.
       
   141     TInt ret = RProperty::Define(RProcess().SecureId(), CSsmUiSpecific::SimStatusPropertyKey(), RProperty::EInt,
       
   142                                          KAllowAllPolicy, KAllowAllPolicy);
       
   143     TEST(KErrNone == ret || KErrAlreadyExists == ret);
       
   144     
       
   145     //Connect to SsmStateManager
       
   146     RSsmStateManager stateManager;
       
   147     ret = stateManager.Connect();
       
   148     TEST(KErrNone == ret);
       
   149     const TUint KStartupSimSecurityStatusUid = CSsmUiSpecific::SimStatusPropertyKey();
       
   150     
       
   151     //register the swp mapping for Sim security status with its swp policy
       
   152     ret = stateManager.RegisterSwpMapping(KStartupSimSecurityStatusUid, KTestSimStatusSwpPolicy);
       
   153     TEST(KErrNone == ret || KErrAlreadyExists == ret);
       
   154     stateManager.Close();
       
   155     }
       
   156 
       
   157 /////////////////////////////////////////////////////////////////////////////////////
       
   158 /**
       
   159 Old Test CaseID 		APPFWK-CUSTCMD-0006
       
   160 New Test CaseID 		DEVSRVS-SSREFPLUGINS-CUSTCMD-0006
       
   161  */
       
   162 
       
   163 
       
   164 
       
   165 void CCustomCmdTestSimSecurityCheck::TestGeneralL()
       
   166 	{
       
   167 	//Testing some of the functions from ui specific dll.
       
   168 	const TUid KPSStartupUid = {0x2000E65E};
       
   169 	const TUid KSecurityPinNotifierUid = {0x2000E667};
       
   170 	
       
   171 	TUid uid1 = CSsmUiSpecific::StartupPSUid();
       
   172 	TEST(KPSStartupUid == uid1);
       
   173 
       
   174 	TUid uid2 = CSsmUiSpecific::SecurityPinNotifierUid();
       
   175 	TEST(KSecurityPinNotifierUid == uid2);
       
   176 	
       
   177 	TEST( CSsmUiSpecific::IsSimlessOfflineSupported() );
       
   178 	
       
   179 	TEST( CSsmUiSpecific::IsNormalBoot() );
       
   180 	
       
   181 	TEST( CSsmUiSpecific::IsSimChangedReset() );
       
   182     
       
   183 	//Get the instance of ui specific dll
       
   184 	CSsmUiSpecific* ssmSecurityCustomCmdUid = CSsmUiSpecific::InstanceL();
       
   185 	
       
   186 	//Set the security status as passed
       
   187 	ssmSecurityCustomCmdUid->SetSecurityStatus(EStrtSecurityCheckPassed);
       
   188 	
       
   189 	//Get the security status
       
   190 	TStrtSecurityStatus sst = ssmSecurityCustomCmdUid->SecurityStatus();
       
   191 	
       
   192 	//Test the security status with EStrtSecurityCheckPassed which was set
       
   193 	TEST(EStrtSecurityCheckPassed == sst); 
       
   194 
       
   195 	//Delete created uispecific object
       
   196 	CSsmUiSpecific::Release();
       
   197 	}
       
   198 
       
   199 //
       
   200 static TInt CallBack1L(TAny* aCCustomCmdTestSimSecurityCheck)
       
   201 	{
       
   202 	//Call back function to stop active scheduler
       
   203 	CCustomCmdTestSimSecurityCheck* test = reinterpret_cast<CCustomCmdTestSimSecurityCheck*>(aCCustomCmdTestSimSecurityCheck);
       
   204 	test->CallBack1RunL();
       
   205 	return KErrNone;
       
   206 	}
       
   207 
       
   208 void CCustomCmdTestSimSecurityCheck::CallBack1RunL()
       
   209 	{
       
   210 	//Stop the active scheduler if the request is completed else
       
   211 	//callback once again
       
   212 	if(iRequest != KRequestPending)
       
   213 		{
       
   214 		iActiveSchedulerWait->AsyncStop();
       
   215 		}
       
   216 	else
       
   217 		{
       
   218 		iAsyncStopScheduler->CallBack();
       
   219 		}
       
   220 	}
       
   221 
       
   222 /**
       
   223 Old Test CaseID 		APPFWK-CUSTCMD-0007
       
   224 New Test CaseID 		DEVSRVS-SSREFPLUGINS-CUSTCMD-0006
       
   225  */
       
   226 
       
   227 void CCustomCmdTestSimSecurityCheck::TestHandleSIMPresentL()
       
   228 	{
       
   229 	TestHandleSIMPresent1L();
       
   230 	TestHandleSIMPresent2L();
       
   231 	TestHandleSIMPresent3L();
       
   232 	}
       
   233 
       
   234 void CCustomCmdTestSimSecurityCheck::TestHandleSIMPresent1L()
       
   235 	{
       
   236 	_LIT(KTESTLOG, "TestHandleSIMPresent1L");
       
   237 	INFO_PRINTF1(KTESTLOG);
       
   238 
       
   239 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::EPUK1Required;
       
   240 	iRequest = KRequestPending;
       
   241 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   242 	iCustomCmdCheck->HandleSIMPresent();
       
   243 
       
   244 	TCallBack stop(CallBack1L, this);
       
   245 	iAsyncStopScheduler->Set(stop);
       
   246 
       
   247 	iAsyncStopScheduler->CallBack();
       
   248 	iActiveSchedulerWait->Start();
       
   249 	TEST(KErrGeneral == iRequest.Int());
       
   250 	}
       
   251 
       
   252 void CCustomCmdTestSimSecurityCheck::TestHandleSIMPresent2L()
       
   253 	{
       
   254 	_LIT(KTESTLOG, "TestHandleSIMPresent2L");
       
   255 	TInt result = RProperty::Set(CSsmUiSpecific::StartupPSUid(), CSsmUiSpecific::SimStatusPropertyKey(), ESimStatusUninitialized);
       
   256 	TEST(KErrNone == result);
       
   257 	INFO_PRINTF1(KTESTLOG);
       
   258 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::EYes;
       
   259 	iRequest = KRequestPending;
       
   260 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   261 	iCustomCmdCheck->HandleSIMPresent();
       
   262 	TCallBack stop(CallBack2L, this);
       
   263 
       
   264 	iAsyncStopScheduler->Set(stop);
       
   265 	iAsyncStopScheduler->CallBack();
       
   266 	iActiveSchedulerWait->Start();
       
   267 #ifdef __WINS__	
       
   268 	TEST(KErrNone == iRequest.Int());
       
   269 #else
       
   270 	//Other tests which ran before this might have already loaded sus pluing (ssmclayersup.dll) which 
       
   271 	//will result in KErrAlreadyExists. This will happen only in armv5 as it runs 
       
   272 	//all the tests with out rebooting
       
   273 	TEST(KErrNone == iRequest.Int() || KErrAlreadyExists == iRequest.Int());
       
   274 #endif
       
   275 	}
       
   276 
       
   277 void CCustomCmdTestSimSecurityCheck::TestHandleSIMPresent3L()
       
   278 	{
       
   279 	_LIT(KTESTLOG, "TestHandleSIMPresent3L");
       
   280 	INFO_PRINTF1(KTESTLOG);
       
   281 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::ENo;
       
   282 	iRequest = KRequestPending;
       
   283 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   284 	iCustomCmdCheck->HandleSIMPresent();
       
   285 
       
   286 	TCallBack stop(CallBack1L, this);
       
   287 	iAsyncStopScheduler->Set(stop);
       
   288 	iAsyncStopScheduler->CallBack();
       
   289 	iActiveSchedulerWait->Start();
       
   290 	TEST(KErrNone == iRequest.Int());
       
   291 	}
       
   292 
       
   293 //
       
   294 
       
   295 /*
       
   296 Test Case ID            DEVSRVS-SSREFPLUGINS-CUSTCMD-0006
       
   297 */
       
   298 
       
   299 void CCustomCmdTestSimSecurityCheck::TestHandleSIMInvalidL()
       
   300     {
       
   301     TestHandleSIMInvalid1L();
       
   302     TestHandleSIMInvalid2L();
       
   303     TestHandleSIMInvalid3L();
       
   304     }
       
   305 
       
   306 
       
   307 void CCustomCmdTestSimSecurityCheck::TestHandleSIMInvalid1L()
       
   308     {
       
   309     _LIT(KTESTLOG, "TestHandleSIMInvalid1L");
       
   310     INFO_PRINTF1(KTESTLOG);
       
   311     iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::EPUK1Required;
       
   312     iRequest = KRequestPending;
       
   313     iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   314     iCustomCmdCheck->HandleSIMInvalid();
       
   315 
       
   316     TCallBack stop(CallBack2L, this);
       
   317     iAsyncStopScheduler->Set(stop);
       
   318     iAsyncStopScheduler->CallBack();
       
   319     iActiveSchedulerWait->Start();
       
   320     TEST(KErrGeneral == iRequest.Int());
       
   321     }
       
   322 
       
   323 void CCustomCmdTestSimSecurityCheck::TestHandleSIMInvalid2L()
       
   324     {
       
   325     _LIT(KTESTLOG, "TestHandleSIMInvalid2L");
       
   326     INFO_PRINTF1(KTESTLOG);
       
   327     iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::EYes;
       
   328     iRequest = KRequestPending;
       
   329     iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   330     iCustomCmdCheck->HandleSIMInvalid();
       
   331 
       
   332     TCallBack stop(CallBack2L, this);
       
   333     iAsyncStopScheduler->Set(stop);
       
   334     iAsyncStopScheduler->CallBack();
       
   335     iActiveSchedulerWait->Start();
       
   336     TEST(KErrNone == iRequest.Int());
       
   337     }
       
   338 
       
   339 void CCustomCmdTestSimSecurityCheck::TestHandleSIMInvalid3L()
       
   340     {
       
   341     _LIT(KTESTLOG, "TestHandleSIMInvalid3L");
       
   342     INFO_PRINTF1(KTESTLOG);
       
   343     iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::ENo;
       
   344     iRequest = KRequestPending;
       
   345     iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   346     iCustomCmdCheck->HandleSIMInvalid();
       
   347 
       
   348     TCallBack stop(CallBack2L, this);
       
   349     iAsyncStopScheduler->Set(stop);
       
   350     iAsyncStopScheduler->CallBack();
       
   351     iActiveSchedulerWait->Start();
       
   352     TEST(KErrNone == iRequest.Int());
       
   353     }
       
   354 
       
   355 //
       
   356 
       
   357 /**
       
   358 Old Test CaseID 		APPFWK-CUSTCMD-0008
       
   359 New Test CaseID 		DEVSRVS-SSREFPLUGINS-CUSTCMD-0006
       
   360  */
       
   361 
       
   362 void CCustomCmdTestSimSecurityCheck::TestHandleSIMRejectedL()
       
   363 	{
       
   364 	TestHandleSIMRejected1L();
       
   365 	TestHandleSIMRejected2L();
       
   366 	TestHandleSIMRejected3L();
       
   367 	}
       
   368 
       
   369 void CCustomCmdTestSimSecurityCheck::TestHandleSIMRejected1L()
       
   370 	{
       
   371 	_LIT(KTESTLOG, "TestHandleSIMRejected1L");
       
   372 	INFO_PRINTF1(KTESTLOG);
       
   373 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::EPUK1Required;
       
   374 	iRequest = KRequestPending;
       
   375 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   376 	iCustomCmdCheck->HandleSIMRejected();
       
   377 
       
   378 	TCallBack stop(CallBack1L, this);
       
   379 	iAsyncStopScheduler->Set(stop);
       
   380 	iAsyncStopScheduler->CallBack();
       
   381 	iActiveSchedulerWait->Start();
       
   382 	TEST(KErrGeneral == iRequest.Int());
       
   383 	}
       
   384 
       
   385 void CCustomCmdTestSimSecurityCheck::TestHandleSIMRejected2L()
       
   386 	{
       
   387 	_LIT(KTESTLOG, "TestHandleSIMRejected2L");
       
   388 	INFO_PRINTF1(KTESTLOG);
       
   389 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::EYes;
       
   390 	iRequest = KRequestPending;
       
   391 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   392 	iCustomCmdCheck->HandleSIMRejected();
       
   393 
       
   394 	TCallBack stop(CallBack2L, this);
       
   395 	iAsyncStopScheduler->Set(stop);
       
   396 	iAsyncStopScheduler->CallBack();
       
   397 	iActiveSchedulerWait->Start();
       
   398 	//Security observer might have already been loaded so returning with KErrAlreadyExists
       
   399 	TEST(KErrNone == iRequest.Int());
       
   400 
       
   401 	TInt val;
       
   402 	//Get the startup PS value for sim security status
       
   403 	TInt result = RProperty::Get(iCustomCmdCheck->iStartupPSUid, KStartupSimSecurityStatus, val);
       
   404 	TEST(KErrNone == result);
       
   405 	
       
   406 	//Test the sim security status value
       
   407 	TEST(ESimRejected == val);
       
   408 	}
       
   409 
       
   410 void CCustomCmdTestSimSecurityCheck::TestHandleSIMRejected3L()
       
   411 	{
       
   412 	_LIT(KTESTLOG, "TestHandleSIMRejected3L");
       
   413 	INFO_PRINTF1(KTESTLOG);
       
   414 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::ENo;
       
   415 	iRequest = KRequestPending;
       
   416 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   417 	iCustomCmdCheck->HandleSIMRejected();
       
   418 
       
   419 	TCallBack stop(CallBack2L, this);
       
   420 	iAsyncStopScheduler->Set(stop);
       
   421 	iAsyncStopScheduler->CallBack();
       
   422 	iActiveSchedulerWait->Start();
       
   423 	TEST(KErrNone == iRequest.Int());
       
   424 	}
       
   425 
       
   426 //
       
   427 static TInt CallBack2L(TAny* aCCustomCmdTestSimSecurityCheck)
       
   428 	{
       
   429 	CCustomCmdTestSimSecurityCheck* test = reinterpret_cast<CCustomCmdTestSimSecurityCheck*>(aCCustomCmdTestSimSecurityCheck);
       
   430 	test->CallBack2RunL();
       
   431 	return KErrNone;
       
   432 	}
       
   433 
       
   434 void CCustomCmdTestSimSecurityCheck::CallBack2RunL()
       
   435 	{
       
   436 	if(iRequest != KRequestPending)
       
   437 		{
       
   438 		iActiveSchedulerWait->AsyncStop();
       
   439 		}
       
   440 	else
       
   441 		{
       
   442 		iAsyncStopScheduler->CallBack();
       
   443 		
       
   444 		//Simulate entering the password only when it is asked for
       
   445 		if(iCustomCmdCheck->iState == StartupAdaptation::EAskPIN ||
       
   446 			iCustomCmdCheck->iState == StartupAdaptation::EAskPUK ||
       
   447 			iCustomCmdCheck->iState == StartupAdaptation::EAskSEC ||
       
   448 			iCustomCmdCheck->iState == StartupAdaptation::ESIMLock)
       
   449 			{
       
   450 			SimulatePasswordEntry();
       
   451 			}
       
   452 		}
       
   453 	}
       
   454 
       
   455 /**
       
   456 Old Test CaseID 		APPFWK-CUSTCMD-0009
       
   457 New Test CaseID 		DEVSRVS-SSREFPLUGINS-CUSTCMD-0006
       
   458  */
       
   459 
       
   460 
       
   461 void CCustomCmdTestSimSecurityCheck::TestHandleSIMBlockedL()
       
   462 	{
       
   463 	TestHandleSIMBlocked1L();
       
   464 	TestHandleSIMBlocked2L();
       
   465 	TestHandleSIMBlocked3L();
       
   466 	TestHandleSIMBlocked4L();
       
   467 	}
       
   468 
       
   469 void CCustomCmdTestSimSecurityCheck::TestHandleSIMBlocked1L()
       
   470 	{
       
   471 	_LIT(KTESTLOG, "TestHandleSIMBlocked1L");
       
   472 	INFO_PRINTF1(KTESTLOG);
       
   473 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::EPUK1Required;
       
   474 	iRequest = KRequestPending;
       
   475 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   476 	iCustomCmdCheck->HandleSIMBlocked();
       
   477 
       
   478 	TCallBack stop(CallBack2L, this);
       
   479 	iAsyncStopScheduler->Set(stop);
       
   480 	iAsyncStopScheduler->CallBack();
       
   481 	iActiveSchedulerWait->Start();
       
   482 	TEST(KErrNone == iRequest.Int());
       
   483 	}
       
   484 
       
   485 void CCustomCmdTestSimSecurityCheck::TestHandleSIMBlocked2L()
       
   486 	{
       
   487 	_LIT(KTESTLOG, "TestHandleSIMBlocked2L");
       
   488 	INFO_PRINTF1(KTESTLOG);
       
   489 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::EYes;
       
   490 	iRequest = KRequestPending;
       
   491 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   492 	iCustomCmdCheck->HandleSIMBlocked();
       
   493 
       
   494 	TCallBack stop(CallBack1L, this);
       
   495 	iAsyncStopScheduler->Set(stop);
       
   496 	iAsyncStopScheduler->CallBack();
       
   497 	iActiveSchedulerWait->Start();
       
   498 	TEST(KErrGeneral == iRequest.Int());
       
   499 	}
       
   500 
       
   501 void CCustomCmdTestSimSecurityCheck::TestHandleSIMBlocked3L()
       
   502 	{
       
   503 	_LIT(KTESTLOG, "TestHandleSIMBlocked3L");
       
   504 	INFO_PRINTF1(KTESTLOG);
       
   505 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::ENo;
       
   506 	iRequest = KRequestPending;
       
   507 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   508 	iCustomCmdCheck->HandleSIMBlocked();
       
   509 
       
   510 	TCallBack stop(CallBack2L, this);
       
   511 	iAsyncStopScheduler->Set(stop);
       
   512 	iAsyncStopScheduler->CallBack();
       
   513 	iActiveSchedulerWait->Start();
       
   514 	TEST(KErrNone == iRequest.Int());
       
   515 	}
       
   516 
       
   517 void CCustomCmdTestSimSecurityCheck::TestHandleSIMBlocked4L()
       
   518 	{
       
   519 	_LIT(KTESTLOG, "TestHandleSIMBlocked4L");
       
   520 	INFO_PRINTF1(KTESTLOG);
       
   521 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::EUPUKRequired;
       
   522 	iRequest = KRequestPending;
       
   523 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   524 	iCustomCmdCheck->HandleSIMBlocked();
       
   525 
       
   526 	TCallBack stop(CallBack2L, this);
       
   527 	iAsyncStopScheduler->Set(stop);
       
   528 	iAsyncStopScheduler->CallBack();
       
   529 	iActiveSchedulerWait->Start();
       
   530 	TEST(KErrNone == iRequest.Int());
       
   531 	}
       
   532 //
       
   533 
       
   534 /**
       
   535 Old Test CaseID 		APPFWK-CUSTCMD-0010
       
   536 New Test CaseID 		DEVSRVS-SSREFPLUGINS-CUSTCMD-0006
       
   537  */
       
   538 
       
   539 
       
   540 void CCustomCmdTestSimSecurityCheck::TestHandlePINRequiredL()
       
   541 	{
       
   542 	TestHandlePINRequired1L();
       
   543 	TestHandlePINRequired2L();
       
   544 	TestHandlePINRequired3L();
       
   545 	TestHandlePINRequired4L();
       
   546 	}
       
   547 
       
   548 void CCustomCmdTestSimSecurityCheck::TestHandlePINRequired1L()
       
   549 	{
       
   550 	_LIT(KTESTLOG, "TestHandlePINRequired1L");
       
   551 	INFO_PRINTF1(KTESTLOG);
       
   552 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::EUPUKRequired;
       
   553 	iRequest = KRequestPending;
       
   554 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   555 	iCustomCmdCheck->HandlePINRequired();
       
   556 
       
   557 	TCallBack stop(CallBack2L, this);
       
   558 	iAsyncStopScheduler->Set(stop);
       
   559 	iAsyncStopScheduler->CallBack();
       
   560 	iActiveSchedulerWait->Start();
       
   561 	TEST(KErrGeneral == iRequest.Int());
       
   562 	}
       
   563 
       
   564 void CCustomCmdTestSimSecurityCheck::TestHandlePINRequired2L()
       
   565 	{
       
   566 	_LIT(KTESTLOG, "TestHandlePINRequired2L");
       
   567 	INFO_PRINTF1(KTESTLOG);
       
   568 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::EPIN1Required;
       
   569 	iRequest = KRequestPending;
       
   570 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   571 	iCustomCmdCheck->HandlePINRequired();
       
   572 
       
   573 	TCallBack stop(CallBack2L, this);
       
   574 	iAsyncStopScheduler->Set(stop);
       
   575 	iAsyncStopScheduler->CallBack();
       
   576 	iActiveSchedulerWait->Start();
       
   577 	TEST(KErrNone == iRequest.Int());
       
   578 	}
       
   579 
       
   580 void CCustomCmdTestSimSecurityCheck::TestHandlePINRequired3L()
       
   581 	{
       
   582 	_LIT(KTESTLOG, "TestHandlePINRequired3L");
       
   583 	INFO_PRINTF1(KTESTLOG);
       
   584 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::EUPINRequired;
       
   585 	iRequest = KRequestPending;
       
   586 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   587 	iCustomCmdCheck->HandlePINRequired();
       
   588 
       
   589 	TCallBack stop(CallBack2L, this);
       
   590 	iAsyncStopScheduler->Set(stop);
       
   591 	iAsyncStopScheduler->CallBack();
       
   592 	iActiveSchedulerWait->Start();
       
   593 	TEST(KErrNone == iRequest.Int());
       
   594 	}
       
   595 
       
   596 void CCustomCmdTestSimSecurityCheck::TestHandlePINRequired4L()
       
   597 	{
       
   598 	_LIT(KTESTLOG, "TestHandlePINRequired4L");
       
   599 	INFO_PRINTF1(KTESTLOG);
       
   600 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::ENo;
       
   601 	iRequest = KRequestPending;
       
   602 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   603 	iCustomCmdCheck->HandlePINRequired();
       
   604 
       
   605 	TCallBack stop(CallBack2L, this);
       
   606 	iAsyncStopScheduler->Set(stop);
       
   607 	iAsyncStopScheduler->CallBack();
       
   608 	iActiveSchedulerWait->Start();
       
   609 	TEST(KErrNone == iRequest.Int());
       
   610 	}
       
   611 
       
   612 //
       
   613 /**
       
   614 Old Test CaseID 		APPFWK-CUSTCMD-0012
       
   615 New Test CaseID 		DEVSRVS-SSREFPLUGINS-CUSTCMD-0006
       
   616  */
       
   617 
       
   618 void CCustomCmdTestSimSecurityCheck::TestHandleSIMLessOfflineSupportedL()
       
   619 	{
       
   620 	_LIT(KTESTLOG, "TestHandleSIMLessOfflineSupportedL");
       
   621 	INFO_PRINTF1(KTESTLOG);
       
   622 	
       
   623 	iRequest = KRequestPending;
       
   624 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   625 	iCustomCmdCheck->HandleSIMLessOfflineSupported();
       
   626 
       
   627 	TCallBack stop(CallBack2L, this);
       
   628 	iAsyncStopScheduler->Set(stop);
       
   629 	iAsyncStopScheduler->CallBack();
       
   630 	iActiveSchedulerWait->Start();
       
   631 	TEST(KErrNone == iRequest.Int());
       
   632 	}
       
   633 
       
   634 //
       
   635 /**
       
   636 Old Test CaseID 		APPFWK-CUSTCMD-0013
       
   637 New Test CaseID 		DEVSRVS-SSREFPLUGINS-CUSTCMD-0006
       
   638  */
       
   639 
       
   640 
       
   641 void CCustomCmdTestSimSecurityCheck::TestHandleSIMLockL()
       
   642 	{
       
   643 	TestHandleSIMLock1L();
       
   644 	TestHandleSIMLock2L();
       
   645 	TestHandleSIMLock3L();
       
   646 	TestHandleSIMLock4L();
       
   647 	TestHandleSIMLock5L();
       
   648 	}
       
   649 
       
   650 void CCustomCmdTestSimSecurityCheck::TestHandleSIMLock1L()
       
   651 	{
       
   652 	_LIT(KTESTLOG, "TestHandleSIMLock1L");
       
   653 	INFO_PRINTF1(KTESTLOG);
       
   654 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::EUPUKRequired;
       
   655 	iRequest = KRequestPending;
       
   656 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   657 	iCustomCmdCheck->HandleSIMLock();
       
   658 
       
   659 	TCallBack stop(CallBack1L, this);
       
   660 	iAsyncStopScheduler->Set(stop);
       
   661 	iAsyncStopScheduler->CallBack();
       
   662 	iActiveSchedulerWait->Start();
       
   663 	TEST(KErrGeneral == iRequest.Int());
       
   664 	}
       
   665 
       
   666 void CCustomCmdTestSimSecurityCheck::TestHandleSIMLock2L()
       
   667 	{
       
   668 	_LIT(KTESTLOG, "TestHandleSIMLock2L");
       
   669 	INFO_PRINTF1(KTESTLOG);
       
   670 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::ESimLockRestricted;
       
   671 	iRequest = KRequestPending;
       
   672 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   673 	iCustomCmdCheck->HandleSIMLock();
       
   674 
       
   675 	TCallBack stop(CallBack1L, this);
       
   676 	iAsyncStopScheduler->Set(stop);
       
   677 	iAsyncStopScheduler->CallBack();
       
   678 	iActiveSchedulerWait->Start();
       
   679 	TEST(KErrNone == iRequest.Int());
       
   680 	}
       
   681 
       
   682 void CCustomCmdTestSimSecurityCheck::TestHandleSIMLock3L()
       
   683 	{
       
   684 	_LIT(KTESTLOG, "TestHandleSIMLock3L");
       
   685 	INFO_PRINTF1(KTESTLOG);
       
   686 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::ESimLockOk;
       
   687 	iRequest = KRequestPending;
       
   688 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   689 	iCustomCmdCheck->HandleSIMLock();
       
   690 
       
   691 	TCallBack stop(CallBack1L, this);
       
   692 	iAsyncStopScheduler->Set(stop);
       
   693 	iAsyncStopScheduler->CallBack();
       
   694 	iActiveSchedulerWait->Start();
       
   695 	TEST(KErrNone == iRequest.Int());
       
   696 	}
       
   697 
       
   698 void CCustomCmdTestSimSecurityCheck::TestHandleSIMLock4L()
       
   699 	{
       
   700 	_LIT(KTESTLOG, "TestHandleSIMLock4L");
       
   701 	INFO_PRINTF1(KTESTLOG);
       
   702 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::ESimLockRestrictionOn;
       
   703 	iRequest = KRequestPending;
       
   704 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   705 	iCustomCmdCheck->HandleSIMLock();
       
   706 
       
   707 	TCallBack stop(CallBack1L, this);
       
   708 	iAsyncStopScheduler->Set(stop);
       
   709 	iAsyncStopScheduler->CallBack();
       
   710 	iActiveSchedulerWait->Start();
       
   711 	TEST(KErrNone == iRequest.Int());
       
   712 	}
       
   713 
       
   714 void CCustomCmdTestSimSecurityCheck::TestHandleSIMLock5L()
       
   715 	{
       
   716 	_LIT(KTESTLOG, "TestHandleSIMLock5L");
       
   717 	INFO_PRINTF1(KTESTLOG);
       
   718 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::ESimLockRestrictionPending;
       
   719 	iRequest = KRequestPending;
       
   720 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   721 	iCustomCmdCheck->HandleSIMLock();
       
   722 
       
   723 	TCallBack stop(CallBack1L, this);
       
   724 	iAsyncStopScheduler->Set(stop);
       
   725 	iAsyncStopScheduler->CallBack();
       
   726 	iActiveSchedulerWait->Start();
       
   727 	TEST(KErrNone == iRequest.Int());
       
   728 	}
       
   729 
       
   730 //
       
   731 /**
       
   732 Old Test CaseID 		APPFWK-CUSTCMD-0015
       
   733 New Test CaseID 		DEVSRVS-SSREFPLUGINS-CUSTCMD-0006
       
   734  */
       
   735 
       
   736 void CCustomCmdTestSimSecurityCheck::TestHandlePINAskedL()
       
   737 	{
       
   738 	TestHandlePINAsked1L();
       
   739 	TestHandlePINAsked2L();
       
   740 	TestHandlePINAsked3L();
       
   741 	TestHandlePINAsked4L();
       
   742 	}
       
   743 
       
   744 void CCustomCmdTestSimSecurityCheck::TestHandlePINAsked1L()
       
   745 	{
       
   746 	_LIT(KTESTLOG, "TestHandlePINAsked1L");
       
   747 	INFO_PRINTF1(KTESTLOG);
       
   748 	iRequest = KRequestPending;
       
   749 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   750 	iCustomCmdCheck->iSsmSecurityCheckNotifier = CSsmSecurityCheckNotifier::NewL(ESecInfoSimLockRestrOn);
       
   751 	iCustomCmdCheck->HandlePINAsked();
       
   752 
       
   753 	TCallBack stop(CallBack2L, this);
       
   754 	iAsyncStopScheduler->Set(stop);
       
   755 	iAsyncStopScheduler->CallBack();
       
   756 	iActiveSchedulerWait->Start();
       
   757 	TEST(KErrGeneral == iRequest.Int());
       
   758 
       
   759 	delete iCustomCmdCheck->iSsmSecurityCheckNotifier;
       
   760 	iCustomCmdCheck->iSsmSecurityCheckNotifier = NULL;
       
   761 	}
       
   762 
       
   763 void CCustomCmdTestSimSecurityCheck::TestHandlePINAsked2L()
       
   764 	{
       
   765 	_LIT(KTESTLOG, "TestHandlePINAsked2L");
       
   766 	INFO_PRINTF1(KTESTLOG);
       
   767 	iCustomCmdCheck->iNoteType = ESecCodePIN1;
       
   768 	iRequest = KRequestPending;
       
   769 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   770 	iCustomCmdCheck->iSsmSecurityCheckNotifier = CSsmSecurityCheckNotifier::NewL(ESecInfoSimLockRestrOn);
       
   771 	iCustomCmdCheck->ExecuteCancel();
       
   772 	iCustomCmdCheck->HandlePINAsked();
       
   773 
       
   774 	TCallBack stop(CallBack2L, this);
       
   775 	iAsyncStopScheduler->Set(stop);
       
   776 	iAsyncStopScheduler->CallBack();
       
   777 	iActiveSchedulerWait->Start();
       
   778 	TEST(KErrCancel == iRequest.Int());
       
   779 
       
   780 	delete iCustomCmdCheck->iSsmSecurityCheckNotifier;
       
   781 	iCustomCmdCheck->iSsmSecurityCheckNotifier = NULL;
       
   782 	}
       
   783 
       
   784 void CCustomCmdTestSimSecurityCheck::TestHandlePINAsked3L()
       
   785 	{
       
   786 	_LIT(KTESTLOG, "TestHandlePINAsked3L");
       
   787 	INFO_PRINTF1(KTESTLOG);
       
   788 	iCustomCmdCheck->iNoteType = ESecCodeUPIN;
       
   789 	iRequest = KRequestPending;
       
   790 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   791 	iCustomCmdCheck->iStateChangePending = EFalse;
       
   792 	iCustomCmdCheck->iSsmSecurityCheckNotifier = CSsmSecurityCheckNotifier::NewL(ESecInfoSimLockRestrOn);
       
   793 	iCustomCmdCheck->Cancel();
       
   794 	iCustomCmdCheck->HandlePINAsked();
       
   795 
       
   796 	TCallBack stop(CallBack2L, this);
       
   797 	iAsyncStopScheduler->Set(stop);
       
   798 	iAsyncStopScheduler->CallBack();
       
   799 	iActiveSchedulerWait->Start();
       
   800 	TEST(KErrNone == iRequest.Int());
       
   801 
       
   802 	delete iCustomCmdCheck->iSsmSecurityCheckNotifier;
       
   803 	iCustomCmdCheck->iSsmSecurityCheckNotifier = NULL;
       
   804 	}
       
   805 
       
   806 void CCustomCmdTestSimSecurityCheck::TestHandlePINAsked4L()
       
   807 	{
       
   808 	_LIT(KTESTLOG, "TestHandlePINAsked4L");
       
   809 	INFO_PRINTF1(KTESTLOG);
       
   810 	iCustomCmdCheck->iNoteType = ESecCodeSPC;
       
   811 	iRequest = KRequestPending;
       
   812 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   813 	iCustomCmdCheck->iSsmSecurityCheckNotifier = CSsmSecurityCheckNotifier::NewL(ESecInfoSimLockRestrOn);
       
   814 	iCustomCmdCheck->Cancel();
       
   815 	iCustomCmdCheck->HandlePINAsked();
       
   816 	
       
   817 	TCallBack stop(CallBack2L, this);
       
   818 	iAsyncStopScheduler->Set(stop);
       
   819 	iAsyncStopScheduler->CallBack();
       
   820 	iActiveSchedulerWait->Start();
       
   821 	TEST(KErrGeneral == iRequest.Int());
       
   822 	delete iCustomCmdCheck->iSsmSecurityCheckNotifier;
       
   823 	iCustomCmdCheck->iSsmSecurityCheckNotifier = NULL;
       
   824 	}
       
   825 
       
   826 //
       
   827 /**
       
   828 Old Test CaseID 		APPFWK-CUSTCMD-0016
       
   829 New Test CaseID 		DEVSRVS-SSREFPLUGINS-CUSTCMD-0006
       
   830  */
       
   831 
       
   832 
       
   833 void CCustomCmdTestSimSecurityCheck::TestHandlePUKAskedL()
       
   834 	{
       
   835 	_LIT(KTESTLOG, "TestHandlePUKAskedL");
       
   836 	INFO_PRINTF1(KTESTLOG);
       
   837 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::EUPUKRequired;
       
   838 	iRequest = KRequestPending;
       
   839 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
   840 	iCustomCmdCheck->iStateChangePending = EFalse;
       
   841 	iCustomCmdCheck->iSsmSecurityCheckNotifier = CSsmSecurityCheckNotifier::NewL(ESecInfoSimLockRestrOn);
       
   842 	iCustomCmdCheck->Cancel();
       
   843 	iCustomCmdCheck->HandlePUKAsked();
       
   844 
       
   845 	TCallBack stop(CallBack2L, this);
       
   846 	iAsyncStopScheduler->Set(stop);
       
   847 	iAsyncStopScheduler->CallBack();
       
   848 	iActiveSchedulerWait->Start();
       
   849 	TEST(KErrNone == iRequest.Int());
       
   850 
       
   851 	TInt val;
       
   852 	TInt result = RProperty::Get(iCustomCmdCheck->iStartupPSUid, KStartupSimSecurityStatus, val);
       
   853 	TEST(KErrNone == result);
       
   854 	TEST(ESimRejected == val);
       
   855 	}
       
   856 //
       
   857 /**
       
   858 Old Test CaseID 		APPFWK-CUSTCMD-0018
       
   859 New Test CaseID 		DEVSRVS-SSREFPLUGINS-CUSTCMD-0006
       
   860  */
       
   861 
       
   862 
       
   863 void CCustomCmdTestSimSecurityCheck::TestSimFunctionsL()
       
   864 	{
       
   865 	_LIT(KTESTLOG, "TestSimFunctions");
       
   866 	INFO_PRINTF1(KTESTLOG);
       
   867 
       
   868 	TestSimNotSupported();
       
   869 	TestSimRemoved();
       
   870 	TestSimReadable();
       
   871 	TestSimUsable();
       
   872 	}
       
   873 
       
   874 void CCustomCmdTestSimSecurityCheck::TestSimNotSupported()
       
   875 	{
       
   876 	//Cancel any request if they are active
       
   877 	iCustomCmdCheck->Cancel();
       
   878 
       
   879 	TInt result = RProperty::Set(CSsmUiSpecific::StartupPSUid(), CSsmUiSpecific::SimStatusPropertyKey(), ESimStatusUninitialized);
       
   880 	TEST(KErrNone == result);
       
   881 	iCustomCmdCheck->SimNotSupported();
       
   882 
       
   883 	//Wait for PS value to get updated
       
   884 	User::After(2000000);
       
   885 
       
   886 	TInt simResult;
       
   887 	result = RProperty::Get(CSsmUiSpecific::StartupPSUid(), CSsmUiSpecific::SimStatusPropertyKey(), simResult);
       
   888 	TEST(KErrNone == result);
       
   889 	TEST(simResult == ESimNotSupported);
       
   890 	}
       
   891 
       
   892 void CCustomCmdTestSimSecurityCheck::TestSimRemoved()
       
   893 	{
       
   894 	//Cancel any request if they are active
       
   895 	iCustomCmdCheck->Cancel();
       
   896 
       
   897 	TInt result = RProperty::Set(CSsmUiSpecific::StartupPSUid(), CSsmUiSpecific::SimStatusPropertyKey(), ESimUsable);
       
   898 	TEST(KErrNone == result);
       
   899 	iCustomCmdCheck->SimRemoved();
       
   900 
       
   901 	//Wait for PS value to get updated
       
   902 	User::After(2000000);
       
   903 
       
   904 	TInt simResult;
       
   905 	result = RProperty::Get(CSsmUiSpecific::StartupPSUid(), CSsmUiSpecific::SimStatusPropertyKey(), simResult);
       
   906 	TEST(KErrNone == result);
       
   907 	TEST(simResult == ESimNotPresent);
       
   908 	}
       
   909 
       
   910 void CCustomCmdTestSimSecurityCheck::TestSimReadable()
       
   911 	{
       
   912 	//Cancel any request if they are active
       
   913 	iCustomCmdCheck->Cancel();
       
   914 
       
   915 	TInt result = RProperty::Set(CSsmUiSpecific::StartupPSUid(), CSsmUiSpecific::SimStatusPropertyKey(), ESimNotPresent);
       
   916 	TEST(KErrNone == result);
       
   917 	iCustomCmdCheck->SimReadable();
       
   918 
       
   919 	//Wait for PS value to get updated
       
   920 	User::After(2000000);
       
   921 
       
   922 	TInt simResult;
       
   923 	result = RProperty::Get(CSsmUiSpecific::StartupPSUid(), CSsmUiSpecific::SimStatusPropertyKey(), simResult);
       
   924 	TEST(KErrNone == result);
       
   925 	TEST(simResult == ESimReadable);
       
   926 	}
       
   927 
       
   928 void CCustomCmdTestSimSecurityCheck::TestSimUsable()
       
   929 	{
       
   930 	//Cancel any request if they are active
       
   931 	iCustomCmdCheck->Cancel();
       
   932 
       
   933 	TInt result = RProperty::Set(CSsmUiSpecific::StartupPSUid(), CSsmUiSpecific::SimStatusPropertyKey(), ESimReadable);
       
   934 	TEST(KErrNone == result);
       
   935 	iCustomCmdCheck->SimUsable();
       
   936 
       
   937 	//Wait for PS value to get updated
       
   938 	User::After(2000000);
       
   939 
       
   940 	TInt simResult;
       
   941 	result = RProperty::Get(CSsmUiSpecific::StartupPSUid(), CSsmUiSpecific::SimStatusPropertyKey(), simResult);
       
   942 	TEST(KErrNone == result);
       
   943 	TEST(simResult == ESimUsable);
       
   944 	}
       
   945 
       
   946 //
       
   947 static TInt CallBack3L(TAny* aCCustomCmdTestSimSecurityCheck)
       
   948 	{
       
   949 	CCustomCmdTestSimSecurityCheck* test = reinterpret_cast<CCustomCmdTestSimSecurityCheck*>(aCCustomCmdTestSimSecurityCheck);
       
   950 	test->CallBack3RunL();
       
   951 	return KErrNone;
       
   952 	}
       
   953 
       
   954 void CCustomCmdTestSimSecurityCheck::SimulatePasswordEntry()
       
   955 	{
       
   956 	TRawEvent eventDown;
       
   957 	TRawEvent eventUp;
       
   958 
       
   959 	//Simulate the key press ,(comma) in to pin notifier dialogue
       
   960 	eventDown.Set(TRawEvent::EKeyDown, EStdKeyComma);
       
   961 	UserSvr::AddEvent(eventDown);
       
   962 	eventUp.Set(TRawEvent::EKeyUp, EStdKeyComma);
       
   963 	UserSvr::AddEvent(eventUp);
       
   964 	User::After(100000);
       
   965 
       
   966 	eventDown.Set(TRawEvent::EKeyDown, EStdKeyEnter);
       
   967 	UserSvr::AddEvent(eventDown);
       
   968 	eventUp.Set(TRawEvent::EKeyUp, EStdKeyEnter);
       
   969 	UserSvr::AddEvent(eventUp);
       
   970 	User::After(100000);
       
   971 	}
       
   972 
       
   973 void CCustomCmdTestSimSecurityCheck::CallBack3RunL()
       
   974 	{
       
   975 	if(iRequest != KRequestPending)
       
   976 		{
       
   977 		iActiveSchedulerWait->AsyncStop();
       
   978 		}
       
   979 	else
       
   980 		{
       
   981 		iAsyncStopScheduler->CallBack();
       
   982 		if(iCustomCmdCheck->iState == StartupAdaptation::EAskPIN ||
       
   983 			iCustomCmdCheck->iState == StartupAdaptation::EAskPUK ||
       
   984 			iCustomCmdCheck->iState == StartupAdaptation::EAskSEC ||
       
   985 			iCustomCmdCheck->iState == StartupAdaptation::ESIMLock)
       
   986 			{
       
   987 			//Reset the security code status PS so that test goes further
       
   988 			TInt result = RProperty::Set(CSsmUiSpecific::StartupPSUid(), KStartupSecurityCodeQueryStatus, ESecurityQueryActive);
       
   989 			TEST(KErrNone == result);
       
   990 			SimulatePasswordEntry();
       
   991 			}
       
   992 		}
       
   993 	}
       
   994 
       
   995 /**
       
   996 Old Test CaseID 		APPFWK-CUSTCMD-0020
       
   997 New Test CaseID 		DEVSRVS-SSREFPLUGINS-CUSTCMD-0006
       
   998  */
       
   999 
       
  1000 void CCustomCmdTestSimSecurityCheck::TestSecurityNoteObserverL()
       
  1001 	{
       
  1002 	TestSecurityNoteObserver1L();
       
  1003 	TestSecurityNoteObserver2L();
       
  1004 	}
       
  1005 
       
  1006 void CCustomCmdTestSimSecurityCheck::TestSecurityNoteObserver1L()
       
  1007 	{
       
  1008 	_LIT(KTESTLOG, "TestSecurityNoteObserver1L");
       
  1009 	INFO_PRINTF1(KTESTLOG);
       
  1010 	iCustomCmdCheck->iSecurityStateInfo = StartupAdaptation::EPIN1Required;
       
  1011 	iRequest = KRequestPending;
       
  1012 	iCustomCmdCheck->iExecuteRequest = &iRequest;
       
  1013 	iCustomCmdCheck->HandlePINRequired();
       
  1014 
       
  1015 	TCallBack stop(CallBack3L, this);
       
  1016 	iAsyncStopScheduler->Set(stop);
       
  1017 	iAsyncStopScheduler->CallBack();
       
  1018 	iActiveSchedulerWait->Start();
       
  1019 	TEST(KErrNone == iRequest.Int());
       
  1020 	TInt propertyValue;
       
  1021 	TInt result = RProperty::Get(CSsmUiSpecific::StartupPSUid(), KPSSplashShutdown, propertyValue);
       
  1022 	TEST(KErrNone == result);
       
  1023 	TEST(propertyValue == ESplashShutdown);
       
  1024 	}
       
  1025 
       
  1026 void CCustomCmdTestSimSecurityCheck::TestSecurityNoteObserver2L()
       
  1027 	{
       
  1028 	_LIT(KTESTLOG, "TestSecurityNoteObserver2L");
       
  1029 	INFO_PRINTF1(KTESTLOG);
       
  1030 	TBufC8<1> dummy;
       
  1031 	iCustomCmdCheck->StartSecurityNoteObserverL();
       
  1032 	iCustomCmdCheck->Execute(dummy, iRequest);
       
  1033 	iCustomCmdCheck->ExecuteCancel();
       
  1034 	iCustomCmdCheck->iStateChangePending = EFalse;
       
  1035 	
       
  1036 	TCallBack stop(CallBack3L, this);
       
  1037 	iAsyncStopScheduler->Set(stop);
       
  1038 	iAsyncStopScheduler->CallBack();
       
  1039 	iActiveSchedulerWait->Start();
       
  1040 	TEST(KErrCancel == iRequest.Int());
       
  1041 	}
       
  1042 
       
  1043 //
       
  1044 TVerdict CCustomCmdTestSimSecurityCheck::doTestStepL()
       
  1045 	{
       
  1046 	__UHEAP_MARK;
       
  1047 	TestGeneralL();
       
  1048 	TestHandleSIMPresentL();
       
  1049 	TestHandleSIMInvalidL();
       
  1050 	TestHandleSIMRejectedL();
       
  1051 	TestHandleSIMBlockedL();
       
  1052 	TestHandlePINRequiredL();
       
  1053 	TestSecurityNoteObserverL();
       
  1054 	TestHandleSIMLessOfflineSupportedL();
       
  1055 	TestHandleSIMLockL();
       
  1056 	TestHandlePINAskedL();
       
  1057 	TestHandlePUKAskedL();
       
  1058 	TestSimFunctionsL();
       
  1059 
       
  1060 	//Close the security check custom custom
       
  1061 	iCustomCmdCheck->Close();
       
  1062 
       
  1063 	//Delete the security check custom custom
       
  1064 	iCustomCmdCheck->Release();
       
  1065 	__UHEAP_MARKEND;
       
  1066 	return TestStepResult();
       
  1067 	}