void TestFindingL(CContactDatabase& aDb) { test.Next(_L("Test FindLC")); syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrLocked); syncChecker->SetValidateResponseL(MContactSynchroniser::ESearch,KErrLocked); CContactItemFieldDef* fieldDef=new(ELeave) CContactItemFieldDef; CleanupStack::PushL(fieldDef); fieldDef->AppendL(KUidContactFieldFamilyName); TRAPD(err,TestFindL(aDb, KGivenEditName, fieldDef, test) ); test(err==KErrLocked); CleanupStack::PopAndDestroy(fieldDef); CContactItemFieldDef* fieldDef2=new(ELeave) CContactItemFieldDef; CleanupStack::PushL(fieldDef2); fieldDef2->AppendL(KUidContactFieldPhoneNumber); TRAP(err, TestFindL(aDb, KTelephoneNum, fieldDef2, test) ); test(err==KErrLocked); CleanupStack::PopAndDestroy(fieldDef2); test.Next(_L("Test FindInTextDefL")); TCallBack callBack(findWordSplitterL); CContactTextDef* textDef=CContactTextDef::NewLC(); textDef->AppendL(TContactTextDefItem(KUidContactFieldFamilyName)); CDesCArray* desArray = new(ELeave) CDesCArrayFlat(5); desArray->AppendL(_L("e")); CContactIdArray* arr = NULL; TRAP(err,arr = TestFindInTextDefL(aDb,*desArray,textDef, callBack, test) ); // test(err==KErrLocked); desArray->Delete(0); delete desArray; //FIX delete arr; CleanupStack::PopAndDestroy(textDef); test.Next(_L("Test FindInTextDefL2")); TCallBack callBack2(findWordSplitterL); CContactTextDef* textDef2=CContactTextDef::NewLC(); textDef2->AppendL(TContactTextDefItem(KUidContactFieldFamilyName)); textDef2->AppendL(TContactTextDefItem(KUidContactFieldUrl)); CDesCArray* desArray2 = new(ELeave) CDesCArrayFlat(5); desArray2->AppendL(_L("e")); TRAP(err,arr = TestFindInTextDefL(aDb,*desArray2,textDef2, callBack2, test) ); // test(err==KErrLocked); desArray2->Delete(0); delete desArray2; //FIX delete arr; CleanupStack::PopAndDestroy(textDef2); }
GLDEF_C TInt E32Main() { test.Title(); __UHEAP_MARK; test.Start(_L("Create some CPeriodics")); myScheduler* pScheduler = new myScheduler; myScheduler::Install(pScheduler); pPer1 = CPeriodic::New(0); pPer2 = CPeriodic::NewL(0); pPer3 = CPeriodic::NewL(10); pPer4 = CPeriodic::NewL(100); pPer5 = CPeriodic::NewL(100); pPer6 = CPeriodic::NewL(100); pPer7 = CPeriodic::NewL(100); myTimer* pTimer = new myTimer(50); test.Next(_L("Start them")); TCallBack callBack1(CallBackFn,(TAny*)1); TCallBack callBack2(CallBackFn,(TAny*)2); TCallBack callBack3(CallBackFn,(TAny*)3); TCallBack callBack4(CallBackPanic,(TAny*)4); TCallBack callBack5(CallBackPanic,(TAny*)5); TCallBack callBack6(CallBackPanic,(TAny*)6); TCallBack callBack7(CallBackPanic,(TAny*)7); TInt p=0; HAL::Get(HAL::ESystemTickPeriod, p); User::After(p); // ensure tick does not occur while starting all these timers pPer1->Start(2*p+1,7*p+1,callBack1); //After 3 ticks, complete every 8th tick pPer2->Start(1, 2*p+1,callBack2); //After 1 tick , complete every 3rd tick pPer3->Start(7*p+1, p+1,callBack3); //After 8 ticks, complete every 2nd tick pPer4->Start(KMaxTInt,KMaxTInt,callBack4); pPer5->Start(60000000,60000000,callBack5); pPer6->Start(KMaxTInt/91,KMaxTInt/91,callBack6); pPer7->Start(KMaxTInt/91+1,KMaxTInt/91+1,callBack7); pTimer->After(20*p-1); // ensure there's enough time for them to fill up the array. /* Time per1 per2 per3 1 - 2 3 - 4 - 5 6 7 - 8 - 9 10 - - 11 - 12 - 13 - 14 - */ myScheduler::Start(); TInt i; for (i=0; i<counter; ++i) { test.Printf(_L(" Time: %7d Periodic: %d\n"),static_cast<TUint32>(Times[i].Int64()-Times[0].Int64()),Array[i]); } test(Array[0]==2); test(Array[1]==1); test(Array[2]==2); test(Array[3]==2); test(Array[4]==3); TBool normal56 = (Array[5]==3 && Array[6]==2); TBool reverse56 = (Array[5]==2 && Array[6]==3); if (UserSvr::HalFunction(EHalGroupKernel, EKernelHalNumLogicalCpus, 0, 0) > 1) { // If there are multiple processors the order of 'simultaneous' timers is undefined since // the test may get to run as soon as the first timer is completed, instead of only after // the timer thread blocks, which would be after both timers completed. test(normal56 || reverse56); } else test(normal56); test(Array[7]==1); test(Array[8]==3); test(Array[9]==2); test(Array[10]==3); test.Next(_L("Destroy them")); delete pPer1; delete pPer2; delete pPer3; delete pPer4; delete pPer5; delete pPer6; delete pPer7; delete pTimer; delete pScheduler; test.Next(_L("Test CHeartbeat")); testHeartbeat(); test.Next(_L("Test TTimerLockSpec")); testLockSpec(); __UHEAP_MARKEND; test.End(); return(KErrNone); }