/** add agent field to contact b. set value of agent to contact a. export contacts a & b. check access count for a & b(should be 0), check value of agent(should equal b) open contact b, delete all fields. commit. import contacts a and b. check that agent field is not imported. */ void CAccessCountTests::AgentExportImportAccessTestL() { const TContactItemId KFirstContactId = iIterate->NextL();//contact a const TContactItemId KSecondContactId = iIterate->NextL();//contact b //open contact a and populate all fields OpenL(KFirstContactId, *iViewAll); SetContactFieldsL(*iContactItem); CommitL(); //open contact b OpenL(KSecondContactId,*iViewAll); //populate all fields SetContactFieldsL(*iContactItem); //add contact a id as an agent field value AddAgentFieldL(KFirstContactId); CommitL(); CContactIdArray *ArrayOfExportedContactIds = CContactIdArray::NewLC(); //set contact a and b to be export ArrayOfExportedContactIds->AddL(KFirstContactId); ArrayOfExportedContactIds->AddL(KSecondContactId); //export contact a & b ExportVcardL(*ArrayOfExportedContactIds); const TInt KFirstContactAccessCountAfterExport = GetAccessCountL(KFirstContactId); const TInt KSecondContactAccessCountAfterExport = GetAccessCountL(KSecondContactId); const TInt KSecondContactAgentFieldAfterExport = GetAgentFieldL(KSecondContactId); CleanupStack::PopAndDestroy(ArrayOfExportedContactIds); //delete all fields from contact b OpenL(KSecondContactId,*iViewAll); iFields->Reset(); CommitL(); //import exported contacts ImportVcardL(); const TInt KFirstContactAccessCountAfterImport = GetAccessCountL(KFirstContactId); const TInt KSecondContactAccessCountAfterImport = GetAccessCountL(KSecondContactId); const TContactItemId KSecondContactAgentFieldAfterImport = GetAgentFieldL(KSecondContactId); //importing & exporting contacts should not affect the access count INTCOMPARE( KFirstContactAccessCountAfterExport , ==, 0, 0, 0 ); INTCOMPARE( KSecondContactAccessCountAfterExport , ==, 0, 0, 0 ); INTCOMPARE( KFirstContactAccessCountAfterExport , ==, KFirstContactAccessCountAfterImport, 0, 0 ); INTCOMPARE( KSecondContactAccessCountAfterExport , ==, KSecondContactAccessCountAfterImport, 0, 0 ); //agent field values should not be exported/imported INTCOMPARE( KFirstContactId , ==, KSecondContactAgentFieldAfterImport, 0, 0 ); //exporting contacts should not affect the internal state of the contacts agent field INTCOMPARE( KSecondContactAgentFieldAfterExport , ==, KFirstContactId, 0, 0 ); iParent->Fs().Delete(KVcardFile);//cleanup of exported vcard file }
void CTransactionsStep::TransactionPerformanceL( const TBool aDelete, const FieldFullness aField, const TInt aContacts, TReal &aDiffseconds, TReal &aCumseconds) { iContacts = ( ( aContacts / KTransactionSize ) + 1 ) * KTransactionSize ; TInt64 cumlative = 0; TInt64 diff = 0; TTime startT; TTime finishT; TTime start; TTime finish; TInt j = 0; for(; j < KPerfIter; ++j) { CPerformanceFunctionalityBase::InitializeL(); ModifyContactsL(aField); ExportVcardL( aDelete, KVcardFile ); RFileReadStream rfrs; CleanupClosePushL( rfrs ); User::LeaveIfError( rfrs.Open( iParent->Fs(), KVcardFile, EFileRead | EFileShareAny ) ); TInt i = 0; start.UniversalTime(); for(; i < iContacts; i+=KTransactionSize) { iContactsDatabase->DatabaseBeginLC(EFalse); ImportVcardL(KTransactionSize, rfrs); startT.UniversalTime(); iContactsDatabase->DatabaseCommitLP(EFalse); finishT.UniversalTime(); cumlative += ( finishT.MicroSecondsFrom( startT ).Int64() ); } finish.UniversalTime(); diff += ( finish.MicroSecondsFrom(start).Int64() ); CleanupStack::PopAndDestroy(&rfrs); } User::LeaveIfError( iParent->Fs().Delete(KVcardFile) ); aDiffseconds = (TReal) diff / (1000000 * KPerfIter); aCumseconds = (TReal) cumlative / (1000000 * KPerfIter); _LIT(KMicroPerformance, "Micro performance: %d"); _LIT(KSecondsPerformance, "performance in seconds: %f"); _LIT(KCommitPerformance, "commit performance in seconds: %f"); ALLPRINT2(KMicroPerformance, diff); ALLPRINT2(KSecondsPerformance, aDiffseconds ); ALLPRINT2(KCommitPerformance, aCumseconds ); }