os/security/authorisation/userpromptservice/database/test/tupsdb/source/tupsdbstep.h
Update contrib.
2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
28 #include "activewaiter.h"
31 #include <test/testexecutelogger.h>
32 #include <test/tefunit.h>
34 #include "upscommon.h"
35 #include <scs/cleanuputils.h>
37 using namespace UserPromptService;
39 _LIT8(KFingerprint, "FingerprintABCDEFGHIJKLMNOPR%d");
40 _LIT8(KClientEntity,"ClientEntityABCDEFGHIJKLMNOP%d");
41 _LIT(KDescription, "DestinationABCDEFGHIJKLMNOPRSVWXYZ0123456789%d");
42 _LIT(KDbName, "tupsdecisions.db");
43 _LIT(KLogName, "tperfomance.log");
45 //Constants for performance test
46 _LIT(KServerNum, "server_num");
47 _LIT(KServiceNum, "service_num");
48 _LIT(KClientNum, "client_num");
49 _LIT(KEvaluatorNum, "evaluator_num");
50 _LIT(KRecordNum, "records_num");
51 _LIT(KRetrieveNum, "retrieve_num");
53 //Constants for unit tests
54 _LIT(KOpType, "OperationType");
55 _LIT(KCreateDatabase,"CreateDatabase");
56 _LIT(KDeleteDatabase,"DeleteDatabase");
57 _LIT(KCreateFilterSingleCall, "CreateFilterSingleCall");
58 _LIT(KCreateFilterMultipleCalls, "CreateFilterMultipleCalls");
59 _LIT(KCreateDecision, "CreateDecision");
60 _LIT(KInsertRecord, "Insert");
61 _LIT(KDeleteRecord, "Delete");
62 _LIT(KSingleLookup, "SingleLookup");
63 _LIT(KMultipleLookup, "MultipleLookup");
64 _LIT(KVerifyRecord, "Verify");
65 _LIT(KFillTable, "FillTable");
66 _LIT(KAllFingerprints,"AllFingerprints");
67 _LIT(KCompactDatabase,"Compact");
68 _LIT(KUpdateRecord, "Update");
71 _LIT(KDbLocation, "DatabaseLocation");
72 _LIT(KExpectedResult, "ExpectedResult");
73 _LIT(KExpectedRecords,"ExpectedRecords");
74 _LIT(KOOMCondition, "OOMCondition");
75 _LIT(KComparison, "ComparisonOp");
76 _LIT(KCancel, "Cancel");
78 _LIT(KStepPerformance, "MeasurePerformance");
79 _LIT(KStepUnitTest, "RunUpsDbUnitTest");
80 _LIT(KDecisionFileName,"decisions.dat");
83 _LIT(KStrErrNone, "KErrNone");
84 _LIT(KStrErrUpsBadFingerprintLength, "KErrUpsBadFingerprintLength");
85 _LIT(KStrErrUpsMissingArgument, "KErrUpsMissingArgument");
86 _LIT(KStrErrUpsBadClientEntityLength,"KErrUpsBadClientEntityLength");
87 _LIT(KStrErrUpsBadDescriptionLength, "KErrUpsBadDescriptionLength");
89 const TInt KMd5Length = 0x10;
91 static const TInt KUpsDescriptionLength = 255;
93 class CUpsDbBaseStep : public CTestStep
95 Implements handy functions used for testing decision database.
102 void StartTimer(TTime &aTime);
104 //Stops the timer and returns the elapsed time
105 void StopTimer(TTime &aStartTime, TInt64 &aElapsedTime);
107 //Fill the decision table with a specified number of sample decision records
108 void FillTableL(CDecisionDbW &aUpsDb, TInt aRecordNum, TInt aClientNum, TInt aServiceNum, TInt aServerNum, TInt aEvaluatorNum);
110 //Create a writable decision database object
111 CDecisionDbW* CreateDatabaseLC(TDesC &aDbLocation, RFs& aFs);
113 //Get a decision record from the database
114 CDecisionRecord *GetDecisionLC(CDecisionDbW &aUpsDb, CDecisionFilter &aFilter);
116 //Get a set of decision records from the database
117 void GetDecisionsL(CDecisionDbW &aUpsDb, CDecisionFilter &aFilter, TBool aCancel, RPointerArray<CDecisionRecord>& aRecordList);
119 //Delete a set of records
120 void RemoveDecisionsL(CDecisionDbW &aUpsDb, CDecisionFilter &aFilter);
123 void RemoveAllDecisionsL(CDecisionDbW &aUpsDb, RFs& aFs);
125 //Insert a record into the decision database
126 void InsertRecordL(CDecisionDbW &aUpsDb, CDecisionRecord &aRecord);
129 CDecisionFilter *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);
130 CDecisionFilter *CreateFilterLC(TInt aFlag, TInt aClientId, TInt aEvaluatorId, TInt aServiceId, TInt aServerId, TDesC8 &aFingerPrint, TDesC8& aClientEntity,TInt aMajorPolicyVersion, TInt aRecordId, TDesC& aDescription, TInt aResult, TInt aEvaluatorInfo, TComparisonOp aComparisonOp);
133 CDecisionRecord *CreateRecordL(TInt aClientId, TInt aEvaluatorId, TInt aServiceId, TInt aServerId, TDesC8 &aFingerPrint, TDesC8 &aClientEntity,
134 TDesC &aDecription, TInt aResult, TInt aMajorPolicyVersion, TInt aEvaluatorInfo, TInt aRecordId);
136 //Updates a decision record
137 void UpdateRecordL(CDecisionDbW& aUpsDb, CDecisionFilter& aFilter, CDecisionRecord& aRecord);
139 //Creates a number of decision records by using all characters between 0x01 and 0xFF in Fingerprint value
140 void TestFingerprintValuesL(CDecisionDbW& aUpsDb);
142 //Compacts decision database
143 void CompactDatabaseL(CDecisionDbW& aUpsDb, TBool aCancel);
145 //Assigns member variables from configuration file
146 void ReadConfigurationFile(TDes &aKeyNotFound);
148 //Converts error string to number
149 TInt ConvertNumber(TDesC& aError);
152 void SetFilterFiledsL(CDecisionFilter &aFilter, TInt aFlag, TInt aClientId, TInt aEvaluatorId, TInt aServiceId, TInt aServerId, TDesC8 &aFingerPrint, TDesC8& aClientEntity,TInt aMajorPolicyVersion, TInt aRecordId, TDesC& aDescription, TInt aResult, TInt aEvaluatorInfo, TComparisonOp aComparisonOp);
163 CActiveScheduler *iScheduler;
164 CActiveWaiter *iWaiter;
169 class CUpsDbStepPerformance : public CUpsDbBaseStep
170 //Performs perfomance tests
173 CUpsDbStepPerformance();
174 ~CUpsDbStepPerformance();
175 virtual TVerdict doTestStepPreambleL();
176 virtual TVerdict doTestStepPostambleL();
177 virtual TVerdict doTestStepL();
183 TFileName iDbLocation;
184 TFileName iPerformanceLog;
187 class CUpsDbStepUnitTest : public CUpsDbBaseStep
188 //Performs all unit tests tests
193 ENotSupported, //Requested operation is not supported
194 ECreateDatabase, //Create a new database
195 EDeleteDatabase, //Delete all records and the database
196 ECreateFilterSingleCall, //Creates a filter object with single call
197 ECreateFilterMultipleCalls, //Creates a filter object with multiple call
198 ECreateDecision, //Creates a decision record object
199 EInsertRecord, //Insert a number of decision
200 EDeleteRecord, //Delete a record from the decision database
201 ESingleLookup, //Lookup for single decision record
202 EMultipleLookup, //Lookup for multipe decision records
203 EVerifyRecord, //Verify the record read in previous operation
204 EFillTable, //Fill anumber of records into the decision table
205 EAllFingerprints, //Tries all binary values between 0-255 to create a fingerprint
206 ECompact, //Compact the decision database
207 EUpdate //Update the last retrieved record
210 CUpsDbStepUnitTest();
211 ~CUpsDbStepUnitTest();
212 virtual TVerdict doTestStepPreambleL();
213 virtual TVerdict doTestStepPostambleL();
214 virtual TVerdict doTestStepL();
216 TVerdict doOOMTestL();
219 void ReadDecisionFieldsL(TBool aHash);
220 void OpenDecisionFileL(TFileMode aMode);
221 void WriteDecisionL(CDecisionRecord &aRecord);
222 CDecisionRecord *ReadDecisionL();
223 void CloseDecisionFile();
226 TUpsDbUnitTest iOpType;
238 TInt iMajorPolicyVersion;
240 TComparisonOp iComparison;
245 TFileName iDecisionFileName;
246 RFileWriteStream iFileWriteStream;
247 RFileReadStream iFileReadStream;
250 #endif //TUPSDBSTEP_H