sl@0: /* sl@0: * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #ifndef TUPSDBSTEP_H sl@0: #define TUPSDBSTEP_H sl@0: sl@0: #include "tupsdb.h" sl@0: #include "activewaiter.h" sl@0: #include "upsdbw.h" sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "upscommon.h" sl@0: #include sl@0: sl@0: using namespace UserPromptService; sl@0: sl@0: _LIT8(KFingerprint, "FingerprintABCDEFGHIJKLMNOPR%d"); sl@0: _LIT8(KClientEntity,"ClientEntityABCDEFGHIJKLMNOP%d"); sl@0: _LIT(KDescription, "DestinationABCDEFGHIJKLMNOPRSVWXYZ0123456789%d"); sl@0: _LIT(KDbName, "tupsdecisions.db"); sl@0: _LIT(KLogName, "tperfomance.log"); sl@0: sl@0: //Constants for performance test sl@0: _LIT(KServerNum, "server_num"); sl@0: _LIT(KServiceNum, "service_num"); sl@0: _LIT(KClientNum, "client_num"); sl@0: _LIT(KEvaluatorNum, "evaluator_num"); sl@0: _LIT(KRecordNum, "records_num"); sl@0: _LIT(KRetrieveNum, "retrieve_num"); sl@0: sl@0: //Constants for unit tests sl@0: _LIT(KOpType, "OperationType"); sl@0: _LIT(KCreateDatabase,"CreateDatabase"); sl@0: _LIT(KDeleteDatabase,"DeleteDatabase"); sl@0: _LIT(KCreateFilterSingleCall, "CreateFilterSingleCall"); sl@0: _LIT(KCreateFilterMultipleCalls, "CreateFilterMultipleCalls"); sl@0: _LIT(KCreateDecision, "CreateDecision"); sl@0: _LIT(KInsertRecord, "Insert"); sl@0: _LIT(KDeleteRecord, "Delete"); sl@0: _LIT(KSingleLookup, "SingleLookup"); sl@0: _LIT(KMultipleLookup, "MultipleLookup"); sl@0: _LIT(KVerifyRecord, "Verify"); sl@0: _LIT(KFillTable, "FillTable"); sl@0: _LIT(KAllFingerprints,"AllFingerprints"); sl@0: _LIT(KCompactDatabase,"Compact"); sl@0: _LIT(KUpdateRecord, "Update"); sl@0: sl@0: sl@0: _LIT(KDbLocation, "DatabaseLocation"); sl@0: _LIT(KExpectedResult, "ExpectedResult"); sl@0: _LIT(KExpectedRecords,"ExpectedRecords"); sl@0: _LIT(KOOMCondition, "OOMCondition"); sl@0: _LIT(KComparison, "ComparisonOp"); sl@0: _LIT(KCancel, "Cancel"); sl@0: sl@0: _LIT(KStepPerformance, "MeasurePerformance"); sl@0: _LIT(KStepUnitTest, "RunUpsDbUnitTest"); sl@0: _LIT(KDecisionFileName,"decisions.dat"); sl@0: sl@0: //Errors sl@0: _LIT(KStrErrNone, "KErrNone"); sl@0: _LIT(KStrErrUpsBadFingerprintLength, "KErrUpsBadFingerprintLength"); sl@0: _LIT(KStrErrUpsMissingArgument, "KErrUpsMissingArgument"); sl@0: _LIT(KStrErrUpsBadClientEntityLength,"KErrUpsBadClientEntityLength"); sl@0: _LIT(KStrErrUpsBadDescriptionLength, "KErrUpsBadDescriptionLength"); sl@0: sl@0: const TInt KMd5Length = 0x10; sl@0: sl@0: static const TInt KUpsDescriptionLength = 255; sl@0: sl@0: class CUpsDbBaseStep : public CTestStep sl@0: /** sl@0: Implements handy functions used for testing decision database. sl@0: */ sl@0: { sl@0: protected: sl@0: CUpsDbBaseStep(); sl@0: ~CUpsDbBaseStep(); sl@0: //Start a timer sl@0: void StartTimer(TTime &aTime); sl@0: sl@0: //Stops the timer and returns the elapsed time sl@0: void StopTimer(TTime &aStartTime, TInt64 &aElapsedTime); sl@0: sl@0: //Fill the decision table with a specified number of sample decision records sl@0: void FillTableL(CDecisionDbW &aUpsDb, TInt aRecordNum, TInt aClientNum, TInt aServiceNum, TInt aServerNum, TInt aEvaluatorNum); sl@0: sl@0: //Create a writable decision database object sl@0: CDecisionDbW* CreateDatabaseLC(TDesC &aDbLocation, RFs& aFs); sl@0: sl@0: //Get a decision record from the database sl@0: CDecisionRecord *GetDecisionLC(CDecisionDbW &aUpsDb, CDecisionFilter &aFilter); sl@0: sl@0: //Get a set of decision records from the database sl@0: void GetDecisionsL(CDecisionDbW &aUpsDb, CDecisionFilter &aFilter, TBool aCancel, RPointerArray& aRecordList); sl@0: sl@0: //Delete a set of records sl@0: void RemoveDecisionsL(CDecisionDbW &aUpsDb, CDecisionFilter &aFilter); sl@0: sl@0: //Delete all records sl@0: void RemoveAllDecisionsL(CDecisionDbW &aUpsDb, RFs& aFs); sl@0: sl@0: //Insert a record into the decision database sl@0: void InsertRecordL(CDecisionDbW &aUpsDb, CDecisionRecord &aRecord); sl@0: sl@0: //Creates a filter sl@0: 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); sl@0: 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); sl@0: sl@0: //Create a decision sl@0: CDecisionRecord *CreateRecordL(TInt aClientId, TInt aEvaluatorId, TInt aServiceId, TInt aServerId, TDesC8 &aFingerPrint, TDesC8 &aClientEntity, sl@0: TDesC &aDecription, TInt aResult, TInt aMajorPolicyVersion, TInt aEvaluatorInfo, TInt aRecordId); sl@0: sl@0: //Updates a decision record sl@0: void UpdateRecordL(CDecisionDbW& aUpsDb, CDecisionFilter& aFilter, CDecisionRecord& aRecord); sl@0: sl@0: //Creates a number of decision records by using all characters between 0x01 and 0xFF in Fingerprint value sl@0: void TestFingerprintValuesL(CDecisionDbW& aUpsDb); sl@0: sl@0: //Compacts decision database sl@0: void CompactDatabaseL(CDecisionDbW& aUpsDb, TBool aCancel); sl@0: sl@0: //Assigns member variables from configuration file sl@0: void ReadConfigurationFile(TDes &aKeyNotFound); sl@0: sl@0: //Converts error string to number sl@0: TInt ConvertNumber(TDesC& aError); sl@0: sl@0: private: sl@0: 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); sl@0: sl@0: protected: sl@0: TInt iRecordNum; sl@0: TInt iServerNum; sl@0: TInt iServiceNum; sl@0: TInt iClientNum; sl@0: TInt iEvaluatorNum; sl@0: TInt iRetrieveNum; sl@0: RFs iFs; sl@0: RFile iFile; sl@0: CActiveScheduler *iScheduler; sl@0: CActiveWaiter *iWaiter; sl@0: TBool iLog; sl@0: TBuf8<256> iBuffer; sl@0: }; sl@0: sl@0: class CUpsDbStepPerformance : public CUpsDbBaseStep sl@0: //Performs perfomance tests sl@0: { sl@0: public: sl@0: CUpsDbStepPerformance(); sl@0: ~CUpsDbStepPerformance(); sl@0: virtual TVerdict doTestStepPreambleL(); sl@0: virtual TVerdict doTestStepPostambleL(); sl@0: virtual TVerdict doTestStepL(); sl@0: sl@0: private: sl@0: void PrintHeader(); sl@0: sl@0: private: sl@0: TFileName iDbLocation; sl@0: TFileName iPerformanceLog; sl@0: }; sl@0: sl@0: class CUpsDbStepUnitTest : public CUpsDbBaseStep sl@0: //Performs all unit tests tests sl@0: { sl@0: public: sl@0: enum TUpsDbUnitTest sl@0: { sl@0: ENotSupported, //Requested operation is not supported sl@0: ECreateDatabase, //Create a new database sl@0: EDeleteDatabase, //Delete all records and the database sl@0: ECreateFilterSingleCall, //Creates a filter object with single call sl@0: ECreateFilterMultipleCalls, //Creates a filter object with multiple call sl@0: ECreateDecision, //Creates a decision record object sl@0: EInsertRecord, //Insert a number of decision sl@0: EDeleteRecord, //Delete a record from the decision database sl@0: ESingleLookup, //Lookup for single decision record sl@0: EMultipleLookup, //Lookup for multipe decision records sl@0: EVerifyRecord, //Verify the record read in previous operation sl@0: EFillTable, //Fill anumber of records into the decision table sl@0: EAllFingerprints, //Tries all binary values between 0-255 to create a fingerprint sl@0: ECompact, //Compact the decision database sl@0: EUpdate //Update the last retrieved record sl@0: }; sl@0: public: sl@0: CUpsDbStepUnitTest(); sl@0: ~CUpsDbStepUnitTest(); sl@0: virtual TVerdict doTestStepPreambleL(); sl@0: virtual TVerdict doTestStepPostambleL(); sl@0: virtual TVerdict doTestStepL(); sl@0: TVerdict doTestL(); sl@0: TVerdict doOOMTestL(); sl@0: sl@0: protected: sl@0: void ReadDecisionFieldsL(TBool aHash); sl@0: void OpenDecisionFileL(TFileMode aMode); sl@0: void WriteDecisionL(CDecisionRecord &aRecord); sl@0: CDecisionRecord *ReadDecisionL(); sl@0: void CloseDecisionFile(); sl@0: sl@0: protected: sl@0: TUpsDbUnitTest iOpType; sl@0: TPtrC iDbLocation; sl@0: sl@0: TInt iClientSid; sl@0: TInt iEvaluatorId; sl@0: TInt iServiceId; sl@0: TInt iServerSid; sl@0: RBuf8 iFingerprint; sl@0: RBuf8 iClientEntity; sl@0: TPtrC iDescription; sl@0: TInt iResult; sl@0: TInt iEvaluatorInfo; sl@0: TInt iMajorPolicyVersion; sl@0: TInt iRecordId; sl@0: TComparisonOp iComparison; sl@0: TInt iSetFlag; sl@0: TBool iOOMCondition; sl@0: TBool iCancel; sl@0: sl@0: TFileName iDecisionFileName; sl@0: RFileWriteStream iFileWriteStream; sl@0: RFileReadStream iFileReadStream; sl@0: }; sl@0: sl@0: #endif //TUPSDBSTEP_H