os/security/authorisation/userpromptservice/database/test/tupsdb/source/tupsdbbase.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 * Implements basic database test functions.
    16 *
    17 */
    18 
    19 
    20 /**
    21  @file
    22  @test
    23 */
    24 
    25 #include "tupsdbstep.h"
    26 #include <test/testexecutelog.h>
    27 
    28 using namespace UserPromptService;
    29 
    30 
    31 //
    32 //CUpsDbBaseStep
    33 //
    34 
    35 CUpsDbBaseStep::CUpsDbBaseStep()
    36 /**
    37 	onstructor Code
    38  */
    39 	{
    40    
    41 	}
    42 	
    43 CUpsDbBaseStep::~CUpsDbBaseStep()
    44 /**
    45 	Destructor Code
    46  */
    47 	{
    48 
    49 	} 
    50 
    51 
    52 CDecisionFilter *CUpsDbBaseStep::CreateFilterL(TInt aFlag, TInt aClientSid, TInt aEvaluatorId, TInt aServiceId, TInt aServerSid, TDesC8 &aFingerprint, TDesC8& aClientEntity,TInt aMajorPolicyVersion, TInt aRecordId, TDesC& aDescription, TInt aResult, TInt aEvaluatorInfo, TComparisonOp aComparisonOp)
    53  /**
    54 	Creates an empty filter object and then passes it to SetFilterFiledsL to get assigned all filter keys separately. 
    55 	This function is used to test NewL method of CDecisionFilter
    56 	
    57 	@param aFlag		 Shows which filter keys have been set 
    58 	@param aClientSid	 Secure Id of client application
    59 	@param aEvaluatorId	 UID for the policy evaluator DLL
    60 	@param aServiceId	 UID for service 
    61 	@param aServerSid	 UID for the system server
    62 	@param aFingerprint	 Hash of the destination and/or opaque data.
    63 	@param aClientEntity The name of the entity within the client that requested the service. 
    64 	@param aMajorPolicyVersion The major version of the policy file.
    65 	@param aRecordId	 An auto-incrementing record number.
    66 	@param aDescription A copy of description and/or opaque
    67 	@param aResult Whether the request should be approved
    68 	@param aEvaluatorInfo Policy evaluator specific data
    69 	@param aComparisonOp Comparison Operator (=,!=,<,> etc.)
    70 	
    71 	@return				 A pointer to the newly allocated filter object.
    72  */	
    73 	{
    74 	//Create an empty filter
    75 	CDecisionFilter *filter = CDecisionFilter::NewL();
    76 	CleanupStack::PushL(filter);
    77 	
    78 	SetFilterFiledsL(*filter, aFlag, aClientSid, aEvaluatorId, aServiceId, aServerSid,aFingerprint, aClientEntity, aMajorPolicyVersion, aRecordId, aDescription, aResult, aEvaluatorInfo, aComparisonOp);
    79 	
    80 	CleanupStack::Pop(filter);
    81 	return filter;
    82 	}
    83 
    84 
    85 CDecisionFilter *CUpsDbBaseStep::CreateFilterLC(TInt aFlag, TInt aClientSid, TInt aEvaluatorId, TInt aServiceId, TInt aServerSid, TDesC8 &aFingerprint, TDesC8& aClientEntity,TInt aMajorPolicyVersion, TInt aRecordId, TDesC& aDescription, TInt aResult, TInt aEvaluatorInfo, TComparisonOp aComparisonOp)
    86 /**
    87 	Creates an empty filter object and then calls SetFilterFiledsL to get assigned all filter keys separately. 
    88 	This function is used to test NewLC method of CDecisionFilter
    89 	
    90 	@see CUpsDbBaseStep::CreateFilterL
    91 	
    92 	@return A pointer to the newly allocated filter object. The pointer is also put onto the cleanup stack.
    93  */	
    94 	{
    95 	//Create an empty filter
    96 	CDecisionFilter *filter = CDecisionFilter::NewLC();
    97 	
    98 	SetFilterFiledsL(*filter, aFlag, aClientSid, aEvaluatorId, aServiceId, aServerSid,aFingerprint, aClientEntity, aMajorPolicyVersion, aRecordId, aDescription, aResult, aEvaluatorInfo, aComparisonOp);
    99 	
   100 	return filter;
   101 	}
   102 
   103 
   104 void CUpsDbBaseStep::SetFilterFiledsL(CDecisionFilter &aFilter, TInt aFlag, TInt aClientSid, TInt aEvaluatorId, TInt aServiceId, TInt aServerSid, TDesC8 &aFingerprint, TDesC8& aClientEntity, TInt aMajorPolicyVersion, TInt aRecordId, TDesC& aDescription, TInt aResult, TInt aEvaluatorInfo, TComparisonOp aComparisonOp)
   105 /**
   106 	This method assigns all the fields of a provided filter object with the supplied parameters.
   107 	The method is called by CreateFilterL and CreateFilterLC methods.
   108 	
   109 	@see CUpsDbBaseStep::CreateFilterL
   110 	@param aFilter Empty decision filter object
   111  */
   112 	{
   113 	//Sets the variables using aFlag
   114 	if(aFlag & KSetClientSid)
   115 		{
   116 		aFilter.SetClientSid(TSecureId(aClientSid), aComparisonOp);
   117 		}
   118 	
   119 	if(aFlag & KSetEvaluatorId)
   120 		{
   121 		aFilter.SetEvaluatorId(TUid::Uid(aEvaluatorId),aComparisonOp);
   122 		}
   123 	
   124 	if(aFlag & KSetServiceId)
   125 		{
   126 		aFilter.SetServiceId(TUid::Uid(aServiceId),aComparisonOp);
   127 		}
   128 	
   129 	if(aFlag & KSetServerSid)
   130 		{
   131 		aFilter.SetServerSid(TSecureId(aServerSid),aComparisonOp);
   132 		}
   133 		
   134 	if(aFlag & KSetFingerprint)
   135 		{
   136 		aFilter.SetFingerprintL(aFingerprint,aComparisonOp);
   137 		}
   138 	
   139 	if(aFlag & KSetClientEntity)
   140 		{
   141 		aFilter.SetClientEntityL(aClientEntity,aComparisonOp);
   142 		}
   143 	
   144 	if(aFlag & KSetMajorPolicyVersion)
   145 		{
   146 		aFilter.SetMajorPolicyVersion(aMajorPolicyVersion,aComparisonOp);
   147 		}
   148 	
   149 	if(aFlag & KSetRecordId)
   150 		{
   151 		aFilter.SetRecordId(aRecordId,aComparisonOp);
   152 		}
   153 	
   154 	if(aFlag & KSetDescription)
   155 		{
   156 		aFilter.SetDescriptionL(aDescription,aComparisonOp);
   157 		}
   158 		
   159 	if(aFlag & KSetResult)
   160 		{
   161 		aFilter.SetResult(aResult,aComparisonOp);
   162 		}
   163 		
   164 	if(aFlag & KSetEvaluatorInfo)
   165 		{
   166 		aFilter.SetEvaluatorInfo(aEvaluatorInfo,aComparisonOp);
   167 		}
   168 	}
   169 
   170 	
   171 CDecisionRecord *CUpsDbBaseStep::CreateRecordL(TInt aClientSid, TInt aEvaluatorId, TInt aServiceId, TInt aServerSid, TDesC8 &aFingerprint, TDesC8 &aClientEntity,
   172 											   TDesC &aDecription, TInt aResult, TInt aMajorPolicyVersion, TInt aEvaluatorInfo, TInt aRecordId)
   173 /**
   174 	Creates a decision record from provided parameters.
   175 	
   176 	@param aClientSid	  Secure Id of client application
   177 	@param aEvaluatorId	  UID for the policy evaluator DLL
   178 	@param aServiceId	  UID for service e.g. sms, mms, telephony, gprs
   179 	@param aServerSid	  UID for the system server that the decision applies to
   180 	@param aFingerprint	  Hash of the destination and/or opaque data. Maximum length is 32 bytes.
   181 	@param aClientEntity  The name of the entity within the client that requested the service. Maximum length is 32 bytes. 
   182 	@param aDescription	  A copy of description and/or opaque. 
   183 	@param aResult		  Whether the request should be approved (=1) or denied (=0)
   184 	@param aMajorPolicyVersion The major version of the policy file.
   185 	@param aEvaluatorInfo Policy evaluator specific data
   186 	@param aRecordId	  An auto-incrementing record number.
   187 	
   188 	@return				  A pointer to the newly allocated decision record object, if creation is successful.
   189 
   190  */
   191 	{
   192 	CDecisionRecord *newRecord;
   193 	
   194 	newRecord = CDecisionRecord::NewL(TSecureId(aClientSid),TUid::Uid(aEvaluatorId),TUid::Uid(aServiceId),TSecureId(aServerSid),aFingerprint,aClientEntity,aDecription,aResult,aMajorPolicyVersion,aEvaluatorInfo, aRecordId);
   195 	
   196 	return newRecord;
   197 	}
   198 
   199 
   200 void CUpsDbBaseStep::StartTimer(TTime &aTime)
   201 /**
   202 	Assigns current time to the provided parameter
   203 	@param aTime Keeps the current time
   204  */
   205 	{
   206 	aTime.HomeTime();
   207 	}
   208 		
   209 
   210 void CUpsDbBaseStep::StopTimer(TTime &aStartTime, TInt64 &aElapsedTime)
   211 /**
   212 	Substracts the provided time from current time and returns the elapsed time.
   213 	@param aStartTime First measured time
   214 	@param aElapsedTime The elapsed time from the first measurement
   215  */
   216 	{
   217 	TTime endTime;
   218 	endTime.HomeTime();
   219 	
   220 	TTimeIntervalMicroSeconds timeDiff = endTime.MicroSecondsFrom(aStartTime);
   221 	aElapsedTime = timeDiff.Int64();
   222 	
   223 	if(iLog)
   224 		{
   225 		_LIT8(KMessage,"%Ld");
   226 		iBuffer.AppendFormat(KMessage,aElapsedTime);
   227 		iFile.Write(iBuffer);
   228 		iFile.Write(_L8(";"));
   229 		iBuffer.Zero();
   230 		}
   231 	}
   232 	
   233 
   234 void CUpsDbBaseStep::FillTableL(CDecisionDbW &aUpsDb, TInt aRecordNum, TInt aClientNum, TInt aServiceNum, TInt aServerNum, TInt aEvaluatorNum)
   235 /**
   236 	Fill the decision table with a specified number of decision records.
   237 	The parameteres are used as seeds to create sample decision records. 
   238 	
   239 	@param aUpsDb		 Handle to the database
   240 	@param aRecordNum	 Number of records which will be inserted into the database
   241 	@param aClientNum	 Number of different clients 
   242 	@param aServiceNum	 Number of different services provided by each server
   243 	@param aServerNum	 Number of different servers
   244 	@param aEvaluatorNum Number of different policy evaluator DLLs
   245  */
   246 	{
   247 	TSecureId clientId = TSecureId(0);
   248 	TSecureId serverId = TSecureId(0);
   249 	TUid serviceId	 =TUid::Null();
   250 	TUid evaluatorId =TUid::Null();
   251 	
   252 	TUint8 result = 0;
   253 	TUint16 policyMajorVersion = 2;
   254 	
   255 	TBuf8<KDbMaxName> bufFP;
   256 	TBuf8<KDbMaxName> bufCE;
   257 	TBuf<KDbMaxName> bufD;
   258 	
   259 	CDecisionRecord* newRecord = NULL;
   260 	
   261 	for(TInt i=0; i<aRecordNum; i++)
   262 		{
   263 		bufFP.AppendFormat(KFingerprint,i);
   264 		bufCE.AppendFormat(KClientEntity,i);
   265 		bufD.AppendFormat(KDescription,i);
   266 		
   267 		CMD5* md5FP = CMD5::NewL();
   268 		CleanupStack::PushL(md5FP);
   269 		
   270 		CMD5* md5CE = CMD5::NewL();
   271 		CleanupStack::PushL(md5CE);
   272 		
   273 		clientId=TSecureId(i%aClientNum + aRecordNum);
   274 		serviceId=TUid::Uid(i%aServiceNum + 10000 + aRecordNum);
   275 		serverId =TSecureId(i%aServerNum + 100000 + aRecordNum);
   276 		evaluatorId = TUid::Uid(i%aEvaluatorNum + 1000000 + aRecordNum);
   277 		
   278 		result = i%2;
   279 		
   280 		newRecord = CDecisionRecord::NewLC(clientId,evaluatorId,serviceId,serverId,md5FP->Hash(bufFP),md5CE->Hash(bufCE),bufD, result,policyMajorVersion, 0);
   281 		
   282 		aUpsDb.CreateDecisionL(*newRecord);
   283 		
   284 		CleanupStack::PopAndDestroy(newRecord);
   285 		CleanupStack::PopAndDestroy(2); //md5FP and md5CE
   286 		
   287 		bufFP.Zero();
   288 		bufCE.Zero();
   289 		bufD.Zero();
   290 		}
   291 	}
   292 	
   293 
   294 CDecisionDbW *CUpsDbBaseStep::CreateDatabaseLC(TDesC& aDbLocation, RFs& aFs)
   295 /**
   296 	Create a writable decision database object. Prints the consumed time to perform this operation.
   297 	
   298 	@param aDbLocation Where the database will be created
   299  */
   300 	{
   301 	TTime startTime;
   302 	//Timer is started
   303 	StartTimer(startTime);
   304 	
   305 	//Database is created
   306 	CDecisionDbW *upsDb = CDecisionDbW::NewLC(aDbLocation, aFs);
   307 	
   308 	//Timer is stopped
   309 	TInt64 elapsedTime = 0;
   310 	StopTimer(startTime,elapsedTime);
   311 	
   312 	INFO_PRINTF2(_L("Decision database created in %Ld microseconds."), elapsedTime);
   313 	
   314 	return upsDb;
   315 	}
   316 	
   317 
   318 CDecisionRecord *CUpsDbBaseStep::GetDecisionLC(CDecisionDbW &aUpsDb, CDecisionFilter &aFilter)
   319 /**
   320 	Get a decision record from the database. This function uses single record lookup method (RDbTable).
   321 	Prints the consumed time to perform this operation.
   322 	
   323 	@param aUpsDb Handle to the database
   324 	@param aFilter Filter
   325  */
   326 	{
   327 	TTime startTime;
   328 	//Timer is started
   329 	StartTimer(startTime);
   330 	
   331 	CDecisionRecord *retRecord = NULL;
   332 	retRecord = aUpsDb.GetDecisionL(aFilter);
   333 	if(retRecord)
   334 		{
   335 		CleanupStack::PushL(retRecord);
   336 		}
   337 	
   338 	//Timer is stopped
   339 	TInt64 elapsedTime = 0;
   340 	StopTimer(startTime,elapsedTime);
   341 	
   342 	if(retRecord)
   343 		{
   344 		INFO_PRINTF2(_L("A single record retrieved in %Ld microseconds."), elapsedTime);
   345 		}
   346 	
   347 	return retRecord;
   348 	}
   349 	
   350 
   351 void CUpsDbBaseStep::GetDecisionsL(CDecisionDbW &aUpsDb, CDecisionFilter &aFilter, TBool aCancel, RPointerArray<CDecisionRecord>& aRecordList)
   352 /**
   353    Get a set of decision records from the database. Uses multiple records lookup method (RDbView).
   354    Prints the consumed time to perform this operation.
   355  */
   356 	{
   357 	TTime startTime;
   358 	//Timer is started
   359 	StartTimer(startTime);
   360 	
   361 	CDecisionView *dbView = aUpsDb.CreateViewL(aFilter);
   362 	CleanupStack::PushL(dbView);
   363 
   364 	dbView->EvaluateView(iWaiter->iStatus);
   365 	TInt num = 0;
   366 	if(aCancel)
   367 		{
   368 		dbView->Cancel();
   369 		iWaiter->WaitActiveL(KErrCancel);
   370 		}
   371 	else
   372 		{
   373 		iWaiter->WaitActiveL(KErrNone);
   374 		CDecisionRecord *record = NULL;		
   375 		
   376 		while((record = dbView->NextDecisionL()) != NULL)
   377 			{
   378 			CleanupStack::PushL(record);
   379 			num++;
   380 			aRecordList.AppendL(record);
   381 			CleanupStack::Pop(record);
   382 			}
   383 		}
   384 	
   385 	//Timer is stopped
   386 	TInt64 elapsedTime = 0;
   387 	StopTimer(startTime,elapsedTime);
   388 	
   389 	INFO_PRINTF3(_L("%d records retrieved in %Ld microseconds."), num, elapsedTime);
   390 	CleanupStack::PopAndDestroy(dbView);
   391 	}
   392 	
   393 
   394 void CUpsDbBaseStep::RemoveDecisionsL(CDecisionDbW &aUpsDb, CDecisionFilter &aFilter)
   395 /**
   396 	Delete a set of records. Prints the consumed time to perform this operation.
   397  */
   398 	{
   399 	TTime startTime;
   400 	//Timer is started
   401 	StartTimer(startTime);
   402 	
   403 	aUpsDb.RemoveDecisionsL(aFilter);
   404 	
   405 	//Timer is stopped
   406 	TInt64 elapsedTime = 0;
   407 	StopTimer(startTime,elapsedTime);
   408 	
   409 	INFO_PRINTF2(_L("A set of records deleted in %Ld microseconds."), elapsedTime);
   410 	}
   411 	
   412 	
   413 void CUpsDbBaseStep::RemoveAllDecisionsL(CDecisionDbW &aUpsDb, RFs& aFs)
   414 /**
   415 	Deletes all records in the database. Actually delete all database.
   416 	Prints the consumed time to perform this operation.
   417  */
   418 	{
   419 	TTime startTime;
   420 	//Timer is started
   421 	StartTimer(startTime);
   422 	
   423 	aUpsDb.DeleteDatabaseL(aFs);
   424 	
   425 	//Timer is stopped
   426 	TInt64 elapsedTime = 0;
   427 	StopTimer(startTime,elapsedTime);
   428 	
   429 	INFO_PRINTF2(_L("All records deleted in %Ld microseconds."), elapsedTime);
   430 	}
   431 	
   432 
   433 void CUpsDbBaseStep::InsertRecordL(CDecisionDbW &aUpsDb, CDecisionRecord &aRecord)
   434 /**
   435 	Inserts the provided record into the decision database. Prints the consumed time to perform this operation.
   436  */
   437 	{
   438 	TTime startTime;
   439 	//Timer is started
   440 	StartTimer(startTime);
   441 	
   442 	aUpsDb.CreateDecisionL(aRecord);
   443 	
   444 	//Timer is stopped
   445 	TInt64 elapsedTime = 0;
   446 	StopTimer(startTime,elapsedTime);
   447 	
   448 	INFO_PRINTF2(_L("A record inserted in %Ld microseconds."), elapsedTime);
   449 	}
   450 	
   451 
   452 void CUpsDbBaseStep::ReadConfigurationFile(TDes &aKeyNotFound)
   453 /**
   454 	Reads the key fileds from the ini file which are used to fill table with a specified number of
   455 	sample records.
   456 	@param aKeyNotFound The appended list of the key names which have not been found
   457  */
   458 	{
   459 	
   460 	if(EFalse == GetIntFromConfig(ConfigSection(),KRecordNum, iRecordNum))
   461 		{
   462 		aKeyNotFound.Append(KRecordNum);
   463 		aKeyNotFound.Append(_L(" "));
   464 		}
   465 	else if(EFalse == GetIntFromConfig(ConfigSection(),KServerNum, iServerNum))
   466 		{
   467 		aKeyNotFound.Append(KServerNum);
   468 		aKeyNotFound.Append(_L(" "));
   469 		}
   470 	else if(EFalse == GetIntFromConfig(ConfigSection(),KServiceNum, iServiceNum))
   471 		{
   472 		aKeyNotFound.Append(KServiceNum);
   473 		aKeyNotFound.Append(_L(" "));
   474 		}
   475 	else if(EFalse == GetIntFromConfig(ConfigSection(),KClientNum, iClientNum))
   476 		{
   477 		aKeyNotFound.Append(KClientNum);
   478 		aKeyNotFound.Append(_L(" "));
   479 		}
   480 	else if(EFalse == GetIntFromConfig(ConfigSection(),KEvaluatorNum, iEvaluatorNum))
   481 		{
   482 		aKeyNotFound.Append(KEvaluatorNum);
   483 		aKeyNotFound.Append(_L(" "));
   484 		}
   485 	else if(EFalse == GetIntFromConfig(ConfigSection(),KRetrieveNum, iRetrieveNum))
   486 		{
   487 		aKeyNotFound.Append(KRetrieveNum);
   488 		aKeyNotFound.Append(_L(" "));
   489 		}
   490 	}
   491 
   492 
   493 TInt CUpsDbBaseStep::ConvertNumber(TDesC& aError)
   494 /**
   495 	Converts error string  to number
   496 	@param aError Error string
   497 */	
   498 		{
   499 		TInt error = KErrNotFound;
   500 		
   501 		if(!aError.CompareF(KStrErrNone))
   502 			{
   503 			error = KErrNone;	
   504 			}
   505 		else if(!aError.CompareF(KStrErrUpsBadFingerprintLength))
   506 			{
   507 			error = KErrUpsBadFingerprintLength;
   508 			}
   509 		else if(!aError.CompareF(KStrErrUpsMissingArgument))
   510 			{
   511 			error = KErrUpsMissingArgument;
   512 			}
   513 		else if(!aError.CompareF(KStrErrUpsBadClientEntityLength))
   514 			{
   515 			error = KErrUpsBadClientEntityLength;
   516 			}
   517 			
   518 		return error;
   519 		}
   520 		
   521 static void PopulateFingerPrint(TDes8& aBuf, TInt aStart)
   522 	{
   523 	TUint8 *ptr = (TUint8 *)aBuf.Ptr();
   524 	
   525 	TInt pos;
   526 	TInt value;
   527 	
   528 	for(pos = 0, value = aStart; pos < KUpsMaxFingerprintLength; ++pos, ++value )
   529 		{
   530 		ptr[pos] = value;
   531 		}
   532 	aBuf.SetLength(pos);	
   533 	}
   534 
   535 void CUpsDbBaseStep::TestFingerprintValuesL(CDecisionDbW& aUpsDb)
   536 /**
   537 	Creates a number of decision records by using all characters 
   538 	between 0x01 and 0xFF in Fingerprint value.
   539  */
   540 
   541 	{
   542 	TInt clientId		= 1;
   543 	TInt serverId		= 2;
   544 	TInt serviceId		= 3;
   545 	TInt evaluatorId	= 4;
   546 	TInt evaluatorInfo	= 5;
   547 	TInt result			= 0;
   548 	TInt policyVersion	= 9;
   549 	TInt recordId		= 0;
   550 	
   551 	CDecisionRecord *record = NULL;
   552 	CDecisionFilter *filter = NULL;
   553 	RPointerArray<CDecisionRecord> recordList;	
   554 	TBuf8<KUpsMaxFingerprintLength> bufFp;
   555 	TBuf8<KUpsMaxClientEntityLength> bufCe;
   556 	TBuf<KUpsDescriptionLength> bufDes;
   557 	bufFp.SetLength(KUpsMaxFingerprintLength);
   558 	bufCe.SetLength(KUpsMaxClientEntityLength);
   559 	TInt flag = KSetClientSid|KSetEvaluatorId|KSetServiceId|KSetServerSid|KSetFingerprint|KSetClientEntity;
   560 	TInt pos = 0;
   561 	
   562 	for(pos=0; pos <= KUpsDescriptionLength+1; pos+= KUpsMaxFingerprintLength)
   563 		{
   564 		PopulateFingerPrint(bufFp, pos);
   565 		record = CreateRecordL(++clientId,++evaluatorId,++serviceId,++serverId, bufFp, bufCe, bufDes, result, policyVersion, evaluatorInfo, recordId);
   566 		CleanupStack::PushL(record);
   567 		InsertRecordL(aUpsDb,*record);
   568 		
   569 		filter = CreateFilterLC(flag,clientId,evaluatorId,serviceId,serverId,bufFp,bufCe,policyVersion,recordId,bufDes,result,evaluatorInfo,EEqual);
   570 		CleanupResetAndDestroyPushL(recordList);
   571 		GetDecisionsL(aUpsDb, *filter, EFalse, recordList);
   572 		if(recordList.Count() != 1)
   573 			{
   574 			SetTestStepResult(EFail);
   575 			CleanupStack::PopAndDestroy(3, record);
   576 			break;
   577 			}		
   578 		CleanupStack::PopAndDestroy(3, record);
   579 		}	
   580 	}
   581 
   582 
   583 void CUpsDbBaseStep::CompactDatabaseL(CDecisionDbW& aUpsDb, TBool aCancel)
   584 /**
   585 	Compacts the decision database.
   586  */
   587 	{
   588 	TTime startTime;
   589 	//Timer is started
   590 	StartTimer(startTime);
   591 	
   592 	CDecisionDbCompactor *dbCompact = aUpsDb.PrepareCompactionLC();
   593 	dbCompact->Compact(iWaiter->iStatus);
   594 	
   595 	if(aCancel)
   596 		{
   597 		dbCompact->Cancel();
   598 		iWaiter->WaitActiveL(KErrCancel);
   599 		}
   600 	else
   601 		{
   602 		iWaiter->WaitActiveL(KErrNone);		
   603 		}
   604 		
   605 	//Timer is stopped
   606 	TInt64 elapsedTime = 0;
   607 	StopTimer(startTime,elapsedTime);
   608 			
   609 	if(iWaiter->iStatus == 0)
   610 		{
   611 		INFO_PRINTF2(_L("Compaction has been achieved in %Ld microseconds."), elapsedTime);
   612 		}
   613 	else
   614 		{
   615 		if(!aCancel && iWaiter->iStatus!=KErrCancel)
   616 			{
   617 			ERR_PRINTF1(_L("Failed to compact database!"));
   618 			SetTestStepResult(EFail);		
   619 			}
   620 		}
   621 		
   622 	CleanupStack::PopAndDestroy(dbCompact);
   623 	}
   624 
   625 
   626 void CUpsDbBaseStep::UpdateRecordL(CDecisionDbW& aUpsDb, CDecisionFilter& aFilter, CDecisionRecord& aRecord)
   627 /**
   628 	Updates a decision record from the decision database.
   629 	
   630 	@param aUpsDb A pointer to the decision database object
   631 	@param aFilter Filter used to find the record which will be updated
   632 	@param aRecord New record containing the values which will be updated
   633  */
   634 	{
   635 	TTime startTime;
   636 	//Timer is started
   637 	StartTimer(startTime);
   638 	
   639 	if(EFalse == aUpsDb.UpdateDecisionL(aFilter,aRecord))
   640 		{
   641 		SetTestStepResult(EFail);
   642 		User::Leave(KErrNotFound);
   643 		}
   644 	else
   645 		{
   646 		//Timer is stopped
   647 		TInt64 elapsedTime = 0;
   648 		StopTimer(startTime,elapsedTime);
   649 		INFO_PRINTF2(_L("The record was updated in %Ld microseconds."), elapsedTime);	
   650 		}
   651 		
   652 	}