/**
doTestStepL()
Reads the POP account name from the ini file. If ALL string is mentioned in the .ini file 
it deletes all the IMAP accounts, Else deletes the IMAP account whose name is 
mentioned in the ini file

@return
Returns the test step result
*/
TVerdict CT_MsgDeletePopAccount::doTestStepL()
	{
	INFO_PRINTF1(_L("Test Step: Delete Pop Account"));
	TPtrC popAccountName;
	// Read Pop Account Name from ini file
	if(!GetStringFromConfig(ConfigSection(), KPopAccountName, popAccountName))
		{
		ERR_PRINTF1(_L("Account name not specified"));
		SetTestStepResult(EFail);
		}
	else
		{	
		CEmailAccounts* account = CEmailAccounts::NewLC();
		
		RArray<TPopAccount> arrayPop3Accounts;
		CleanupClosePushL(arrayPop3Accounts);
		account->GetPopAccountsL(arrayPop3Accounts);
		TInt count=arrayPop3Accounts.Count();
		
		TBuf<12> temp(popAccountName);
		temp.UpperCase();	// Making case insensitive
		if(temp.CompareC(_L("ALL")) == 0)
			{
			INFO_PRINTF2(_L("Deleting all accounts. Total = %d"), count);
			for(TInt i=0; i<count; i++)
				{
				TPopAccount id = arrayPop3Accounts[i];
				account->DeletePopAccountL(id);
				}
			}			
		else 
			{
			TBool deleteFlag = EFalse;
			for(TInt i = 0; i < count; i++)
				{
				if(popAccountName.CompareC(arrayPop3Accounts[i].iPopAccountName) == 0)
					{
					account->DeletePopAccountL(arrayPop3Accounts[i]);
					// Just ensure that if we try to delete it again we hopefuly get an error
					// or can see that it has been deleted.
					arrayPop3Accounts.Remove(i);
					deleteFlag = ETrue;
					break;					
					}
				}
			if(deleteFlag)
				{
				INFO_PRINTF2(_L("Pop acount \" %S \" deleted"), &popAccountName);	
				}
			else
				{
				ERR_PRINTF2(_L("Pop acount \" %S \" not found"), &popAccountName);
				SetTestStepResult(EFail);
				User::Leave(KErrNotFound);
				}
			}
		CleanupStack::PopAndDestroy(2, account);	//arrayPop3Accounts,account
		}
	return TestStepResult();
	}
Exemplo n.º 2
0
// Each test step must supply a implementation for doTestStepL
enum TVerdict CTestAppLoaderEndTask::doTestStepL( void )
	{
	// Printing to the console and log file
	INFO_PRINTF1(_L("TEST-> END TASK"));

	TPtrC	program;
	if ( !GetStringFromConfig(ConfigSection(), KProgram, program) )
		{
		ERR_PRINTF2(KErrMissingParameter, &KProgram());
		SetTestStepResult(EFail);
		}
	else
		{
		RApaLsSession	apaLsSession;
		User::LeaveIfError(apaLsSession.Connect());
		CleanupClosePushL(apaLsSession);
	    User::LeaveIfError(apaLsSession.GetAllApps());

		RWsSession	ws;
		User::LeaveIfError(ws.Connect());
		CleanupClosePushL(ws);
		
	    TInt					numWindowGroups = ws.NumWindowGroups();
	    CArrayFixFlat<TInt>*	windowGroupList = new(ELeave) CArrayFixFlat<TInt>(numWindowGroups);
	    CleanupStack::PushL(windowGroupList);

	    // Populate array with current group list ids
	    User::LeaveIfError(ws.WindowGroupList(windowGroupList));

	    CApaWindowGroupName*	windowGroupName = CApaWindowGroupName::NewLC(ws);

	    /* Note: we use windowGroupList->Count() instead of numWindowGroups, as in the middle of the
	     * update the list could change in length (or worse, be reduced) thus producing an out of bounds
	     * error if numWindowGroups were used
	     */
	    TBool	searching=ETrue;
	    for ( TInt i=0; (i<windowGroupList->Count()) && searching; ++i )
	    	{
	        TInt	wgId = windowGroupList->At(i);
	        windowGroupName->ConstructFromWgIdL(wgId);

	        TUid	appUid = windowGroupName->AppUid();

	        TApaAppInfo	appInfo;
	        HBufC* 		appCaption = NULL;
	        // Some applications, like midlets, may not provide any info
	        if (apaLsSession.GetAppInfo(appInfo, appUid) == KErrNone)
	        	{
	            appCaption = appInfo.iCaption.AllocL();
	        	}
	        else
	        	{
	            appCaption = windowGroupName->Caption().AllocL();
	        	}
            CleanupStack::PushL(appCaption);

	        // Only list 'visible' applications
	        if ( appCaption->Length() )
	        	{
	            TPtrC	caption=*appCaption;
		        INFO_PRINTF2(KLogTask, &caption);

		        if ( program.CompareC(caption)==0 )
		        	{
					searching=EFalse;
					TApaTask	task(ws);
					task.SetWgId(wgId);
					if (task.Exists())
						{
						task.EndTask();
						}
					else
						{
						ERR_PRINTF2(KErrTaskNotFound, &program);
						SetTestStepResult(EFail);
						}
		        	}
				}
            CleanupStack::Pop(1, appCaption); // taskEntry, appCaption
	    	}

	    if ( searching )
	    	{
			ERR_PRINTF2(KErrTaskNotFound, &program);
			SetTestStepResult(EFail);
	    	}
	    CleanupStack::PopAndDestroy(4, &apaLsSession);    // windowGroupName, windowGroupList
		}

	// test steps return a result
	return TestStepResult();
	}
void CT_LbsPrivFwBaseRequest::VerifyPrivNotifierData(CPosNetworkPrivacyRequestInfo* aNetPrivReqInfo, const TLbsTestRequestInfo& aExtReqInfo)
	{
	INFO_PRINTF1(_L("CT_LbsPrivFwBaseRequest::VerifyPrivNotifierData()"));

	TBuf<KLbsMaxClientNameSize2> testNotifClientName;
	TLbsTestRequestInfo::TFormatIndicator testNotifClientId;
	aExtReqInfo.GetClientName(testNotifClientName);
	testNotifClientId = aExtReqInfo.ClientNameFormat();
	
	TBuf<KLbsMaxRequesterIdSize2> testNotifRequesterName;
	TLbsTestRequestInfo::TFormatIndicator testNotifRequesterId;
	aExtReqInfo.GetRequesterId(testNotifRequesterName);
	testNotifRequesterId = aExtReqInfo.RequesterIdFormat();

	TLbsTestRequestInfo::TRequestType storedRequestType;
	TLbsTestRequestInfo::TRequestType receivedRequestType;

	receivedRequestType = aExtReqInfo.RequestType();
	
	TPtrC testApiClient;
	TPtrC testApiRequestor;
	
	if(iRequestInfoType == ERequestInfoTypeSupl)
		{
		CPosSUPLPrivacyRequestInfo* suplReqInfo = static_cast<CPosSUPLPrivacyRequestInfo*>(aNetPrivReqInfo);
		CPosSUPLPrivacyRequestInfo::TIdType testApiRequestorId;
		CPosSUPLPrivacyRequestInfo::TIdType testApiClientId;	
		
		suplReqInfo->GetLCSClient(testApiClient, testApiClientId);
		suplReqInfo->GetRequestor(testApiRequestor, testApiRequestorId);
		storedRequestType = suplReqInfo->RequestType();
		
		if(storedRequestType != receivedRequestType)
			{
			ERR_PRINTF3(_L("CT_LbsPrivFwBaseRequest::VerifyPrivNotifierData() - Failed Client RequestTypes Differ, sent value %d, recieved value %d."), storedRequestType, receivedRequestType);
			iStep->SetTestStepResult(EFail);
			}
		
		if(!CompareRequestInfoType(testNotifClientId, testApiClientId))
			{
			ERR_PRINTF1(_L("CT_LbsPrivFwBaseRequest::VerifyPrivNotifierData() - Failed Client Ids Differ"));
			iStep->SetTestStepResult(EFail);
			}
		if(!CompareRequestInfoType(testNotifRequesterId, testApiRequestorId))
			{
			ERR_PRINTF1(_L("CT_LbsPrivFwBaseRequest::VerifyPrivNotifierData() - Failed Requester Ids Differ"));
			iStep->SetTestStepResult(EFail);
			}
		}
	else if(iRequestInfoType == ERequestInfoTypeGsm)
		{
		CPosGSMPrivacyRequestInfo* gsmReqInfo = static_cast<CPosGSMPrivacyRequestInfo*>(aNetPrivReqInfo);
		CPosGSMPrivacyRequestInfo::TIdType testApiRequestorId;
		CPosGSMPrivacyRequestInfo::TIdType testApiClientId;
		
		gsmReqInfo->GetLCSClient(testApiClient, testApiClientId);
		gsmReqInfo->GetRequestor(testApiRequestor, testApiRequestorId);
		storedRequestType = gsmReqInfo->RequestType();
		
		if(storedRequestType != receivedRequestType)
			{
			ERR_PRINTF3(_L("CT_LbsPrivFwBaseRequest::VerifyPrivNotifierData() - Failed Client RequestTypes Differ, sent value %d, recieved value %d."), storedRequestType, receivedRequestType);
			iStep->SetTestStepResult(EFail);
			}
			
		if(!CompareRequestInfoType(testNotifClientId, testApiClientId))
			{
			ERR_PRINTF1(_L("CT_LbsPrivFwBaseRequest::VerifyPrivNotifierData() - Failed Client Ids Differ"));
			iStep->SetTestStepResult(EFail);
			}
		if(!CompareRequestInfoType(testNotifRequesterId, testApiRequestorId))
			{
			ERR_PRINTF1(_L("CT_LbsPrivFwBaseRequest::VerifyPrivNotifierData() - Failed Requester Ids Differ"));
			iStep->SetTestStepResult(EFail);
			}
		}
	// Notifier Names may be truncated as a shorter buffer is used.
	if(iPrivacyHandler != EPrivacyHandleByNotifier)
		{
		if(testApiClient.CompareC(testNotifClientName) != 0)
			{
			ERR_PRINTF1(_L("CT_LbsPrivFwBaseRequest::VerifyPrivNotifierData() - Failed Client Names Differ"));
			iStep->SetTestStepResult(EFail);
			}
		if(testApiRequestor.CompareC(testNotifRequesterName) != 0)
			{
			ERR_PRINTF1(_L("CT_LbsPrivFwBaseRequest::VerifyPrivNotifierData() - Failed Requester Names Differ"));
			iStep->SetTestStepResult(EFail);
			}
		}
	else
		{
		/**
		 * Notifier validation here
		 * -Requestor Id should be max32 characters
		 * -Client name should be max64 Characters
		 * -The first 32/64 or less characters of each should match.
		 * testApiClient is longest, testNotifClientName comes back from notifier and SHOULD be truncated
		 */
		

		TPtrC rwClientName(testNotifClientName);
		TPtrC rwRequesterName(testNotifRequesterName);
		
		TInt numOfCharactersInClientName = rwClientName.Length();
		TInt numOfCharactersInRequesterName = rwRequesterName.Length();
		
		if(	numOfCharactersInClientName > KLbsMaxClientNameSize)
			{
			ERR_PRINTF1(_L("CT_LbsPrivFwBaseRequest::VerifyPrivNotifierData() - Failed, Client too long."));
			iStep->SetTestStepResult(EFail);
			}
		
		if(	numOfCharactersInRequesterName > KLbsMaxRequesterIdSize)
			{
			ERR_PRINTF1(_L("CT_LbsPrivFwBaseRequest::VerifyPrivNotifierData() - Failed, Requestor too long."));
			iStep->SetTestStepResult(EFail);
			}
		
		if( testApiClient.Find(testNotifClientName) == KErrNotFound ||
			testApiClient.Find(testNotifClientName) > 0	)
			{
			ERR_PRINTF1(_L("CT_LbsPrivFwBaseRequest::VerifyPrivNotifierData() - Failed, Client name mismatch."));
			iStep->SetTestStepResult(EFail);
			}
		
		if( testApiRequestor.Find(testNotifRequesterName) == KErrNotFound ||
			testApiRequestor.Find(testNotifRequesterName) > 0 )
			{
			ERR_PRINTF1(_L("CT_LbsPrivFwBaseRequest::VerifyPrivNotifierData() - Failed, Requester name mismatch."));
			iStep->SetTestStepResult(EFail);
			}
		
		}
	}