void CContactRemoteViewBase::ConstructL(MContactViewObserver& aObserver) /** Protected second phase constructor. Starts an active object which notifies this view (by calling its HandleContactViewEvent() function) when view events occur in the server side view. This remote view in turn passes the events to its observers. @capability ReadUserData @param aObserver An observer that receives notifications when this view is ready for use and when changes take place in it. The observer receives a TContactViewEvent::EReady event when the view is ready. An attempt to use the view before this notification causes a panic. */ { CContactViewBase::ConstructL(); OpenL(aObserver); iNotifier=new(ELeave) CContactRemoteViewNotifier(iView,TCallBack(NotifierCallBack,this)); iNotifier->Start(); }
void CNotificationStep::UnkownChangeTestL() { INFO_PRINTF1(KTest1); TContactItemId cid = iIterate->NextL(); TInt i = 0; for( ; i < KMaxNumberOfEventsInEventQueue + 10; ++i ) { OpenL( cid ); CommitL( EFalse ); } AddEventL( EContactDbObserverEventContactChanged ); AddContactL( cid ); AddEventL( EContactDbObserverEventUnknownChanges ); AddContactL( -1 ); iMyActive->iCheck = &CNotificationStep::UnkownChangeCheck; iMyActive->Activate(); iStart.UniversalTime(); CActiveScheduler::Start(); }
void CTransactionsStep::UpdateCommitTransactionTestL(const TBool aRevert) { CPerformanceFunctionalityBase::InitializeL(); const TContactItemId cid = iIterate->NextL(); const TContactItemId cid2 = iIterate->NextL(); iContactsDatabase->DatabaseBeginLC(EFalse); OpenL( cid ); SetAllFieldsL( GetNextFieldL(KStringFields, KField, ETrue) ); CommitL(ETrue); EndTransactionL(aRevert); iContactsDatabase->DatabaseBeginLC(EFalse); ReadL( cid2 ); SetAllFieldsL( GetNextFieldL(KStringFields, KField, EFalse) ); iContactsDatabase->UpdateContactLC(cid2, iContactItem); CleanupStack::PopAndDestroy(); CloseL( ETrue ); EndTransactionL(aRevert); if(aRevert) { iIterate->Reset(); TInt i = 0; for(; i < iContacts; ++i) { ReadL( iIterate->NextL() ); TESTPRINTI( CheckAllFieldsL(KNullDesC), i ); CloseL( ETrue ); } } else { ReadL( cid ); TESTPRINT( CheckAllFieldsL( GetNextFieldL(KStringFields, KField, ETrue) ) ); CloseL( ETrue ); ReadL( cid2 ); TESTPRINT( CheckAllFieldsL( GetNextFieldL(KStringFields, KField, EFalse) ) ); CloseL( ETrue ); } }
/** Protected second phase constructor. The view is sorted according to the sort order and view preferences specified, using a low priority idle time active object. The specified view observer is notified when the view is sorted and ready for use. Called by NewL(). @param aObserver An observer that receives notifications when this view is ready for use and when changes take place in it. The observer receives a TContactViewEvent::EReady event when the view is ready. Any attempt to use the view before this notification will Leave with KErrNotReady. @param aSortOrder Specifies the fields to use to sort the items in the view. @param aUseNamedPlugin A flag indicates whether the aSortPluginName parameter is valid. @param aSortPluginName Specifies a plug-in that will be used to compare view contacts when the the view is sorted. This name is used by ECOM to select the plugin, and is matched with the "default_data" of all ECOM plugins that support the required interface. */ void CContactLocalView::ConstructL(MContactViewObserver& aObserver,const RContactViewSortOrder& aSortOrder, TBool aUseNamedPlugin, const TDesC8& aSortPluginName) { CContactViewBase::ConstructL(); if(iFactory == NULL) { iFactory = const_cast<CContactDatabase&>(iDb).FactoryL(); } OpenL(aObserver); if (aUseNamedPlugin) { // find and load Sort plug-in if (aSortPluginName.Length()) { TUid sortPluginUid = FindSortPluginImplL (aSortPluginName); LoadViewSortPluginL(sortPluginUid, iViewPreferences); } } else { // find and load default Sort plug-in (if any) TUid sortPluginUid = FindDefaultViewSortPluginImplL(); if (sortPluginUid != KNullUid) { LoadViewSortPluginL(sortPluginUid, iViewPreferences); } } //Initialise sort order and textdef. SetSortOrderL(aSortOrder); //Create view contact manager to handle sorting iViewCntMgr = CViewContactManager::NewL(*this, *iFactory, *iTextDef, iViewPreferences, SortPluginImpl()); if (&iDb != NULL) { const_cast<CContactDatabase&>(iDb).AddObserverL(*this); } //Doing the sort. SortL(); }
void CConcurrentNotifierStep::UnkownChangeTestL() { INFO_PRINTF1(KTest13); SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue); iWaiting = ETrue; iMyActive->Activate(); TContactItemId cid = iIterate->NextL(); TInt i = 0; iContactsDatabase->DatabaseBeginLC(EFalse); for( ; i < KMaxNumberOfEventsInEventQueue + 1; ++i ) { OpenL( cid ); CommitL( EFalse ); } AddEventL( EContactDbObserverEventUnknownChanges ); AddContactL( -1 ); EndTransactionL(); SetMessageCountL(); iStart.UniversalTime(); }
/** Delete all fields from all contacts */ void CContactViewTest::EmptyFieldsetSortTestL() { ALLPRINT(KTest6); ClosePersistanceL(EFalse); ResetDatabaseL(); TInt i; for(i = 0; i < iContacts; ++i) { const TContactItemId cid = iIterate->NextL(); OpenL(cid, *iViewAll); //deletes all fields iFields->Reset(); CommitL(); } ResetSortL(); OpenPersistanceL(); iObserver->SetView( CreateViewL() ); iObserver->iMainFunc = NULL; iObserver->iDoFunc = &CContactViewTest::doEmptyFieldsetSortTestL; }
TVerdict CConcurrentInitializerStep::doTestStepL() { __UHEAP_MARK; _LIT(KStartTest,"CConcurrentInitializerStep::doTestStepL()"); INFO_PRINTF1(KStartTest); //Block start InitializeL(); iIterate->Reset(); TInt j = 0; for(; j < iContacts; ++j) { OpenL(iIterate->NextL()); TInt fieldId=iFields->Find(KUidContactFieldPhoneNumber); SetFieldL(fieldId,GetFieldL(KStringFields, KField, 1));// if this is not set, speeddial cant be set CommitL(EFalse); } iIterate->Reset(); Cleanup(); __UHEAP_MARKEND; return TestStepResult(); }
/** populates all contacts either moderately, fully, or not at all */ void CTransactionsStep::ModifyContactsL(const FieldFullness aField) { if(aField == EEmpty) { return; } iIterate->Reset(); TInt j = 0; for(; j < iContacts; ++j) { OpenL(iIterate->NextL()); if(aField == EFull) { SetAllFieldsL( GetFieldL(KStringFields, KField, 2) ); } else { SetManyFieldsL(GetFieldL(KStringFields, KField, 4) , KMediumFields); } CommitL(EFalse); } }
/** check for unknownchange notification cause by the transaction queue being overloaded */ void CNotificationStep::TransactionUnkownChangeTestL(const TBool aRevert) { INFO_PRINTF1(KTest2); TContactItemId cid = iIterate->NextL(); TInt i = 0; iContactsDatabase->DatabaseBeginLC(EFalse); for( ; i < KMaxNumberOfEventsInEventQueue + 1; ++i ) { OpenL( cid ); CommitL( ETrue ); } EndTransactionL( aRevert ); if( !aRevert ) { AddEventL( EContactDbObserverEventUnknownChanges ); AddContactL( -1 ); } iMyActive->iCheck = &CNotificationStep::TransactionUnkownChangeCheck; iMyActive->Activate(); iStart.UniversalTime(); CActiveScheduler::Start(); }
void CConcurrentNotifierStep::SingleCommitTransactionTestL() { if( iRevert ) { INFO_PRINTF1(KTest102); } else { INFO_PRINTF1(KTest10); } SetSharedTextL(KSharedNextTest, KSingleCharacter, ETrue); iWaiting = ETrue; TContactItemId cid = iIterate->NextL(); iContactsDatabase->DatabaseBeginLC(EFalse); OpenL( cid ); CommitL( ETrue ); AddEventL(EContactDbObserverEventContactChanged); AddContactL( cid ); EndTransactionL(); SetMessageCountL(); iStart.UniversalTime(); }
/** populate database with full, medium or empty contacts */ void CContactViewTest::PerformanceTestL() { ClosePersistanceL( EFalse ); ResetDatabaseL(iPerformanceContacts); //populate contacts if( EMedium == iFullness ) { if( EFew == iPerformanceContacts ) { ALLPRINT(KTest81); } TInt i = 0; for(; i < iContacts; ++i) { const TContactItemId cid = iIterate->NextL(); OpenL(cid, *iViewAll); SetMediumL(); CommitL(); } } else if( EFull == iFullness ) { if( EFew == iPerformanceContacts ) { ALLPRINT(KTest82); } TInt i = 0; for(; i < iContacts; ++i) { const TContactItemId cid = iIterate->NextL(); OpenL(cid, *iViewAll); SetFullL(); CommitL(); } } else { if( EFew == iPerformanceContacts ) { ALLPRINT(KTest8); } } /** Print the number of contacts used for this test */ switch( iPerformanceContacts ) { case EFew: { _LIT(KFewContacts,"Few contacts"); ALLPRINT( KFewContacts ); iPerformanceContacts = EMid; break; } case EMid: { _LIT(KMidContacts,"Mid contacts"); ALLPRINT( KMidContacts ); iPerformanceContacts = EMany; break; } case EMany: { _LIT(KManyContacts,"Many contacts"); ALLPRINT( KManyContacts ); iPerformanceContacts = EMax; break; } case EMax: { _LIT(KMaxContacts,"Max contacts"); ALLPRINT( KMaxContacts ); iPerformanceContacts = EDone; break; } default: { _LIT(KInvalidContacts,"bad performance contacts"); User::Panic(KInvalidContacts, 333 ); break; } } _LIT(KStartCompact,"Start Compact"); ALLPRINT( KStartCompact ); iContactsDatabase->CompactL();//to make sure that the server is not busy doing automatic compaction _LIT(KEndCompact,"End Compact"); ALLPRINT( KEndCompact ); //Create sortorder with typical uids ResetSortL(); iSortOrder->AppendL(KUidContactFieldGivenName); iSortOrder->AppendL(KUidContactFieldAdditionalName); iSortOrder->AppendL(KUidContactFieldFamilyName); iSortOrder->AppendL(KUidContactFieldPhoneNumber); OpenPersistanceL(); _LIT(KStartView,"Start view creation"); ALLPRINT( KStartView ); //note time view is created iStartC.UniversalTime(); iObserver->SetView( CreateViewL() ); //note time vie creat is completed iStartP.UniversalTime(); _LIT(KEndView,"End view creation, wait for view to be populated"); ALLPRINT( KEndView ); iObserver->iMainFunc = NULL; iObserver->iDoFunc = &CContactViewTest::doPerformanceTestL; }
void CTransactionsStep::ManyUpdateCommitTransactionTestL( const TBool aRevert ) { iContacts = 1000; CPerformanceFunctionalityBase::InitializeL(); RCntList backuplist; backuplist.CopyL( *iIterate ); iContactsDatabase->DatabaseBeginLC(EFalse); TInt added = 0; TInt deleted = 0; TInt updated = 0; TInt k = 0; for(; k < iContacts; k++) { switch( k % KNumCUDOperations ) { case ( EOpen ): { OpenL( iIterate->NextL() ); //if setting first contact read first field from stringfields section //otherwise read next field in list of fields stored in ini file secion SetAllFieldsL( GetNextFieldL(KStringFields, KField, 0 == k ) ); CommitL(ETrue); ++updated; } break; case ( EUpdate ): { TContactItemId cid = iIterate->NextL(); ReadL( cid ); //if setting first contact read first field from stringfields section //otherwise read next field in list of fields stored in ini file secion SetAllFieldsL( GetNextFieldL(KStringFields, KField, 0 == k ) ); iContactsDatabase->UpdateContactLC(cid, iContactItem); CleanupStack::PopAndDestroy(); CloseL( ETrue ); ++updated; } break; case ( EAddDelete ): { DeleteContactL( iIterate->NextL(), ETrue ); //iterator position is shifted back, so that next nextL call is correct iIterate->PreviousL(); ++deleted; //Empty contact is appended to the database, //Contact id is stored at the end of iterator list not at current iterator position AddEmptyContactsL( 1, ETrue ); ++added; } break; default: { _LIT(KInvalidTest, "Invalid Case"); User::Panic(KInvalidTest, 555); } break; } } EndTransactionL(aRevert); TESTPRINT( iContactsDatabase->CountL() == iContacts ); CContactItemFieldSet& templateFields = iTemplate->CardFields(); TInt fieldsCount = templateFields.Count() - 1; if(aRevert) { //if transaction is reverted / rolledback, all contacts should be //unchanged, i.e. they should all contain empty fields only backuplist.Reset(); TInt err = KErrNone; for(k = 0; k < iContacts; ++k) { TRAP(err, ReadL( backuplist.NextL() ) ); TESTPRINTI( KErrNone == err, k ); TESTPRINTI( CheckAllFieldsL( KNullDesC ), k ); CloseL( ETrue ); } } else { iIterate->Reset(); //all updated contact should contain the appropriated updated field value for(k = 0; k < updated; ++k) { ReadL( iIterate->NextL() ); TESTPRINTI(iFields->Count() == fieldsCount, k); //if reading first contact read first field from stringfields section //otherwise read next field in list of fields stored in ini file secion TESTPRINTI( CheckAllFieldsL( GetNextFieldL(KStringFields, KField, 0 == k ) ), k ); CloseL( ETrue ); } //all newly added contacts, should contain empty fields only. for(k = 0; k < added; ++k) { ReadL( iIterate->NextL() ); TESTPRINTI( iFields->Count() == fieldsCount, k); TESTPRINTI( CheckAllFieldsL( KNullDesC ), k); CloseL( ETrue ); } } }
void CContactFilteredView::ConstructL(MContactViewObserver& aObserver) { CContactViewBase::ConstructL(); OpenL(aObserver); iView.OpenL(*this); }
/**opens and read contct aCid using the default viewdefs. then it reads and minimally reads aCid using aView, it stores the number relevant fields after each read/open, then checks that the values match the expected resluts as constrained by aZeroN/H, aZeroN == all normal fields should be excluded, aZeroH == all hidden fields should be excluded*/ TBool CViewDefAllFieldsTest::FieldCountCompL( const TContactItemId aCid, const CContactItemViewDef &aView, const TBool aDefault, const TBool aZeroN, const TBool aZeroH) { TBool SingleCheck = EFalse; TBool OverallResult = ETrue; TInt counti = 0; TInt countr = 0; TInt countrv = 0; TInt countrAll = 0; TInt countrAllv = 0; TInt countrm = 0; TInt hcounti = 0; TInt hcountr = 0; TInt hcountrv = 0; TInt hcountrm = 0; OpenL(aCid,aView, ETrue); SetContactFieldsL(*iContactItem); counti = iFields->Count(); hcounti = CountHiddenFields(*iFields); CommitL(); ReadL(aCid,*iViewAll,EFalse); countrv = CountEmpty(*iFields); countrAllv = iFields->Count(); hcountrv = CountHiddenFields(*iFields); Close(); ReadL(aCid,aView,aDefault); countr = CountEmpty(*iFields); countrAll = iFields->Count(); hcountr = CountHiddenFields(*iFields); Close(); ReadMinimalL(aCid, aView, *iDefView, aDefault); countrm = iFields->Count(); hcountrm = CountHiddenFields(*iFields); Close(); SingleCheck = INTCOMPARE( countrAllv, ==, counti, 0, 0 ); OverallResult = OverallResult && SingleCheck; SingleCheck = INTCOMPARE(hcounti , ==, hcountrv, 0, 0 ); OverallResult = OverallResult && SingleCheck; SingleCheck = INTCOMPARE(countrv , ==, 0, 0, 0 ); OverallResult = OverallResult && SingleCheck; SingleCheck = INTCOMPARE( ( countrAll - countr) , ==, countrm , 0, 0 ); OverallResult = OverallResult && SingleCheck; if(aZeroN) { SingleCheck = INTCOMPARE( ( countr - hcountr ) , ==, ( counti - hcounti ) , 0, 0 ); OverallResult = OverallResult && SingleCheck; SingleCheck = INTCOMPARE( ( countrm - hcountrm ) , ==, 0 , 0, 0 ); OverallResult = OverallResult && SingleCheck; } else {
/* test that contactitems can be deleted successfully irregardless of the contents of their agent value */ void CAccessCountTests::ForwardAgentDeletionTestL(const TInt aNumContacts) { TBool DeleteSuccess = EFalse; TContactItemId PreviousContactId = -1; TContactItemId CurrentContactId = iIterate->NextL(); TInt err = KErrNone; TInt i = 0; for(; i < aNumContacts; ++i) { PreviousContactId = CurrentContactId; CurrentContactId = iIterate->NextL(); //open contact item OpenL(CurrentContactId, *iViewAll); //add agent field and set to previous contact id AddAgentFieldL(PreviousContactId); CommitL(); //print agent values useful for debugging INFO_PRINTF2(KAgentValue, GetAgentFieldL(CurrentContactId) ); } //move iterator to start first contact in list for( i = 0 ; i < aNumContacts; ++i ) { CurrentContactId = iIterate->PreviousL(); } //attempt to delete contacts starting from first contact to last contact for( i = 0 ; i < aNumContacts ; ++i ) { //attempt to delete contact iContactsDatabase->DeleteContactL(CurrentContactId); //attempt to read deleted contact TRAP( err, ReadL(CurrentContactId, *iViewAll) ); Close(); //fail test if contact is still present DeleteSuccess = INTCOMPARE( err, ==, KErrNotFound , i, 0 ); CurrentContactId = iIterate->NextL(); if( ! DeleteSuccess ) { break; } } //if test fails if(!DeleteSuccess) { //remove rest of contacts from iterator const TInt end = i + 1; for(i = 0 ; i < end ; ++i) { iIterate->RemoveL(CurrentContactId); CurrentContactId = iIterate->PreviousL(); } CurrentContactId = iIterate->NextL(); for(i = end ; i < aNumContacts ; ++i) { iIterate->RemoveL(CurrentContactId); CurrentContactId = iIterate->CurrentL(); } } }
/** This sanity test method is executed at the start of the test run to verify that UPT methods in this class are stable before any of the performance tests are carried out // what tests does it do? @return KErrNone if command was prepared correctly and system wide error code otherwise. */ TInt CUptCsvGenerator::TestL() { //define filepaths for the test csv files according to the test platform. #ifdef __WINSCW__ _LIT(KTestFileAppend, "c:\\te_CSVoutputfileAppend.csv"); _LIT(KTestFileOverwrite, "c:\\te_CSVoutputfileOverwrite.csv"); #else _LIT(KTestFileAppend, "e:\\te_CSVoutputfileAppend.csv"); _LIT(KTestFileOverwrite, "e:\\te_CSVoutputfileOverwrite.csv"); #endif //initialise some generic data to write to csv RArray<TInt64> atestdata1; RArray<TInt64> atestdata2; CleanupClosePushL(atestdata1); CleanupClosePushL(atestdata2); //data of the form: //0 1 2 3 4 5 6 7 8 9 TInt data1element=10; for(TInt i=0; i!=data1element;i++) { atestdata1.Append((TInt64) i); } //data of the form: //0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 11000 TInt data2element=12; for(TInt i=0; i!=data2element;i++) { atestdata2.Append((TInt64) i*1000); } //now test the CSV Generator functions //test the append data option - outputfile should contain an extra 6 lines of data of the form: // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 // 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000 // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 // 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000 // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 // 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000 TInt appendcount=3; for(TInt i=0; i!=appendcount;i++) { OpenL(KTestFileAppend, ETrue); WriteL(atestdata1); WriteNewLineL(); WriteL(atestdata2); WriteNewLineL(); Close(); } //test the overwrite data option - outputfile should contain only 2 lines of data of the form: // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 // 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000 for(TInt i=0; i!=appendcount;i++) { OpenL(KTestFileOverwrite, EFalse); WriteL(atestdata1); WriteNewLineL(); WriteL(atestdata2); WriteNewLineL(); Close(); } // read the files back to check they are valid, as an automated check RFs fsSession; RFile appendfile; RFile overwritefile; TInt filesize; User::LeaveIfError(fsSession.Connect()); //sizes in bytes of generated output csv data TInt appendsize=appendcount*(sizeof(atestdata1)+sizeof(atestdata2)+2*sizeof(KCsvNewLine)+(data1element+data2element)*sizeof(KCsvComma)); TInt overwritesize=(sizeof(atestdata1)+sizeof(atestdata2)+2*sizeof(KCsvNewLine)+(data1element+data2element)*sizeof(KCsvComma)); // fill buffers used for data read from the outputted file RBuf8 readappendfile; readappendfile.CreateL(appendsize); RBuf8 readoverwritefile; readoverwritefile.CreateL(overwritesize); CleanupClosePushL(readappendfile); CleanupClosePushL(readoverwritefile); // comparison data buffers used to contain the expected data RBuf8 acompareappend; acompareappend.CreateL(appendsize); RBuf8 acompareoverwrite; acompareoverwrite.CreateL(overwritesize); CleanupClosePushL(acompareappend); CleanupClosePushL(acompareoverwrite); //fill comparison array for appended data TInt err=FillReferenceBuffer(acompareappend, appendcount, atestdata1, data1element, atestdata2, data2element); //first check the appended file by reading back the last 6 lines in the file and comparing with acompareappend if(err==KErrNone) { if(appendfile.Open(fsSession, KTestFileAppend, EFileRead)) { if(appendfile.Size(filesize)) { if(appendfile.Read((filesize-sizeof(acompareappend)),readappendfile)) { if(!readappendfile.Compare(acompareappend)) err=KErrGeneral; } } } } // close test output csv file appendfile.Close(); //given the above has passed, //fill comparison array for overwritten data if(err==KErrNone) err=FillReferenceBuffer(acompareoverwrite, (TInt) 0, atestdata1, data1element, atestdata2, data2element); //check the overwritten file by reading back the only 2 lines in the file and comparing with acompareoverwrite //Note: as a thorough check- read from a zero offset if(err==KErrNone) { if(overwritefile.Open(fsSession, KTestFileOverwrite, EFileRead)) { if(overwritefile.Size(filesize)) { if(overwritefile.Read(0,readoverwritefile)) { if(!readoverwritefile.Compare(acompareoverwrite)) err=KErrGeneral; } } } } // close test output csv file overwritefile.Close(); CleanupStack::PopAndDestroy(&atestdata1); CleanupStack::PopAndDestroy(&atestdata2); CleanupStack::PopAndDestroy(&readappendfile); CleanupStack::PopAndDestroy(&readoverwritefile); CleanupStack::PopAndDestroy(&acompareappend); CleanupStack::PopAndDestroy(&acompareoverwrite); return err; }