os/security/authorisation/userpromptservice/database/test/tupsdb/source/tupsdbstep.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
* Performs decision filter, record and database tests
sl@0
    16
*
sl@0
    17
*/
sl@0
    18
sl@0
    19
sl@0
    20
/**
sl@0
    21
 @file
sl@0
    22
 @test
sl@0
    23
*/
sl@0
    24
sl@0
    25
#include "tupsdbstep.h"
sl@0
    26
#include <test/testexecutelog.h>
sl@0
    27
sl@0
    28
using namespace UserPromptService;
sl@0
    29
sl@0
    30
sl@0
    31
CUpsDbStepUnitTest::CUpsDbStepUnitTest()
sl@0
    32
/**
sl@0
    33
	Constructer
sl@0
    34
 */
sl@0
    35
	{
sl@0
    36
	iComparison = EEqual;
sl@0
    37
	iCancel = EFalse;	
sl@0
    38
	}
sl@0
    39
	
sl@0
    40
CUpsDbStepUnitTest::~CUpsDbStepUnitTest()
sl@0
    41
/**
sl@0
    42
	Destructor
sl@0
    43
 */
sl@0
    44
	{
sl@0
    45
	iFs.Close();
sl@0
    46
	iFileWriteStream.Close();
sl@0
    47
	iFileReadStream.Close();
sl@0
    48
	delete iWaiter;
sl@0
    49
	delete iScheduler;
sl@0
    50
	}
sl@0
    51
sl@0
    52
	
sl@0
    53
TVerdict CUpsDbStepUnitTest::doTestStepPreambleL()
sl@0
    54
/**
sl@0
    55
	This function is called at the beginning of the test step. First reads the operation type
sl@0
    56
	and converts it to a proper enumaration value (TUpsDbUnitTest). Then gets the specified 
sl@0
    57
	database location. The test fails if the database location can not be found, except
sl@0
    58
	the unit tests of the decision record and filter objects.
sl@0
    59
 */
sl@0
    60
	{
sl@0
    61
	iScheduler = new(ELeave) CActiveScheduler;
sl@0
    62
	CActiveScheduler::Install(iScheduler);
sl@0
    63
	iWaiter = new(ELeave)CActiveWaiter(Logger());
sl@0
    64
	
sl@0
    65
	iLog = EFalse;
sl@0
    66
	
sl@0
    67
	TPtrC opType;
sl@0
    68
sl@0
    69
	if(EFalse == GetStringFromConfig(ConfigSection(),KOpType,opType))
sl@0
    70
		{
sl@0
    71
		ERR_PRINTF2(_L("Failed to read '%S' key of configuration"),&KOpType);
sl@0
    72
		SetTestStepResult(EFail);
sl@0
    73
		}
sl@0
    74
	
sl@0
    75
	if(!opType.CompareF(KInsertRecord))
sl@0
    76
		{
sl@0
    77
		iOpType = EInsertRecord;
sl@0
    78
		}
sl@0
    79
	else if(!opType.CompareF(KDeleteRecord))
sl@0
    80
		{
sl@0
    81
		iOpType = EDeleteRecord;
sl@0
    82
		}
sl@0
    83
	else if(!opType.CompareF(KSingleLookup))
sl@0
    84
		{
sl@0
    85
		iOpType = ESingleLookup;
sl@0
    86
		}
sl@0
    87
	else if(!opType.CompareF(KMultipleLookup))
sl@0
    88
		{
sl@0
    89
		iOpType = EMultipleLookup;
sl@0
    90
		}
sl@0
    91
	else if(!opType.CompareF(KVerifyRecord))
sl@0
    92
		{
sl@0
    93
		iOpType = EVerifyRecord;
sl@0
    94
		}
sl@0
    95
	else if(!opType.CompareF(KCreateDatabase))
sl@0
    96
		{
sl@0
    97
		iOpType = ECreateDatabase;
sl@0
    98
		}
sl@0
    99
	else if(!opType.CompareF(KDeleteDatabase))
sl@0
   100
		{
sl@0
   101
		iOpType = EDeleteDatabase;
sl@0
   102
		}
sl@0
   103
	else if(!opType.CompareF(KCreateFilterSingleCall))
sl@0
   104
		{
sl@0
   105
		iOpType = ECreateFilterSingleCall;
sl@0
   106
		}
sl@0
   107
	else if(!opType.CompareF(KCreateFilterMultipleCalls))
sl@0
   108
		{
sl@0
   109
		iOpType = ECreateFilterMultipleCalls;
sl@0
   110
		}
sl@0
   111
	else if(!opType.CompareF(KCreateDecision))
sl@0
   112
		{
sl@0
   113
		iOpType = ECreateDecision;
sl@0
   114
		}
sl@0
   115
	else if(!opType.CompareF(KFillTable))
sl@0
   116
		{
sl@0
   117
		iOpType = EFillTable;
sl@0
   118
		}
sl@0
   119
	else if(!opType.CompareF(KAllFingerprints))
sl@0
   120
		{
sl@0
   121
		iOpType = EAllFingerprints;
sl@0
   122
		}
sl@0
   123
	else if(!opType.CompareF(KCompactDatabase))
sl@0
   124
		{
sl@0
   125
		iOpType = ECompact;
sl@0
   126
		}
sl@0
   127
	else if(!opType.CompareF(KUpdateRecord))
sl@0
   128
		{
sl@0
   129
		iOpType = EUpdate;
sl@0
   130
		}
sl@0
   131
	else
sl@0
   132
		{
sl@0
   133
		iOpType = ENotSupported;
sl@0
   134
		}
sl@0
   135
	
sl@0
   136
	if(EFalse == GetStringFromConfig(ConfigSection(),KDbLocation,iDbLocation))
sl@0
   137
		{
sl@0
   138
		if((iOpType != ECreateFilterSingleCall) && (iOpType != ECreateDecision) && 
sl@0
   139
		   (iOpType != ECreateFilterMultipleCalls) && (iOpType != ENotSupported))
sl@0
   140
			{
sl@0
   141
			ERR_PRINTF2(_L("Failed to read '%S' key of configuration"),&KDbLocation);
sl@0
   142
			SetTestStepResult(EFail);
sl@0
   143
			User::Leave(KErrNotFound);
sl@0
   144
			}
sl@0
   145
		}
sl@0
   146
	
sl@0
   147
	GetBoolFromConfig(ConfigSection(), KOOMCondition,iOOMCondition);
sl@0
   148
	
sl@0
   149
	User::LeaveIfError(iFs.Connect());
sl@0
   150
	User::LeaveIfError(iFs.CreatePrivatePath(EDriveC));			
sl@0
   151
	return TestStepResult();
sl@0
   152
	}
sl@0
   153
sl@0
   154
sl@0
   155
TVerdict CUpsDbStepUnitTest::doTestStepL()
sl@0
   156
/**
sl@0
   157
	Calls actual test step or OOM test
sl@0
   158
 */
sl@0
   159
	{
sl@0
   160
	if (!iOOMCondition)
sl@0
   161
		{
sl@0
   162
		 doTestL(); 
sl@0
   163
		}
sl@0
   164
	else
sl@0
   165
		{
sl@0
   166
 		return doOOMTestL();
sl@0
   167
	    }	
sl@0
   168
sl@0
   169
   	 return TestStepResult();
sl@0
   170
	}
sl@0
   171
sl@0
   172
sl@0
   173
TVerdict CUpsDbStepUnitTest::doTestL()
sl@0
   174
/**
sl@0
   175
	Perform the actual test steps. Unit tests for all provided database operations
sl@0
   176
	and creation of both filter and decision record objects.
sl@0
   177
 */
sl@0
   178
	{
sl@0
   179
	
sl@0
   180
	//Define required objects
sl@0
   181
	CDecisionDbW    *upsDb  = NULL;
sl@0
   182
	CDecisionRecord *record = NULL;
sl@0
   183
	CDecisionFilter *filter = NULL;
sl@0
   184
	CleanupClosePushL(iFingerprint);
sl@0
   185
	CleanupClosePushL(iClientEntity);
sl@0
   186
		
sl@0
   187
	switch(iOpType)
sl@0
   188
		{
sl@0
   189
		case ECreateDatabase:
sl@0
   190
			{
sl@0
   191
			//Make sure the database file does not exist
sl@0
   192
			iFs.Delete(iDbLocation);
sl@0
   193
			
sl@0
   194
			//Create the database
sl@0
   195
			upsDb = CreateDatabaseLC(iDbLocation, iFs);
sl@0
   196
			
sl@0
   197
			//Disconnect
sl@0
   198
			CleanupStack::PopAndDestroy(upsDb);
sl@0
   199
			break;
sl@0
   200
			}
sl@0
   201
		
sl@0
   202
		case EDeleteDatabase:
sl@0
   203
			{
sl@0
   204
			//Connect to the database
sl@0
   205
			upsDb = CDecisionDbW::NewL(iDbLocation, iFs);
sl@0
   206
			CleanupStack::PushL(upsDb);
sl@0
   207
			
sl@0
   208
			//Delete all records and database
sl@0
   209
			RemoveAllDecisionsL(*upsDb, iFs);
sl@0
   210
			
sl@0
   211
			//Disconnect
sl@0
   212
			CleanupStack::PopAndDestroy(upsDb);
sl@0
   213
			break;
sl@0
   214
			}
sl@0
   215
		
sl@0
   216
		case ECreateFilterSingleCall:
sl@0
   217
			{
sl@0
   218
			//Read the decision values from the config file
sl@0
   219
			ReadDecisionFieldsL(EFalse);
sl@0
   220
			
sl@0
   221
			TPtrC strExpectedResult;
sl@0
   222
			if(EFalse == GetStringFromConfig(ConfigSection(),KExpectedResult,strExpectedResult))
sl@0
   223
				{
sl@0
   224
				ERR_PRINTF1(_L("Expected result is missing!"));
sl@0
   225
				SetTestStepResult(EFail);
sl@0
   226
				break;
sl@0
   227
				}
sl@0
   228
			TInt expectedResult = ConvertNumber(strExpectedResult);
sl@0
   229
				
sl@0
   230
			//First method is to create a filter with single function call	
sl@0
   231
			TRAPD(error,filter = CDecisionFilter::NewL(TUid::Uid(iClientSid),TUid::Uid(iEvaluatorId),TUid::Uid(iServiceId),TUid::Uid(iServerSid),iFingerprint,iClientEntity,iMajorPolicyVersion));	
sl@0
   232
			
sl@0
   233
			if(error != expectedResult)
sl@0
   234
				{
sl@0
   235
				ERR_PRINTF3(_L("In the single call method, the result (%d) is different from the expected result (%d)"), error, expectedResult);
sl@0
   236
				SetTestStepResult(EFail);
sl@0
   237
				}
sl@0
   238
				
sl@0
   239
			if(error == KErrNone)
sl@0
   240
				{
sl@0
   241
				INFO_PRINTF1(_L("Successful to create a decision filter using the single call method"));
sl@0
   242
				delete filter;
sl@0
   243
				}
sl@0
   244
			else
sl@0
   245
				{
sl@0
   246
				INFO_PRINTF1(_L("Failed to create a decision filter using the single call method"));
sl@0
   247
				}
sl@0
   248
				
sl@0
   249
			break;
sl@0
   250
			}
sl@0
   251
		
sl@0
   252
		case ECreateFilterMultipleCalls:
sl@0
   253
			{
sl@0
   254
			//Read the decision values from the config file
sl@0
   255
			ReadDecisionFieldsL(EFalse);
sl@0
   256
			
sl@0
   257
			TPtrC strExpectedResult;
sl@0
   258
			if(EFalse == GetStringFromConfig(ConfigSection(),KExpectedResult,strExpectedResult))
sl@0
   259
				{
sl@0
   260
				ERR_PRINTF1(_L("Expected result is missing!"));
sl@0
   261
				SetTestStepResult(EFail);
sl@0
   262
				break;
sl@0
   263
				}
sl@0
   264
			TInt expectedResult = ConvertNumber(strExpectedResult);
sl@0
   265
				
sl@0
   266
			//Second method is to create an empty filter and then set provided fields
sl@0
   267
			TRAPD(error,filter = CreateFilterL(iSetFlag,iClientSid,iEvaluatorId,iServiceId,iServerSid,iFingerprint,iClientEntity,iMajorPolicyVersion,iRecordId,iDescription,iResult,iEvaluatorInfo,iComparison));		
sl@0
   268
			
sl@0
   269
				if(error != expectedResult)
sl@0
   270
				{
sl@0
   271
				ERR_PRINTF3(_L("In the multiple calls method, the result (%d) is different from the expected result (%d)"), error, expectedResult);
sl@0
   272
				SetTestStepResult(EFail);
sl@0
   273
				}
sl@0
   274
				
sl@0
   275
			if(error == KErrNone)
sl@0
   276
				{
sl@0
   277
				INFO_PRINTF1(_L("Successful to create a decision filter using the multiple calls method"));
sl@0
   278
				delete filter;
sl@0
   279
				}
sl@0
   280
			else
sl@0
   281
				{
sl@0
   282
				INFO_PRINTF1(_L("Failed to create a decision filter using the multiple calls method"));
sl@0
   283
				}
sl@0
   284
				
sl@0
   285
			break;
sl@0
   286
			}
sl@0
   287
			
sl@0
   288
		case ECreateDecision:
sl@0
   289
			{
sl@0
   290
			//Read the decision values from the config file
sl@0
   291
			ReadDecisionFieldsL(EFalse);
sl@0
   292
			
sl@0
   293
			TPtrC strExpectedResult;
sl@0
   294
			if(EFalse == GetStringFromConfig(ConfigSection(),KExpectedResult,strExpectedResult))
sl@0
   295
				{
sl@0
   296
				ERR_PRINTF1(_L("Expected result is missing!"));
sl@0
   297
				SetTestStepResult(EFail);
sl@0
   298
				break;
sl@0
   299
				}
sl@0
   300
			TInt expectedResult = ConvertNumber(strExpectedResult);
sl@0
   301
			
sl@0
   302
			TRAPD(error,record = CreateRecordL(iClientSid,iEvaluatorId,iServiceId,iServerSid,iFingerprint,iClientEntity,iDescription,iResult,iMajorPolicyVersion,iEvaluatorInfo,iRecordId));
sl@0
   303
			
sl@0
   304
			if(error != expectedResult)
sl@0
   305
				{
sl@0
   306
				ERR_PRINTF3(_L("The result (%d) is different from the expected result (%d)"), error, expectedResult);
sl@0
   307
				SetTestStepResult(EFail);
sl@0
   308
				}
sl@0
   309
				
sl@0
   310
				if(error == KErrNone)
sl@0
   311
				{
sl@0
   312
				INFO_PRINTF1(_L("Successful to create a decision record"));
sl@0
   313
				delete record;
sl@0
   314
				}
sl@0
   315
			else
sl@0
   316
				{
sl@0
   317
				INFO_PRINTF1(_L("Failed to create a decision record"));
sl@0
   318
				}
sl@0
   319
				
sl@0
   320
			break;
sl@0
   321
			}
sl@0
   322
			
sl@0
   323
		case EInsertRecord:
sl@0
   324
			{
sl@0
   325
			//Read the decision values from the config file
sl@0
   326
			ReadDecisionFieldsL(ETrue);
sl@0
   327
			
sl@0
   328
			//ClientSid,EvaluatorId,ServiceId,ServerSid and Fingerprint must be provided
sl@0
   329
			if((iSetFlag & (KSetClientSid|KSetEvaluatorId|KSetServiceId|KSetServerSid|KSetFingerprint))!=
sl@0
   330
			   (KSetClientSid|KSetEvaluatorId|KSetServiceId|KSetServerSid|KSetFingerprint))
sl@0
   331
				{
sl@0
   332
				SetTestStepResult(EFail);
sl@0
   333
				break;
sl@0
   334
				}
sl@0
   335
				
sl@0
   336
			//Create decision record
sl@0
   337
			record = CreateRecordL(iClientSid,iEvaluatorId,iServiceId,iServerSid,iFingerprint,iClientEntity,iDescription,iResult,iMajorPolicyVersion,iEvaluatorInfo,iRecordId);
sl@0
   338
			CleanupStack::PushL(record);
sl@0
   339
			
sl@0
   340
			//Connect to the database
sl@0
   341
			upsDb = CDecisionDbW::NewL(iDbLocation,iFs);
sl@0
   342
			CleanupStack::PushL(upsDb);
sl@0
   343
			
sl@0
   344
			//Insert the decision
sl@0
   345
			InsertRecordL(*upsDb, *record);
sl@0
   346
			
sl@0
   347
			//Disconnect and destroy objects
sl@0
   348
			CleanupStack::PopAndDestroy(2,record);
sl@0
   349
			
sl@0
   350
			break;
sl@0
   351
			}
sl@0
   352
			
sl@0
   353
		case EDeleteRecord:
sl@0
   354
			{
sl@0
   355
			//Read the decision values from the config file
sl@0
   356
			ReadDecisionFieldsL(ETrue);
sl@0
   357
		
sl@0
   358
			if(!iSetFlag)
sl@0
   359
				{
sl@0
   360
				ERR_PRINTF1(_L("A filter key must be supplied at least!"));
sl@0
   361
				SetTestStepResult(EFail);
sl@0
   362
				break;
sl@0
   363
				}
sl@0
   364
								
sl@0
   365
			//Create filter
sl@0
   366
			filter = CreateFilterLC(iSetFlag,iClientSid,iEvaluatorId,iServiceId,iServerSid,iFingerprint,iClientEntity,iMajorPolicyVersion,iRecordId,iDescription,iResult,iEvaluatorInfo,iComparison);
sl@0
   367
			
sl@0
   368
			//Connect to the database
sl@0
   369
			upsDb = CDecisionDbW::NewLC(iDbLocation,iFs);	
sl@0
   370
			
sl@0
   371
			//Delete the decision
sl@0
   372
			RemoveDecisionsL(*upsDb, *filter);
sl@0
   373
		
sl@0
   374
			CleanupStack::PopAndDestroy(2,filter);
sl@0
   375
			break;
sl@0
   376
			}
sl@0
   377
		
sl@0
   378
		case ESingleLookup:
sl@0
   379
			{
sl@0
   380
			//Read the decision values from the config file
sl@0
   381
			ReadDecisionFieldsL(ETrue);
sl@0
   382
			
sl@0
   383
			TInt expectedRecords;
sl@0
   384
			if(EFalse == GetIntFromConfig(ConfigSection(),KExpectedRecords,expectedRecords))
sl@0
   385
				{
sl@0
   386
				ERR_PRINTF1(_L("Expected result is missing!"));
sl@0
   387
				SetTestStepResult(EFail);
sl@0
   388
				break;
sl@0
   389
				}
sl@0
   390
			
sl@0
   391
			TPtrC strExpectedResult;
sl@0
   392
			TInt expectedResult=KErrNone;
sl@0
   393
			if(GetStringFromConfig(ConfigSection(),KExpectedResult,strExpectedResult))
sl@0
   394
				{
sl@0
   395
				expectedResult = ConvertNumber(strExpectedResult);
sl@0
   396
				}
sl@0
   397
				
sl@0
   398
			//Create filter
sl@0
   399
			filter = CreateFilterL(iSetFlag,iClientSid,iEvaluatorId,iServiceId,iServerSid,iFingerprint,iClientEntity,iMajorPolicyVersion,iRecordId,iDescription,iResult,iEvaluatorInfo,iComparison);
sl@0
   400
			CleanupStack::PushL(filter);
sl@0
   401
			
sl@0
   402
			//Connect to the database
sl@0
   403
			upsDb = CDecisionDbW::NewLC(iDbLocation,iFs);
sl@0
   404
			
sl@0
   405
			//Retrieve single record
sl@0
   406
			TRAPD(err,record = GetDecisionLC(*upsDb, *filter);if(record)CleanupStack::Pop(record););
sl@0
   407
			if((err==KErrNone)&&(record))
sl@0
   408
				{
sl@0
   409
				CleanupStack::PushL(record);
sl@0
   410
				}
sl@0
   411
			  
sl@0
   412
			if(err!=expectedResult)
sl@0
   413
				{
sl@0
   414
				SetTestStepResult(EFail);
sl@0
   415
				}
sl@0
   416
				
sl@0
   417
			if(record)
sl@0
   418
				{
sl@0
   419
				OpenDecisionFileL(EFileWrite);
sl@0
   420
				WriteDecisionL(*record);
sl@0
   421
				CloseDecisionFile();
sl@0
   422
				CleanupStack::PopAndDestroy();
sl@0
   423
				}
sl@0
   424
			else
sl@0
   425
				{
sl@0
   426
				if(expectedRecords)
sl@0
   427
					{
sl@0
   428
					ERR_PRINTF1(_L("Failed to retrieve a single record"));
sl@0
   429
					SetTestStepResult(EFail);
sl@0
   430
					}
sl@0
   431
				}
sl@0
   432
				
sl@0
   433
	
sl@0
   434
			CleanupStack::PopAndDestroy(upsDb);
sl@0
   435
			CleanupStack::PopAndDestroy(filter);
sl@0
   436
			break;			
sl@0
   437
			}
sl@0
   438
		
sl@0
   439
		case EMultipleLookup:
sl@0
   440
			{
sl@0
   441
			//Read the decision values from the config file
sl@0
   442
			ReadDecisionFieldsL(ETrue);
sl@0
   443
			
sl@0
   444
			//Create filter
sl@0
   445
			filter = CreateFilterL(iSetFlag,iClientSid,iEvaluatorId,iServiceId,iServerSid,iFingerprint,iClientEntity,iMajorPolicyVersion,iRecordId,iDescription,iResult,iEvaluatorInfo,iComparison);
sl@0
   446
			CleanupStack::PushL(filter);
sl@0
   447
			
sl@0
   448
			//Connect to the database
sl@0
   449
			upsDb = CDecisionDbW::NewL(iDbLocation,iFs);
sl@0
   450
			CleanupStack::PushL(upsDb);
sl@0
   451
			
sl@0
   452
			RPointerArray<CDecisionRecord> recordList;
sl@0
   453
			CleanupResetAndDestroyPushL(recordList);
sl@0
   454
			GetDecisionsL(*upsDb, *filter, iCancel, recordList);
sl@0
   455
			
sl@0
   456
			TInt recNum;
sl@0
   457
			recNum = recordList.Count();
sl@0
   458
			if(recNum)
sl@0
   459
				{				
sl@0
   460
				OpenDecisionFileL(EFileWrite);
sl@0
   461
			
sl@0
   462
				for(TInt i=0; i<recNum; ++i)
sl@0
   463
					{
sl@0
   464
					WriteDecisionL(*recordList[i]);
sl@0
   465
					}
sl@0
   466
				CloseDecisionFile();				
sl@0
   467
				}
sl@0
   468
			CleanupStack::PopAndDestroy(&recordList);			
sl@0
   469
				
sl@0
   470
			TInt expectedRecords;
sl@0
   471
			if(EFalse == GetIntFromConfig(ConfigSection(),KExpectedRecords,expectedRecords))
sl@0
   472
				{
sl@0
   473
				expectedRecords=-1;
sl@0
   474
				}
sl@0
   475
			
sl@0
   476
			if(!iCancel && (((expectedRecords>=0) && (recNum != expectedRecords))||((expectedRecords<0) && (recNum<=0))))
sl@0
   477
				{
sl@0
   478
				SetTestStepResult(EFail);
sl@0
   479
				}
sl@0
   480
		
sl@0
   481
			CleanupStack::PopAndDestroy(2,filter);
sl@0
   482
			break;	
sl@0
   483
			}
sl@0
   484
			
sl@0
   485
		case EVerifyRecord:
sl@0
   486
			{
sl@0
   487
			//Read the decision values from the config file
sl@0
   488
			ReadDecisionFieldsL(ETrue);
sl@0
   489
			TBool verified = ETrue;
sl@0
   490
			
sl@0
   491
			OpenDecisionFileL(EFileRead);
sl@0
   492
				
sl@0
   493
			while((record = ReadDecisionL()) != NULL)
sl@0
   494
				{
sl@0
   495
				CleanupStack::PushL(record);
sl@0
   496
				
sl@0
   497
				if(iSetFlag & KSetClientSid)
sl@0
   498
					{
sl@0
   499
					if(record->iClientSid != TSecureId(iClientSid))
sl@0
   500
						{
sl@0
   501
						verified = EFalse;
sl@0
   502
						break;
sl@0
   503
						}
sl@0
   504
					}
sl@0
   505
				
sl@0
   506
				if(iSetFlag & KSetEvaluatorId)
sl@0
   507
					{
sl@0
   508
					if(record->iEvaluatorId != TUid::Uid(iEvaluatorId))
sl@0
   509
						{
sl@0
   510
						verified = EFalse;
sl@0
   511
						break;
sl@0
   512
						}
sl@0
   513
					}
sl@0
   514
				
sl@0
   515
				if(iSetFlag & KSetServiceId)
sl@0
   516
					{
sl@0
   517
					if(record->iServiceId != TUid::Uid(iServiceId))
sl@0
   518
						{
sl@0
   519
						verified = EFalse;
sl@0
   520
						break;
sl@0
   521
						}
sl@0
   522
					}
sl@0
   523
					
sl@0
   524
				if(iSetFlag & KSetServerSid)
sl@0
   525
					{
sl@0
   526
					if(record->iServerSid != TSecureId(iServerSid))
sl@0
   527
						{
sl@0
   528
						verified = EFalse;
sl@0
   529
						break;
sl@0
   530
						}
sl@0
   531
					}
sl@0
   532
				
sl@0
   533
				if(iSetFlag & KSetFingerprint)
sl@0
   534
					{
sl@0
   535
					if(record->iFingerprint.Compare(iFingerprint))
sl@0
   536
						{
sl@0
   537
						verified = EFalse;
sl@0
   538
						break;
sl@0
   539
						}
sl@0
   540
					}
sl@0
   541
				
sl@0
   542
				if(iSetFlag & KSetClientEntity)
sl@0
   543
					{
sl@0
   544
					if(record->iClientEntity.Compare(iClientEntity))
sl@0
   545
						{
sl@0
   546
						verified = EFalse;
sl@0
   547
						break;
sl@0
   548
						}
sl@0
   549
					}
sl@0
   550
				
sl@0
   551
				if(iSetFlag & KSetDescription)
sl@0
   552
					{
sl@0
   553
					if(record->iDescription.Compare(iDescription))
sl@0
   554
						{
sl@0
   555
						verified = EFalse;
sl@0
   556
						break;
sl@0
   557
						}
sl@0
   558
					}
sl@0
   559
				
sl@0
   560
				if(iSetFlag & KSetResult)
sl@0
   561
					{
sl@0
   562
					if(record->iResult != iResult)
sl@0
   563
						{
sl@0
   564
						verified = EFalse;
sl@0
   565
						break;
sl@0
   566
						}
sl@0
   567
					}
sl@0
   568
				
sl@0
   569
				if(iSetFlag & KSetEvaluatorInfo)
sl@0
   570
					{
sl@0
   571
					if(record->iEvaluatorInfo != iEvaluatorInfo)
sl@0
   572
						{
sl@0
   573
						verified = EFalse;
sl@0
   574
						break;
sl@0
   575
						}
sl@0
   576
					}
sl@0
   577
				
sl@0
   578
				if(iSetFlag & KSetMajorPolicyVersion)
sl@0
   579
					{
sl@0
   580
					if(record->iMajorPolicyVersion != iMajorPolicyVersion)
sl@0
   581
						{
sl@0
   582
						verified = EFalse;
sl@0
   583
						break;
sl@0
   584
						}
sl@0
   585
					}
sl@0
   586
				
sl@0
   587
				if(iSetFlag & KSetRecordId)
sl@0
   588
					{
sl@0
   589
					if(record->iRecordId != iRecordId)
sl@0
   590
						{
sl@0
   591
						verified = EFalse;
sl@0
   592
						break;
sl@0
   593
						}
sl@0
   594
					}
sl@0
   595
						
sl@0
   596
				CleanupStack::PopAndDestroy(record);						
sl@0
   597
				}//while
sl@0
   598
			
sl@0
   599
			
sl@0
   600
			if(verified == EFalse)
sl@0
   601
				{
sl@0
   602
				ERR_PRINTF1(_L("Retrieved record(s) is(are) different from the supplied one"));
sl@0
   603
				SetTestStepResult(EFail);
sl@0
   604
				CleanupStack::PopAndDestroy(record);
sl@0
   605
				}
sl@0
   606
			else
sl@0
   607
				{
sl@0
   608
				INFO_PRINTF1(_L("Retrieved record(s) have been verified successfully"));
sl@0
   609
				}
sl@0
   610
				
sl@0
   611
			CloseDecisionFile();
sl@0
   612
			
sl@0
   613
			break;
sl@0
   614
			}
sl@0
   615
		
sl@0
   616
		case EFillTable:
sl@0
   617
			{
sl@0
   618
			TBuf<KUpsDescriptionLength> keyNotFound;
sl@0
   619
			ReadConfigurationFile(keyNotFound);
sl@0
   620
			TInt len = keyNotFound.Length();
sl@0
   621
			if(len > 0)
sl@0
   622
    			{
sl@0
   623
    			//if more than one keys could not read or retrieve_num is not in the list
sl@0
   624
    			if((len > 13) || (keyNotFound.Find(KRetrieveNum) == KErrNotFound))
sl@0
   625
    				{
sl@0
   626
    				ERR_PRINTF2(_L("Failed to read '%S' key of configuration"),&keyNotFound);
sl@0
   627
    				SetTestStepResult(EFail);
sl@0
   628
    				User::Leave(KErrNotFound);
sl@0
   629
    				}	
sl@0
   630
    			}
sl@0
   631
    		//Connect to the decision database
sl@0
   632
			CDecisionDbW* upsDb = CreateDatabaseLC(iDbLocation,iFs);
sl@0
   633
	
sl@0
   634
			//Fill the table with a specified number of decision records	
sl@0
   635
			FillTableL(*upsDb,iRecordNum,iClientNum,iServiceNum,iServerNum,iEvaluatorNum);
sl@0
   636
			
sl@0
   637
			//Disconnect
sl@0
   638
			CleanupStack::PopAndDestroy(upsDb);
sl@0
   639
			break;
sl@0
   640
			}
sl@0
   641
		
sl@0
   642
		case EAllFingerprints:
sl@0
   643
			{
sl@0
   644
			//Connect to the decision database
sl@0
   645
			CDecisionDbW* upsDb = CreateDatabaseLC(iDbLocation,iFs);
sl@0
   646
			TestFingerprintValuesL(*upsDb);
sl@0
   647
			//Disconnect
sl@0
   648
			CleanupStack::PopAndDestroy(upsDb);
sl@0
   649
			break;
sl@0
   650
			}
sl@0
   651
		
sl@0
   652
		case ECompact:
sl@0
   653
			{
sl@0
   654
			ReadDecisionFieldsL(ETrue);
sl@0
   655
			//Connect to the decision database
sl@0
   656
			CDecisionDbW* upsDb = CreateDatabaseLC(iDbLocation,iFs);
sl@0
   657
			CompactDatabaseL(*upsDb,iCancel);
sl@0
   658
			//Disconnect
sl@0
   659
			CleanupStack::PopAndDestroy(upsDb);
sl@0
   660
			break;
sl@0
   661
			}
sl@0
   662
		
sl@0
   663
		case EUpdate:
sl@0
   664
			{
sl@0
   665
			//Open the decision file containing the record which will be updated
sl@0
   666
			OpenDecisionFileL(EFileRead);
sl@0
   667
			//Read the record	
sl@0
   668
			record = ReadDecisionL();
sl@0
   669
			//Close the decision file
sl@0
   670
			CloseDecisionFile();
sl@0
   671
			//If we could not read the record, the test step fails
sl@0
   672
			if(!record)
sl@0
   673
				{
sl@0
   674
				SetTestStepResult(EFail);
sl@0
   675
				break;
sl@0
   676
				}
sl@0
   677
			CleanupStack::PushL(record);
sl@0
   678
			
sl@0
   679
			//Create filter from the record which has been read from the decision file
sl@0
   680
			TInt flag = (KSetClientSid|KSetEvaluatorId|KSetServiceId|KSetServerSid|KSetFingerprint|KSetClientEntity|KSetMajorPolicyVersion);
sl@0
   681
			filter = CreateFilterL(flag,record->iClientSid.iId,record->iEvaluatorId.iUid,record->iServiceId.iUid,record->iServerSid.iId,record->iFingerprint,record->iClientEntity,record->iMajorPolicyVersion,record->iRecordId,iDescription,iResult,iEvaluatorInfo,iComparison);
sl@0
   682
			CleanupStack::PushL(filter);
sl@0
   683
			
sl@0
   684
			//Create a new file
sl@0
   685
			ReadDecisionFieldsL(ETrue);
sl@0
   686
			//Create a new record from the values in the configuration file
sl@0
   687
			CDecisionRecord *newRecord = CreateRecordL(iClientSid,iEvaluatorId,iServiceId,iServerSid,iFingerprint,iClientEntity,iDescription,iResult,iMajorPolicyVersion,iEvaluatorInfo,iRecordId);
sl@0
   688
			CleanupStack::PushL(newRecord);
sl@0
   689
										
sl@0
   690
			//Connect to the decision database
sl@0
   691
			CDecisionDbW* upsDb = CreateDatabaseLC(iDbLocation,iFs);
sl@0
   692
			//Update the record
sl@0
   693
			UpdateRecordL(*upsDb, *filter, *newRecord);
sl@0
   694
			
sl@0
   695
			CleanupStack::PopAndDestroy(4, record);
sl@0
   696
			
sl@0
   697
			break;
sl@0
   698
			}
sl@0
   699
			
sl@0
   700
		case ENotSupported:
sl@0
   701
			{
sl@0
   702
			ERR_PRINTF1(_L("The provided key is not supported!"));
sl@0
   703
			SetTestStepResult(EFail);
sl@0
   704
			break;
sl@0
   705
			}
sl@0
   706
		}
sl@0
   707
		
sl@0
   708
	CleanupStack::PopAndDestroy(2); //Pop RBufs	
sl@0
   709
	return TestStepResult();
sl@0
   710
	}
sl@0
   711
sl@0
   712
sl@0
   713
TVerdict CUpsDbStepUnitTest::doOOMTestL()
sl@0
   714
/**
sl@0
   715
	Performs OOM test
sl@0
   716
 */
sl@0
   717
	{
sl@0
   718
	TVerdict verdict = EFail;
sl@0
   719
 	TInt countAfter = 0;
sl@0
   720
	TInt countBefore = 0;
sl@0
   721
 	for (TInt oomCount = 0; ; oomCount++)
sl@0
   722
 		{
sl@0
   723
 		INFO_PRINTF2(_L("\n ==== Number of memory allocations %d ===="), oomCount);
sl@0
   724
 		verdict = EFail;
sl@0
   725
 		__UHEAP_RESET;
sl@0
   726
 		__UHEAP_SETFAIL(RHeap::EDeterministic, oomCount);
sl@0
   727
 		countBefore = User::CountAllocCells();
sl@0
   728
 		TRAPD(error, doTestL());// ----> This is the actual test that runs under OOM conditions.
sl@0
   729
 		countAfter = User::CountAllocCells();
sl@0
   730
 		__UHEAP_RESET;
sl@0
   731
 		
sl@0
   732
 		TESTL(error == KErrNone || error == KErrNoMemory);
sl@0
   733
 		
sl@0
   734
 		if (error == KErrNone)
sl@0
   735
 			{
sl@0
   736
 			verdict = EPass;
sl@0
   737
 			INFO_PRINTF2(_L("OOM Status %d"),error);
sl@0
   738
			INFO_PRINTF1(_L("Test outcome : Passed"));
sl@0
   739
  			break;
sl@0
   740
 			}
sl@0
   741
 		else
sl@0
   742
 			{
sl@0
   743
 			if (countBefore != countAfter)
sl@0
   744
 				{
sl@0
   745
 				INFO_PRINTF2(_L("OOM Status %d"),error);
sl@0
   746
 				INFO_PRINTF2(_L("OOM Failed at %d"), oomCount);
sl@0
   747
 				SetTestStepResult(verdict);  
sl@0
   748
 				break;
sl@0
   749
 				}
sl@0
   750
 			}
sl@0
   751
 		INFO_PRINTF2(_L("OOM Failed Point status %d"), error);
sl@0
   752
		}
sl@0
   753
	INFO_PRINTF3(_L("Heap alloc count ok: %d final vs %d initial"), countAfter,countBefore);
sl@0
   754
 	SetTestStepResult(verdict);
sl@0
   755
 	if (verdict==EFail)
sl@0
   756
	 	{
sl@0
   757
 		User::Leave(KErrGeneral);	 		
sl@0
   758
	 	}	 	
sl@0
   759
 	return verdict;
sl@0
   760
	}
sl@0
   761
	
sl@0
   762
	
sl@0
   763
TVerdict CUpsDbStepUnitTest::doTestStepPostambleL()
sl@0
   764
/**
sl@0
   765
	Runs at the end of the step. Do nothing.
sl@0
   766
 */
sl@0
   767
	{
sl@0
   768
	iFs.Close();
sl@0
   769
	return TestStepResult();
sl@0
   770
	}
sl@0
   771
sl@0
   772
sl@0
   773
void CUpsDbStepUnitTest::ReadDecisionFieldsL(TBool aHash)
sl@0
   774
/**
sl@0
   775
	Reads the fileds required to create a decision record or filter.
sl@0
   776
	
sl@0
   777
	@param aHash Hashes fingerprint and client entity values if ETrue.
sl@0
   778
 */
sl@0
   779
	{
sl@0
   780
	if(GetHexFromConfig(ConfigSection(),KColClientSid,iClientSid))
sl@0
   781
		{
sl@0
   782
		iSetFlag |= KSetClientSid;
sl@0
   783
		}
sl@0
   784
		
sl@0
   785
	if(GetHexFromConfig(ConfigSection(),KColEvaluatorId,iEvaluatorId))
sl@0
   786
		{
sl@0
   787
		iSetFlag |= KSetEvaluatorId;
sl@0
   788
		}
sl@0
   789
		
sl@0
   790
	if(GetHexFromConfig(ConfigSection(),KColServiceId,iServiceId))
sl@0
   791
		{
sl@0
   792
		iSetFlag |= KSetServiceId;
sl@0
   793
		}
sl@0
   794
		
sl@0
   795
	if(GetHexFromConfig(ConfigSection(),KColServerSid,iServerSid))
sl@0
   796
		{
sl@0
   797
		iSetFlag |= KSetServerSid;
sl@0
   798
		}
sl@0
   799
		
sl@0
   800
	TPtrC string; //16-bit temporary pointer
sl@0
   801
	CMD5 *md5 = CMD5::NewL();
sl@0
   802
	CleanupStack::PushL(md5);
sl@0
   803
		
sl@0
   804
	if(GetStringFromConfig(ConfigSection(),KColFingerprint,string))
sl@0
   805
		{
sl@0
   806
		if(string.Length() > 0)
sl@0
   807
			{
sl@0
   808
			//Copy to convert 16-bit to 8-bit
sl@0
   809
			iFingerprint.CreateL(string.Length()*2);
sl@0
   810
			iFingerprint.Copy(string);
sl@0
   811
			if(aHash)
sl@0
   812
				{
sl@0
   813
				TPtrC8 hashed = md5->Hash(iFingerprint);
sl@0
   814
				if(string.Length()*2 < hashed.Length())
sl@0
   815
					{
sl@0
   816
					iFingerprint.ReAlloc(hashed.Length());
sl@0
   817
					}
sl@0
   818
				iFingerprint.Copy(hashed);
sl@0
   819
				md5->Reset();
sl@0
   820
				}
sl@0
   821
			}
sl@0
   822
		iSetFlag |= KSetFingerprint;
sl@0
   823
		}
sl@0
   824
			
sl@0
   825
	if(GetStringFromConfig(ConfigSection(),KColClientEntity,string))
sl@0
   826
		{
sl@0
   827
		if(string.Length() > 0)
sl@0
   828
			{
sl@0
   829
			//Copy to convert 16-bit to 8-bit
sl@0
   830
			iClientEntity.CreateL(string.Length()*2);
sl@0
   831
			iClientEntity.Copy(string);
sl@0
   832
			if(aHash)
sl@0
   833
				{
sl@0
   834
				TPtrC8 hashed = md5->Hash(iClientEntity);
sl@0
   835
				if(string.Length()*2 < hashed.Length())
sl@0
   836
					{
sl@0
   837
					iClientEntity.ReAlloc(hashed.Length());
sl@0
   838
					}
sl@0
   839
				iClientEntity.Copy(hashed);
sl@0
   840
				}
sl@0
   841
			}
sl@0
   842
		iSetFlag |= KSetClientEntity;
sl@0
   843
		}
sl@0
   844
	
sl@0
   845
	CleanupStack::PopAndDestroy(md5);
sl@0
   846
	
sl@0
   847
	if(GetStringFromConfig(ConfigSection(),KColDescription,iDescription))
sl@0
   848
		{
sl@0
   849
		iSetFlag |= KSetDescription;	
sl@0
   850
		}
sl@0
   851
	
sl@0
   852
	if(GetIntFromConfig(ConfigSection(),KColResult,iResult))
sl@0
   853
		{
sl@0
   854
		iSetFlag |= KSetResult;	
sl@0
   855
		}
sl@0
   856
					
sl@0
   857
	if(GetIntFromConfig(ConfigSection(),KColEvaluatorInfo,iEvaluatorInfo))
sl@0
   858
		{
sl@0
   859
		iSetFlag |= KSetEvaluatorInfo;	
sl@0
   860
		}
sl@0
   861
	
sl@0
   862
	if(GetIntFromConfig(ConfigSection(),KColMajorPolicyVersion,iMajorPolicyVersion))
sl@0
   863
		{
sl@0
   864
		iSetFlag |= KSetMajorPolicyVersion;
sl@0
   865
		}
sl@0
   866
	
sl@0
   867
	if(GetIntFromConfig(ConfigSection(),KColRecordId,iRecordId))
sl@0
   868
		{
sl@0
   869
		iSetFlag |= KSetRecordId;
sl@0
   870
		}
sl@0
   871
	
sl@0
   872
	TInt compOp;
sl@0
   873
	if(GetHexFromConfig(ConfigSection(),KComparison,compOp))
sl@0
   874
		{
sl@0
   875
		iComparison = static_cast<TComparisonOp>(compOp);
sl@0
   876
		}		
sl@0
   877
	
sl@0
   878
	GetIntFromConfig(ConfigSection(),KCancel,iCancel);
sl@0
   879
	}
sl@0
   880
sl@0
   881
sl@0
   882
void CUpsDbStepUnitTest::OpenDecisionFileL(TFileMode aMode)
sl@0
   883
/**
sl@0
   884
	Opens a log file which is used to write/read decision records.
sl@0
   885
	@param aMode File open mode. If EFileWrite, the existed file is replaced with new one.
sl@0
   886
 */
sl@0
   887
	{
sl@0
   888
	//The file server connection will be closed in the destructor
sl@0
   889
	User::LeaveIfError(iFs.CreatePrivatePath(EDriveC));
sl@0
   890
	
sl@0
   891
	User::LeaveIfError(iFs.PrivatePath(iDecisionFileName));
sl@0
   892
	iDecisionFileName.Append(KDecisionFileName);
sl@0
   893
	
sl@0
   894
	if((aMode & EFileWrite)== EFileWrite)
sl@0
   895
		{
sl@0
   896
		User::LeaveIfError(iFileWriteStream.Replace(iFs,iDecisionFileName,aMode));
sl@0
   897
		}
sl@0
   898
	else if((aMode & EFileRead)== EFileRead)
sl@0
   899
		{
sl@0
   900
		User::LeaveIfError(iFileReadStream.Open(iFs,iDecisionFileName,aMode));
sl@0
   901
		}
sl@0
   902
	//Note that the streams will be closed in the destructor
sl@0
   903
	}
sl@0
   904
sl@0
   905
void CUpsDbStepUnitTest::WriteDecisionL(CDecisionRecord &aRecord)
sl@0
   906
/**
sl@0
   907
	Writes a provided decision into the decision log file. This file is then used
sl@0
   908
	to verify the written records.
sl@0
   909
 */
sl@0
   910
	{
sl@0
   911
	iFileWriteStream.WriteInt32L(aRecord.iClientSid.iId);
sl@0
   912
	iFileWriteStream.WriteInt32L(aRecord.iEvaluatorId.iUid);
sl@0
   913
	iFileWriteStream.WriteInt32L(aRecord.iServiceId.iUid);
sl@0
   914
	iFileWriteStream.WriteInt32L(aRecord.iServerSid.iId);
sl@0
   915
	iFileWriteStream.WriteUint8L(aRecord.iResult);
sl@0
   916
	iFileWriteStream.WriteUint32L(aRecord.iEvaluatorInfo);
sl@0
   917
	iFileWriteStream.WriteUint16L(aRecord.iMajorPolicyVersion);
sl@0
   918
	iFileWriteStream.WriteUint32L(aRecord.iRecordId);
sl@0
   919
	
sl@0
   920
	iFileWriteStream.WriteInt16L(aRecord.iFingerprint.Length());
sl@0
   921
	iFileWriteStream.WriteL(aRecord.iFingerprint);
sl@0
   922
	
sl@0
   923
	if(aRecord.iClientEntity.Length())
sl@0
   924
		{
sl@0
   925
		iFileWriteStream.WriteInt16L(aRecord.iClientEntity.Length());
sl@0
   926
		iFileWriteStream.WriteL(aRecord.iClientEntity);
sl@0
   927
		}
sl@0
   928
	else
sl@0
   929
		{
sl@0
   930
		iFileWriteStream.WriteInt16L(4);
sl@0
   931
		iFileWriteStream.WriteL(_L8("NULL"));	
sl@0
   932
		}
sl@0
   933
	
sl@0
   934
	if(aRecord.iDescription.Length())
sl@0
   935
		{
sl@0
   936
		iFileWriteStream.WriteInt16L(aRecord.iDescription.Length());
sl@0
   937
		iFileWriteStream.WriteL(aRecord.iDescription);
sl@0
   938
		}
sl@0
   939
	else
sl@0
   940
		{
sl@0
   941
		iFileWriteStream.WriteInt16L(4);
sl@0
   942
		iFileWriteStream.WriteL(_L("NULL"));
sl@0
   943
		}
sl@0
   944
	
sl@0
   945
	iFileWriteStream.CommitL();
sl@0
   946
	}
sl@0
   947
	
sl@0
   948
	
sl@0
   949
CDecisionRecord *CUpsDbStepUnitTest::ReadDecisionL()
sl@0
   950
/**
sl@0
   951
	Reads and returns a decision record from the log file. If reaches the file end, returns NULL.
sl@0
   952
	The records retrieved from the log file are compared with the records defined in the configuration file.
sl@0
   953
 */
sl@0
   954
	{	
sl@0
   955
	
sl@0
   956
	TBuf8<KDbMaxName> fingerPrint;
sl@0
   957
	TBuf8<KDbMaxName> clientEntity;
sl@0
   958
	TBuf<KDbMaxName> description;
sl@0
   959
	TInt len;
sl@0
   960
	CDecisionRecord *record = NULL;
sl@0
   961
	
sl@0
   962
	TStreamPos currentPosition = iFileReadStream.Source()->TellL(MStreamBuf::ERead);
sl@0
   963
	TStreamPos endPosition = iFileReadStream.Source()->SeekL(MStreamBuf::ERead,EStreamEnd);
sl@0
   964
	
sl@0
   965
	if(currentPosition == endPosition)
sl@0
   966
		{
sl@0
   967
		INFO_PRINTF1(_L("Reached to the end of the decision file"));
sl@0
   968
		return record;
sl@0
   969
		}
sl@0
   970
			
sl@0
   971
	iFileReadStream.Source()->SeekL(MStreamBuf::ERead,currentPosition);
sl@0
   972
	CleanupClosePushL(iFileReadStream);//In first read a byte is allocated inside the stream, so push it
sl@0
   973
	TInt32  clientId 	  		= iFileReadStream.ReadInt32L();
sl@0
   974
	TInt32  evaluatorId   		= iFileReadStream.ReadInt32L();
sl@0
   975
	TInt32  serviceId 	  		= iFileReadStream.ReadInt32L();
sl@0
   976
	TInt32  serverId	  		= iFileReadStream.ReadInt32L();
sl@0
   977
	TUint8  result		  		= iFileReadStream.ReadUint8L();
sl@0
   978
	TUint32 evaluatorInfo 		= iFileReadStream.ReadUint32L();
sl@0
   979
	TUint16 policyMajorVersion 	= iFileReadStream.ReadUint16L();
sl@0
   980
	TUint32 recordId 	  		= iFileReadStream.ReadUint32L();
sl@0
   981
	
sl@0
   982
	len = iFileReadStream.ReadInt16L();
sl@0
   983
	iFileReadStream.ReadL(fingerPrint,len);
sl@0
   984
	len = iFileReadStream.ReadInt16L();
sl@0
   985
	iFileReadStream.ReadL(clientEntity,len);
sl@0
   986
	len = iFileReadStream.ReadInt16L();
sl@0
   987
	iFileReadStream.ReadL(description,len);
sl@0
   988
	
sl@0
   989
	if(!clientEntity.Compare(_L8("NULL")))
sl@0
   990
		{
sl@0
   991
		clientEntity.SetLength(0);
sl@0
   992
		}
sl@0
   993
		
sl@0
   994
	if(!description.Compare(_L("NULL")))
sl@0
   995
		{
sl@0
   996
		description.SetLength(0);
sl@0
   997
		}
sl@0
   998
	
sl@0
   999
	//Create a decision record from readings
sl@0
  1000
	record = CreateRecordL((TInt)clientId,(TInt)evaluatorId,(TInt)serviceId,(TInt)serverId,fingerPrint,clientEntity,description,(TInt)result,(TInt)policyMajorVersion,(TInt)evaluatorInfo,(TInt)recordId);
sl@0
  1001
	CleanupStack::Pop(&iFileReadStream);	
sl@0
  1002
	return record;
sl@0
  1003
	}
sl@0
  1004
	
sl@0
  1005
void CUpsDbStepUnitTest::CloseDecisionFile()
sl@0
  1006
/**
sl@0
  1007
	Closes the file server session and read/write stream objects
sl@0
  1008
 */
sl@0
  1009
	{
sl@0
  1010
	iFileReadStream.Close();
sl@0
  1011
	iFileWriteStream.Close();
sl@0
  1012
	}
sl@0
  1013